]> Untitled Git - lemmy.git/blob - crates/apub/src/protocol/activities/community/announce.rs
When announcing incoming activities, keep extra fields (#2550)
[lemmy.git] / crates / apub / src / protocol / activities / community / announce.rs
1 use crate::{objects::community::ApubCommunity, protocol::IdOrNestedObject};
2 use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one_or_many};
3 use activitystreams_kinds::activity::AnnounceType;
4 use serde::{Deserialize, Serialize};
5 use serde_json::{Map, Value};
6 use url::Url;
7
8 #[derive(Clone, Debug, Deserialize, Serialize)]
9 #[serde(rename_all = "camelCase")]
10 pub struct AnnounceActivity {
11   pub(crate) actor: ObjectId<ApubCommunity>,
12   #[serde(deserialize_with = "deserialize_one_or_many")]
13   pub(crate) to: Vec<Url>,
14   pub(crate) object: IdOrNestedObject<RawAnnouncableActivities>,
15   #[serde(deserialize_with = "deserialize_one_or_many")]
16   pub(crate) cc: Vec<Url>,
17   #[serde(rename = "type")]
18   pub(crate) kind: AnnounceType,
19   pub(crate) id: Url,
20 }
21
22 /// Use this to receive community inbox activities, and then announce them if valid. This
23 /// ensures that all json fields are kept, even if Lemmy doesnt understand them.
24 #[derive(Clone, Debug, Deserialize, Serialize)]
25 pub struct RawAnnouncableActivities {
26   pub(crate) id: Url,
27   pub(crate) actor: Url,
28   #[serde(flatten)]
29   pub(crate) other: Map<String, Value>,
30 }