"url",
]
+[[package]]
+name = "activitystreams-kinds"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0784e99afd032199d3ed70cefb8eb3a8d1aef15f7f2c4e68d033c4e12bb6079e"
+dependencies = [
+ "serde",
+ "url",
+]
+
[[package]]
name = "actix"
version = "0.12.0"
name = "lemmy_apub"
version = "0.14.1"
dependencies = [
- "activitystreams",
+ "activitystreams-kinds",
"actix",
"actix-rt",
"actix-web",
lemmy_api_common = { version = "=0.14.1", path = "../api_common" }
lemmy_websocket = { version = "=0.14.1", path = "../websocket" }
diesel = "1.4.8"
-activitystreams = "0.7.0-alpha.11"
+activitystreams-kinds = "0.1.2"
bcrypt = "0.10.1"
chrono = { version = "0.4.19", features = ["serde"] }
serde_json = { version = "1.0.68", features = ["preserve_order"] }
objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson},
protocol::activities::{create_or_update::comment::CreateOrUpdateComment, CreateOrUpdateType},
};
-use activitystreams::{link::LinkExt, public};
+use activitystreams_kinds::public;
use lemmy_api_common::{blocking, check_post_deleted_or_removed};
use lemmy_apub_lib::{
data::Data,
let tagged_users: Vec<ObjectId<ApubPerson>> = create_or_update
.tag
.iter()
- .map(|t| t.href())
- .flatten()
- .map(|t| ObjectId::new(t.clone()))
+ .map(|t| t.href.clone())
+ .map(ObjectId::new)
.collect();
let mut inboxes = vec![];
for t in tagged_users {
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::community::add_mod::AddMod,
};
-use activitystreams::{activity::kind::AddType, public};
+use activitystreams_kinds::{activity::AddType, public};
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
data::Data,
objects::community::ApubCommunity,
protocol::activities::{community::announce::AnnounceActivity, CreateOrUpdateType},
};
-use activitystreams::{activity::kind::AnnounceType, public};
+use activitystreams_kinds::{activity::AnnounceType, public};
use lemmy_apub_lib::{
data::Data,
object_id::ObjectId,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::community::block_user::BlockUserFromCommunity,
};
-use activitystreams::{activity::kind::BlockType, public};
+use activitystreams_kinds::{activity::BlockType, public};
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
data::Data,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::community::remove_mod::RemoveMod,
};
-use activitystreams::{activity::kind::RemoveType, public};
+use activitystreams_kinds::{activity::RemoveType, public};
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
data::Data,
protocol::activities::community::report::Report,
PostOrComment,
};
-use activitystreams::activity::kind::FlagType;
+use activitystreams_kinds::activity::FlagType;
use lemmy_api_common::{blocking, comment::CommentReportResponse, post::PostReportResponse};
use lemmy_apub_lib::{
data::Data,
undo_block_user::UndoBlockUserFromCommunity,
},
};
-use activitystreams::{activity::kind::UndoType, public};
+use activitystreams_kinds::{activity::UndoType, public};
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
data::Data,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::community::update::UpdateCommunity,
};
-use activitystreams::{activity::kind::UpdateType, public};
+use activitystreams_kinds::{activity::UpdateType, public};
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
data::Data,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::deletion::delete::Delete,
};
-use activitystreams::{activity::kind::DeleteType, public};
+use activitystreams_kinds::{activity::DeleteType, public};
use anyhow::anyhow;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::deletion::{delete::Delete, undo_delete::UndoDelete},
};
-use activitystreams::{activity::kind::UndoType, public};
+use activitystreams_kinds::{activity::UndoType, public};
use anyhow::anyhow;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
activities::{generate_activity_id, send_lemmy_activity, verify_activity},
protocol::activities::following::{accept::AcceptFollowCommunity, follow::FollowCommunity},
};
-use activitystreams::activity::kind::AcceptType;
+use activitystreams_kinds::activity::AcceptType;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
data::Data,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::following::{accept::AcceptFollowCommunity, follow::FollowCommunity},
};
-use activitystreams::activity::kind::FollowType;
+use activitystreams_kinds::activity::FollowType;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
data::Data,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::following::{follow::FollowCommunity, undo_follow::UndoFollowCommunity},
};
-use activitystreams::activity::kind::UndoType;
+use activitystreams_kinds::activity::UndoType;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
data::Data,
insert_activity,
objects::{community::ApubCommunity, person::ApubPerson},
};
-use activitystreams::public;
+use activitystreams_kinds::public;
use anyhow::anyhow;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost},
protocol::activities::{create_or_update::post::CreateOrUpdatePost, CreateOrUpdateType},
};
-use activitystreams::public;
+use activitystreams_kinds::public;
use anyhow::anyhow;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
objects::{person::ApubPerson, private_message::ApubPrivateMessage},
protocol::activities::private_message::delete::DeletePrivateMessage,
};
-use activitystreams::activity::kind::DeleteType;
+use activitystreams_kinds::activity::DeleteType;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
data::Data,
undo_delete::UndoDeletePrivateMessage,
},
};
-use activitystreams::activity::kind::UndoType;
+use activitystreams_kinds::activity::UndoType;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
data::Data,
},
PostOrComment,
};
-use activitystreams::{activity::kind::UndoType, public};
+use activitystreams_kinds::{activity::UndoType, public};
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
data::Data,
protocol::activities::voting::vote::{Vote, VoteType},
PostOrComment,
};
-use activitystreams::public;
+use activitystreams_kinds::public;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
data::Data,
objects::person::ApubPerson,
protocol::collections::group_moderators::GroupModerators,
};
-use activitystreams::{chrono::NaiveDateTime, collection::kind::OrderedCollectionType};
+use activitystreams_kinds::collection::OrderedCollectionType;
+use chrono::NaiveDateTime;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{object_id::ObjectId, traits::ApubObject, verify::verify_domains_match};
use lemmy_db_schema::{
collections::group_outbox::GroupOutbox,
},
};
-use activitystreams::collection::kind::OrderedCollectionType;
+use activitystreams_kinds::collection::OrderedCollectionType;
use chrono::NaiveDateTime;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
-use activitystreams::{base::AnyBase, primitives::OneOrMany};
use serde::{Deserialize, Serialize};
lazy_static! {
- static ref CONTEXT: OneOrMany<AnyBase> =
+ static ref CONTEXT: Vec<serde_json::Value> =
serde_json::from_str(include_str!("../assets/lemmy/context.json")).expect("parse context");
}
-#[derive(Serialize, Deserialize)]
+#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct WithContext<T> {
#[serde(rename = "@context")]
- context: OneOrMany<AnyBase>,
+ context: Vec<serde_json::Value>,
#[serde(flatten)]
inner: T,
}
objects::{community::ApubCommunity, person::ApubPerson},
protocol::objects::{group::Group, person::Person},
};
-use activitystreams::{chrono::NaiveDateTime, url::Url};
+use chrono::NaiveDateTime;
use lemmy_apub_lib::traits::{ActorType, ApubObject};
use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext;
use serde::Deserialize;
+use url::Url;
#[derive(Clone, Debug)]
pub enum UserOrCommunity {
fetcher::webfinger::webfinger_resolve_actor,
objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson},
};
-use activitystreams::{
- base::BaseExt,
- link::{LinkExt, Mention},
-};
+use activitystreams_kinds::link::MentionType;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{object_id::ObjectId, traits::ActorType};
use lemmy_db_schema::{
LemmyError,
};
use lemmy_websocket::LemmyContext;
+use serde::{Deserialize, Serialize};
use url::Url;
+#[derive(Clone, Debug, Deserialize, Serialize)]
+pub struct Mention {
+ pub href: Url,
+ name: Option<String>,
+ #[serde(rename = "type")]
+ pub kind: MentionType,
+}
+
pub struct MentionsAndAddresses {
pub ccs: Vec<Url>,
pub tags: Vec<Mention>,
let mut addressed_ccs: Vec<Url> = vec![community_id.into(), parent_creator.actor_id()];
// Add the mention tag
- let mut parent_creator_tag = Mention::new();
- parent_creator_tag
- .set_href(parent_creator.actor_id.clone().into())
- .set_name(format!(
+ let parent_creator_tag = Mention {
+ href: parent_creator.actor_id.clone().into(),
+ name: Some(format!(
"@{}@{}",
&parent_creator.name,
&parent_creator.actor_id().domain().expect("has domain")
- ));
+ )),
+ kind: MentionType::Mention,
+ };
let mut tags = vec![parent_creator_tag];
// Get the person IDs for any mentions
let actor_id: ObjectId<ApubPerson> = ObjectId::new(actor_id);
addressed_ccs.push(actor_id.to_string().parse()?);
- let mut mention_tag = Mention::new();
- mention_tag
- .set_href(actor_id.into())
- .set_name(mention.full_name());
+ let mention_tag = Mention {
+ href: actor_id.into(),
+ name: Some(mention.full_name()),
+ kind: MentionType::Mention,
+ };
tags.push(mention_tag);
}
}
},
PostOrComment,
};
-use activitystreams::{object::kind::NoteType, public};
+use activitystreams_kinds::{object::NoteType, public};
use anyhow::anyhow;
use chrono::NaiveDateTime;
use html2md::parse_html;
Source,
},
};
-use activitystreams::{actor::kind::GroupType, object::kind::ImageType};
+use activitystreams_kinds::actor::GroupType;
use chrono::NaiveDateTime;
use itertools::Itertools;
use lemmy_api_common::blocking;
content: bio,
media_type: MediaTypeMarkdown::Markdown,
});
- let icon = self.icon.clone().map(|url| ImageObject {
- kind: ImageType::Image,
- url: url.into(),
- });
- let image = self.banner.clone().map(|url| ImageObject {
- kind: ImageType::Image,
- url: url.into(),
- });
+ let icon = self.icon.clone().map(ImageObject::new);
+ let image = self.banner.clone().map(ImageObject::new);
let group = Group {
kind: GroupType::Group,
Source,
},
};
-use activitystreams::object::kind::ImageType;
use chrono::NaiveDateTime;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
content: bio,
media_type: MediaTypeMarkdown::Markdown,
});
- let icon = self.avatar.clone().map(|url| ImageObject {
- kind: ImageType::Image,
- url: url.into(),
- });
- let image = self.banner.clone().map(|url| ImageObject {
- kind: ImageType::Image,
- url: url.into(),
- });
+ let icon = self.avatar.clone().map(ImageObject::new);
+ let image = self.banner.clone().map(ImageObject::new);
let person = Person {
kind,
Source,
},
};
-use activitystreams::{
- object::kind::{ImageType, PageType},
- public,
-};
+use activitystreams_kinds::{object::PageType, public};
use chrono::NaiveDateTime;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
content: body,
media_type: MediaTypeMarkdown::Markdown,
});
- let image = self.thumbnail_url.clone().map(|thumb| ImageObject {
- kind: ImageType::Image,
- url: thumb.into(),
- });
+ let image = self.thumbnail_url.clone().map(ImageObject::new);
let page = Page {
r#type: PageType::Page,
-use crate::objects::person::ApubPerson;
-use activitystreams::{activity::kind::AddType, unparsed::Unparsed};
+use crate::{objects::person::ApubPerson, protocol::Unparsed};
+use activitystreams_kinds::activity::AddType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
-use crate::{activity_lists::AnnouncableActivities, objects::community::ApubCommunity};
-use activitystreams::{activity::kind::AnnounceType, unparsed::Unparsed};
+use crate::{
+ activity_lists::AnnouncableActivities,
+ objects::community::ApubCommunity,
+ protocol::Unparsed,
+};
+use activitystreams_kinds::activity::AnnounceType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
-use crate::objects::{community::ApubCommunity, person::ApubPerson};
-use activitystreams::{activity::kind::BlockType, unparsed::Unparsed};
+use crate::{
+ objects::{community::ApubCommunity, person::ApubPerson},
+ protocol::Unparsed,
+};
+use activitystreams_kinds::activity::BlockType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
use crate::protocol::{
activities::community::{
add_mod::AddMod,
+ announce::AnnounceActivity,
block_user::BlockUserFromCommunity,
remove_mod::RemoveMod,
report::Report,
},
tests::test_parse_lemmy_item,
};
- use activitystreams::activity::Announce;
- use serial_test::serial;
#[actix_rt::test]
- #[serial]
async fn test_parse_lemmy_community() {
- test_parse_lemmy_item::<Announce>(
+ test_parse_lemmy_item::<AnnounceActivity>(
"assets/lemmy/activities/community/announce_create_page.json",
);
-use crate::objects::person::ApubPerson;
-use activitystreams::{activity::kind::RemoveType, unparsed::Unparsed};
+use crate::{objects::person::ApubPerson, protocol::Unparsed};
+use activitystreams_kinds::activity::RemoveType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
use crate::{
fetcher::post_or_comment::PostOrComment,
objects::{community::ApubCommunity, person::ApubPerson},
+ protocol::Unparsed,
};
-use activitystreams::{activity::kind::FlagType, unparsed::Unparsed};
+use activitystreams_kinds::activity::FlagType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
use crate::{
objects::person::ApubPerson,
- protocol::activities::community::block_user::BlockUserFromCommunity,
+ protocol::{activities::community::block_user::BlockUserFromCommunity, Unparsed},
};
-use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
+use activitystreams_kinds::activity::UndoType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
-use crate::{objects::person::ApubPerson, protocol::objects::group::Group};
-use activitystreams::{activity::kind::UpdateType, unparsed::Unparsed};
+use crate::{
+ objects::person::ApubPerson,
+ protocol::{objects::group::Group, Unparsed},
+};
+use activitystreams_kinds::activity::UpdateType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
use crate::{
+ mentions::Mention,
objects::person::ApubPerson,
- protocol::{activities::CreateOrUpdateType, objects::note::Note},
+ protocol::{activities::CreateOrUpdateType, objects::note::Note, Unparsed},
};
-use activitystreams::{link::Mention, unparsed::Unparsed};
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
tests::test_parse_lemmy_item,
},
};
- use serial_test::serial;
#[actix_rt::test]
- #[serial]
async fn test_parse_create_or_update() {
test_parse_lemmy_item::<CreateOrUpdatePost>(
"assets/lemmy/activities/create_or_update/create_page.json",
use crate::{
objects::person::ApubPerson,
- protocol::{activities::CreateOrUpdateType, objects::page::Page},
+ protocol::{activities::CreateOrUpdateType, objects::page::Page, Unparsed},
};
-use activitystreams::unparsed::Unparsed;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
-use crate::{objects::person::ApubPerson, protocol::objects::tombstone::Tombstone};
-use activitystreams::{activity::kind::DeleteType, unparsed::Unparsed};
+use crate::{
+ objects::person::ApubPerson,
+ protocol::{objects::tombstone::Tombstone, Unparsed},
+};
+use activitystreams_kinds::activity::DeleteType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
activities::deletion::{delete::Delete, undo_delete::UndoDelete},
tests::test_parse_lemmy_item,
};
- use serial_test::serial;
#[actix_rt::test]
- #[serial]
async fn test_parse_lemmy_deletion() {
test_parse_lemmy_item::<Delete>("assets/lemmy/activities/deletion/remove_note.json");
test_parse_lemmy_item::<Delete>("assets/lemmy/activities/deletion/delete_page.json");
-use crate::{objects::person::ApubPerson, protocol::activities::deletion::delete::Delete};
-use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
+use crate::{
+ objects::person::ApubPerson,
+ protocol::{activities::deletion::delete::Delete, Unparsed},
+};
+use activitystreams_kinds::activity::UndoType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
use crate::{
objects::community::ApubCommunity,
- protocol::activities::following::follow::FollowCommunity,
+ protocol::{activities::following::follow::FollowCommunity, Unparsed},
};
-use activitystreams::{activity::kind::AcceptType, unparsed::Unparsed};
+use activitystreams_kinds::activity::AcceptType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
-use crate::objects::{community::ApubCommunity, person::ApubPerson};
-use activitystreams::{activity::kind::FollowType, unparsed::Unparsed};
+use crate::{
+ objects::{community::ApubCommunity, person::ApubPerson},
+ protocol::Unparsed,
+};
+use activitystreams_kinds::activity::FollowType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
},
tests::test_parse_lemmy_item,
};
- use serial_test::serial;
#[actix_rt::test]
- #[serial]
async fn test_parse_lemmy_accept_follow() {
test_parse_lemmy_item::<FollowCommunity>("assets/lemmy/activities/following/follow.json");
test_parse_lemmy_item::<AcceptFollowCommunity>("assets/lemmy/activities/following/accept.json");
use crate::{
objects::person::ApubPerson,
- protocol::activities::following::follow::FollowCommunity,
+ protocol::{activities::following::follow::FollowCommunity, Unparsed},
};
-use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
+use activitystreams_kinds::activity::UndoType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
use crate::{
objects::person::ApubPerson,
- protocol::{activities::CreateOrUpdateType, objects::chat_message::ChatMessage},
+ protocol::{activities::CreateOrUpdateType, objects::chat_message::ChatMessage, Unparsed},
};
-use activitystreams::unparsed::Unparsed;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
-use crate::objects::{person::ApubPerson, private_message::ApubPrivateMessage};
-use activitystreams::{activity::kind::DeleteType, unparsed::Unparsed};
+use crate::{
+ objects::{person::ApubPerson, private_message::ApubPrivateMessage},
+ protocol::Unparsed,
+};
+use activitystreams_kinds::activity::DeleteType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
},
tests::test_parse_lemmy_item,
};
- use serial_test::serial;
#[actix_rt::test]
- #[serial]
async fn test_parse_lemmy_private_message() {
test_parse_lemmy_item::<CreateOrUpdatePrivateMessage>(
"assets/lemmy/activities/private_message/create.json",
use crate::{
objects::person::ApubPerson,
- protocol::activities::private_message::delete::DeletePrivateMessage,
+ protocol::{activities::private_message::delete::DeletePrivateMessage, Unparsed},
};
-use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
+use activitystreams_kinds::activity::UndoType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
activities::voting::{undo_vote::UndoVote, vote::Vote},
tests::test_parse_lemmy_item,
};
- use serial_test::serial;
#[actix_rt::test]
- #[serial]
async fn test_parse_lemmy_voting() {
test_parse_lemmy_item::<Vote>("assets/lemmy/activities/voting/like_note.json");
test_parse_lemmy_item::<Vote>("assets/lemmy/activities/voting/dislike_page.json");
-use crate::{objects::person::ApubPerson, protocol::activities::voting::vote::Vote};
-use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
+use crate::{
+ objects::person::ApubPerson,
+ protocol::{activities::voting::vote::Vote, Unparsed},
+};
+use activitystreams_kinds::activity::UndoType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
-use crate::{fetcher::post_or_comment::PostOrComment, objects::person::ApubPerson};
-use activitystreams::unparsed::Unparsed;
+use crate::{
+ fetcher::post_or_comment::PostOrComment,
+ objects::person::ApubPerson,
+ protocol::Unparsed,
+};
use anyhow::anyhow;
use lemmy_apub_lib::object_id::ObjectId;
use lemmy_utils::LemmyError;
use crate::generate_followers_url;
-use activitystreams::collection::kind::CollectionType;
+use activitystreams_kinds::collection::CollectionType;
use lemmy_api_common::blocking;
use lemmy_db_schema::source::community::Community;
use lemmy_db_views_actor::community_follower_view::CommunityFollowerView;
use crate::objects::person::ApubPerson;
-use activitystreams::collection::kind::OrderedCollectionType;
+use activitystreams_kinds::collection::OrderedCollectionType;
use lemmy_apub_lib::object_id::ObjectId;
use serde::{Deserialize, Serialize};
use url::Url;
use crate::protocol::activities::community::announce::AnnounceActivity;
-use activitystreams::collection::kind::OrderedCollectionType;
+use activitystreams_kinds::collection::OrderedCollectionType;
use serde::{Deserialize, Serialize};
use url::Url;
},
tests::test_parse_lemmy_item,
};
- use serial_test::serial;
#[actix_rt::test]
- #[serial]
async fn test_parse_lemmy_collections() {
test_parse_lemmy_item::<GroupFollowers>("assets/lemmy/collections/group_followers.json");
let outbox = test_parse_lemmy_item::<GroupOutbox>("assets/lemmy/collections/group_outbox.json");
use crate::generate_outbox_url;
-use activitystreams::collection::kind::OrderedCollectionType;
+use activitystreams_kinds::collection::OrderedCollectionType;
use lemmy_db_schema::source::person::Person;
use lemmy_utils::LemmyError;
use serde::{Deserialize, Serialize};
-use activitystreams::object::kind::ImageType;
+use activitystreams_kinds::object::ImageType;
use serde::{Deserialize, Serialize};
use url::Url;
use lemmy_apub_lib::values::MediaTypeMarkdown;
+use lemmy_db_schema::newtypes::DbUrl;
+use std::collections::HashMap;
pub mod activities;
pub(crate) mod collections;
#[serde(rename_all = "camelCase")]
pub struct ImageObject {
#[serde(rename = "type")]
- pub(crate) kind: ImageType,
+ kind: ImageType,
pub(crate) url: Url,
}
+impl ImageObject {
+ pub(crate) fn new(url: DbUrl) -> Self {
+ ImageObject {
+ kind: ImageType::Image,
+ url: url.into(),
+ }
+ }
+}
+
+#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize)]
+#[serde(transparent)]
+pub struct Unparsed(HashMap<String, serde_json::Value>);
+
#[cfg(test)]
pub(crate) mod tests {
use crate::objects::tests::file_to_json_object;
use crate::{
objects::{person::ApubPerson, private_message::ApubPrivateMessage},
- protocol::Source,
-};
-use activitystreams::{
- chrono::{DateTime, FixedOffset},
- unparsed::Unparsed,
+ protocol::{Source, Unparsed},
};
+use chrono::{DateTime, FixedOffset};
use lemmy_apub_lib::{object_id::ObjectId, values::MediaTypeHtml};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
community_outbox::ApubCommunityOutbox,
},
objects::{community::ApubCommunity, get_summary_from_string_or_source},
- protocol::{objects::Endpoints, ImageObject, Source},
+ protocol::{objects::Endpoints, ImageObject, Source, Unparsed},
};
-use activitystreams::{actor::kind::GroupType, unparsed::Unparsed};
+use activitystreams_kinds::actor::GroupType;
use chrono::{DateTime, FixedOffset};
use lemmy_apub_lib::{object_id::ObjectId, signatures::PublicKey, verify::verify_domains_match};
use lemmy_db_schema::{naive_now, source::community::CommunityForm};
tests::test_parse_lemmy_item,
},
};
- use serial_test::serial;
#[actix_rt::test]
- #[serial]
async fn test_parse_object() {
test_parse_lemmy_item::<Person>("assets/lemmy/objects/person.json");
test_parse_lemmy_item::<Group>("assets/lemmy/objects/group.json");
use crate::{
fetcher::post_or_comment::PostOrComment,
+ mentions::Mention,
objects::{comment::ApubComment, person::ApubPerson, post::ApubPost},
- protocol::Source,
+ protocol::{Source, Unparsed},
};
-use activitystreams::{link::Mention, object::kind::NoteType, unparsed::Unparsed};
+use activitystreams_kinds::object::NoteType;
use chrono::{DateTime, FixedOffset};
use lemmy_api_common::blocking;
use lemmy_apub_lib::{object_id::ObjectId, values::MediaTypeHtml};
use crate::{
objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost},
- protocol::{ImageObject, Source},
+ protocol::{ImageObject, Source, Unparsed},
};
-use activitystreams::{object::kind::PageType, unparsed::Unparsed};
+use activitystreams_kinds::object::PageType;
use anyhow::anyhow;
use chrono::{DateTime, FixedOffset};
use lemmy_apub_lib::{
use crate::{
objects::person::ApubPerson,
- protocol::{objects::Endpoints, ImageObject, Source},
+ protocol::{objects::Endpoints, ImageObject, Source, Unparsed},
};
-use activitystreams::{unparsed::Unparsed, url::Url};
use chrono::{DateTime, FixedOffset};
use lemmy_apub_lib::{object_id::ObjectId, signatures::PublicKey};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
+use url::Url;
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
pub enum UserTypes {
-use activitystreams::object::kind::TombstoneType;
+use activitystreams_kinds::object::TombstoneType;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use url::Url;