3 comment::{get_notif_recipients, send_websocket_message},
6 verify_person_in_community,
12 use activitystreams::{activity::kind::CreateType, base::BaseExt};
15 verify_domains_match_opt,
19 use lemmy_db_schema::source::comment::Comment;
20 use lemmy_utils::LemmyError;
21 use lemmy_websocket::{LemmyContext, UserOperationCrud};
24 #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
25 #[serde(rename_all = "camelCase")]
26 pub struct CreateComment {
30 #[serde(rename = "type")]
33 common: ActivityCommonFields,
36 #[async_trait::async_trait(?Send)]
37 impl ActivityHandler for CreateComment {
40 context: &LemmyContext,
41 request_counter: &mut i32,
42 ) -> Result<(), LemmyError> {
43 let community = extract_community(&self.cc, context, request_counter).await?;
45 verify_activity(self.common())?;
46 verify_person_in_community(
48 &community.actor_id(),
53 verify_domains_match_opt(&self.common.actor, self.object.id_unchecked())?;
54 // TODO: should add a check that the correct community is in cc (probably needs changes to
55 // comment deserialization)
61 context: &LemmyContext,
62 request_counter: &mut i32,
63 ) -> Result<(), LemmyError> {
64 let comment = Comment::from_apub(
67 self.common.actor.clone(),
73 get_notif_recipients(&self.common.actor, &comment, context, request_counter).await?;
74 send_websocket_message(
77 UserOperationCrud::CreateComment,
83 fn common(&self) -> &ActivityCommonFields {