1 use crate::activities::{
2 comment::{get_notif_recipients, send_websocket_message},
4 verify_person_in_community,
6 use activitystreams::{activity::kind::CreateType, base::BaseExt};
7 use lemmy_apub::{objects::FromApub, NoteExt};
8 use lemmy_apub_lib::{verify_domains_match_opt, ActivityCommonFields, ActivityHandler, PublicUrl};
9 use lemmy_db_schema::source::comment::Comment;
10 use lemmy_utils::LemmyError;
11 use lemmy_websocket::{LemmyContext, UserOperationCrud};
14 #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
15 #[serde(rename_all = "camelCase")]
16 pub struct CreateComment {
20 #[serde(rename = "type")]
23 common: ActivityCommonFields,
26 #[async_trait::async_trait(?Send)]
27 impl ActivityHandler for CreateComment {
30 context: &LemmyContext,
31 request_counter: &mut i32,
32 ) -> Result<(), LemmyError> {
33 verify_activity(self.common())?;
34 verify_person_in_community(&self.common.actor, &self.cc, context, request_counter).await?;
35 verify_domains_match_opt(&self.common.actor, self.object.id_unchecked())?;
36 // TODO: should add a check that the correct community is in cc (probably needs changes to
37 // comment deserialization)
43 context: &LemmyContext,
44 request_counter: &mut i32,
45 ) -> Result<(), LemmyError> {
46 let comment = Comment::from_apub(
49 self.common.actor.clone(),
55 get_notif_recipients(&self.common.actor, &comment, context, request_counter).await?;
56 send_websocket_message(
59 UserOperationCrud::CreateComment,
65 fn common(&self) -> &ActivityCommonFields {