})
}
+pub(crate) fn deserialize_one<'de, T, D>(deserializer: D) -> Result<[T; 1], D::Error>
+where
+ T: Deserialize<'de>,
+ D: Deserializer<'de>,
+{
+ #[derive(Deserialize)]
+ #[serde(untagged)]
+ enum MaybeArray<T> {
+ Simple(T),
+ Array([T; 1]),
+ }
+
+ let result: MaybeArray<T> = Deserialize::deserialize(deserializer)?;
+ Ok(match result {
+ MaybeArray::Simple(value) => [value],
+ MaybeArray::Array(value) => value,
+ })
+}
+
pub enum EndpointType {
Community,
Person,
#[serde(rename_all = "camelCase")]
pub struct Report {
pub(crate) actor: ObjectId<ApubPerson>,
+ #[serde(deserialize_with = "crate::deserialize_one")]
pub(crate) to: [ObjectId<ApubCommunity>; 1],
pub(crate) object: ObjectId<PostOrComment>,
pub(crate) summary: String,
pub struct CreateOrUpdatePrivateMessage {
pub(crate) id: Url,
pub(crate) actor: ObjectId<ApubPerson>,
+ #[serde(deserialize_with = "crate::deserialize_one")]
pub(crate) to: [ObjectId<ApubPerson>; 1],
pub(crate) object: ChatMessage,
#[serde(rename = "type")]
#[serde(rename_all = "camelCase")]
pub struct DeletePrivateMessage {
pub(crate) actor: ObjectId<ApubPerson>,
+ #[serde(deserialize_with = "crate::deserialize_one")]
pub(crate) to: [ObjectId<ApubPerson>; 1],
pub(crate) object: ObjectId<ApubPrivateMessage>,
#[serde(rename = "type")]
#[serde(rename_all = "camelCase")]
pub struct UndoDeletePrivateMessage {
pub(crate) actor: ObjectId<ApubPerson>,
+ #[serde(deserialize_with = "crate::deserialize_one")]
pub(crate) to: [ObjectId<ApubPerson>; 1],
pub(crate) object: DeletePrivateMessage,
#[serde(rename = "type")]
pub(crate) r#type: ChatMessageType,
pub(crate) id: ObjectId<ApubPrivateMessage>,
pub(crate) attributed_to: ObjectId<ApubPerson>,
+ #[serde(deserialize_with = "crate::deserialize_one")]
pub(crate) to: [ObjectId<ApubPerson>; 1],
pub(crate) content: String,
pub(crate) media_type: Option<MediaTypeHtml>,