]> Untitled Git - lemmy.git/commitdiff
Update activitystreams to 0.7.0-alpha.11
authorFelix Ableitner <me@nutomic.com>
Tue, 9 Mar 2021 13:18:24 +0000 (14:18 +0100)
committerFelix Ableitner <me@nutomic.com>
Tue, 9 Mar 2021 17:14:15 +0000 (18:14 +0100)
Cargo.lock
crates/apub/Cargo.toml
crates/apub/src/inbox/receive_for_community.rs
crates/apub/src/objects/mod.rs
crates/apub/src/objects/post.rs

index 959aec106675ee3fd85a36aa2ec3976f5f4a132b..a4b9fcc823862715ce8a43d505918e3cc76889ed 100644 (file)
@@ -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",
index b0538af6add304cd21e4fefc7688fabd060149fa..acb19db0995b49caf437c9cd59e27b7e405dfe0b 100644 (file)
@@ -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"] }
index aab17840100542d2a12d3be7407958b365318b7b..438a8b3d850ac1c7f0308069f24adc353d25ad6c 100644 (file)
@@ -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)
index 6b59e577660fbad42a8ceae67cd06f23914b7498..47d80cc2359afda117529b1b68862d37d5a23e70 100644 (file)
@@ -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)
index b066e6f8cb5dc023be5b49c01d4cf752236c49a7..e9052bdd56573759b80a63007122173a24b97b7a 100644 (file)
@@ -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!())?