1 use crate::activities::{
2 post::send_websocket_message,
4 verify_person_in_community,
6 use activitystreams::{activity::kind::CreateType, base::BaseExt};
8 fetcher::person::get_or_fetch_and_upsert_person,
13 use lemmy_apub_lib::{verify_domains_match_opt, ActivityCommonFields, ActivityHandler, PublicUrl};
14 use lemmy_db_schema::source::post::Post;
15 use lemmy_utils::LemmyError;
16 use lemmy_websocket::{LemmyContext, UserOperationCrud};
19 #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
20 #[serde(rename_all = "camelCase")]
21 pub struct CreatePost {
25 #[serde(rename = "type")]
28 common: ActivityCommonFields,
31 #[async_trait::async_trait(?Send)]
32 impl ActivityHandler for CreatePost {
35 context: &LemmyContext,
36 request_counter: &mut i32,
37 ) -> Result<(), LemmyError> {
38 verify_activity(self.common())?;
39 verify_person_in_community(&self.common.actor, &self.cc, context, request_counter).await?;
40 verify_domains_match_opt(&self.common.actor, self.object.id_unchecked())?;
46 context: &LemmyContext,
47 request_counter: &mut i32,
48 ) -> Result<(), LemmyError> {
50 get_or_fetch_and_upsert_person(&self.common.actor, context, request_counter).await?;
51 let post = Post::from_apub(
60 send_websocket_message(post.id, UserOperationCrud::CreatePost, context).await
63 fn common(&self) -> &ActivityCommonFields {