2 activities::community::announce::GetCommunity,
3 objects::community::ApubCommunity,
4 protocol::activities::{
7 announce::AnnounceActivity,
8 block_user::BlockUserFromCommunity,
11 undo_block_user::UndoBlockUserFromCommunity,
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},
29 use lemmy_apub_lib::traits::{ActivityFields, ActivityHandler};
30 use lemmy_utils::LemmyError;
31 use lemmy_websocket::LemmyContext;
32 use serde::{Deserialize, Serialize};
34 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler, ActivityFields)]
36 #[activity_handler(LemmyContext)]
37 pub enum SharedInboxActivities {
38 GroupInboxActivities(GroupInboxActivities),
39 // Note, pm activities need to be at the end, otherwise comments will end up here. We can probably
40 // avoid this problem by replacing createpm.object with our own struct, instead of NoteExt.
41 PersonInboxActivities(PersonInboxActivities),
44 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler, ActivityFields)]
46 #[activity_handler(LemmyContext)]
47 pub enum GroupInboxActivities {
48 FollowCommunity(FollowCommunity),
49 UndoFollowCommunity(UndoFollowCommunity),
50 AnnouncableActivities(AnnouncableActivities),
54 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler, ActivityFields)]
56 #[activity_handler(LemmyContext)]
57 pub enum PersonInboxActivities {
58 AcceptFollowCommunity(AcceptFollowCommunity),
59 /// Some activities can also be sent from user to user, eg a comment with mentions
60 AnnouncableActivities(AnnouncableActivities),
61 CreateOrUpdatePrivateMessage(CreateOrUpdatePrivateMessage),
62 DeletePrivateMessage(DeletePrivateMessage),
63 UndoDeletePrivateMessage(UndoDeletePrivateMessage),
64 AnnounceActivity(Box<AnnounceActivity>),
67 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler, ActivityFields)]
69 #[activity_handler(LemmyContext)]
70 pub enum AnnouncableActivities {
71 CreateOrUpdateComment(CreateOrUpdateComment),
72 CreateOrUpdatePost(Box<CreateOrUpdatePost>),
76 UndoDelete(UndoDelete),
77 UpdateCommunity(Box<UpdateCommunity>),
78 BlockUserFromCommunity(BlockUserFromCommunity),
79 UndoBlockUserFromCommunity(UndoBlockUserFromCommunity),
84 #[async_trait::async_trait(?Send)]
85 impl GetCommunity for AnnouncableActivities {
86 async fn get_community(
88 context: &LemmyContext,
89 request_counter: &mut i32,
90 ) -> Result<ApubCommunity, LemmyError> {
91 use AnnouncableActivities::*;
92 let community = match self {
93 CreateOrUpdateComment(a) => a.get_community(context, request_counter).await?,
94 CreateOrUpdatePost(a) => a.get_community(context, request_counter).await?,
95 Vote(a) => a.get_community(context, request_counter).await?,
96 UndoVote(a) => a.get_community(context, request_counter).await?,
97 Delete(a) => a.get_community(context, request_counter).await?,
98 UndoDelete(a) => a.get_community(context, request_counter).await?,
99 UpdateCommunity(a) => a.get_community(context, request_counter).await?,
100 BlockUserFromCommunity(a) => a.get_community(context, request_counter).await?,
101 UndoBlockUserFromCommunity(a) => a.get_community(context, request_counter).await?,
102 AddMod(a) => a.get_community(context, request_counter).await?,
103 RemoveMod(a) => a.get_community(context, request_counter).await?,