3 comment::{get_notif_recipients, send_websocket_message},
5 verify_person_in_community,
10 use activitystreams::{activity::kind::CreateType, base::BaseExt};
11 use lemmy_apub_lib::{verify_domains_match_opt, ActivityCommonFields, ActivityHandler, PublicUrl};
12 use lemmy_db_schema::source::comment::Comment;
13 use lemmy_utils::LemmyError;
14 use lemmy_websocket::{LemmyContext, UserOperationCrud};
17 #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
18 #[serde(rename_all = "camelCase")]
19 pub struct CreateComment {
23 #[serde(rename = "type")]
26 common: ActivityCommonFields,
29 #[async_trait::async_trait(?Send)]
30 impl ActivityHandler for CreateComment {
33 context: &LemmyContext,
34 request_counter: &mut i32,
35 ) -> Result<(), LemmyError> {
36 verify_activity(self.common())?;
37 verify_person_in_community(&self.common.actor, &self.cc, context, request_counter).await?;
38 verify_domains_match_opt(&self.common.actor, self.object.id_unchecked())?;
39 // TODO: should add a check that the correct community is in cc (probably needs changes to
40 // comment deserialization)
46 context: &LemmyContext,
47 request_counter: &mut i32,
48 ) -> Result<(), LemmyError> {
49 let comment = Comment::from_apub(
52 self.common.actor.clone(),
58 get_notif_recipients(&self.common.actor, &comment, context, request_counter).await?;
59 send_websocket_message(
62 UserOperationCrud::CreateComment,
68 fn common(&self) -> &ActivityCommonFields {