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]]
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",

View 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"] }

View 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)

View 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)

View 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!())?