fix threading in chained responses

pull/14/head
Ondřej Hruška 2 years ago
parent 6c9041eedd
commit 3a4f0ef153
  1. 22
      src/group_handler/handle_mention.rs

@ -283,6 +283,8 @@ impl<'a> ProcessMention<'a> {
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 mut parent = self.status.id.clone();
for p in parts {
if let Ok(post) = StatusBuilder::new()
.status(p)
@ -291,10 +293,12 @@ impl<'a> ProcessMention<'a> {
} else {
"text/plain"
})
.in_reply_to(&parent)
.visibility(Visibility::Direct)
.build()
{
self.client.new_status(post).await?;
let status = self.client.new_status(post).await?;
parent = status.id;
}
// Sleep a bit to avoid throttling
@ -307,15 +311,25 @@ impl<'a> ProcessMention<'a> {
async fn send_announcement_multipart(&self, msg : &str) -> Result<(), GroupError> {
let parts = smart_split(msg, None, self.config.get_character_limit());
let mut parent = None;
for p in parts {
let post = StatusBuilder::new()
let mut builder = StatusBuilder::new();
builder
.status(p)
.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()
.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
tokio::time::sleep(Duration::from_secs(1)).await;

Loading…
Cancel
Save