]> Untitled Git - lemmy.git/blob - crates/apub/src/protocol/objects/mod.rs
20aaca181cfef1f92560efb99ee4d041bd212445
[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::{
21     context::WithContext,
22     objects::tests::file_to_json_object,
23     protocol::{
24       objects::{
25         chat_message::ChatMessage,
26         group::Group,
27         instance::Instance,
28         note::Note,
29         page::Page,
30         person::Person,
31         tombstone::Tombstone,
32       },
33       tests::test_parse_lemmy_item,
34     },
35   };
36
37   #[actix_rt::test]
38   async fn test_parse_objects_lemmy() {
39     test_parse_lemmy_item::<Instance>("assets/lemmy/objects/instance.json").unwrap();
40     test_parse_lemmy_item::<Group>("assets/lemmy/objects/group.json").unwrap();
41     test_parse_lemmy_item::<Person>("assets/lemmy/objects/person.json").unwrap();
42     test_parse_lemmy_item::<Page>("assets/lemmy/objects/page.json").unwrap();
43     test_parse_lemmy_item::<Note>("assets/lemmy/objects/note.json").unwrap();
44     test_parse_lemmy_item::<ChatMessage>("assets/lemmy/objects/chat_message.json").unwrap();
45     test_parse_lemmy_item::<Tombstone>("assets/lemmy/objects/tombstone.json").unwrap();
46   }
47
48   #[actix_rt::test]
49   async fn test_parse_objects_pleroma() {
50     file_to_json_object::<WithContext<Person>>("assets/pleroma/objects/person.json").unwrap();
51     file_to_json_object::<WithContext<Note>>("assets/pleroma/objects/note.json").unwrap();
52     file_to_json_object::<WithContext<ChatMessage>>("assets/pleroma/objects/chat_message.json")
53       .unwrap();
54   }
55
56   #[actix_rt::test]
57   async fn test_parse_objects_smithereen() {
58     file_to_json_object::<WithContext<Person>>("assets/smithereen/objects/person.json").unwrap();
59     file_to_json_object::<Note>("assets/smithereen/objects/note.json").unwrap();
60   }
61
62   #[actix_rt::test]
63   async fn test_parse_objects_mastodon() {
64     file_to_json_object::<WithContext<Person>>("assets/mastodon/objects/person.json").unwrap();
65     file_to_json_object::<WithContext<Note>>("assets/mastodon/objects/note.json").unwrap();
66   }
67
68   #[actix_rt::test]
69   async fn test_parse_objects_lotide() {
70     file_to_json_object::<WithContext<Group>>("assets/lotide/objects/group.json").unwrap();
71     file_to_json_object::<WithContext<Person>>("assets/lotide/objects/person.json").unwrap();
72     file_to_json_object::<WithContext<Note>>("assets/lotide/objects/note.json").unwrap();
73     file_to_json_object::<WithContext<Page>>("assets/lotide/objects/page.json").unwrap();
74     file_to_json_object::<WithContext<Tombstone>>("assets/lotide/objects/tombstone.json").unwrap();
75   }
76
77   #[actix_rt::test]
78   async fn test_parse_object_friendica() {
79     file_to_json_object::<WithContext<Person>>("assets/friendica/objects/person.json").unwrap();
80     file_to_json_object::<WithContext<Note>>("assets/friendica/objects/note.json").unwrap();
81   }
82 }