mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-15 20:00:33 +00:00
2ef0f8f5f8
* implement language tags for site/community in db and api * add api checks for valid languages * during db migration, update existing users, sites, communities to have all languages enabled * init new users/communities with site languages (not all languages) * federate site/community languages * fix tests * when updating site languages, limit community languages to this subset also, when making a new post and subset of user lang, community lang contains only one item, use that as post lang * add tests for actor_language db functions * include language list in siteview/communityview * Fix some of the review comments * Some more review changes * Add todo about boxed query * Add default_post_language to GetCommunityResponse
50 lines
1.5 KiB
Rust
50 lines
1.5 KiB
Rust
use crate::{
|
|
objects::instance::ApubSite,
|
|
protocol::{objects::LanguageTag, ImageObject, Source},
|
|
};
|
|
use activitypub_federation::{
|
|
core::{object_id::ObjectId, signatures::PublicKey},
|
|
deser::{helpers::deserialize_skip_error, values::MediaTypeHtml},
|
|
};
|
|
use chrono::{DateTime, FixedOffset};
|
|
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: InstanceType,
|
|
pub(crate) id: ObjectId<ApubSite>,
|
|
// site name
|
|
pub(crate) name: String,
|
|
pub(crate) inbox: Url,
|
|
/// mandatory field in activitypub, lemmy currently serves an empty outbox
|
|
pub(crate) outbox: Url,
|
|
pub(crate) public_key: PublicKey,
|
|
|
|
// sidebar
|
|
pub(crate) content: Option<String>,
|
|
#[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>,
|
|
/// instance icon
|
|
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>>,
|
|
}
|