2021-10-29 10:32:42 +00:00
|
|
|
use crate::{
|
|
|
|
activities::community::announce::GetCommunity,
|
|
|
|
objects::community::ApubCommunity,
|
2021-11-11 19:49:15 +00:00
|
|
|
protocol::{
|
|
|
|
activities::{
|
|
|
|
community::{
|
|
|
|
add_mod::AddMod,
|
|
|
|
announce::AnnounceActivity,
|
|
|
|
block_user::BlockUserFromCommunity,
|
|
|
|
remove_mod::RemoveMod,
|
|
|
|
report::Report,
|
|
|
|
undo_block_user::UndoBlockUserFromCommunity,
|
|
|
|
update::UpdateCommunity,
|
|
|
|
},
|
|
|
|
create_or_update::{comment::CreateOrUpdateComment, post::CreateOrUpdatePost},
|
|
|
|
deletion::{delete::Delete, undo_delete::UndoDelete},
|
|
|
|
following::{
|
|
|
|
accept::AcceptFollowCommunity,
|
|
|
|
follow::FollowCommunity,
|
|
|
|
undo_follow::UndoFollowCommunity,
|
|
|
|
},
|
|
|
|
private_message::{
|
|
|
|
create_or_update::CreateOrUpdatePrivateMessage,
|
|
|
|
delete::DeletePrivateMessage,
|
|
|
|
undo_delete::UndoDeletePrivateMessage,
|
|
|
|
},
|
|
|
|
voting::{undo_vote::UndoVote, vote::Vote},
|
2021-10-29 10:32:42 +00:00
|
|
|
},
|
2021-11-18 15:20:35 +00:00
|
|
|
objects::page::Page,
|
2021-10-29 10:32:42 +00:00
|
|
|
},
|
|
|
|
};
|
2021-11-03 17:33:51 +00:00
|
|
|
use lemmy_apub_lib::traits::ActivityHandler;
|
2021-11-01 13:05:20 +00:00
|
|
|
use lemmy_utils::LemmyError;
|
|
|
|
use lemmy_websocket::LemmyContext;
|
|
|
|
use serde::{Deserialize, Serialize};
|
2021-10-29 10:32:42 +00:00
|
|
|
|
2021-11-03 17:33:51 +00:00
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
|
2021-10-29 10:32:42 +00:00
|
|
|
#[serde(untagged)]
|
|
|
|
#[activity_handler(LemmyContext)]
|
|
|
|
pub enum SharedInboxActivities {
|
2021-11-09 18:16:37 +00:00
|
|
|
GroupInboxActivities(Box<GroupInboxActivities>),
|
2021-10-29 10:32:42 +00:00
|
|
|
// Note, pm activities need to be at the end, otherwise comments will end up here. We can probably
|
|
|
|
// avoid this problem by replacing createpm.object with our own struct, instead of NoteExt.
|
2021-11-06 13:25:34 +00:00
|
|
|
PersonInboxActivities(Box<PersonInboxActivities>),
|
2021-10-29 10:32:42 +00:00
|
|
|
}
|
|
|
|
|
2021-11-03 17:33:51 +00:00
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
|
2021-10-29 10:32:42 +00:00
|
|
|
#[serde(untagged)]
|
|
|
|
#[activity_handler(LemmyContext)]
|
|
|
|
pub enum GroupInboxActivities {
|
|
|
|
FollowCommunity(FollowCommunity),
|
|
|
|
UndoFollowCommunity(UndoFollowCommunity),
|
2021-11-06 13:25:34 +00:00
|
|
|
AnnouncableActivities(Box<AnnouncableActivities>),
|
2021-10-29 10:32:42 +00:00
|
|
|
Report(Report),
|
|
|
|
}
|
|
|
|
|
2021-11-03 17:33:51 +00:00
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
|
2021-10-29 10:32:42 +00:00
|
|
|
#[serde(untagged)]
|
|
|
|
#[activity_handler(LemmyContext)]
|
|
|
|
pub enum PersonInboxActivities {
|
|
|
|
AcceptFollowCommunity(AcceptFollowCommunity),
|
|
|
|
/// Some activities can also be sent from user to user, eg a comment with mentions
|
|
|
|
AnnouncableActivities(AnnouncableActivities),
|
|
|
|
CreateOrUpdatePrivateMessage(CreateOrUpdatePrivateMessage),
|
|
|
|
DeletePrivateMessage(DeletePrivateMessage),
|
|
|
|
UndoDeletePrivateMessage(UndoDeletePrivateMessage),
|
2021-11-06 13:25:34 +00:00
|
|
|
AnnounceActivity(AnnounceActivity),
|
2021-10-29 10:32:42 +00:00
|
|
|
}
|
|
|
|
|
2021-11-03 17:33:51 +00:00
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler)]
|
2021-10-29 10:32:42 +00:00
|
|
|
#[serde(untagged)]
|
|
|
|
#[activity_handler(LemmyContext)]
|
|
|
|
pub enum AnnouncableActivities {
|
|
|
|
CreateOrUpdateComment(CreateOrUpdateComment),
|
2021-11-06 13:25:34 +00:00
|
|
|
CreateOrUpdatePost(CreateOrUpdatePost),
|
2021-10-29 10:32:42 +00:00
|
|
|
Vote(Vote),
|
|
|
|
UndoVote(UndoVote),
|
|
|
|
Delete(Delete),
|
|
|
|
UndoDelete(UndoDelete),
|
2021-11-06 13:25:34 +00:00
|
|
|
UpdateCommunity(UpdateCommunity),
|
2021-10-29 10:32:42 +00:00
|
|
|
BlockUserFromCommunity(BlockUserFromCommunity),
|
|
|
|
UndoBlockUserFromCommunity(UndoBlockUserFromCommunity),
|
|
|
|
AddMod(AddMod),
|
|
|
|
RemoveMod(RemoveMod),
|
2021-11-11 19:49:15 +00:00
|
|
|
// For compatibility with Pleroma/Mastodon (send only)
|
|
|
|
Page(Page),
|
2021-10-29 10:32:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[async_trait::async_trait(?Send)]
|
|
|
|
impl GetCommunity for AnnouncableActivities {
|
2021-12-06 14:54:47 +00:00
|
|
|
#[tracing::instrument(skip(self, context))]
|
2021-10-29 10:32:42 +00:00
|
|
|
async fn get_community(
|
|
|
|
&self,
|
|
|
|
context: &LemmyContext,
|
|
|
|
request_counter: &mut i32,
|
|
|
|
) -> Result<ApubCommunity, LemmyError> {
|
|
|
|
use AnnouncableActivities::*;
|
|
|
|
let community = match self {
|
|
|
|
CreateOrUpdateComment(a) => a.get_community(context, request_counter).await?,
|
|
|
|
CreateOrUpdatePost(a) => a.get_community(context, request_counter).await?,
|
|
|
|
Vote(a) => a.get_community(context, request_counter).await?,
|
|
|
|
UndoVote(a) => a.get_community(context, request_counter).await?,
|
|
|
|
Delete(a) => a.get_community(context, request_counter).await?,
|
|
|
|
UndoDelete(a) => a.get_community(context, request_counter).await?,
|
|
|
|
UpdateCommunity(a) => a.get_community(context, request_counter).await?,
|
|
|
|
BlockUserFromCommunity(a) => a.get_community(context, request_counter).await?,
|
|
|
|
UndoBlockUserFromCommunity(a) => a.get_community(context, request_counter).await?,
|
|
|
|
AddMod(a) => a.get_community(context, request_counter).await?,
|
|
|
|
RemoveMod(a) => a.get_community(context, request_counter).await?,
|
2021-11-11 19:49:15 +00:00
|
|
|
Page(_) => unimplemented!(),
|
2021-10-29 10:32:42 +00:00
|
|
|
};
|
|
|
|
Ok(community)
|
|
|
|
}
|
|
|
|
}
|