]> Untitled Git - lemmy.git/blob - crates/apub/src/protocol/objects/mod.rs
Accept comments with hashtags from Friendica (#2236)
[lemmy.git] / crates / apub / src / protocol / objects / mod.rs
1 use serde::{Deserialize, Serialize};
2 use url::Url;
3
4 pub(crate) mod chat_message;
5 pub(crate) mod group;
6 pub(crate) mod instance;
7 pub(crate) mod note;
8 pub(crate) mod page;
9 pub(crate) mod person;
10 pub(crate) mod tombstone;
11
12 #[derive(Clone, Debug, Deserialize, Serialize)]
13 #[serde(rename_all = "camelCase")]
14 pub struct Endpoints {
15   pub shared_inbox: Url,
16 }
17
18 #[cfg(test)]
19 mod tests {
20   use crate::protocol::{
21     objects::{
22       chat_message::ChatMessage,
23       group::Group,
24       instance::Instance,
25       note::Note,
26       page::Page,
27       person::Person,
28       tombstone::Tombstone,
29     },
30     tests::{test_json, test_parse_lemmy_item},
31   };
32
33   #[test]
34   fn test_parse_objects_lemmy() {
35     test_parse_lemmy_item::<Instance>("assets/lemmy/objects/instance.json").unwrap();
36     test_parse_lemmy_item::<Group>("assets/lemmy/objects/group.json").unwrap();
37     test_parse_lemmy_item::<Person>("assets/lemmy/objects/person.json").unwrap();
38     test_parse_lemmy_item::<Page>("assets/lemmy/objects/page.json").unwrap();
39     test_parse_lemmy_item::<Note>("assets/lemmy/objects/note.json").unwrap();
40     test_parse_lemmy_item::<ChatMessage>("assets/lemmy/objects/chat_message.json").unwrap();
41     test_parse_lemmy_item::<Tombstone>("assets/lemmy/objects/tombstone.json").unwrap();
42   }
43
44   #[test]
45   fn test_parse_objects_pleroma() {
46     test_json::<Person>("assets/pleroma/objects/person.json").unwrap();
47     test_json::<Note>("assets/pleroma/objects/note.json").unwrap();
48     test_json::<ChatMessage>("assets/pleroma/objects/chat_message.json").unwrap();
49   }
50
51   #[test]
52   fn test_parse_objects_smithereen() {
53     test_json::<Person>("assets/smithereen/objects/person.json").unwrap();
54     test_json::<Note>("assets/smithereen/objects/note.json").unwrap();
55   }
56
57   #[test]
58   fn test_parse_objects_mastodon() {
59     test_json::<Person>("assets/mastodon/objects/person.json").unwrap();
60     test_json::<Note>("assets/mastodon/objects/note.json").unwrap();
61   }
62
63   #[test]
64   fn test_parse_objects_lotide() {
65     test_json::<Group>("assets/lotide/objects/group.json").unwrap();
66     test_json::<Person>("assets/lotide/objects/person.json").unwrap();
67     test_json::<Note>("assets/lotide/objects/note.json").unwrap();
68     test_json::<Page>("assets/lotide/objects/page.json").unwrap();
69     test_json::<Tombstone>("assets/lotide/objects/tombstone.json").unwrap();
70   }
71
72   #[test]
73   fn test_parse_object_friendica() {
74     test_json::<Person>("assets/friendica/objects/person_1.json").unwrap();
75     test_json::<Person>("assets/friendica/objects/person_2.json").unwrap();
76     test_json::<Page>("assets/friendica/objects/page_1.json").unwrap();
77     test_json::<Page>("assets/friendica/objects/page_2.json").unwrap();
78     test_json::<Note>("assets/friendica/objects/note_1.json").unwrap();
79     test_json::<Note>("assets/friendica/objects/note_2.json").unwrap();
80   }
81
82   #[test]
83   fn test_parse_object_gnusocial() {
84     test_json::<Person>("assets/gnusocial/objects/person.json").unwrap();
85     test_json::<Group>("assets/gnusocial/objects/group.json").unwrap();
86     test_json::<Page>("assets/gnusocial/objects/page.json").unwrap();
87     test_json::<Note>("assets/gnusocial/objects/note.json").unwrap();
88   }
89 }