[[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",
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"] }
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::*,
};
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)
{
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)
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!())?