2 activities::community::announce::GetCommunity,
3 objects::community::ApubCommunity,
8 announce::AnnounceActivity,
9 block_user::BlockUserFromCommunity,
10 remove_mod::RemoveMod,
12 undo_block_user::UndoBlockUserFromCommunity,
13 update::UpdateCommunity,
15 create_or_update::{comment::CreateOrUpdateComment, post::CreateOrUpdatePost},
16 deletion::{delete::Delete, undo_delete::UndoDelete},
18 accept::AcceptFollowCommunity,
19 follow::FollowCommunity,
20 undo_follow::UndoFollowCommunity,
23 create_or_update::CreateOrUpdatePrivateMessage,
24 delete::DeletePrivateMessage,
25 undo_delete::UndoDeletePrivateMessage,
27 voting::{undo_vote::UndoVote, vote::Vote},
32 use lemmy_apub_lib::traits::ActivityHandler;
33 use lemmy_utils::LemmyError;
34 use lemmy_websocket::LemmyContext;
35 use serde::{Deserialize, Serialize};
37 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
39 #[activity_handler(LemmyContext)]
40 pub enum SharedInboxActivities {
41 GroupInboxActivities(Box<GroupInboxActivities>),
42 // Note, pm activities need to be at the end, otherwise comments will end up here. We can probably
43 // avoid this problem by replacing createpm.object with our own struct, instead of NoteExt.
44 PersonInboxActivities(Box<PersonInboxActivities>),
47 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
49 #[activity_handler(LemmyContext)]
50 pub enum GroupInboxActivities {
51 FollowCommunity(FollowCommunity),
52 UndoFollowCommunity(UndoFollowCommunity),
53 AnnouncableActivities(Box<AnnouncableActivities>),
57 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
59 #[activity_handler(LemmyContext)]
60 pub enum PersonInboxActivities {
61 AcceptFollowCommunity(AcceptFollowCommunity),
62 /// Some activities can also be sent from user to user, eg a comment with mentions
63 AnnouncableActivities(AnnouncableActivities),
64 CreateOrUpdatePrivateMessage(CreateOrUpdatePrivateMessage),
65 DeletePrivateMessage(DeletePrivateMessage),
66 UndoDeletePrivateMessage(UndoDeletePrivateMessage),
67 AnnounceActivity(AnnounceActivity),
70 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
72 #[activity_handler(LemmyContext)]
73 pub enum AnnouncableActivities {
74 CreateOrUpdateComment(CreateOrUpdateComment),
75 CreateOrUpdatePost(CreateOrUpdatePost),
79 UndoDelete(UndoDelete),
80 UpdateCommunity(UpdateCommunity),
81 BlockUserFromCommunity(BlockUserFromCommunity),
82 UndoBlockUserFromCommunity(UndoBlockUserFromCommunity),
85 // For compatibility with Pleroma/Mastodon (send only)
89 #[async_trait::async_trait(?Send)]
90 impl GetCommunity for AnnouncableActivities {
91 async fn get_community(
93 context: &LemmyContext,
94 request_counter: &mut i32,
95 ) -> Result<ApubCommunity, LemmyError> {
96 use AnnouncableActivities::*;
97 let community = match self {
98 CreateOrUpdateComment(a) => a.get_community(context, request_counter).await?,
99 CreateOrUpdatePost(a) => a.get_community(context, request_counter).await?,
100 Vote(a) => a.get_community(context, request_counter).await?,
101 UndoVote(a) => a.get_community(context, request_counter).await?,
102 Delete(a) => a.get_community(context, request_counter).await?,
103 UndoDelete(a) => a.get_community(context, request_counter).await?,
104 UpdateCommunity(a) => a.get_community(context, request_counter).await?,
105 BlockUserFromCommunity(a) => a.get_community(context, request_counter).await?,
106 UndoBlockUserFromCommunity(a) => a.get_community(context, request_counter).await?,
107 AddMod(a) => a.get_community(context, request_counter).await?,
108 RemoveMod(a) => a.get_community(context, request_counter).await?,
109 Page(_) => unimplemented!(),