1 use crate::activities::{
2 comment::{remove::RemoveComment, send_websocket_message},
5 use activitystreams::activity::kind::UndoType;
6 use lemmy_api_common::blocking;
7 use crate::{check_is_apub_id_valid, fetcher::objects::get_or_fetch_and_insert_comment};
8 use lemmy_apub_lib::{verify_domains_match, ActivityCommonFields, ActivityHandlerNew, PublicUrl};
9 use lemmy_db_queries::source::comment::Comment_;
10 use lemmy_db_schema::source::comment::Comment;
11 use lemmy_utils::LemmyError;
12 use lemmy_websocket::{LemmyContext, UserOperationCrud};
15 #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
16 #[serde(rename_all = "camelCase")]
17 pub struct UndoRemoveComment {
19 object: RemoveComment,
21 #[serde(rename = "type")]
24 common: ActivityCommonFields,
27 #[async_trait::async_trait(?Send)]
28 impl ActivityHandlerNew for UndoRemoveComment {
31 context: &LemmyContext,
32 request_counter: &mut i32,
33 ) -> Result<(), LemmyError> {
34 verify_domains_match(&self.common.actor, self.common.id_unchecked())?;
35 check_is_apub_id_valid(&self.common.actor, false)?;
36 verify_mod_action(&self.common.actor, self.cc[0].clone(), context).await?;
37 self.object.verify(context, request_counter).await
42 context: &LemmyContext,
43 request_counter: &mut i32,
44 ) -> Result<(), LemmyError> {
46 get_or_fetch_and_insert_comment(&self.object.object, context, request_counter).await?;
48 let removed_comment = blocking(context.pool(), move |conn| {
49 Comment::update_removed(conn, comment.id, false)
53 send_websocket_message(
56 UserOperationCrud::EditComment,
62 fn common(&self) -> &ActivityCommonFields {