2021-10-29 10:32:42 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2021-12-14 13:30:37 +00:00
|
|
|
use strum_macros::Display;
|
2021-10-29 10:32:42 +00:00
|
|
|
|
2022-02-07 19:23:12 +00:00
|
|
|
pub mod block;
|
2021-10-29 10:32:42 +00:00
|
|
|
pub mod community;
|
|
|
|
pub mod create_or_update;
|
|
|
|
pub mod deletion;
|
|
|
|
pub mod following;
|
|
|
|
pub mod voting;
|
|
|
|
|
2022-09-26 14:09:32 +00:00
|
|
|
#[derive(Clone, Debug, Display, Deserialize, Serialize, PartialEq, Eq)]
|
2021-10-29 10:32:42 +00:00
|
|
|
pub enum CreateOrUpdateType {
|
|
|
|
Create,
|
|
|
|
Update,
|
|
|
|
}
|
2022-02-17 22:04:01 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use crate::protocol::{
|
|
|
|
activities::{
|
2022-05-06 23:53:33 +00:00
|
|
|
community::announce::AnnounceActivity,
|
2022-12-01 20:52:49 +00:00
|
|
|
create_or_update::{note::CreateOrUpdateNote, page::CreateOrUpdatePage},
|
2022-02-17 22:04:01 +00:00
|
|
|
deletion::delete::Delete,
|
2022-11-23 23:40:47 +00:00
|
|
|
following::{follow::Follow, undo_follow::UndoFollow},
|
2022-03-29 15:48:29 +00:00
|
|
|
voting::{undo_vote::UndoVote, vote::Vote},
|
2022-02-17 22:04:01 +00:00
|
|
|
},
|
|
|
|
tests::test_json,
|
|
|
|
};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_parse_smithereen_activities() {
|
2022-12-01 20:52:49 +00:00
|
|
|
test_json::<CreateOrUpdateNote>("assets/smithereen/activities/create_note.json").unwrap();
|
2022-02-17 22:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_parse_pleroma_activities() {
|
2022-12-01 20:52:49 +00:00
|
|
|
test_json::<CreateOrUpdateNote>("assets/pleroma/activities/create_note.json").unwrap();
|
2022-02-17 22:04:01 +00:00
|
|
|
test_json::<Delete>("assets/pleroma/activities/delete.json").unwrap();
|
2022-11-23 23:40:47 +00:00
|
|
|
test_json::<Follow>("assets/pleroma/activities/follow.json").unwrap();
|
2022-02-17 22:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_parse_mastodon_activities() {
|
2022-12-01 20:52:49 +00:00
|
|
|
test_json::<CreateOrUpdateNote>("assets/mastodon/activities/create_note.json").unwrap();
|
2022-02-17 22:04:01 +00:00
|
|
|
test_json::<Delete>("assets/mastodon/activities/delete.json").unwrap();
|
2022-11-23 23:40:47 +00:00
|
|
|
test_json::<Follow>("assets/mastodon/activities/follow.json").unwrap();
|
|
|
|
test_json::<UndoFollow>("assets/mastodon/activities/undo_follow.json").unwrap();
|
2022-07-29 13:32:12 +00:00
|
|
|
test_json::<Vote>("assets/mastodon/activities/like_page.json").unwrap();
|
|
|
|
test_json::<UndoVote>("assets/mastodon/activities/undo_like_page.json").unwrap();
|
2022-02-17 22:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_parse_lotide_activities() {
|
2022-12-01 20:52:49 +00:00
|
|
|
test_json::<CreateOrUpdatePage>("assets/lotide/activities/create_page.json").unwrap();
|
|
|
|
test_json::<CreateOrUpdatePage>("assets/lotide/activities/create_page_image.json").unwrap();
|
|
|
|
test_json::<CreateOrUpdateNote>("assets/lotide/activities/create_note_reply.json").unwrap();
|
2022-02-17 22:04:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_parse_friendica_activities() {
|
2022-12-01 20:52:49 +00:00
|
|
|
test_json::<CreateOrUpdatePage>("assets/friendica/activities/create_page_1.json").unwrap();
|
|
|
|
test_json::<CreateOrUpdatePage>("assets/friendica/activities/create_page_2.json").unwrap();
|
|
|
|
test_json::<CreateOrUpdateNote>("assets/friendica/activities/create_note.json").unwrap();
|
|
|
|
test_json::<CreateOrUpdateNote>("assets/friendica/activities/update_note.json").unwrap();
|
2022-03-29 15:48:29 +00:00
|
|
|
test_json::<Delete>("assets/friendica/activities/delete.json").unwrap();
|
|
|
|
test_json::<Vote>("assets/friendica/activities/like_page.json").unwrap();
|
|
|
|
test_json::<Vote>("assets/friendica/activities/dislike_page.json").unwrap();
|
|
|
|
test_json::<UndoVote>("assets/friendica/activities/undo_dislike_page.json").unwrap();
|
2022-02-17 22:04:01 +00:00
|
|
|
}
|
2022-03-24 16:33:42 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_parse_gnusocial_activities() {
|
2022-12-01 20:52:49 +00:00
|
|
|
test_json::<CreateOrUpdatePage>("assets/gnusocial/activities/create_page.json").unwrap();
|
|
|
|
test_json::<CreateOrUpdateNote>("assets/gnusocial/activities/create_note.json").unwrap();
|
2022-03-24 16:33:42 +00:00
|
|
|
test_json::<Vote>("assets/gnusocial/activities/like_note.json").unwrap();
|
|
|
|
}
|
2022-05-06 23:53:33 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_parse_peertube_activities() {
|
|
|
|
test_json::<AnnounceActivity>("assets/peertube/activities/announce_video.json").unwrap();
|
|
|
|
}
|
2022-02-17 22:04:01 +00:00
|
|
|
}
|