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