Update activitystreams to 0.7.0-alpha.11

This commit is contained in:
Felix Ableitner 2021-03-09 14:18:24 +01:00
parent 9172eff65a
commit dcf40db225
5 changed files with 27 additions and 16 deletions

4
Cargo.lock generated
View file

@ -4,9 +4,9 @@ version = 3
[[package]] [[package]]
name = "activitystreams" name = "activitystreams"
version = "0.7.0-alpha.10" version = "0.7.0-alpha.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe7ceed015dfca322d3bcec3653909c77557e7e57df72e98cb8806e2c93cc919" checksum = "3a5da1d857ec9ca65ef8d0469cdd64e7b93b59d6cad26f1444bf84b62f3eadd4"
dependencies = [ dependencies = [
"chrono", "chrono",
"mime", "mime",

View file

@ -17,7 +17,7 @@ lemmy_db_views_actor = { path = "../db_views_actor" }
lemmy_api_structs = { path = "../api_structs" } lemmy_api_structs = { path = "../api_structs" }
lemmy_websocket = { path = "../websocket" } lemmy_websocket = { path = "../websocket" }
diesel = "1.4.5" diesel = "1.4.5"
activitystreams = "0.7.0-alpha.10" activitystreams = "0.7.0-alpha.11"
activitystreams-ext = "0.1.0-alpha.2" activitystreams-ext = "0.1.0-alpha.2"
bcrypt = "0.9.0" bcrypt = "0.9.0"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }

View file

@ -40,7 +40,18 @@ use crate::{
PostOrComment, PostOrComment,
}; };
use activitystreams::{ 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, base::AnyBase,
prelude::*, prelude::*,
}; };
@ -442,12 +453,15 @@ async fn verify_actor_is_community_mod<T, Kind>(
context: &LemmyContext, context: &LemmyContext,
) -> Result<Community, LemmyError> ) -> Result<Community, LemmyError>
where where
T: ActorAndObjectRef + BaseExt<Kind>, T: ActorAndObjectRef + BaseExt<Kind> + OptTargetRef,
{ {
// should be the moderators collection of a local community // should be the moderators collection of a local community
// TODO: not compiling, seems to be a bug in activitystreams crate let target = activity
let target = Url::parse("")?; //activity.target().as_single_xsd_any_uri().context(location_info!())?; .target()
// TODO: very hacky .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_id: DbUrl = Url::parse(&target.to_string().replace("/moderators", ""))?.into();
let community = blocking(&context.pool(), move |conn| { let community = blocking(&context.pool(), move |conn| {
Community::read_from_apub_id(&conn, &community_id) Community::read_from_apub_id(&conn, &community_id)

View file

@ -132,19 +132,17 @@ where
{ {
let content = object let content = object
.content() .content()
.map(|s| s.as_single_xsd_string()) .map(|s| s.as_single_xsd_string().map(|s2| s2.to_string()))
.flatten() .flatten();
.map(|s| s.to_string());
if content.is_some() { if content.is_some() {
let source = object.source().context(location_info!())?; let source = object.source().context(location_info!())?;
let source = Object::<()>::from_any_base(source.to_owned())?.context(location_info!())?; let source = Object::<()>::from_any_base(source.to_owned())?.context(location_info!())?;
check_is_markdown(source.media_type())?; check_is_markdown(source.media_type())?;
let source_content = source let source_content = source
.content() .content()
.map(|s| s.as_single_xsd_string()) .map(|s| s.as_single_xsd_string().map(|s2| s2.to_string()))
.flatten() .flatten()
.context(location_info!())? .context(location_info!())?;
.to_string();
return Ok(Some(source_content)); return Ok(Some(source_content));
} }
Ok(None) Ok(None)

View file

@ -178,10 +178,9 @@ impl FromApubToForm<PageExt> for PostForm {
let name = page let name = page
.inner .inner
.name() .name()
.map(|s| s.map(|s2| s2.to_owned()))
// The following is for compatibility with lemmy v0.9.9 and older // The following is for compatibility with lemmy v0.9.9 and older
// TODO: remove it after some time (along with the map above) // 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!())? .context(location_info!())?
.as_single_xsd_string() .as_single_xsd_string()
.context(location_info!())? .context(location_info!())?