CommunityPersonBan,
CommunityPersonBanForm,
},
- moderator::{ModBan, ModBanForm},
+ moderator::{ModBan, ModBanForm, ModBanFromCommunity, ModBanFromCommunityForm},
person::Person,
},
traits::{Bannable, Crud, Followable},
}
// write to mod log
- let form = ModBanForm {
+ let form = ModBanFromCommunityForm {
mod_person_id: mod_person.id,
other_person_id: blocked_person.id,
+ community_id: community.id,
reason: self.summary,
banned: Some(true),
expires,
};
- blocking(context.pool(), move |conn| ModBan::create(conn, &form)).await??;
+ blocking(context.pool(), move |conn| {
+ ModBanFromCommunity::create(conn, &form)
+ })
+ .await??;
}
}
use lemmy_db_schema::{
source::{
community::{CommunityPersonBan, CommunityPersonBanForm},
- moderator::{ModBan, ModBanForm},
+ moderator::{ModBan, ModBanForm, ModBanFromCommunity, ModBanFromCommunityForm},
person::Person,
},
traits::{Bannable, Crud},
.await??;
// write to mod log
- let form = ModBanForm {
+ let form = ModBanFromCommunityForm {
mod_person_id: mod_person.id,
other_person_id: blocked_person.id,
+ community_id: community.id,
reason: self.object.summary,
banned: Some(false),
expires,
};
- blocking(context.pool(), move |conn| ModBan::create(conn, &form)).await??;
+ blocking(context.pool(), move |conn| {
+ ModBanFromCommunity::create(conn, &form)
+ })
+ .await??;
}
}
traits::{ActivityHandler, ActorType},
};
use lemmy_db_schema::{
- source::community::{CommunityModerator, CommunityModeratorForm},
- traits::Joinable,
+ source::{
+ community::{CommunityModerator, CommunityModeratorForm},
+ moderator::{ModAddCommunity, ModAddCommunityForm},
+ },
+ traits::{Crud, Joinable},
};
use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext;
CommunityModerator::join(conn, &form)
})
.await??;
+
+ // write mod log
+ let actor = self
+ .actor
+ .dereference(context, context.client(), request_counter)
+ .await?;
+ let form = ModAddCommunityForm {
+ mod_person_id: actor.id,
+ other_person_id: new_mod.id,
+ community_id: community.id,
+ removed: Some(false),
+ };
+ blocking(context.pool(), move |conn| {
+ ModAddCommunity::create(conn, &form)
+ })
+ .await??;
}
// TODO: send websocket notification about added mod
Ok(())
traits::{ActivityHandler, ActorType},
};
use lemmy_db_schema::{
- source::community::{CommunityModerator, CommunityModeratorForm},
- traits::Joinable,
+ source::{
+ community::{CommunityModerator, CommunityModeratorForm},
+ moderator::{ModAddCommunity, ModAddCommunityForm},
+ },
+ traits::{Crud, Joinable},
};
use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext;
CommunityModerator::leave(conn, &form)
})
.await??;
+
+ // write mod log
+ let actor = self
+ .actor
+ .dereference(context, context.client(), request_counter)
+ .await?;
+ let form = ModAddCommunityForm {
+ mod_person_id: actor.id,
+ other_person_id: remove_mod.id,
+ community_id: community.id,
+ removed: Some(true),
+ };
+ blocking(context.pool(), move |conn| {
+ ModAddCommunity::create(conn, &form)
+ })
+ .await??;
+
// TODO: send websocket notification about removed mod
Ok(())
}
Some(reason)
};
receive_remove_action(
- &self.actor,
+ &self
+ .actor
+ .dereference(context, context.client(), request_counter)
+ .await?,
self.object.id(),
reason,
context,
- request_counter,
)
.await
} else {
#[tracing::instrument(skip_all)]
pub(in crate::activities) async fn receive_remove_action(
- actor: &ObjectId<ApubPerson>,
+ actor: &ApubPerson,
object: &Url,
reason: Option<String>,
context: &LemmyContext,
- request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let actor = actor
- .dereference(context, context.client(), request_counter)
- .await?;
use UserOperationCrud::*;
match DeletableObjects::read_from_db(object, context).await? {
DeletableObjects::Community(community) => {
generate_activity_id,
verify_activity,
},
- objects::community::ApubCommunity,
+ objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::deletion::{delete::Delete, undo_delete::UndoDelete},
};
use activitystreams_kinds::activity::UndoType;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{data::Data, object_id::ObjectId, traits::ActivityHandler};
-use lemmy_db_schema::source::{comment::Comment, community::Community, person::Person, post::Post};
+use lemmy_db_schema::{
+ source::{
+ comment::Comment,
+ community::Community,
+ moderator::{
+ ModRemoveComment,
+ ModRemoveCommentForm,
+ ModRemoveCommunity,
+ ModRemoveCommunityForm,
+ ModRemovePost,
+ ModRemovePostForm,
+ },
+ person::Person,
+ post::Post,
+ },
+ traits::Crud,
+};
use lemmy_utils::LemmyError;
use lemmy_websocket::{
send::{send_comment_ws_message_simple, send_community_ws_message, send_post_ws_message},
request_counter: &mut i32,
) -> Result<(), LemmyError> {
if self.object.summary.is_some() {
- UndoDelete::receive_undo_remove_action(self.object.object.id(), context).await
+ UndoDelete::receive_undo_remove_action(
+ &self
+ .actor
+ .dereference(context, context.client(), request_counter)
+ .await?,
+ self.object.object.id(),
+ context,
+ )
+ .await
} else {
receive_delete_action(
self.object.object.id(),
#[tracing::instrument(skip_all)]
pub(in crate::activities) async fn receive_undo_remove_action(
+ actor: &ApubPerson,
object: &Url,
context: &LemmyContext,
) -> Result<(), LemmyError> {
"Only local admin can restore community",
));
}
+ let form = ModRemoveCommunityForm {
+ mod_person_id: actor.id,
+ community_id: community.id,
+ removed: Some(false),
+ reason: None,
+ expires: None,
+ };
+ blocking(context.pool(), move |conn| {
+ ModRemoveCommunity::create(conn, &form)
+ })
+ .await??;
let deleted_community = blocking(context.pool(), move |conn| {
Community::update_removed(conn, community.id, false)
})
send_community_ws_message(deleted_community.id, EditCommunity, None, None, context).await?;
}
DeletableObjects::Post(post) => {
+ let form = ModRemovePostForm {
+ mod_person_id: actor.id,
+ post_id: post.id,
+ removed: Some(false),
+ reason: None,
+ };
+ blocking(context.pool(), move |conn| {
+ ModRemovePost::create(conn, &form)
+ })
+ .await??;
let removed_post = blocking(context.pool(), move |conn| {
Post::update_removed(conn, post.id, false)
})
send_post_ws_message(removed_post.id, EditPost, None, None, context).await?;
}
DeletableObjects::Comment(comment) => {
+ let form = ModRemoveCommentForm {
+ mod_person_id: actor.id,
+ comment_id: comment.id,
+ removed: Some(false),
+ reason: None,
+ };
+ blocking(context.pool(), move |conn| {
+ ModRemoveComment::create(conn, &form)
+ })
+ .await??;
let removed_comment = blocking(context.pool(), move |conn| {
Comment::update_removed(conn, comment.id, false)
})
.await?;
let community = page.extract_community(context, request_counter).await?;
+ // TODO: write mod log if stickied or locked changed
+
let url = if let Some(attachment) = page.attachment.first() {
Some(attachment.href.clone())
} else {