mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-10 01:19:21 +00:00
442369a041
Adjust dockerfiles, fix cargo.toml and remove unused deps Merge branch 'main' into move-websocket-to-workspace Move api code into workspace Move apub to separate workspace Move websocket code into separate workspace Some code cleanup Remove websocket dependency on API Co-authored-by: Felix Ableitner <me@nutomic.com> Reviewed-on: https://yerbamate.dev/LemmyNet/lemmy/pulls/107
47 lines
1.5 KiB
Rust
47 lines
1.5 KiB
Rust
use crate::inbox::{
|
|
activities::{
|
|
create::receive_create,
|
|
delete::receive_delete,
|
|
dislike::receive_dislike,
|
|
like::receive_like,
|
|
remove::receive_remove,
|
|
undo::receive_undo,
|
|
update::receive_update,
|
|
},
|
|
shared_inbox::{get_community_id_from_activity, receive_unhandled_activity},
|
|
};
|
|
use activitystreams::{
|
|
activity::*,
|
|
base::{AnyBase, BaseExt},
|
|
prelude::ExtendsExt,
|
|
};
|
|
use actix_web::HttpResponse;
|
|
use anyhow::Context;
|
|
use lemmy_utils::{location_info, LemmyError};
|
|
use lemmy_websocket::LemmyContext;
|
|
|
|
pub async fn receive_announce(
|
|
activity: AnyBase,
|
|
context: &LemmyContext,
|
|
) -> Result<HttpResponse, LemmyError> {
|
|
let announce = Announce::from_any_base(activity)?.context(location_info!())?;
|
|
|
|
// ensure that announce and community come from the same instance
|
|
let community = get_community_id_from_activity(&announce)?;
|
|
announce.id(community.domain().context(location_info!())?)?;
|
|
|
|
let kind = announce.object().as_single_kind_str();
|
|
let object = announce.object();
|
|
let object2 = object.clone().one().context(location_info!())?;
|
|
match kind {
|
|
Some("Create") => receive_create(object2, context).await,
|
|
Some("Update") => receive_update(object2, context).await,
|
|
Some("Like") => receive_like(object2, context).await,
|
|
Some("Dislike") => receive_dislike(object2, context).await,
|
|
Some("Delete") => receive_delete(object2, context).await,
|
|
Some("Remove") => receive_remove(object2, context).await,
|
|
Some("Undo") => receive_undo(object2, context).await,
|
|
_ => receive_unhandled_activity(announce),
|
|
}
|
|
}
|