2 activities::{comment::send_websocket_message, verify_mod_action},
3 check_is_apub_id_valid,
4 fetcher::objects::get_or_fetch_and_insert_comment,
6 use activitystreams::activity::kind::RemoveType;
7 use lemmy_api_common::blocking;
14 use lemmy_db_queries::source::comment::Comment_;
15 use lemmy_db_schema::source::comment::Comment;
16 use lemmy_utils::LemmyError;
17 use lemmy_websocket::{LemmyContext, UserOperationCrud};
20 #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
21 #[serde(rename_all = "camelCase")]
22 pub struct RemoveComment {
24 pub(in crate::activities::comment) object: Url,
26 #[serde(rename = "type")]
29 common: ActivityCommonFields,
32 #[async_trait::async_trait(?Send)]
33 impl ActivityHandlerNew for RemoveComment {
34 async fn verify(&self, context: &LemmyContext, _: &mut i32) -> Result<(), LemmyError> {
35 verify_domains_match(&self.common.actor, self.common.id_unchecked())?;
36 check_is_apub_id_valid(&self.common.actor, false)?;
37 verify_mod_action(&self.common.actor, self.cc[0].clone(), context).await
42 context: &LemmyContext,
43 request_counter: &mut i32,
44 ) -> Result<(), LemmyError> {
45 let comment = get_or_fetch_and_insert_comment(&self.object, context, request_counter).await?;
47 let removed_comment = blocking(context.pool(), move |conn| {
48 Comment::update_removed(conn, comment.id, true)
52 send_websocket_message(
55 UserOperationCrud::EditComment,
61 fn common(&self) -> &ActivityCommonFields {