+
+pub async fn send_add_mod(
+ actor: User_,
+ added_mod: User_,
+ community: Community,
+ context: &LemmyContext,
+) -> Result<(), LemmyError> {
+ let mut add = Add::new(
+ actor.actor_id.clone().into_inner(),
+ added_mod.actor_id.into_inner(),
+ );
+ add
+ .set_many_contexts(lemmy_context()?)
+ .set_id(generate_activity_id(AddType::Add)?)
+ .set_many_tos(vec![community.actor_id.to_owned().into_inner(), public()])
+ .set_target(generate_moderators_url(&community.actor_id)?.into_inner());
+
+ if community.local {
+ community
+ .send_announce(add.into_any_base()?, context)
+ .await?;
+ } else {
+ send_to_community(add, &actor, &community, context).await?;
+ }
+ Ok(())
+}
+
+pub async fn send_remove_mod(
+ actor: User_,
+ removed_mod: User_,
+ community: Community,
+ context: &LemmyContext,
+) -> Result<(), LemmyError> {
+ let mut remove = Remove::new(
+ actor.actor_id.clone().into_inner(),
+ removed_mod.actor_id.into_inner(),
+ );
+ remove
+ .set_many_contexts(lemmy_context()?)
+ .set_id(generate_activity_id(RemoveType::Remove)?)
+ .set_many_tos(vec![community.actor_id.to_owned().into_inner(), public()])
+ .set_target(generate_moderators_url(&community.actor_id)?.into_inner());
+
+ if community.local {
+ community
+ .send_announce(remove.into_any_base()?, context)
+ .await?;
+ } else {
+ send_to_community(remove, &actor, &community, context).await?;
+ }
+ Ok(())
+}