2021-11-06 13:25:34 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use url::Url;
|
|
|
|
|
2021-10-28 21:17:59 +00:00
|
|
|
pub(crate) mod chat_message;
|
|
|
|
pub(crate) mod group;
|
2022-02-07 19:23:12 +00:00
|
|
|
pub(crate) mod instance;
|
2021-10-28 21:17:59 +00:00
|
|
|
pub(crate) mod note;
|
|
|
|
pub(crate) mod page;
|
2021-11-01 13:05:20 +00:00
|
|
|
pub(crate) mod person;
|
2021-10-28 21:17:59 +00:00
|
|
|
pub(crate) mod tombstone;
|
2021-11-01 13:05:20 +00:00
|
|
|
|
2021-11-06 13:25:34 +00:00
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct Endpoints {
|
2022-01-17 14:40:47 +00:00
|
|
|
pub shared_inbox: Url,
|
2021-11-06 13:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-11-01 13:05:20 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2022-02-17 22:04:01 +00:00
|
|
|
use crate::protocol::{
|
|
|
|
objects::{
|
|
|
|
chat_message::ChatMessage,
|
|
|
|
group::Group,
|
|
|
|
instance::Instance,
|
|
|
|
note::Note,
|
|
|
|
page::Page,
|
|
|
|
person::Person,
|
|
|
|
tombstone::Tombstone,
|
2021-11-09 12:25:19 +00:00
|
|
|
},
|
2022-02-17 22:04:01 +00:00
|
|
|
tests::{test_json, test_parse_lemmy_item},
|
2021-11-01 13:05:20 +00:00
|
|
|
};
|
|
|
|
|
2022-02-17 22:04:01 +00:00
|
|
|
#[test]
|
|
|
|
fn test_parse_objects_lemmy() {
|
2022-02-07 19:23:12 +00:00
|
|
|
test_parse_lemmy_item::<Instance>("assets/lemmy/objects/instance.json").unwrap();
|
2022-01-20 14:13:29 +00:00
|
|
|
test_parse_lemmy_item::<Group>("assets/lemmy/objects/group.json").unwrap();
|
2022-02-07 19:23:12 +00:00
|
|
|
test_parse_lemmy_item::<Person>("assets/lemmy/objects/person.json").unwrap();
|
2022-01-20 14:13:29 +00:00
|
|
|
test_parse_lemmy_item::<Page>("assets/lemmy/objects/page.json").unwrap();
|
|
|
|
test_parse_lemmy_item::<Note>("assets/lemmy/objects/note.json").unwrap();
|
|
|
|
test_parse_lemmy_item::<ChatMessage>("assets/lemmy/objects/chat_message.json").unwrap();
|
|
|
|
test_parse_lemmy_item::<Tombstone>("assets/lemmy/objects/tombstone.json").unwrap();
|
2022-01-17 14:40:47 +00:00
|
|
|
}
|
2021-11-09 12:25:19 +00:00
|
|
|
|
2022-02-17 22:04:01 +00:00
|
|
|
#[test]
|
|
|
|
fn test_parse_objects_pleroma() {
|
|
|
|
test_json::<Person>("assets/pleroma/objects/person.json").unwrap();
|
|
|
|
test_json::<Note>("assets/pleroma/objects/note.json").unwrap();
|
|
|
|
test_json::<ChatMessage>("assets/pleroma/objects/chat_message.json").unwrap();
|
2022-01-17 14:40:47 +00:00
|
|
|
}
|
2021-11-09 12:25:19 +00:00
|
|
|
|
2022-02-17 22:04:01 +00:00
|
|
|
#[test]
|
|
|
|
fn test_parse_objects_smithereen() {
|
|
|
|
test_json::<Person>("assets/smithereen/objects/person.json").unwrap();
|
|
|
|
test_json::<Note>("assets/smithereen/objects/note.json").unwrap();
|
2022-01-17 14:40:47 +00:00
|
|
|
}
|
2021-11-09 12:25:19 +00:00
|
|
|
|
2022-02-17 22:04:01 +00:00
|
|
|
#[test]
|
|
|
|
fn test_parse_objects_mastodon() {
|
|
|
|
test_json::<Person>("assets/mastodon/objects/person.json").unwrap();
|
|
|
|
test_json::<Note>("assets/mastodon/objects/note.json").unwrap();
|
2022-01-17 14:40:47 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 22:04:01 +00:00
|
|
|
#[test]
|
|
|
|
fn test_parse_objects_lotide() {
|
|
|
|
test_json::<Group>("assets/lotide/objects/group.json").unwrap();
|
|
|
|
test_json::<Person>("assets/lotide/objects/person.json").unwrap();
|
|
|
|
test_json::<Note>("assets/lotide/objects/note.json").unwrap();
|
|
|
|
test_json::<Page>("assets/lotide/objects/page.json").unwrap();
|
|
|
|
test_json::<Tombstone>("assets/lotide/objects/tombstone.json").unwrap();
|
2021-11-01 13:05:20 +00:00
|
|
|
}
|
2022-01-28 21:47:34 +00:00
|
|
|
|
2022-02-17 22:04:01 +00:00
|
|
|
#[test]
|
|
|
|
fn test_parse_object_friendica() {
|
2022-04-12 17:10:35 +00:00
|
|
|
test_json::<Person>("assets/friendica/objects/person_1.json").unwrap();
|
|
|
|
test_json::<Person>("assets/friendica/objects/person_2.json").unwrap();
|
2022-03-29 15:48:29 +00:00
|
|
|
test_json::<Page>("assets/friendica/objects/page_1.json").unwrap();
|
|
|
|
test_json::<Page>("assets/friendica/objects/page_2.json").unwrap();
|
2022-04-27 16:12:13 +00:00
|
|
|
test_json::<Note>("assets/friendica/objects/note_1.json").unwrap();
|
|
|
|
test_json::<Note>("assets/friendica/objects/note_2.json").unwrap();
|
2022-01-28 21:47:34 +00:00
|
|
|
}
|
2022-03-24 16:33:42 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_parse_object_gnusocial() {
|
|
|
|
test_json::<Person>("assets/gnusocial/objects/person.json").unwrap();
|
|
|
|
test_json::<Group>("assets/gnusocial/objects/group.json").unwrap();
|
|
|
|
test_json::<Page>("assets/gnusocial/objects/page.json").unwrap();
|
|
|
|
test_json::<Note>("assets/gnusocial/objects/note.json").unwrap();
|
|
|
|
}
|
2022-05-06 23:53:33 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_parse_object_peertube() {
|
|
|
|
test_json::<Person>("assets/peertube/objects/person.json").unwrap();
|
|
|
|
test_json::<Group>("assets/peertube/objects/group.json").unwrap();
|
|
|
|
test_json::<Page>("assets/peertube/objects/video.json").unwrap();
|
|
|
|
test_json::<Note>("assets/peertube/objects/note.json").unwrap();
|
|
|
|
}
|
2021-11-01 13:05:20 +00:00
|
|
|
}
|