From: Felix Ableitner Date: Wed, 25 Nov 2020 17:44:49 +0000 (+0100) Subject: Set valid context for our extra fields (ref #1220) X-Git-Url: http://these/git/%22%7Burl%7D/%7Bicon?a=commitdiff_plain;h=a7b72ed5c4b6646671b47817f3cf112f9f44552b;p=lemmy.git Set valid context for our extra fields (ref #1220) --- diff --git a/Cargo.lock b/Cargo.lock index b2247c87..6b746928 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,9 +2,9 @@ # It is not intended for manual editing. [[package]] name = "activitystreams" -version = "0.7.0-alpha.6" +version = "0.7.0-alpha.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b1afe32371e466a791ced0d6ef6e6b97822bb1a279ee4cc41c4324e61cd0b2b" +checksum = "5e9fedbe571e267d9b93d071bdc4493f944022c6cce717ebb27d352026fc81c4" dependencies = [ "chrono", "mime", diff --git a/docker/federation/start-local-instances.bash b/docker/federation/start-local-instances.bash index 3c374e37..ec2712f1 100755 --- a/docker/federation/start-local-instances.bash +++ b/docker/federation/start-local-instances.bash @@ -1,7 +1,7 @@ #!/bin/bash set -e -sudo docker build ../../ --file ../dev/Dockerfile -t lemmy-federation:latest +sudo docker build ../../ --file ../dev/volume_mount.dockerfile -t lemmy-federation:latest for Item in alpha beta gamma delta epsilon ; do sudo mkdir -p volumes/pictrs_$Item diff --git a/lemmy_apub/Cargo.toml b/lemmy_apub/Cargo.toml index 6dd68bc8..5610ed69 100644 --- a/lemmy_apub/Cargo.toml +++ b/lemmy_apub/Cargo.toml @@ -14,7 +14,7 @@ lemmy_db = { path = "../lemmy_db" } lemmy_structs = { path = "../lemmy_structs" } lemmy_websocket = { path = "../lemmy_websocket" } diesel = "1.4" -activitystreams = "0.7.0-alpha.6" +activitystreams = "0.7.0-alpha.7" activitystreams-ext = "0.1.0-alpha.2" bcrypt = "0.8" chrono = { version = "0.4", features = ["serde"] } diff --git a/lemmy_apub/src/activities/send/comment.rs b/lemmy_apub/src/activities/send/comment.rs index fa0c8b33..2aee7b6e 100644 --- a/lemmy_apub/src/activities/send/comment.rs +++ b/lemmy_apub/src/activities/send/comment.rs @@ -1,6 +1,7 @@ use crate::{ activities::send::generate_activity_id, activity_queue::{send_comment_mentions, send_to_community}, + extensions::context::lemmy_context, fetcher::get_or_fetch_and_upsert_user, ActorType, ApubLikeableType, @@ -62,7 +63,7 @@ impl ApubObjectType for Comment { let mut create = Create::new(creator.actor_id.to_owned(), note.into_any_base()?); create - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(CreateType::Create)?) .set_to(public()) .set_many_ccs(ccs) @@ -95,7 +96,7 @@ impl ApubObjectType for Comment { let mut update = Update::new(creator.actor_id.to_owned(), note.into_any_base()?); update - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(UpdateType::Update)?) .set_to(public()) .set_many_ccs(ccs) @@ -119,7 +120,7 @@ impl ApubObjectType for Comment { let mut delete = Delete::new(creator.actor_id.to_owned(), Url::parse(&self.ap_id)?); delete - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(DeleteType::Delete)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -145,7 +146,7 @@ impl ApubObjectType for Comment { // Generate a fake delete activity, with the correct object let mut delete = Delete::new(creator.actor_id.to_owned(), Url::parse(&self.ap_id)?); delete - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(DeleteType::Delete)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -153,7 +154,7 @@ impl ApubObjectType for Comment { // Undo that fake activity let mut undo = Undo::new(creator.actor_id.to_owned(), delete.into_any_base()?); undo - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(UndoType::Undo)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -174,7 +175,7 @@ impl ApubObjectType for Comment { let mut remove = Remove::new(mod_.actor_id.to_owned(), Url::parse(&self.ap_id)?); remove - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(RemoveType::Remove)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -196,7 +197,7 @@ impl ApubObjectType for Comment { // Generate a fake delete activity, with the correct object let mut remove = Remove::new(mod_.actor_id.to_owned(), Url::parse(&self.ap_id)?); remove - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(RemoveType::Remove)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -204,7 +205,7 @@ impl ApubObjectType for Comment { // Undo that fake activity let mut undo = Undo::new(mod_.actor_id.to_owned(), remove.into_any_base()?); undo - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(UndoType::Undo)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -230,7 +231,7 @@ impl ApubLikeableType for Comment { let mut like = Like::new(creator.actor_id.to_owned(), note.into_any_base()?); like - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(LikeType::Like)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -253,7 +254,7 @@ impl ApubLikeableType for Comment { let mut dislike = Dislike::new(creator.actor_id.to_owned(), note.into_any_base()?); dislike - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(DislikeType::Dislike)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -280,7 +281,7 @@ impl ApubLikeableType for Comment { let mut like = Like::new(creator.actor_id.to_owned(), note.into_any_base()?); like - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(DislikeType::Dislike)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -288,7 +289,7 @@ impl ApubLikeableType for Comment { // Undo that fake activity let mut undo = Undo::new(creator.actor_id.to_owned(), like.into_any_base()?); undo - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(UndoType::Undo)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); diff --git a/lemmy_apub/src/activities/send/community.rs b/lemmy_apub/src/activities/send/community.rs index 2373596f..775f8c25 100644 --- a/lemmy_apub/src/activities/send/community.rs +++ b/lemmy_apub/src/activities/send/community.rs @@ -2,6 +2,7 @@ use crate::{ activities::send::generate_activity_id, activity_queue::{send_activity_single_dest, send_to_community_followers}, check_is_apub_id_valid, + extensions::context::lemmy_context, fetcher::get_or_fetch_and_upsert_user, ActorType, }; @@ -71,7 +72,7 @@ impl ActorType for Community { let mut accept = Accept::new(self.actor_id.to_owned(), follow.into_any_base()?); accept - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(AcceptType::Accept)?) .set_to(user.actor_id()?); @@ -83,7 +84,7 @@ impl ActorType for Community { async fn send_delete(&self, context: &LemmyContext) -> Result<(), LemmyError> { let mut delete = Delete::new(self.actor_id()?, self.actor_id()?); delete - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(DeleteType::Delete)?) .set_to(public()) .set_many_ccs(vec![self.get_followers_url()?]); @@ -96,14 +97,14 @@ impl ActorType for Community { async fn send_undo_delete(&self, context: &LemmyContext) -> Result<(), LemmyError> { let mut delete = Delete::new(self.actor_id()?, self.actor_id()?); delete - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(DeleteType::Delete)?) .set_to(public()) .set_many_ccs(vec![self.get_followers_url()?]); let mut undo = Undo::new(self.actor_id()?, delete.into_any_base()?); undo - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(UndoType::Undo)?) .set_to(public()) .set_many_ccs(vec![self.get_followers_url()?]); @@ -116,7 +117,7 @@ impl ActorType for Community { async fn send_remove(&self, context: &LemmyContext) -> Result<(), LemmyError> { let mut remove = Remove::new(self.actor_id()?, self.actor_id()?); remove - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(RemoveType::Remove)?) .set_to(public()) .set_many_ccs(vec![self.get_followers_url()?]); @@ -129,7 +130,7 @@ impl ActorType for Community { async fn send_undo_remove(&self, context: &LemmyContext) -> Result<(), LemmyError> { let mut remove = Remove::new(self.actor_id()?, self.actor_id()?); remove - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(RemoveType::Remove)?) .set_to(public()) .set_many_ccs(vec![self.get_followers_url()?]); @@ -137,7 +138,7 @@ impl ActorType for Community { // Undo that fake activity let mut undo = Undo::new(self.actor_id()?, remove.into_any_base()?); undo - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(LikeType::Like)?) .set_to(public()) .set_many_ccs(vec![self.get_followers_url()?]); @@ -155,7 +156,7 @@ impl ActorType for Community { ) -> Result<(), LemmyError> { let mut announce = Announce::new(self.actor_id.to_owned(), activity); announce - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(AnnounceType::Announce)?) .set_to(public()) .set_many_ccs(vec![self.get_followers_url()?]); diff --git a/lemmy_apub/src/activities/send/post.rs b/lemmy_apub/src/activities/send/post.rs index 32035952..da78667f 100644 --- a/lemmy_apub/src/activities/send/post.rs +++ b/lemmy_apub/src/activities/send/post.rs @@ -1,6 +1,7 @@ use crate::{ activities::send::generate_activity_id, activity_queue::send_to_community, + extensions::context::lemmy_context, ActorType, ApubLikeableType, ApubObjectType, @@ -40,7 +41,7 @@ impl ApubObjectType for Post { let mut create = Create::new(creator.actor_id.to_owned(), page.into_any_base()?); create - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(CreateType::Create)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -61,7 +62,7 @@ impl ApubObjectType for Post { let mut update = Update::new(creator.actor_id.to_owned(), page.into_any_base()?); update - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(UpdateType::Update)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -79,7 +80,7 @@ impl ApubObjectType for Post { let mut delete = Delete::new(creator.actor_id.to_owned(), Url::parse(&self.ap_id)?); delete - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(DeleteType::Delete)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -101,7 +102,7 @@ impl ApubObjectType for Post { let mut delete = Delete::new(creator.actor_id.to_owned(), Url::parse(&self.ap_id)?); delete - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(DeleteType::Delete)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -109,7 +110,7 @@ impl ApubObjectType for Post { // Undo that fake activity let mut undo = Undo::new(creator.actor_id.to_owned(), delete.into_any_base()?); undo - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(UndoType::Undo)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -127,7 +128,7 @@ impl ApubObjectType for Post { let mut remove = Remove::new(mod_.actor_id.to_owned(), Url::parse(&self.ap_id)?); remove - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(RemoveType::Remove)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -145,7 +146,7 @@ impl ApubObjectType for Post { let mut remove = Remove::new(mod_.actor_id.to_owned(), Url::parse(&self.ap_id)?); remove - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(RemoveType::Remove)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -153,7 +154,7 @@ impl ApubObjectType for Post { // Undo that fake activity let mut undo = Undo::new(mod_.actor_id.to_owned(), remove.into_any_base()?); undo - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(UndoType::Undo)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -176,7 +177,7 @@ impl ApubLikeableType for Post { let mut like = Like::new(creator.actor_id.to_owned(), page.into_any_base()?); like - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(LikeType::Like)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -196,7 +197,7 @@ impl ApubLikeableType for Post { let mut dislike = Dislike::new(creator.actor_id.to_owned(), page.into_any_base()?); dislike - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(DislikeType::Dislike)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -220,7 +221,7 @@ impl ApubLikeableType for Post { let mut like = Like::new(creator.actor_id.to_owned(), page.into_any_base()?); like - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(LikeType::Like)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); @@ -228,7 +229,7 @@ impl ApubLikeableType for Post { // Undo that fake activity let mut undo = Undo::new(creator.actor_id.to_owned(), like.into_any_base()?); undo - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(UndoType::Undo)?) .set_to(public()) .set_many_ccs(vec![community.actor_id()?]); diff --git a/lemmy_apub/src/activities/send/private_message.rs b/lemmy_apub/src/activities/send/private_message.rs index 51d14029..23528b5c 100644 --- a/lemmy_apub/src/activities/send/private_message.rs +++ b/lemmy_apub/src/activities/send/private_message.rs @@ -1,6 +1,7 @@ use crate::{ activities::send::generate_activity_id, activity_queue::send_activity_single_dest, + extensions::context::lemmy_context, ActorType, ApubObjectType, ToApub, @@ -33,7 +34,7 @@ impl ApubObjectType for PrivateMessage { let mut create = Create::new(creator.actor_id.to_owned(), note.into_any_base()?); create - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(CreateType::Create)?) .set_to(recipient.actor_id()?); @@ -50,7 +51,7 @@ impl ApubObjectType for PrivateMessage { let mut update = Update::new(creator.actor_id.to_owned(), note.into_any_base()?); update - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(UpdateType::Update)?) .set_to(recipient.actor_id()?); @@ -64,7 +65,7 @@ impl ApubObjectType for PrivateMessage { let mut delete = Delete::new(creator.actor_id.to_owned(), Url::parse(&self.ap_id)?); delete - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(DeleteType::Delete)?) .set_to(recipient.actor_id()?); @@ -82,14 +83,14 @@ impl ApubObjectType for PrivateMessage { let mut delete = Delete::new(creator.actor_id.to_owned(), Url::parse(&self.ap_id)?); delete - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(DeleteType::Delete)?) .set_to(recipient.actor_id()?); // Undo that fake activity let mut undo = Undo::new(creator.actor_id.to_owned(), delete.into_any_base()?); undo - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(UndoType::Undo)?) .set_to(recipient.actor_id()?); diff --git a/lemmy_apub/src/activities/send/user.rs b/lemmy_apub/src/activities/send/user.rs index 2839d83b..a94f241d 100644 --- a/lemmy_apub/src/activities/send/user.rs +++ b/lemmy_apub/src/activities/send/user.rs @@ -1,6 +1,7 @@ use crate::{ activities::send::generate_activity_id, activity_queue::send_activity_single_dest, + extensions::context::lemmy_context, ActorType, }; use activitystreams::{ @@ -61,7 +62,7 @@ impl ActorType for User_ { let mut follow = Follow::new(self.actor_id.to_owned(), community.actor_id()?); follow - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(FollowType::Follow)?) .set_to(community.actor_id()?); @@ -82,14 +83,14 @@ impl ActorType for User_ { let mut follow = Follow::new(self.actor_id.to_owned(), community.actor_id()?); follow - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(FollowType::Follow)?) .set_to(community.actor_id()?); // Undo that fake activity let mut undo = Undo::new(Url::parse(&self.actor_id)?, follow.into_any_base()?); undo - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(generate_activity_id(UndoType::Undo)?) .set_to(community.actor_id()?); diff --git a/lemmy_apub/src/extensions/context.rs b/lemmy_apub/src/extensions/context.rs new file mode 100644 index 00000000..fe52ab95 --- /dev/null +++ b/lemmy_apub/src/extensions/context.rs @@ -0,0 +1,18 @@ +use activitystreams::{base::AnyBase, context}; +use lemmy_utils::LemmyError; +use serde_json::json; + +pub(crate) fn lemmy_context() -> Result, LemmyError> { + let context_ext = AnyBase::from_arbitrary_json(json!( + { + "sc": "http://schema.org#", + "category": "sc:category", + "sensitive": "as:sensitive", + "stickied": "as:stickied", + "comments_enabled": { + "kind": "sc:Boolean", + "id": "pt:commentsEnabled" + } + }))?; + Ok(vec![AnyBase::from(context()), context_ext]) +} diff --git a/lemmy_apub/src/extensions/mod.rs b/lemmy_apub/src/extensions/mod.rs index f4723a94..4b4c0866 100644 --- a/lemmy_apub/src/extensions/mod.rs +++ b/lemmy_apub/src/extensions/mod.rs @@ -1,3 +1,4 @@ +pub(crate) mod context; pub(crate) mod group_extensions; pub(crate) mod page_extension; pub(crate) mod signatures; diff --git a/lemmy_apub/src/http/community.rs b/lemmy_apub/src/http/community.rs index bd9c86fe..0e2f2802 100644 --- a/lemmy_apub/src/http/community.rs +++ b/lemmy_apub/src/http/community.rs @@ -1,4 +1,5 @@ use crate::{ + extensions::context::lemmy_context, http::{create_apub_response, create_apub_tombstone_response}, ActorType, ToApub, @@ -56,7 +57,7 @@ pub async fn get_apub_community_followers( let mut collection = UnorderedCollection::new(); collection - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(community.get_followers_url()?) .set_total_items(community_followers.len() as u64); Ok(create_apub_response(&collection)) @@ -88,7 +89,7 @@ pub async fn get_apub_community_outbox( let mut collection = OrderedCollection::new(); collection .set_many_items(pages) - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(community.get_outbox_url()?) .set_total_items(len as u64); Ok(create_apub_response(&collection)) diff --git a/lemmy_apub/src/http/user.rs b/lemmy_apub/src/http/user.rs index 31ed5d85..0f2e1a71 100644 --- a/lemmy_apub/src/http/user.rs +++ b/lemmy_apub/src/http/user.rs @@ -1,4 +1,4 @@ -use crate::{http::create_apub_response, ActorType, ToApub}; +use crate::{extensions::context::lemmy_context, http::create_apub_response, ActorType, ToApub}; use activitystreams::{ base::BaseExt, collection::{CollectionExt, OrderedCollection}, @@ -42,7 +42,7 @@ pub async fn get_apub_user_outbox( let mut collection = OrderedCollection::new(); collection .set_many_items(Vec::::new()) - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(user.get_outbox_url()?) .set_total_items(0_u64); Ok(create_apub_response(&collection)) diff --git a/lemmy_apub/src/objects/comment.rs b/lemmy_apub/src/objects/comment.rs index c3d17e6e..277a55d0 100644 --- a/lemmy_apub/src/objects/comment.rs +++ b/lemmy_apub/src/objects/comment.rs @@ -1,4 +1,5 @@ use crate::{ + extensions::context::lemmy_context, fetcher::{ get_or_fetch_and_insert_comment, get_or_fetch_and_insert_post, @@ -64,7 +65,7 @@ impl ToApub for Comment { comment // Not needed when the Post is embedded in a collection (like for community outbox) - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(Url::parse(&self.ap_id)?) .set_published(convert_datetime(self.published)) .set_to(community.actor_id) diff --git a/lemmy_apub/src/objects/community.rs b/lemmy_apub/src/objects/community.rs index c5a614ba..2b383ba5 100644 --- a/lemmy_apub/src/objects/community.rs +++ b/lemmy_apub/src/objects/community.rs @@ -1,5 +1,5 @@ use crate::{ - extensions::group_extensions::GroupExtension, + extensions::{context::lemmy_context, group_extensions::GroupExtension}, fetcher::get_or_fetch_and_upsert_user, objects::{ check_object_domain, @@ -53,7 +53,7 @@ impl ToApub for Community { let mut group = ApObject::new(Group::new()); group - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(Url::parse(&self.actor_id)?) .set_name(self.title.to_owned()) .set_published(convert_datetime(self.published)) diff --git a/lemmy_apub/src/objects/post.rs b/lemmy_apub/src/objects/post.rs index f2bb9add..ce16f8d1 100644 --- a/lemmy_apub/src/objects/post.rs +++ b/lemmy_apub/src/objects/post.rs @@ -1,5 +1,5 @@ use crate::{ - extensions::page_extension::PageExtension, + extensions::{context::lemmy_context, page_extension::PageExtension}, fetcher::{get_or_fetch_and_upsert_community, get_or_fetch_and_upsert_user}, objects::{ check_object_domain, @@ -52,7 +52,7 @@ impl ToApub for Post { // Not needed when the Post is embedded in a collection (like for community outbox) // TODO: need to set proper context defining sensitive/commentsEnabled fields // https://git.asonix.dog/Aardwolf/activitystreams/issues/5 - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(self.ap_id.parse::()?) // Use summary field to be consistent with mastodon content warning. // https://mastodon.xyz/@Louisa/103987265222901387.json diff --git a/lemmy_apub/src/objects/private_message.rs b/lemmy_apub/src/objects/private_message.rs index 1a3b1587..4e9af094 100644 --- a/lemmy_apub/src/objects/private_message.rs +++ b/lemmy_apub/src/objects/private_message.rs @@ -1,5 +1,6 @@ use crate::{ check_is_apub_id_valid, + extensions::context::lemmy_context, fetcher::get_or_fetch_and_upsert_user, objects::{ check_object_domain, @@ -41,7 +42,7 @@ impl ToApub for PrivateMessage { let recipient = blocking(pool, move |conn| User_::read(conn, recipient_id)).await??; private_message - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(Url::parse(&self.ap_id.to_owned())?) .set_published(convert_datetime(self.published)) .set_to(recipient.actor_id) diff --git a/lemmy_apub/src/objects/user.rs b/lemmy_apub/src/objects/user.rs index ae620c2c..ddf33656 100644 --- a/lemmy_apub/src/objects/user.rs +++ b/lemmy_apub/src/objects/user.rs @@ -1,4 +1,5 @@ use crate::{ + extensions::context::lemmy_context, objects::{check_object_domain, get_source_markdown_value, set_content_and_source}, ActorType, FromApub, @@ -32,7 +33,7 @@ impl ToApub for User_ { async fn to_apub(&self, _pool: &DbPool) -> Result { let mut person = ApObject::new(Person::new()); person - .set_context(activitystreams::context()) + .set_many_contexts(lemmy_context()?) .set_id(Url::parse(&self.actor_id)?) .set_published(convert_datetime(self.published));