check_is_apub_id_valid,
fetcher::get_or_fetch_and_upsert_user,
ActorType,
- ToApub,
};
use activitystreams::{
activity::{
};
use anyhow::Context;
use itertools::Itertools;
-use lemmy_db::{community::Community, community_view::CommunityFollowerView, user::User_, DbPool};
+use lemmy_db::{community::Community, community_view::CommunityFollowerView, DbPool};
use lemmy_structs::blocking;
use lemmy_utils::{location_info, settings::Settings, LemmyError};
use lemmy_websocket::LemmyContext;
}
/// If the creator of a community deletes the community, send this to all followers.
- async fn send_delete(&self, creator: &User_, context: &LemmyContext) -> Result<(), LemmyError> {
- let group = self.to_apub(context.pool()).await?;
-
- let mut delete = Delete::new(creator.actor_id.to_owned(), group.into_any_base()?);
+ async fn send_delete(&self, context: &LemmyContext) -> Result<(), LemmyError> {
+ let mut delete = Delete::new(self.actor_id()?, self.actor_id()?);
delete
.set_context(activitystreams::context())
.set_id(generate_activity_id(DeleteType::Delete)?)
}
/// If the creator of a community reverts the deletion of a community, send this to all followers.
- async fn send_undo_delete(
- &self,
- creator: &User_,
- context: &LemmyContext,
- ) -> Result<(), LemmyError> {
- let group = self.to_apub(context.pool()).await?;
-
- let mut delete = Delete::new(creator.actor_id.to_owned(), group.into_any_base()?);
+ async fn send_undo_delete(&self, context: &LemmyContext) -> Result<(), LemmyError> {
+ let mut delete = Delete::new(self.actor_id()?, self.actor_id()?);
delete
.set_context(activitystreams::context())
.set_id(generate_activity_id(DeleteType::Delete)?)
.set_to(public())
.set_many_ccs(vec![self.get_followers_url()?]);
- let mut undo = Undo::new(creator.actor_id.to_owned(), delete.into_any_base()?);
+ let mut undo = Undo::new(self.actor_id()?, delete.into_any_base()?);
undo
.set_context(activitystreams::context())
.set_id(generate_activity_id(UndoType::Undo)?)
}
/// If an admin removes a community, send this to all followers.
- async fn send_remove(&self, mod_: &User_, context: &LemmyContext) -> Result<(), LemmyError> {
- let mut remove = Remove::new(mod_.actor_id.to_owned(), self.actor_id()?);
+ async fn send_remove(&self, context: &LemmyContext) -> Result<(), LemmyError> {
+ let mut remove = Remove::new(self.actor_id()?, self.actor_id()?);
remove
.set_context(activitystreams::context())
.set_id(generate_activity_id(RemoveType::Remove)?)
}
/// If an admin reverts the removal of a community, send this to all followers.
- async fn send_undo_remove(&self, mod_: &User_, context: &LemmyContext) -> Result<(), LemmyError> {
- let mut remove = Remove::new(mod_.actor_id.to_owned(), self.actor_id()?);
+ async fn send_undo_remove(&self, context: &LemmyContext) -> Result<(), LemmyError> {
+ let mut remove = Remove::new(self.actor_id()?, self.actor_id()?);
remove
.set_context(activitystreams::context())
.set_id(generate_activity_id(RemoveType::Remove)?)
.set_many_ccs(vec![self.get_followers_url()?]);
// Undo that fake activity
- let mut undo = Undo::new(mod_.actor_id.to_owned(), remove.into_any_base()?);
+ let mut undo = Undo::new(self.actor_id()?, remove.into_any_base()?);
undo
.set_context(activitystreams::context())
.set_id(generate_activity_id(LikeType::Like)?)