From ca4868cefdbe4035c4c9e4e7770df8d7ad308fdb Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 6 Oct 2020 10:19:01 -0500 Subject: [PATCH] Adding a boolean check to send_activity_internal --- lemmy_apub/src/activity_queue.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lemmy_apub/src/activity_queue.rs b/lemmy_apub/src/activity_queue.rs index 9f7f38cf1..2f11024c4 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 {