private_message::CreateOrUpdatePrivateMessage,
},
deletion::{delete::Delete, delete_user::DeleteUser, undo_delete::UndoDelete},
- following::{
- accept::AcceptFollowCommunity,
- follow::FollowCommunity,
- undo_follow::UndoFollowCommunity,
- },
+ following::{accept::AcceptFollow, follow::Follow, undo_follow::UndoFollow},
voting::{undo_vote::UndoVote, vote::Vote},
},
objects::page::Page,
},
};
-use activitypub_federation::{deser::context::WithContext, traits::activity_handler};
+use activitypub_federation::{data::Data, deser::context::WithContext, traits::ActivityHandler};
use lemmy_utils::error::LemmyError;
use lemmy_websocket::LemmyContext;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
#[serde(untagged)]
-#[activity_handler(LemmyContext, LemmyError)]
+#[enum_delegate::implement(ActivityHandler)]
pub enum SharedInboxActivities {
PersonInboxActivities(Box<WithContext<PersonInboxActivities>>),
GroupInboxActivities(Box<WithContext<GroupInboxActivities>>),
#[derive(Debug, Deserialize, Serialize)]
#[serde(untagged)]
-#[activity_handler(LemmyContext, LemmyError)]
+#[enum_delegate::implement(ActivityHandler)]
pub enum GroupInboxActivities {
- FollowCommunity(FollowCommunity),
- UndoFollowCommunity(UndoFollowCommunity),
+ Follow(Follow),
+ UndoFollow(UndoFollow),
Report(Report),
// This is a catch-all and needs to be last
AnnouncableActivities(RawAnnouncableActivities),
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(untagged)]
-#[activity_handler(LemmyContext, LemmyError)]
+#[enum_delegate::implement(ActivityHandler)]
pub enum PersonInboxActivities {
- AcceptFollowCommunity(AcceptFollowCommunity),
+ AcceptFollow(AcceptFollow),
+ UndoFollow(UndoFollow),
+ FollowCommunity(Follow),
CreateOrUpdatePrivateMessage(CreateOrUpdatePrivateMessage),
Delete(Delete),
UndoDelete(UndoDelete),
/// inbox can fall through to be parsed as GroupInboxActivities::AnnouncableActivities.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(untagged)]
-#[activity_handler(LemmyContext, LemmyError)]
+#[enum_delegate::implement(ActivityHandler)]
pub enum PersonInboxActivitiesWithAnnouncable {
- PersonInboxActivities(PersonInboxActivities),
- AnnouncableActivities(AnnouncableActivities),
+ PersonInboxActivities(Box<PersonInboxActivities>),
+ AnnouncableActivities(Box<AnnouncableActivities>),
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(untagged)]
-#[activity_handler(LemmyContext, LemmyError)]
+#[enum_delegate::implement(ActivityHandler)]
pub enum AnnouncableActivities {
CreateOrUpdateComment(CreateOrUpdateComment),
- CreateOrUpdatePost(Box<CreateOrUpdatePost>),
+ CreateOrUpdatePost(CreateOrUpdatePost),
Vote(Vote),
UndoVote(UndoVote),
Delete(Delete),
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(untagged)]
-#[activity_handler(LemmyContext, LemmyError)]
+#[enum_delegate::implement(ActivityHandler)]
#[allow(clippy::enum_variant_names)]
pub enum SiteInboxActivities {
BlockUser(BlockUser),
#[cfg(test)]
mod tests {
use crate::{
- activity_lists::{GroupInboxActivities, PersonInboxActivities, SiteInboxActivities},
+ activity_lists::{
+ GroupInboxActivities,
+ PersonInboxActivities,
+ PersonInboxActivitiesWithAnnouncable,
+ SiteInboxActivities,
+ },
protocol::tests::test_parse_lemmy_item,
};
fn test_person_inbox() {
test_parse_lemmy_item::<PersonInboxActivities>("assets/lemmy/activities/following/accept.json")
.unwrap();
- test_parse_lemmy_item::<PersonInboxActivities>(
+ test_parse_lemmy_item::<PersonInboxActivitiesWithAnnouncable>(
"assets/lemmy/activities/create_or_update/create_note.json",
)
.unwrap();
- test_parse_lemmy_item::<PersonInboxActivities>(
+ test_parse_lemmy_item::<PersonInboxActivitiesWithAnnouncable>(
"assets/lemmy/activities/create_or_update/create_private_message.json",
)
.unwrap();