From: Dessalines Date: Tue, 6 Oct 2020 15:19:01 +0000 (-0500) Subject: Adding a boolean check to send_activity_internal X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/nerdica.net/static/README.zh.hant.md?a=commitdiff_plain;h=ca4868cefdbe4035c4c9e4e7770df8d7ad308fdb;p=lemmy.git Adding a boolean check to send_activity_internal --- diff --git a/lemmy_apub/src/activity_queue.rs b/lemmy_apub/src/activity_queue.rs index 9f7f38cf..2f11024c 100644 --- a/lemmy_apub/src/activity_queue.rs +++ b/lemmy_apub/src/activity_queue.rs @@ -47,6 +47,7 @@ where creator, vec![to], context.pool(), + true, ) .await?; } @@ -85,6 +86,7 @@ where community, to, context.pool(), + true, ) .await?; @@ -114,6 +116,7 @@ where creator, vec![inbox], context.pool(), + true, ) .await?; } @@ -143,6 +146,7 @@ where creator, mentions, context.pool(), + false, // Don't create a new DB row ) .await?; Ok(()) @@ -158,6 +162,7 @@ async fn send_activity_internal( actor: &dyn ActorType, to: Vec, pool: &DbPool, + insert_into_db: bool, ) -> Result<(), LemmyError> where T: AsObject + Extends, @@ -174,7 +179,12 @@ where let activity = activity.into_any_base()?; let serialised_activity = serde_json::to_string(&activity)?; - insert_activity(actor.user_id(), activity.clone(), true, pool).await?; + + // This is necessary because send_comment and send_comment_mentions + // might send the same ap_id + if insert_into_db { + insert_activity(actor.user_id(), activity.clone(), true, pool).await?; + } // TODO: it would make sense to create a separate task for each destination server let message = SendActivityTask {