2021-11-03 16:26:09 +00:00
|
|
|
use crate::{
|
|
|
|
objects::{person::ApubPerson, private_message::ApubPrivateMessage},
|
2022-04-01 18:25:19 +00:00
|
|
|
protocol::Source,
|
2021-10-28 21:17:59 +00:00
|
|
|
};
|
2022-06-02 14:33:41 +00:00
|
|
|
use activitypub_federation::{
|
2023-03-21 15:03:05 +00:00
|
|
|
fetch::object_id::ObjectId,
|
|
|
|
protocol::{
|
2022-06-02 14:33:41 +00:00
|
|
|
helpers::{deserialize_one, deserialize_skip_error},
|
|
|
|
values::MediaTypeHtml,
|
|
|
|
},
|
|
|
|
};
|
2023-08-24 15:27:00 +00:00
|
|
|
use chrono::{DateTime, Utc};
|
2021-10-28 21:17:59 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use serde_with::skip_serializing_none;
|
|
|
|
|
|
|
|
#[skip_serializing_none]
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct ChatMessage {
|
|
|
|
pub(crate) r#type: ChatMessageType,
|
2021-11-03 16:26:09 +00:00
|
|
|
pub(crate) id: ObjectId<ApubPrivateMessage>,
|
2021-10-28 21:17:59 +00:00
|
|
|
pub(crate) attributed_to: ObjectId<ApubPerson>,
|
2022-06-02 14:33:41 +00:00
|
|
|
#[serde(deserialize_with = "deserialize_one")]
|
2022-06-08 15:45:39 +00:00
|
|
|
pub(crate) to: [ObjectId<ApubPerson>; 1],
|
2021-10-28 21:17:59 +00:00
|
|
|
pub(crate) content: String,
|
2022-02-17 22:04:01 +00:00
|
|
|
|
2021-10-28 21:17:59 +00:00
|
|
|
pub(crate) media_type: Option<MediaTypeHtml>,
|
2022-06-02 14:33:41 +00:00
|
|
|
#[serde(deserialize_with = "deserialize_skip_error", default)]
|
2022-04-01 18:25:19 +00:00
|
|
|
pub(crate) source: Option<Source>,
|
2023-08-24 15:27:00 +00:00
|
|
|
pub(crate) published: Option<DateTime<Utc>>,
|
|
|
|
pub(crate) updated: Option<DateTime<Utc>>,
|
2021-10-28 21:17:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// https://docs.pleroma.social/backend/development/ap_extensions/#chatmessages
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
|
|
pub enum ChatMessageType {
|
|
|
|
ChatMessage,
|
|
|
|
}
|