3 community::announce::{AnnouncableActivities, AnnounceActivity},
6 check_is_apub_id_valid,
7 fetcher::object_id::ObjectId,
9 objects::community::ApubCommunity,
11 use itertools::Itertools;
12 use lemmy_apub_lib::traits::ActorType;
13 use lemmy_utils::LemmyError;
14 use lemmy_websocket::LemmyContext;
21 pub mod undo_block_user;
24 async fn list_community_follower_inboxes(
25 community: &ApubCommunity,
26 additional_inboxes: Vec<Url>,
27 context: &LemmyContext,
28 ) -> Result<Vec<Url>, LemmyError> {
32 .get_follower_inboxes(context.pool(), &context.settings())
39 .filter(|inbox| inbox.host_str() != Some(&context.settings().hostname))
40 .filter(|inbox| check_is_apub_id_valid(inbox, false, &context.settings()).is_ok())
41 .map(|inbox| inbox.to_owned())
46 pub(crate) async fn send_to_community<T: ActorType>(
47 activity: AnnouncableActivities,
50 community: &ApubCommunity,
51 additional_inboxes: Vec<Url>,
52 context: &LemmyContext,
53 ) -> Result<(), LemmyError> {
54 // if this is a local community, we need to do an announce from the community instead
56 insert_activity(activity_id, activity.clone(), true, false, context.pool()).await?;
57 AnnounceActivity::send(activity, community, additional_inboxes, context).await?;
59 let mut inboxes = additional_inboxes;
60 inboxes.push(community.shared_inbox_or_inbox_url());
61 send_lemmy_activity(context, &activity, activity_id, actor, inboxes, false).await?;
67 async fn get_community_from_moderators_url(
69 context: &LemmyContext,
70 request_counter: &mut i32,
71 ) -> Result<ApubCommunity, LemmyError> {
72 let community_id = Url::parse(&moderators.to_string().replace("/moderators", ""))?;
73 ObjectId::new(community_id)
74 .dereference(context, request_counter)