2 objects::{person::ApubPerson, private_message::ApubPrivateMessage},
5 use chrono::{DateTime, FixedOffset};
6 use lemmy_apub_lib::{object_id::ObjectId, values::MediaTypeHtml};
7 use serde::{Deserialize, Serialize};
8 use serde_with::skip_serializing_none;
10 #[skip_serializing_none]
11 #[derive(Clone, Debug, Deserialize, Serialize)]
12 #[serde(rename_all = "camelCase")]
13 pub struct ChatMessage {
14 pub(crate) r#type: ChatMessageType,
15 pub(crate) id: ObjectId<ApubPrivateMessage>,
16 pub(crate) attributed_to: ObjectId<ApubPerson>,
17 #[serde(deserialize_with = "crate::deserialize_one")]
18 pub(crate) to: [ObjectId<ApubPerson>; 1],
19 pub(crate) content: String,
21 pub(crate) media_type: Option<MediaTypeHtml>,
23 #[serde(deserialize_with = "crate::deserialize_skip_error")]
24 pub(crate) source: Option<Source>,
25 pub(crate) published: Option<DateTime<FixedOffset>>,
26 pub(crate) updated: Option<DateTime<FixedOffset>>,
29 /// https://docs.pleroma.social/backend/development/ap_extensions/#chatmessages
30 #[derive(Clone, Debug, Deserialize, Serialize)]
31 pub enum ChatMessageType {