3 create::receive_create,
4 delete::receive_delete,
5 dislike::receive_dislike,
7 remove::receive_remove,
9 update::receive_update,
11 shared_inbox::{get_community_id_from_activity, receive_unhandled_activity},
13 use activitystreams::{
15 base::{AnyBase, BaseExt},
18 use actix_web::HttpResponse;
20 use lemmy_utils::{location_info, LemmyError};
21 use lemmy_websocket::LemmyContext;
23 pub async fn receive_announce(
25 context: &LemmyContext,
26 ) -> Result<HttpResponse, LemmyError> {
27 let announce = Announce::from_any_base(activity)?.context(location_info!())?;
29 // ensure that announce and community come from the same instance
30 let community = get_community_id_from_activity(&announce)?;
31 announce.id(community.domain().context(location_info!())?)?;
33 let kind = announce.object().as_single_kind_str();
34 let object = announce.object();
35 let object2 = object.clone().one().context(location_info!())?;
37 Some("Create") => receive_create(object2, context).await,
38 Some("Update") => receive_update(object2, context).await,
39 Some("Like") => receive_like(object2, context).await,
40 Some("Dislike") => receive_dislike(object2, context).await,
41 Some("Delete") => receive_delete(object2, context).await,
42 Some("Remove") => receive_remove(object2, context).await,
43 Some("Undo") => receive_undo(object2, context).await,
44 _ => receive_unhandled_activity(announce),