fetcher::user_or_community::{PersonOrGroupType, UserOrCommunity},
local_instance,
objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost},
- protocol::{ImageObject, Source},
+ protocol::{objects::LanguageTag, ImageObject, Source},
};
use activitypub_federation::{
core::object_id::ObjectId,
},
traits::{ActivityHandler, ApubObject},
};
-use activitystreams_kinds::link::LinkType;
+use activitystreams_kinds::{link::LinkType, object::ImageType};
use chrono::{DateTime, FixedOffset};
use itertools::Itertools;
use lemmy_db_schema::newtypes::DbUrl;
use serde_with::skip_serializing_none;
use url::Url;
-#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub enum PageType {
Page,
Article,
pub(crate) stickied: Option<bool>,
pub(crate) published: Option<DateTime<FixedOffset>>,
pub(crate) updated: Option<DateTime<FixedOffset>>,
+ pub(crate) language: Option<LanguageTag>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
-pub(crate) struct Attachment {
+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(untagged)]
+pub(crate) enum Attachment {
+ Link(Link),
+ Image(Image),
+}
+
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(untagged)]
pub(crate) enum AttributedTo {
impl Attachment {
pub(crate) fn new(url: DbUrl) -> Attachment {
- Attachment {
+ Attachment::Link(Link {
href: url.into(),
r#type: Default::default(),
- }
+ })
}
}