use activitystreams::{
activity::{Accept, ActorAndObject, Create, Delete, Undo, Update},
base::AnyBase,
+ error::DomainError,
object::Note,
prelude::*,
};
)?
.context(location_info!())?;
- let domain = Some(create.id_unchecked().context(location_info!())?.to_owned());
+ let actor = create
+ .actor()?
+ .to_owned()
+ .single_xsd_any_uri()
+ .context(location_info!())?;
+ let domain = Some(
+ create
+ .id(actor.domain().context(location_info!())?)?
+ .context(location_info!())?
+ .to_owned(),
+ );
let private_message = PrivateMessageForm::from_apub(¬e, context, domain).await?;
let inserted_private_message = blocking(&context.pool(), move |conn| {
)?
.context(location_info!())?;
- let domain = Some(update.id_unchecked().context(location_info!())?.to_owned());
+ let actor = update
+ .actor()?
+ .to_owned()
+ .single_xsd_any_uri()
+ .context(location_info!())?;
+ let domain = Some(
+ update
+ .id(actor.domain().context(location_info!())?)?
+ .context(location_info!())?
+ .to_owned(),
+ );
let private_message_form = PrivateMessageForm::from_apub(¬e, context, domain).await?;
let private_message_ap_id = private_message_form
.to_owned()
.single_xsd_any_uri()
.context(location_info!())?;
+ let actor = delete
+ .actor()?
+ .to_owned()
+ .single_xsd_any_uri()
+ .context(location_info!())?;
+ let delete_id = delete
+ .id(actor.domain().context(location_info!())?)?
+ .map(|i| i.domain())
+ .flatten();
+ if private_message_id.domain() != delete_id {
+ return Err(DomainError.into());
+ }
let private_message = blocking(context.pool(), move |conn| {
PrivateMessage::read_from_apub_id(conn, private_message_id.as_str())
})
.to_owned()
.single_xsd_any_uri()
.context(location_info!())?;
+ let actor = undo
+ .actor()?
+ .to_owned()
+ .single_xsd_any_uri()
+ .context(location_info!())?;
+ let undo_id = undo
+ .id(actor.domain().context(location_info!())?)?
+ .map(|i| i.domain())
+ .flatten();
+ if private_message_id.domain() != undo_id {
+ return Err(DomainError.into());
+ }
+
let private_message = blocking(context.pool(), move |conn| {
PrivateMessage::read_from_apub_id(conn, private_message_id.as_str())
})