2 activities::community::announce::GetCommunity,
3 objects::community::ApubCommunity,
6 block::{block_user::BlockUser, undo_block_user::UndoBlockUser},
9 announce::AnnounceActivity,
10 remove_mod::RemoveMod,
12 update::UpdateCommunity,
14 create_or_update::{comment::CreateOrUpdateComment, post::CreateOrUpdatePost},
15 deletion::{delete::Delete, undo_delete::UndoDelete},
17 accept::AcceptFollowCommunity,
18 follow::FollowCommunity,
19 undo_follow::UndoFollowCommunity,
22 create_or_update::CreateOrUpdatePrivateMessage,
23 delete::DeletePrivateMessage,
24 undo_delete::UndoDeletePrivateMessage,
26 voting::{undo_vote::UndoVote, vote::Vote},
31 use lemmy_apub_lib::traits::ActivityHandler;
32 use lemmy_utils::LemmyError;
33 use lemmy_websocket::LemmyContext;
34 use serde::{Deserialize, Serialize};
36 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
38 #[activity_handler(LemmyContext)]
39 pub enum SharedInboxActivities {
40 GroupInboxActivities(Box<GroupInboxActivities>),
41 // Note, pm activities need to be at the end, otherwise comments will end up here. We can probably
42 // avoid this problem by replacing createpm.object with our own struct, instead of NoteExt.
43 PersonInboxActivities(Box<PersonInboxActivities>),
46 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
48 #[activity_handler(LemmyContext)]
49 pub enum GroupInboxActivities {
50 FollowCommunity(FollowCommunity),
51 UndoFollowCommunity(UndoFollowCommunity),
52 AnnouncableActivities(Box<AnnouncableActivities>),
56 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
58 #[activity_handler(LemmyContext)]
59 pub enum PersonInboxActivities {
60 AcceptFollowCommunity(AcceptFollowCommunity),
61 /// Some activities can also be sent from user to user, eg a comment with mentions
62 AnnouncableActivities(AnnouncableActivities),
63 CreateOrUpdatePrivateMessage(CreateOrUpdatePrivateMessage),
64 DeletePrivateMessage(DeletePrivateMessage),
65 UndoDeletePrivateMessage(UndoDeletePrivateMessage),
66 AnnounceActivity(AnnounceActivity),
69 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
71 #[activity_handler(LemmyContext)]
72 pub enum AnnouncableActivities {
73 CreateOrUpdateComment(CreateOrUpdateComment),
74 CreateOrUpdatePost(CreateOrUpdatePost),
78 UndoDelete(UndoDelete),
79 UpdateCommunity(UpdateCommunity),
81 UndoBlockUser(UndoBlockUser),
84 // For compatibility with Pleroma/Mastodon (send only)
88 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
90 #[activity_handler(LemmyContext)]
91 pub enum SiteInboxActivities {
93 UndoBlockUser(UndoBlockUser),
96 #[async_trait::async_trait(?Send)]
97 impl GetCommunity for AnnouncableActivities {
98 #[tracing::instrument(skip(self, context))]
99 async fn get_community(
101 context: &LemmyContext,
102 request_counter: &mut i32,
103 ) -> Result<ApubCommunity, LemmyError> {
104 use AnnouncableActivities::*;
105 let community = match self {
106 CreateOrUpdateComment(a) => a.get_community(context, request_counter).await?,
107 CreateOrUpdatePost(a) => a.get_community(context, request_counter).await?,
108 Vote(a) => a.get_community(context, request_counter).await?,
109 UndoVote(a) => a.get_community(context, request_counter).await?,
110 Delete(a) => a.get_community(context, request_counter).await?,
111 UndoDelete(a) => a.get_community(context, request_counter).await?,
112 UpdateCommunity(a) => a.get_community(context, request_counter).await?,
113 BlockUser(a) => a.get_community(context, request_counter).await?,
114 UndoBlockUser(a) => a.get_community(context, request_counter).await?,
115 AddMod(a) => a.get_community(context, request_counter).await?,
116 RemoveMod(a) => a.get_community(context, request_counter).await?,
117 Page(_) => unimplemented!(),