3 comment::{create::CreateComment, update::UpdateComment},
6 block_user::BlockUserFromCommunity,
7 undo_block_user::UndoBlockUserFromCommunity,
10 delete::DeletePostCommentOrCommunity,
11 undo_delete::UndoDeletePostCommentOrCommunity,
13 post::{create::CreatePost, update::UpdatePost},
15 remove::RemovePostCommentCommunityOrMod,
16 undo_remove::UndoRemovePostCommentOrCommunity,
21 dislike::DislikePostOrComment,
22 like::LikePostOrComment,
23 undo_dislike::UndoDislikePostOrComment,
24 undo_like::UndoLikePostOrComment,
27 http::is_activity_already_known,
29 use activitystreams::activity::kind::AnnounceType;
30 use lemmy_apub::insert_activity;
31 use lemmy_apub_lib::{ActivityCommonFields, ActivityHandler, PublicUrl};
32 use lemmy_utils::LemmyError;
33 use lemmy_websocket::LemmyContext;
34 use serde::{Deserialize, Serialize};
37 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
39 pub enum AnnouncableActivities {
40 CreateComment(CreateComment),
41 UpdateComment(UpdateComment),
42 CreatePost(CreatePost),
43 UpdatePost(UpdatePost),
44 LikePostOrComment(LikePostOrComment),
45 DislikePostOrComment(DislikePostOrComment),
46 UndoLikePostOrComment(UndoLikePostOrComment),
47 UndoDislikePostOrComment(UndoDislikePostOrComment),
48 DeletePostCommentOrCommunity(DeletePostCommentOrCommunity),
49 UndoDeletePostCommentOrCommunity(UndoDeletePostCommentOrCommunity),
50 RemovePostCommentCommunityOrMod(RemovePostCommentCommunityOrMod),
51 UndoRemovePostCommentOrCommunity(UndoRemovePostCommentOrCommunity),
52 BlockUserFromCommunity(BlockUserFromCommunity),
53 UndoBlockUserFromCommunity(UndoBlockUserFromCommunity),
57 #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
58 #[serde(rename_all = "camelCase")]
59 pub struct AnnounceActivity {
61 object: AnnouncableActivities,
63 #[serde(rename = "type")]
66 common: ActivityCommonFields,
69 #[async_trait::async_trait(?Send)]
70 impl ActivityHandler for AnnounceActivity {
73 context: &LemmyContext,
74 request_counter: &mut i32,
75 ) -> Result<(), LemmyError> {
76 verify_activity(self.common())?;
77 verify_community(&self.common.actor, context, request_counter).await?;
78 self.object.verify(context, request_counter).await?;
84 context: &LemmyContext,
85 request_counter: &mut i32,
86 ) -> Result<(), LemmyError> {
87 if is_activity_already_known(context.pool(), self.object.common().id_unchecked()).await? {
91 self.object.common().id_unchecked(),
98 self.object.receive(context, request_counter).await
101 fn common(&self) -> &ActivityCommonFields {