use crate::{
activities::send_lemmy_activity,
activity_lists::AnnouncableActivities,
- local_instance,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::community::announce::AnnounceActivity,
};
-use activitypub_federation::{core::object_id::ObjectId, traits::Actor};
+use activitypub_federation::{config::Data, traits::Actor};
+use lemmy_api_common::context::LemmyContext;
use lemmy_db_schema::source::person::PersonFollower;
use lemmy_utils::error::LemmyError;
-use lemmy_websocket::LemmyContext;
use url::Url;
-pub mod add_mod;
pub mod announce;
-pub mod remove_mod;
+pub mod collection_add;
+pub mod collection_remove;
+pub mod lock_page;
pub mod report;
pub mod update;
community: &ApubCommunity,
extra_inboxes: Vec<Url>,
is_mod_action: bool,
- context: &LemmyContext,
+ context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
- // send to extra_inboxes
- send_lemmy_activity(context, activity.clone(), actor, extra_inboxes, false).await?;
+ // send to any users which are mentioned or affected directly
+ let mut inboxes = extra_inboxes;
+
+ // send to user followers
+ if !is_mod_action {
+ inboxes.extend(
+ &mut PersonFollower::list_followers(context.pool(), actor.id)
+ .await?
+ .into_iter()
+ .map(|p| ApubPerson(p).shared_inbox_or_inbox()),
+ );
+ }
if community.local {
// send directly to community followers
AnnounceActivity::send(activity.clone().try_into()?, community, context).await?;
} else {
// send to the community, which will then forward to followers
- let inbox = vec![community.shared_inbox_or_inbox()];
- send_lemmy_activity(context, activity.clone(), actor, inbox, false).await?;
- }
-
- // send to those who follow `actor`
- if !is_mod_action {
- let inboxes = PersonFollower::list_followers(context.pool(), actor.id)
- .await?
- .into_iter()
- .map(|p| ApubPerson(p).shared_inbox_or_inbox())
- .collect();
- send_lemmy_activity(context, activity, actor, inboxes, false).await?;
+ inboxes.push(community.shared_inbox_or_inbox());
}
+ send_lemmy_activity(context, activity.clone(), actor, inboxes, false).await?;
Ok(())
}
-
-#[tracing::instrument(skip_all)]
-async fn get_community_from_moderators_url(
- moderators: &Url,
- context: &LemmyContext,
- request_counter: &mut i32,
-) -> Result<ApubCommunity, LemmyError> {
- let community_id = Url::parse(&moderators.to_string().replace("/moderators", ""))?;
- ObjectId::new(community_id)
- .dereference(context, local_instance(context).await, request_counter)
- .await
-}