mirror of https://github.com/LemmyNet/lemmy
Also verify activity domains in shared inbox (fixes #1196)
parent
39cbe5f31f
commit
fe15ff3c51
@ -1,48 +1,50 @@
|
|||||||
use crate::activities::receive::{
|
use crate::{
|
||||||
create::receive_create,
|
activities::receive::{
|
||||||
delete::receive_delete,
|
create::receive_create,
|
||||||
dislike::receive_dislike,
|
delete::receive_delete,
|
||||||
like::receive_like,
|
dislike::receive_dislike,
|
||||||
receive_unhandled_activity,
|
like::receive_like,
|
||||||
remove::receive_remove,
|
receive_unhandled_activity,
|
||||||
undo::receive_undo,
|
remove::receive_remove,
|
||||||
update::receive_update,
|
undo::receive_undo,
|
||||||
};
|
update::receive_update,
|
||||||
use activitystreams::{
|
verify_activity_domains_valid,
|
||||||
activity::*,
|
},
|
||||||
base::{AnyBase, BaseExt},
|
check_is_apub_id_valid,
|
||||||
prelude::ExtendsExt,
|
ActorType,
|
||||||
};
|
};
|
||||||
|
use activitystreams::{activity::*, base::AnyBase, prelude::ExtendsExt};
|
||||||
use actix_web::HttpResponse;
|
use actix_web::HttpResponse;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use lemmy_utils::{location_info, LemmyError};
|
use lemmy_utils::{location_info, LemmyError};
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
|
||||||
pub async fn receive_announce(
|
pub async fn receive_announce(
|
||||||
activity: AnyBase,
|
|
||||||
context: &LemmyContext,
|
context: &LemmyContext,
|
||||||
|
activity: AnyBase,
|
||||||
|
actor: &dyn ActorType,
|
||||||
) -> Result<HttpResponse, LemmyError> {
|
) -> Result<HttpResponse, LemmyError> {
|
||||||
let announce = Announce::from_any_base(activity)?.context(location_info!())?;
|
let announce = Announce::from_any_base(activity)?.context(location_info!())?;
|
||||||
|
verify_activity_domains_valid(&announce, actor.actor_id()?, false)?;
|
||||||
|
|
||||||
// ensure that announce and community come from the same instance
|
let kind = announce.object().as_single_kind_str();
|
||||||
let community_id = announce
|
let object = announce
|
||||||
.actor()?
|
.object()
|
||||||
.to_owned()
|
.to_owned()
|
||||||
.single_xsd_any_uri()
|
.one()
|
||||||
.context(location_info!())?;
|
.context(location_info!())?;
|
||||||
announce.id(community_id.domain().context(location_info!())?)?;
|
|
||||||
|
|
||||||
let kind = announce.object().as_single_kind_str();
|
let inner_id = object.id().context(location_info!())?.to_owned();
|
||||||
let object = announce.object();
|
check_is_apub_id_valid(&inner_id)?;
|
||||||
let object2 = object.clone().one().context(location_info!())?;
|
|
||||||
match kind {
|
match kind {
|
||||||
Some("Create") => receive_create(object2, context).await,
|
Some("Create") => receive_create(context, object, inner_id).await,
|
||||||
Some("Update") => receive_update(object2, context).await,
|
Some("Update") => receive_update(context, object, inner_id).await,
|
||||||
Some("Like") => receive_like(object2, context).await,
|
Some("Like") => receive_like(context, object, inner_id).await,
|
||||||
Some("Dislike") => receive_dislike(object2, context).await,
|
Some("Dislike") => receive_dislike(context, object, inner_id).await,
|
||||||
Some("Delete") => receive_delete(object2, context).await,
|
Some("Delete") => receive_delete(context, object, inner_id).await,
|
||||||
Some("Remove") => receive_remove(object2, context).await,
|
Some("Remove") => receive_remove(context, object, inner_id).await,
|
||||||
Some("Undo") => receive_undo(object2, context).await,
|
Some("Undo") => receive_undo(context, object, inner_id).await,
|
||||||
_ => receive_unhandled_activity(announce),
|
_ => receive_unhandled_activity(announce),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue