]> Untitled Git - lemmy.git/blob - crates/apub/src/protocol/objects/mod.rs
04c65357893d5f970995fea13c0bc714b18a5fd3
[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 note;
7 pub(crate) mod page;
8 pub(crate) mod person;
9 pub(crate) mod tombstone;
10
11 #[derive(Clone, Debug, Deserialize, Serialize)]
12 #[serde(rename_all = "camelCase")]
13 pub struct Endpoints {
14   pub shared_inbox: Url,
15 }
16
17 #[cfg(test)]
18 mod tests {
19   use crate::{
20     context::WithContext,
21     objects::tests::file_to_json_object,
22     protocol::{
23       objects::{chat_message::ChatMessage, group::Group, note::Note, page::Page, person::Person},
24       tests::test_parse_lemmy_item,
25     },
26   };
27
28   #[actix_rt::test]
29   async fn test_parse_object_lemmy() {
30     test_parse_lemmy_item::<Person>("assets/lemmy/objects/person.json");
31     test_parse_lemmy_item::<Group>("assets/lemmy/objects/group.json");
32     test_parse_lemmy_item::<Page>("assets/lemmy/objects/page.json");
33     test_parse_lemmy_item::<Note>("assets/lemmy/objects/note.json");
34     test_parse_lemmy_item::<ChatMessage>("assets/lemmy/objects/chat_message.json");
35   }
36
37   #[actix_rt::test]
38   async fn test_parse_object_pleroma() {
39     file_to_json_object::<WithContext<Person>>("assets/pleroma/objects/person.json").unwrap();
40     file_to_json_object::<WithContext<Note>>("assets/pleroma/objects/note.json").unwrap();
41     file_to_json_object::<WithContext<ChatMessage>>("assets/pleroma/objects/chat_message.json")
42       .unwrap();
43   }
44
45   #[actix_rt::test]
46   async fn test_parse_object_smithereen() {
47     file_to_json_object::<WithContext<Person>>("assets/smithereen/objects/person.json").unwrap();
48     file_to_json_object::<Note>("assets/smithereen/objects/note.json").unwrap();
49   }
50
51   #[actix_rt::test]
52   async fn test_parse_object_mastodon() {
53     file_to_json_object::<Person>("assets/mastodon/objects/person.json").unwrap();
54     file_to_json_object::<Note>("assets/mastodon/objects/note.json").unwrap();
55   }
56
57   #[actix_rt::test]
58   async fn test_parse_object_lotide() {
59     file_to_json_object::<WithContext<Group>>("assets/lotide/objects/group.json").unwrap();
60     file_to_json_object::<WithContext<Person>>("assets/lotide/objects/person.json").unwrap();
61     file_to_json_object::<WithContext<Note>>("assets/lotide/objects/note.json").unwrap();
62     file_to_json_object::<WithContext<Page>>("assets/lotide/objects/page.json").unwrap();
63   }
64 }