use crate::{
objects::instance::ApubSite,
- protocol::{ImageObject, SourceCompat},
+ protocol::{objects::LanguageTag, ImageObject, Source},
+};
+use activitypub_federation::{
+ core::{object_id::ObjectId, signatures::PublicKey},
+ deser::{helpers::deserialize_skip_error, values::MediaTypeHtml},
};
-use activitystreams_kinds::actor::ServiceType;
use chrono::{DateTime, FixedOffset};
-use lemmy_apub_lib::{object_id::ObjectId, signatures::PublicKey, values::MediaTypeHtml};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use url::Url;
+#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
+pub enum InstanceType {
+ Application,
+ Service,
+}
+
#[skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Instance {
#[serde(rename = "type")]
- pub(crate) kind: ServiceType,
+ pub(crate) kind: InstanceType,
pub(crate) id: ObjectId<ApubSite>,
// site name
pub(crate) name: String,
// sidebar
pub(crate) content: Option<String>,
- pub(crate) source: Option<SourceCompat>,
+ #[serde(deserialize_with = "deserialize_skip_error", default)]
+ pub(crate) source: Option<Source>,
// short instance description
pub(crate) summary: Option<String>,
pub(crate) media_type: Option<MediaTypeHtml>,
pub(crate) icon: Option<ImageObject>,
/// instance banner
pub(crate) image: Option<ImageObject>,
+ #[serde(default)]
+ pub(crate) language: Vec<LanguageTag>,
pub(crate) published: DateTime<FixedOffset>,
pub(crate) updated: Option<DateTime<FixedOffset>>,
}