From: Felix Ableitner <me@nutomic.com>
Date: Tue, 9 Mar 2021 13:18:24 +0000 (+0100)
Subject: Update activitystreams to 0.7.0-alpha.11
X-Git-Url: http://these/git/readmes/%7Bpost.ap_id%7D?a=commitdiff_plain;h=dcf40db22535ebd2dbf1fa26b42c5426875b7ced;p=lemmy.git

Update activitystreams to 0.7.0-alpha.11
---

diff --git a/Cargo.lock b/Cargo.lock
index 959aec10..a4b9fcc8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,9 +4,9 @@ version = 3
 
 [[package]]
 name = "activitystreams"
-version = "0.7.0-alpha.10"
+version = "0.7.0-alpha.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fe7ceed015dfca322d3bcec3653909c77557e7e57df72e98cb8806e2c93cc919"
+checksum = "3a5da1d857ec9ca65ef8d0469cdd64e7b93b59d6cad26f1444bf84b62f3eadd4"
 dependencies = [
  "chrono",
  "mime",
diff --git a/crates/apub/Cargo.toml b/crates/apub/Cargo.toml
index b0538af6..acb19db0 100644
--- a/crates/apub/Cargo.toml
+++ b/crates/apub/Cargo.toml
@@ -17,7 +17,7 @@ lemmy_db_views_actor = { path = "../db_views_actor" }
 lemmy_api_structs = { path = "../api_structs" }
 lemmy_websocket = { path = "../websocket" }
 diesel = "1.4.5"
-activitystreams = "0.7.0-alpha.10"
+activitystreams = "0.7.0-alpha.11"
 activitystreams-ext = "0.1.0-alpha.2"
 bcrypt = "0.9.0"
 chrono = { version = "0.4.19", features = ["serde"] }
diff --git a/crates/apub/src/inbox/receive_for_community.rs b/crates/apub/src/inbox/receive_for_community.rs
index aab17840..438a8b3d 100644
--- a/crates/apub/src/inbox/receive_for_community.rs
+++ b/crates/apub/src/inbox/receive_for_community.rs
@@ -40,7 +40,18 @@ use crate::{
   PostOrComment,
 };
 use activitystreams::{
-  activity::{ActorAndObjectRef, Add, Create, Delete, Dislike, Like, Remove, Undo, Update},
+  activity::{
+    ActorAndObjectRef,
+    Add,
+    Create,
+    Delete,
+    Dislike,
+    Like,
+    OptTargetRef,
+    Remove,
+    Undo,
+    Update,
+  },
   base::AnyBase,
   prelude::*,
 };
@@ -442,12 +453,15 @@ async fn verify_actor_is_community_mod<T, Kind>(
   context: &LemmyContext,
 ) -> Result<Community, LemmyError>
 where
-  T: ActorAndObjectRef + BaseExt<Kind>,
+  T: ActorAndObjectRef + BaseExt<Kind> + OptTargetRef,
 {
   // should be the moderators collection of a local community
-  // TODO: not compiling, seems to be a bug in activitystreams crate
-  let target = Url::parse("")?; //activity.target().as_single_xsd_any_uri().context(location_info!())?;
-                                // TODO: very hacky
+  let target = activity
+    .target()
+    .map(|t| t.as_single_xsd_string())
+    .flatten()
+    .context(location_info!())?;
+  // TODO: very hacky, we should probably store the moderators url in db
   let community_id: DbUrl = Url::parse(&target.to_string().replace("/moderators", ""))?.into();
   let community = blocking(&context.pool(), move |conn| {
     Community::read_from_apub_id(&conn, &community_id)
diff --git a/crates/apub/src/objects/mod.rs b/crates/apub/src/objects/mod.rs
index 6b59e577..47d80cc2 100644
--- a/crates/apub/src/objects/mod.rs
+++ b/crates/apub/src/objects/mod.rs
@@ -132,19 +132,17 @@ where
 {
   let content = object
     .content()
-    .map(|s| s.as_single_xsd_string())
-    .flatten()
-    .map(|s| s.to_string());
+    .map(|s| s.as_single_xsd_string().map(|s2| s2.to_string()))
+    .flatten();
   if content.is_some() {
     let source = object.source().context(location_info!())?;
     let source = Object::<()>::from_any_base(source.to_owned())?.context(location_info!())?;
     check_is_markdown(source.media_type())?;
     let source_content = source
       .content()
-      .map(|s| s.as_single_xsd_string())
+      .map(|s| s.as_single_xsd_string().map(|s2| s2.to_string()))
       .flatten()
-      .context(location_info!())?
-      .to_string();
+      .context(location_info!())?;
     return Ok(Some(source_content));
   }
   Ok(None)
diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs
index b066e6f8..e9052bdd 100644
--- a/crates/apub/src/objects/post.rs
+++ b/crates/apub/src/objects/post.rs
@@ -178,10 +178,9 @@ impl FromApubToForm<PageExt> for PostForm {
     let name = page
       .inner
       .name()
-      .map(|s| s.map(|s2| s2.to_owned()))
       // The following is for compatibility with lemmy v0.9.9 and older
       // TODO: remove it after some time (along with the map above)
-      .or_else(|| page.inner.summary().map(|s| s.to_owned()))
+      .or_else(|| page.inner.summary())
       .context(location_info!())?
       .as_single_xsd_string()
       .context(location_info!())?