2 activities::community::announce::{AnnouncableActivities, AnnounceActivity},
3 check_is_apub_id_valid,
4 fetcher::object_id::ObjectId,
6 objects::community::ApubCommunity,
9 use itertools::Itertools;
10 use lemmy_apub_lib::traits::ActorType;
11 use lemmy_utils::LemmyError;
12 use lemmy_websocket::LemmyContext;
19 pub mod undo_block_user;
22 async fn list_community_follower_inboxes(
23 community: &ApubCommunity,
24 additional_inboxes: Vec<Url>,
25 context: &LemmyContext,
26 ) -> Result<Vec<Url>, LemmyError> {
30 .get_follower_inboxes(context.pool(), &context.settings())
37 .filter(|inbox| inbox.host_str() != Some(&context.settings().hostname))
38 .filter(|inbox| check_is_apub_id_valid(inbox, false, &context.settings()).is_ok())
39 .map(|inbox| inbox.to_owned())
44 pub(crate) async fn send_to_community<T: ActorType>(
45 activity: AnnouncableActivities,
48 community: &ApubCommunity,
49 additional_inboxes: Vec<Url>,
50 context: &LemmyContext,
51 ) -> Result<(), LemmyError> {
52 // if this is a local community, we need to do an announce from the community instead
54 insert_activity(activity_id, activity.clone(), true, false, context.pool()).await?;
55 AnnounceActivity::send(activity, community, additional_inboxes, context).await?;
57 let mut inboxes = additional_inboxes;
58 inboxes.push(community.shared_inbox_or_inbox_url());
59 send_lemmy_activity(context, &activity, activity_id, actor, inboxes, false).await?;
65 async fn get_community_from_moderators_url(
67 context: &LemmyContext,
68 request_counter: &mut i32,
69 ) -> Result<ApubCommunity, LemmyError> {
70 let community_id = Url::parse(&moderators.to_string().replace("/moderators", ""))?;
71 ObjectId::new(community_id)
72 .dereference(context, request_counter)