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, delete_user::DeleteUser, undo_delete::UndoDelete},
21 accept::AcceptFollowCommunity,
22 follow::FollowCommunity,
23 undo_follow::UndoFollowCommunity,
25 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};
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),
66 UndoDelete(UndoDelete),
67 AnnounceActivity(AnnounceActivity),
70 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
72 #[activity_handler(LemmyContext)]
73 pub enum AnnouncableActivities {
74 CreateOrUpdateComment(CreateOrUpdateComment),
75 CreateOrUpdatePost(Box<CreateOrUpdatePost>),
79 UndoDelete(UndoDelete),
80 UpdateCommunity(UpdateCommunity),
82 UndoBlockUser(UndoBlockUser),
85 // For compatibility with Pleroma/Mastodon (send only)
89 #[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
91 #[activity_handler(LemmyContext)]
92 #[allow(clippy::enum_variant_names)]
93 pub enum SiteInboxActivities {
95 UndoBlockUser(UndoBlockUser),
96 DeleteUser(DeleteUser),
99 #[async_trait::async_trait(?Send)]
100 impl GetCommunity for AnnouncableActivities {
101 #[tracing::instrument(skip(self, context))]
102 async fn get_community(
104 context: &LemmyContext,
105 request_counter: &mut i32,
106 ) -> Result<ApubCommunity, LemmyError> {
107 use AnnouncableActivities::*;
108 let community = match self {
109 CreateOrUpdateComment(a) => a.get_community(context, request_counter).await?,
110 CreateOrUpdatePost(a) => a.get_community(context, request_counter).await?,
111 Vote(a) => a.get_community(context, request_counter).await?,
112 UndoVote(a) => a.get_community(context, request_counter).await?,
113 Delete(a) => a.get_community(context, request_counter).await?,
114 UndoDelete(a) => a.get_community(context, request_counter).await?,
115 UpdateCommunity(a) => a.get_community(context, request_counter).await?,
116 BlockUser(a) => a.get_community(context, request_counter).await?,
117 UndoBlockUser(a) => a.get_community(context, request_counter).await?,
118 AddMod(a) => a.get_community(context, request_counter).await?,
119 RemoveMod(a) => a.get_community(context, request_counter).await?,
120 Page(_) => unimplemented!(),
126 impl Id for AnnouncableActivities {
127 fn id(&self) -> &Url {
128 use AnnouncableActivities::*;
130 CreateOrUpdateComment(c) => &c.id,
131 CreateOrUpdatePost(c) => &c.id,
133 UndoVote(u) => &u.id,
135 UndoDelete(u) => &u.id,
136 UpdateCommunity(u) => &u.id,
137 BlockUser(b) => &b.id,
138 UndoBlockUser(u) => &u.id,
140 RemoveMod(r) => &r.id,
141 Page(p) => p.id.inner(),