2 activities::send_lemmy_activity,
3 activity_lists::AnnouncableActivities,
5 objects::community::ApubCommunity,
6 protocol::activities::community::announce::AnnounceActivity,
8 use lemmy_apub_lib::{object_id::ObjectId, traits::ActorType};
9 use lemmy_utils::LemmyError;
10 use lemmy_websocket::LemmyContext;
18 pub mod undo_block_user;
21 pub(crate) async fn send_to_community<T: ActorType>(
22 activity: AnnouncableActivities,
25 community: &ApubCommunity,
26 additional_inboxes: Vec<Url>,
27 context: &LemmyContext,
28 ) -> Result<(), LemmyError> {
29 // if this is a local community, we need to do an announce from the community instead
30 let object_value = serde_json::to_value(&activity)?;
32 insert_activity(activity_id, object_value, true, false, context.pool()).await?;
33 AnnounceActivity::send(activity, community, additional_inboxes, context).await?;
35 let mut inboxes = additional_inboxes;
36 inboxes.push(community.shared_inbox_or_inbox_url());
37 send_lemmy_activity(context, &activity, activity_id, actor, inboxes, false).await?;
43 async fn get_community_from_moderators_url(
45 context: &LemmyContext,
46 request_counter: &mut i32,
47 ) -> Result<ApubCommunity, LemmyError> {
48 let community_id = Url::parse(&moderators.to_string().replace("/moderators", ""))?;
49 ObjectId::new(community_id)
50 .dereference(context, request_counter)