+ pub(crate) language: Option<LanguageTag>,
+ pub(crate) audience: Option<ObjectId<ApubCommunity>>,
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub(crate) struct Link {
+ pub(crate) href: Url,
+ pub(crate) r#type: LinkType,
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub(crate) struct Image {
+ #[serde(rename = "type")]
+ pub(crate) kind: ImageType,
+ pub(crate) url: Url,
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub(crate) struct Document {
+ #[serde(rename = "type")]
+ pub(crate) kind: DocumentType,
+ pub(crate) url: Url,
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(untagged)]
+pub(crate) enum Attachment {
+ Link(Link),
+ Image(Image),
+ Document(Document),
+}
+
+impl Attachment {
+ pub(crate) fn url(self) -> Url {
+ match self {
+ // url as sent by Lemmy (new)
+ Attachment::Link(l) => l.href,
+ // image sent by lotide
+ Attachment::Image(i) => i.url,
+ // sent by mobilizon
+ Attachment::Document(d) => d.url,
+ }
+ }
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(untagged)]
+pub(crate) enum AttributedTo {
+ Lemmy(ObjectId<ApubPerson>),
+ Peertube([AttributedToPeertube; 2]),
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub(crate) struct AttributedToPeertube {
+ #[serde(rename = "type")]
+ pub kind: PersonOrGroupType,
+ pub id: ObjectId<UserOrCommunity>,