1 use lemmy_db_schema::source::language::Language;
2 use serde::{Deserialize, Serialize};
5 pub(crate) mod chat_message;
7 pub(crate) mod instance;
10 pub(crate) mod person;
11 pub(crate) mod tombstone;
13 #[derive(Clone, Debug, Deserialize, Serialize)]
14 #[serde(rename_all = "camelCase")]
15 pub struct Endpoints {
16 pub shared_inbox: Url,
19 #[derive(Clone, Debug, Deserialize, Serialize)]
20 #[serde(rename_all = "camelCase")]
21 pub(crate) struct LanguageTag {
22 pub(crate) identifier: String,
23 pub(crate) name: String,
27 pub(crate) fn new(lang: Language) -> Option<LanguageTag> {
29 if lang.code == "und" {
33 identifier: lang.code,
42 use crate::protocol::{
44 chat_message::ChatMessage,
52 tests::{test_json, test_parse_lemmy_item},
56 fn test_parse_objects_lemmy() {
57 test_parse_lemmy_item::<Instance>("assets/lemmy/objects/instance.json").unwrap();
58 test_parse_lemmy_item::<Group>("assets/lemmy/objects/group.json").unwrap();
59 test_parse_lemmy_item::<Person>("assets/lemmy/objects/person.json").unwrap();
60 test_parse_lemmy_item::<Page>("assets/lemmy/objects/page.json").unwrap();
61 test_parse_lemmy_item::<Note>("assets/lemmy/objects/note.json").unwrap();
62 test_parse_lemmy_item::<ChatMessage>("assets/lemmy/objects/chat_message.json").unwrap();
63 test_parse_lemmy_item::<Tombstone>("assets/lemmy/objects/tombstone.json").unwrap();
67 fn test_parse_objects_pleroma() {
68 test_json::<Person>("assets/pleroma/objects/person.json").unwrap();
69 test_json::<Note>("assets/pleroma/objects/note.json").unwrap();
70 test_json::<ChatMessage>("assets/pleroma/objects/chat_message.json").unwrap();
74 fn test_parse_objects_smithereen() {
75 test_json::<Person>("assets/smithereen/objects/person.json").unwrap();
76 test_json::<Note>("assets/smithereen/objects/note.json").unwrap();
80 fn test_parse_objects_mastodon() {
81 test_json::<Person>("assets/mastodon/objects/person.json").unwrap();
82 test_json::<Note>("assets/mastodon/objects/note.json").unwrap();
86 fn test_parse_objects_lotide() {
87 test_json::<Group>("assets/lotide/objects/group.json").unwrap();
88 test_json::<Person>("assets/lotide/objects/person.json").unwrap();
89 test_json::<Note>("assets/lotide/objects/note.json").unwrap();
90 test_json::<Page>("assets/lotide/objects/page.json").unwrap();
91 test_json::<Tombstone>("assets/lotide/objects/tombstone.json").unwrap();
95 fn test_parse_object_friendica() {
96 test_json::<Person>("assets/friendica/objects/person_1.json").unwrap();
97 test_json::<Person>("assets/friendica/objects/person_2.json").unwrap();
98 test_json::<Page>("assets/friendica/objects/page_1.json").unwrap();
99 test_json::<Page>("assets/friendica/objects/page_2.json").unwrap();
100 test_json::<Note>("assets/friendica/objects/note_1.json").unwrap();
101 test_json::<Note>("assets/friendica/objects/note_2.json").unwrap();
105 fn test_parse_object_gnusocial() {
106 test_json::<Person>("assets/gnusocial/objects/person.json").unwrap();
107 test_json::<Group>("assets/gnusocial/objects/group.json").unwrap();
108 test_json::<Page>("assets/gnusocial/objects/page.json").unwrap();
109 test_json::<Note>("assets/gnusocial/objects/note.json").unwrap();
113 fn test_parse_object_peertube() {
114 test_json::<Person>("assets/peertube/objects/person.json").unwrap();
115 test_json::<Group>("assets/peertube/objects/group.json").unwrap();
116 test_json::<Page>("assets/peertube/objects/video.json").unwrap();
117 test_json::<Note>("assets/peertube/objects/note.json").unwrap();