mirror of
https://git.ondrovo.com/MightyPork/group-actor.git
synced 2024-11-21 15:41:03 +00:00
fix threading in chained responses
This commit is contained in:
parent
6c9041eedd
commit
3a4f0ef153
1 changed files with 18 additions and 4 deletions
|
@ -283,6 +283,8 @@ impl<'a> ProcessMention<'a> {
|
||||||
|
|
||||||
async fn send_reply_multipart(&self, mention : String, msg : String) -> Result<(), GroupError> {
|
async fn send_reply_multipart(&self, mention : String, msg : String) -> Result<(), GroupError> {
|
||||||
let parts = smart_split(&msg, Some(mention), self.config.get_character_limit());
|
let parts = smart_split(&msg, Some(mention), self.config.get_character_limit());
|
||||||
|
|
||||||
|
let mut parent = self.status.id.clone();
|
||||||
for p in parts {
|
for p in parts {
|
||||||
if let Ok(post) = StatusBuilder::new()
|
if let Ok(post) = StatusBuilder::new()
|
||||||
.status(p)
|
.status(p)
|
||||||
|
@ -291,10 +293,12 @@ impl<'a> ProcessMention<'a> {
|
||||||
} else {
|
} else {
|
||||||
"text/plain"
|
"text/plain"
|
||||||
})
|
})
|
||||||
|
.in_reply_to(&parent)
|
||||||
.visibility(Visibility::Direct)
|
.visibility(Visibility::Direct)
|
||||||
.build()
|
.build()
|
||||||
{
|
{
|
||||||
self.client.new_status(post).await?;
|
let status = self.client.new_status(post).await?;
|
||||||
|
parent = status.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sleep a bit to avoid throttling
|
// Sleep a bit to avoid throttling
|
||||||
|
@ -307,15 +311,25 @@ impl<'a> ProcessMention<'a> {
|
||||||
async fn send_announcement_multipart(&self, msg : &str) -> Result<(), GroupError> {
|
async fn send_announcement_multipart(&self, msg : &str) -> Result<(), GroupError> {
|
||||||
let parts = smart_split(msg, None, self.config.get_character_limit());
|
let parts = smart_split(msg, None, self.config.get_character_limit());
|
||||||
|
|
||||||
|
let mut parent = None;
|
||||||
for p in parts {
|
for p in parts {
|
||||||
let post = StatusBuilder::new()
|
let mut builder = StatusBuilder::new();
|
||||||
|
|
||||||
|
builder
|
||||||
.status(p)
|
.status(p)
|
||||||
.content_type("text/markdown")
|
.content_type("text/markdown")
|
||||||
.visibility(Visibility::Public)
|
.visibility(Visibility::Public);
|
||||||
|
|
||||||
|
if let Some(p) = parent.as_ref() {
|
||||||
|
builder.in_reply_to(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
let post = builder
|
||||||
.build()
|
.build()
|
||||||
.expect("error build status");
|
.expect("error build status");
|
||||||
|
|
||||||
self.client.new_status(post).await?;
|
let status = self.client.new_status(post).await?;
|
||||||
|
parent = Some(status.id);
|
||||||
|
|
||||||
// Sleep a bit to avoid throttling
|
// Sleep a bit to avoid throttling
|
||||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||||
|
|
Loading…
Reference in a new issue