]> Untitled Git - lemmy.git/blob - crates/apub/src/protocol/activities/mod.rs
Diesel 2.0.0 upgrade (#2452)
[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, Eq)]
12 pub enum CreateOrUpdateType {
13   Create,
14   Update,
15 }
16
17 #[cfg(test)]
18 mod tests {
19   use crate::protocol::{
20     activities::{
21       community::announce::AnnounceActivity,
22       create_or_update::{comment::CreateOrUpdateComment, post::CreateOrUpdatePost},
23       deletion::delete::Delete,
24       following::{follow::FollowCommunity, undo_follow::UndoFollowCommunity},
25       voting::{undo_vote::UndoVote, vote::Vote},
26     },
27     tests::test_json,
28   };
29
30   #[test]
31   fn test_parse_smithereen_activities() {
32     test_json::<CreateOrUpdateComment>("assets/smithereen/activities/create_note.json").unwrap();
33   }
34
35   #[test]
36   fn test_parse_pleroma_activities() {
37     test_json::<CreateOrUpdateComment>("assets/pleroma/activities/create_note.json").unwrap();
38     test_json::<Delete>("assets/pleroma/activities/delete.json").unwrap();
39     test_json::<FollowCommunity>("assets/pleroma/activities/follow.json").unwrap();
40   }
41
42   #[test]
43   fn test_parse_mastodon_activities() {
44     test_json::<CreateOrUpdateComment>("assets/mastodon/activities/create_note.json").unwrap();
45     test_json::<Delete>("assets/mastodon/activities/delete.json").unwrap();
46     test_json::<FollowCommunity>("assets/mastodon/activities/follow.json").unwrap();
47     test_json::<UndoFollowCommunity>("assets/mastodon/activities/undo_follow.json").unwrap();
48     test_json::<Vote>("assets/mastodon/activities/like_page.json").unwrap();
49     test_json::<UndoVote>("assets/mastodon/activities/undo_like_page.json").unwrap();
50   }
51
52   #[test]
53   fn test_parse_lotide_activities() {
54     test_json::<CreateOrUpdatePost>("assets/lotide/activities/create_page.json").unwrap();
55     test_json::<CreateOrUpdatePost>("assets/lotide/activities/create_page_image.json").unwrap();
56     test_json::<CreateOrUpdateComment>("assets/lotide/activities/create_note_reply.json").unwrap();
57   }
58
59   #[test]
60   fn test_parse_friendica_activities() {
61     test_json::<CreateOrUpdatePost>("assets/friendica/activities/create_page_1.json").unwrap();
62     test_json::<CreateOrUpdatePost>("assets/friendica/activities/create_page_2.json").unwrap();
63     test_json::<CreateOrUpdateComment>("assets/friendica/activities/create_note.json").unwrap();
64     test_json::<CreateOrUpdateComment>("assets/friendica/activities/update_note.json").unwrap();
65     test_json::<Delete>("assets/friendica/activities/delete.json").unwrap();
66     test_json::<Vote>("assets/friendica/activities/like_page.json").unwrap();
67     test_json::<Vote>("assets/friendica/activities/dislike_page.json").unwrap();
68     test_json::<UndoVote>("assets/friendica/activities/undo_dislike_page.json").unwrap();
69   }
70
71   #[test]
72   fn test_parse_gnusocial_activities() {
73     test_json::<CreateOrUpdatePost>("assets/gnusocial/activities/create_page.json").unwrap();
74     test_json::<CreateOrUpdateComment>("assets/gnusocial/activities/create_note.json").unwrap();
75     test_json::<Vote>("assets/gnusocial/activities/like_note.json").unwrap();
76   }
77
78   #[test]
79   fn test_parse_peertube_activities() {
80     test_json::<AnnounceActivity>("assets/peertube/activities/announce_video.json").unwrap();
81   }
82 }