1 use crate::activities::{private_message::send_websocket_message, verify_activity, verify_person};
2 use activitystreams::{activity::kind::CreateType, base::BaseExt};
3 use lemmy_apub::{objects::FromApub, NoteExt};
4 use lemmy_apub_lib::{verify_domains_match_opt, ActivityCommonFields, ActivityHandler};
5 use lemmy_db_schema::source::private_message::PrivateMessage;
6 use lemmy_utils::LemmyError;
7 use lemmy_websocket::{LemmyContext, UserOperationCrud};
10 #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
11 #[serde(rename_all = "camelCase")]
12 pub struct CreatePrivateMessage {
15 #[serde(rename = "type")]
18 common: ActivityCommonFields,
21 #[async_trait::async_trait(?Send)]
22 impl ActivityHandler for CreatePrivateMessage {
25 context: &LemmyContext,
26 request_counter: &mut i32,
27 ) -> Result<(), LemmyError> {
28 verify_activity(self.common())?;
29 verify_person(&self.common.actor, context, request_counter).await?;
30 verify_domains_match_opt(&self.common.actor, self.object.id_unchecked())?;
36 context: &LemmyContext,
37 request_counter: &mut i32,
38 ) -> Result<(), LemmyError> {
39 let private_message = PrivateMessage::from_apub(
42 self.common.actor.clone(),
48 send_websocket_message(
50 UserOperationCrud::CreatePrivateMessage,
58 fn common(&self) -> &ActivityCommonFields {