- 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?,
- };
- Ok(community)
+ match self {
+ CreateOrUpdateComment(a) => a.community(context).await,
+ CreateOrUpdatePost(a) => a.community(context).await,
+ Vote(a) => a.community(context).await,
+ UndoVote(a) => a.community(context).await,
+ Delete(a) => a.community(context).await,
+ UndoDelete(a) => a.community(context).await,
+ UpdateCommunity(a) => a.community(context).await,
+ BlockUser(a) => a.community(context).await,
+ UndoBlockUser(a) => a.community(context).await,
+ CollectionAdd(a) => a.community(context).await,
+ CollectionRemove(a) => a.community(context).await,
+ LockPost(a) => a.community(context).await,
+ UndoLockPost(a) => a.community(context).await,
+ Page(_) => unimplemented!(),
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ #![allow(clippy::unwrap_used)]
+ #![allow(clippy::indexing_slicing)]
+
+ use crate::{
+ activity_lists::{
+ GroupInboxActivities,
+ PersonInboxActivities,
+ PersonInboxActivitiesWithAnnouncable,
+ SiteInboxActivities,
+ },
+ protocol::tests::{test_json, test_parse_lemmy_item},
+ };
+
+ #[test]
+ fn test_group_inbox() {
+ test_parse_lemmy_item::<GroupInboxActivities>("assets/lemmy/activities/following/follow.json")
+ .unwrap();
+ test_parse_lemmy_item::<GroupInboxActivities>(
+ "assets/lemmy/activities/create_or_update/create_note.json",
+ )
+ .unwrap();
+ }
+
+ #[test]
+ fn test_person_inbox() {
+ test_parse_lemmy_item::<PersonInboxActivities>("assets/lemmy/activities/following/accept.json")
+ .unwrap();
+ test_parse_lemmy_item::<PersonInboxActivitiesWithAnnouncable>(
+ "assets/lemmy/activities/create_or_update/create_note.json",
+ )
+ .unwrap();
+ test_parse_lemmy_item::<PersonInboxActivitiesWithAnnouncable>(
+ "assets/lemmy/activities/create_or_update/create_private_message.json",
+ )
+ .unwrap();
+ test_json::<PersonInboxActivitiesWithAnnouncable>("assets/mastodon/activities/follow.json")
+ .unwrap();
+ }
+
+ #[test]
+ fn test_site_inbox() {
+ test_parse_lemmy_item::<SiteInboxActivities>(
+ "assets/lemmy/activities/deletion/delete_user.json",
+ )
+ .unwrap();