1 use crate::activities::{comment::send_websocket_message, verify_mod_action};
2 use activitystreams::activity::kind::RemoveType;
3 use lemmy_api_common::blocking;
4 use lemmy_apub::{check_is_apub_id_valid, fetcher::objects::get_or_fetch_and_insert_comment};
5 use lemmy_apub_lib::{verify_domains_match, ActivityCommonFields, ActivityHandlerNew, PublicUrl};
6 use lemmy_db_queries::source::comment::Comment_;
7 use lemmy_db_schema::source::comment::Comment;
8 use lemmy_utils::LemmyError;
9 use lemmy_websocket::{LemmyContext, UserOperationCrud};
12 #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
13 #[serde(rename_all = "camelCase")]
14 pub struct RemoveComment {
16 pub(in crate::activities::comment) object: Url,
18 #[serde(rename = "type")]
21 common: ActivityCommonFields,
24 #[async_trait::async_trait(?Send)]
25 impl ActivityHandlerNew for RemoveComment {
26 async fn verify(&self, context: &LemmyContext, _: &mut i32) -> Result<(), LemmyError> {
27 verify_domains_match(&self.common.actor, self.common.id_unchecked())?;
28 check_is_apub_id_valid(&self.common.actor, false)?;
29 verify_mod_action(&self.common.actor, self.cc[0].clone(), context).await
34 context: &LemmyContext,
35 request_counter: &mut i32,
36 ) -> Result<(), LemmyError> {
37 let comment = get_or_fetch_and_insert_comment(&self.object, context, request_counter).await?;
39 let removed_comment = blocking(context.pool(), move |conn| {
40 Comment::update_removed(conn, comment.id, true)
44 send_websocket_message(
47 UserOperationCrud::EditComment,
53 fn common(&self) -> &ActivityCommonFields {