|
|
@ -4,7 +4,6 @@ use crate::{
|
|
|
|
check_is_apub_id_valid,
|
|
|
|
check_is_apub_id_valid,
|
|
|
|
fetcher::get_or_fetch_and_upsert_user,
|
|
|
|
fetcher::get_or_fetch_and_upsert_user,
|
|
|
|
ActorType,
|
|
|
|
ActorType,
|
|
|
|
ToApub,
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use activitystreams::{
|
|
|
|
use activitystreams::{
|
|
|
|
activity::{
|
|
|
|
activity::{
|
|
|
@ -23,7 +22,7 @@ use activitystreams::{
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use anyhow::Context;
|
|
|
|
use anyhow::Context;
|
|
|
|
use itertools::Itertools;
|
|
|
|
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_structs::blocking;
|
|
|
|
use lemmy_utils::{location_info, settings::Settings, LemmyError};
|
|
|
|
use lemmy_utils::{location_info, settings::Settings, LemmyError};
|
|
|
|
use lemmy_websocket::LemmyContext;
|
|
|
|
use lemmy_websocket::LemmyContext;
|
|
|
@ -85,10 +84,8 @@ impl ActorType for Community {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// If the creator of a community deletes the community, send this to all followers.
|
|
|
|
/// 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> {
|
|
|
|
async fn send_delete(&self, context: &LemmyContext) -> Result<(), LemmyError> {
|
|
|
|
let group = self.to_apub(context.pool()).await?;
|
|
|
|
let mut delete = Delete::new(self.actor_id()?, self.actor_id()?);
|
|
|
|
|
|
|
|
|
|
|
|
let mut delete = Delete::new(creator.actor_id.to_owned(), group.into_any_base()?);
|
|
|
|
|
|
|
|
delete
|
|
|
|
delete
|
|
|
|
.set_context(activitystreams::context())
|
|
|
|
.set_context(activitystreams::context())
|
|
|
|
.set_id(generate_activity_id(DeleteType::Delete)?)
|
|
|
|
.set_id(generate_activity_id(DeleteType::Delete)?)
|
|
|
@ -100,21 +97,15 @@ impl ActorType for Community {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// If the creator of a community reverts the deletion of a community, send this to all followers.
|
|
|
|
/// If the creator of a community reverts the deletion of a community, send this to all followers.
|
|
|
|
async fn send_undo_delete(
|
|
|
|
async fn send_undo_delete(&self, context: &LemmyContext) -> Result<(), LemmyError> {
|
|
|
|
&self,
|
|
|
|
let mut delete = Delete::new(self.actor_id()?, self.actor_id()?);
|
|
|
|
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()?);
|
|
|
|
|
|
|
|
delete
|
|
|
|
delete
|
|
|
|
.set_context(activitystreams::context())
|
|
|
|
.set_context(activitystreams::context())
|
|
|
|
.set_id(generate_activity_id(DeleteType::Delete)?)
|
|
|
|
.set_id(generate_activity_id(DeleteType::Delete)?)
|
|
|
|
.set_to(public())
|
|
|
|
.set_to(public())
|
|
|
|
.set_many_ccs(vec![self.get_followers_url()?]);
|
|
|
|
.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
|
|
|
|
undo
|
|
|
|
.set_context(activitystreams::context())
|
|
|
|
.set_context(activitystreams::context())
|
|
|
|
.set_id(generate_activity_id(UndoType::Undo)?)
|
|
|
|
.set_id(generate_activity_id(UndoType::Undo)?)
|
|
|
@ -126,8 +117,8 @@ impl ActorType for Community {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// If an admin removes a community, send this to all followers.
|
|
|
|
/// If an admin removes a community, send this to all followers.
|
|
|
|
async fn send_remove(&self, mod_: &User_, context: &LemmyContext) -> Result<(), LemmyError> {
|
|
|
|
async fn send_remove(&self, context: &LemmyContext) -> Result<(), LemmyError> {
|
|
|
|
let mut remove = Remove::new(mod_.actor_id.to_owned(), self.actor_id()?);
|
|
|
|
let mut remove = Remove::new(self.actor_id()?, self.actor_id()?);
|
|
|
|
remove
|
|
|
|
remove
|
|
|
|
.set_context(activitystreams::context())
|
|
|
|
.set_context(activitystreams::context())
|
|
|
|
.set_id(generate_activity_id(RemoveType::Remove)?)
|
|
|
|
.set_id(generate_activity_id(RemoveType::Remove)?)
|
|
|
@ -139,8 +130,8 @@ impl ActorType for Community {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// If an admin reverts the removal of a community, send this to all followers.
|
|
|
|
/// 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> {
|
|
|
|
async fn send_undo_remove(&self, context: &LemmyContext) -> Result<(), LemmyError> {
|
|
|
|
let mut remove = Remove::new(mod_.actor_id.to_owned(), self.actor_id()?);
|
|
|
|
let mut remove = Remove::new(self.actor_id()?, self.actor_id()?);
|
|
|
|
remove
|
|
|
|
remove
|
|
|
|
.set_context(activitystreams::context())
|
|
|
|
.set_context(activitystreams::context())
|
|
|
|
.set_id(generate_activity_id(RemoveType::Remove)?)
|
|
|
|
.set_id(generate_activity_id(RemoveType::Remove)?)
|
|
|
@ -148,7 +139,7 @@ impl ActorType for Community {
|
|
|
|
.set_many_ccs(vec![self.get_followers_url()?]);
|
|
|
|
.set_many_ccs(vec![self.get_followers_url()?]);
|
|
|
|
|
|
|
|
|
|
|
|
// Undo that fake activity
|
|
|
|
// 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
|
|
|
|
undo
|
|
|
|
.set_context(activitystreams::context())
|
|
|
|
.set_context(activitystreams::context())
|
|
|
|
.set_id(generate_activity_id(LikeType::Like)?)
|
|
|
|
.set_id(generate_activity_id(LikeType::Like)?)
|
|
|
|