]> Untitled Git - lemmy.git/blob - crates/apub/src/protocol/activities/mod.rs
GNU social compatibility (#2100)
[lemmy.git] / crates / apub / src / protocol / activities / mod.rs
1 use serde::{Deserialize, Serialize};
2 use strum_macros::Display;
3
4 pub mod block;
5 pub mod community;
6 pub mod create_or_update;
7 pub mod deletion;
8 pub mod following;
9 pub mod voting;
10
11 #[derive(Clone, Debug, Display, Deserialize, Serialize, PartialEq)]
12 pub enum CreateOrUpdateType {
13   Create,
14   Update,
15 }
16
17 #[cfg(test)]
18 mod tests {
19   use crate::protocol::{
20     activities::{
21       create_or_update::{comment::CreateOrUpdateComment, post::CreateOrUpdatePost},
22       deletion::delete::Delete,
23       following::{follow::FollowCommunity, undo_follow::UndoFollowCommunity},
24       voting::vote::Vote,
25     },
26     tests::test_json,
27   };
28
29   #[test]
30   fn test_parse_smithereen_activities() {
31     test_json::<CreateOrUpdateComment>("assets/smithereen/activities/create_note.json").unwrap();
32   }
33
34   #[test]
35   fn test_parse_pleroma_activities() {
36     test_json::<CreateOrUpdateComment>("assets/pleroma/activities/create_note.json").unwrap();
37     test_json::<Delete>("assets/pleroma/activities/delete.json").unwrap();
38     test_json::<FollowCommunity>("assets/pleroma/activities/follow.json").unwrap();
39   }
40
41   #[test]
42   fn test_parse_mastodon_activities() {
43     test_json::<CreateOrUpdateComment>("assets/mastodon/activities/create_note.json").unwrap();
44     test_json::<Delete>("assets/mastodon/activities/delete.json").unwrap();
45     test_json::<FollowCommunity>("assets/mastodon/activities/follow.json").unwrap();
46     test_json::<UndoFollowCommunity>("assets/mastodon/activities/undo_follow.json").unwrap();
47   }
48
49   #[test]
50   fn test_parse_lotide_activities() {
51     test_json::<CreateOrUpdatePost>("assets/lotide/activities/create_page.json").unwrap();
52     test_json::<CreateOrUpdateComment>("assets/lotide/activities/create_note_reply.json").unwrap();
53   }
54
55   #[test]
56   fn test_parse_friendica_activities() {
57     test_json::<CreateOrUpdateComment>("assets/friendica/activities/create_note.json").unwrap();
58   }
59
60   #[test]
61   fn test_parse_gnusocial_activities() {
62     test_json::<CreateOrUpdatePost>("assets/gnusocial/activities/create_page.json").unwrap();
63     test_json::<CreateOrUpdateComment>("assets/gnusocial/activities/create_note.json").unwrap();
64     test_json::<Vote>("assets/gnusocial/activities/like_note.json").unwrap();
65   }
66 }