]> Untitled Git - lemmy.git/commitdiff
Set valid context for our extra fields (ref #1220)
authorFelix Ableitner <me@nutomic.com>
Wed, 25 Nov 2020 17:44:49 +0000 (18:44 +0100)
committerFelix Ableitner <me@nutomic.com>
Wed, 25 Nov 2020 17:44:49 +0000 (18:44 +0100)
17 files changed:
Cargo.lock
docker/federation/start-local-instances.bash
lemmy_apub/Cargo.toml
lemmy_apub/src/activities/send/comment.rs
lemmy_apub/src/activities/send/community.rs
lemmy_apub/src/activities/send/post.rs
lemmy_apub/src/activities/send/private_message.rs
lemmy_apub/src/activities/send/user.rs
lemmy_apub/src/extensions/context.rs [new file with mode: 0644]
lemmy_apub/src/extensions/mod.rs
lemmy_apub/src/http/community.rs
lemmy_apub/src/http/user.rs
lemmy_apub/src/objects/comment.rs
lemmy_apub/src/objects/community.rs
lemmy_apub/src/objects/post.rs
lemmy_apub/src/objects/private_message.rs
lemmy_apub/src/objects/user.rs

index b2247c87a953dd11a46e3a226787ba4663416b58..6b7469287b787b48be210a2b3442873fc9280e7a 100644 (file)
@@ -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",
index 3c374e37ebd2ec0561d652483cadc21fbc55cef5..ec2712f14be2f8c38f4bd4c791da87e69f198b13 100755 (executable)
@@ -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
index 6dd68bc8ef75714bf8a4840078d06d1579abc474..5610ed699051fbb132941e4a74526322139dd613 100644 (file)
@@ -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"] }
index fa0c8b33f741205acf5cfd6f39351dc47c5a641d..2aee7b6e30c5ef28d90ef28854d8c2285054ec6e 100644 (file)
@@ -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()?]);
index 2373596f3c9ec3de87239bcb1fc5c1fac51f71a9..775f8c25fa8dd011990add83c61c1a7f0f59a634 100644 (file)
@@ -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()?]);
index 32035952d1f8f28662d03b18d61cb48cfc369d51..da78667f0c824941ecacb56e402d8fd485b7c222 100644 (file)
@@ -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()?]);
index 51d140293bc5702d71522d5976b0883fc04c0358..23528b5c7eaa36bfffac7c2516f6f458b491befa 100644 (file)
@@ -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()?);
 
index 2839d83bac4d77ec542c4fceaac9ba644ec26369..a94f241dac715411cecc0bd7184833f1e7e9c37a 100644 (file)
@@ -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 (file)
index 0000000..fe52ab9
--- /dev/null
@@ -0,0 +1,18 @@
+use activitystreams::{base::AnyBase, context};
+use lemmy_utils::LemmyError;
+use serde_json::json;
+
+pub(crate) fn lemmy_context() -> Result<Vec<AnyBase>, 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])
+}
index f4723a9472062d13e733742c616e1354cbe66262..4b4c08664fa59ce6a09cd86e3832308edfea431a 100644 (file)
@@ -1,3 +1,4 @@
+pub(crate) mod context;
 pub(crate) mod group_extensions;
 pub(crate) mod page_extension;
 pub(crate) mod signatures;
index bd9c86fea613f4bc2a8068564a48ee5e8155c19f..0e2f2802e98e2a28f5e203879f91adc36d4cfac2 100644 (file)
@@ -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))
index 31ed5d85ae961d57d9039ac5274488dc58085065..0f2e1a71cc36898c59b0c4446f592076c8bec11e 100644 (file)
@@ -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::<Url>::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))
index c3d17e6e06c0b167536d03406257e656749b0ecc..277a55d06b8426ce704f24dab50a04e53c131898 100644 (file)
@@ -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)
index c5a614badab7645a3f0b1fff60d2cd94ebd6ad85..2b383ba5b818623c848cdc64063e0d5f1d3748ac 100644 (file)
@@ -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))
index f2bb9addcc5c86ee47359497fbb2bd7130bdb492..ce16f8d136982488193e6327e9d81cbcf59b8800 100644 (file)
@@ -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::<Url>()?)
       // Use summary field to be consistent with mastodon content warning.
       // https://mastodon.xyz/@Louisa/103987265222901387.json
index 1a3b1587c55217184fc95d5d59c8c8069a43495e..4e9af09433754a93f02b0dc2965db0d0b3e8a255 100644 (file)
@@ -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)
index ae620c2c13dbf050d76488f988e8f13cddaa254e..ddf33656c7f7ddc0eee00cac5fbb4380d099875c 100644 (file)
@@ -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<PersonExt, LemmyError> {
     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));