From 74a89f6fe91873b7e1d1bcd815b9061dd1ede227 Mon Sep 17 00:00:00 2001 From: silverpill Date: Sat, 25 Dec 2021 21:44:08 +0000 Subject: [PATCH] Ignore Like(Note) if reaction already exists in database --- src/activitypub/receiver.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/activitypub/receiver.rs b/src/activitypub/receiver.rs index 23020c1..e9dedab 100644 --- a/src/activitypub/receiver.rs +++ b/src/activitypub/receiver.rs @@ -492,12 +492,17 @@ pub async fn receive_activity( post.id }, }; - create_reaction( + match create_reaction( db_client, &author.id, &post_id, Some(&activity.id), - ).await?; + ).await { + Ok(_) => (), + // Ignore activity if reaction is already saved + Err(DatabaseError::AlreadyExists(_)) => return Ok(()), + Err(other_error) => return Err(other_error.into()), + }; NOTE }, (FOLLOW, _) => {