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,
15 comment::CreateOrUpdateComment,
16 post::CreateOrUpdatePost,
17 private_message::CreateOrUpdatePrivateMessage,
19 deletion::{delete::Delete, undo_delete::UndoDelete},
21 accept::AcceptFollowCommunity,
22 follow::FollowCommunity,
23 undo_follow::UndoFollowCommunity,
25 voting::{undo_vote::UndoVote, vote::Vote},
30 use lemmy_apub_lib::traits::ActivityHandler;
31 use lemmy_utils::LemmyError;
32 use lemmy_websocket::LemmyContext;
33 use serde::{Deserialize, Serialize};
35 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
37 #[activity_handler(LemmyContext)]
38 pub enum SharedInboxActivities {
39 GroupInboxActivities(Box<GroupInboxActivities>),
40 // Note, pm activities need to be at the end, otherwise comments will end up here. We can probably
41 // avoid this problem by replacing createpm.object with our own struct, instead of NoteExt.
42 PersonInboxActivities(Box<PersonInboxActivities>),
45 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
47 #[activity_handler(LemmyContext)]
48 pub enum GroupInboxActivities {
49 FollowCommunity(FollowCommunity),
50 UndoFollowCommunity(UndoFollowCommunity),
51 AnnouncableActivities(Box<AnnouncableActivities>),
55 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
57 #[activity_handler(LemmyContext)]
58 pub enum PersonInboxActivities {
59 AcceptFollowCommunity(AcceptFollowCommunity),
60 /// Some activities can also be sent from user to user, eg a comment with mentions
61 AnnouncableActivities(AnnouncableActivities),
62 CreateOrUpdatePrivateMessage(CreateOrUpdatePrivateMessage),
64 UndoDelete(UndoDelete),
65 AnnounceActivity(AnnounceActivity),
68 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
70 #[activity_handler(LemmyContext)]
71 pub enum AnnouncableActivities {
72 CreateOrUpdateComment(CreateOrUpdateComment),
73 CreateOrUpdatePost(CreateOrUpdatePost),
77 UndoDelete(UndoDelete),
78 UpdateCommunity(UpdateCommunity),
80 UndoBlockUser(UndoBlockUser),
83 // For compatibility with Pleroma/Mastodon (send only)
87 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
89 #[activity_handler(LemmyContext)]
90 pub enum SiteInboxActivities {
92 UndoBlockUser(UndoBlockUser),
95 #[async_trait::async_trait(?Send)]
96 impl GetCommunity for AnnouncableActivities {
97 #[tracing::instrument(skip(self, context))]
98 async fn get_community(
100 context: &LemmyContext,
101 request_counter: &mut i32,
102 ) -> Result<ApubCommunity, LemmyError> {
103 use AnnouncableActivities::*;
104 let community = match self {
105 CreateOrUpdateComment(a) => a.get_community(context, request_counter).await?,
106 CreateOrUpdatePost(a) => a.get_community(context, request_counter).await?,
107 Vote(a) => a.get_community(context, request_counter).await?,
108 UndoVote(a) => a.get_community(context, request_counter).await?,
109 Delete(a) => a.get_community(context, request_counter).await?,
110 UndoDelete(a) => a.get_community(context, request_counter).await?,
111 UpdateCommunity(a) => a.get_community(context, request_counter).await?,
112 BlockUser(a) => a.get_community(context, request_counter).await?,
113 UndoBlockUser(a) => a.get_community(context, request_counter).await?,
114 AddMod(a) => a.get_community(context, request_counter).await?,
115 RemoveMod(a) => a.get_community(context, request_counter).await?,
116 Page(_) => unimplemented!(),