"content": "test body",
"mediaType": "text/markdown"
},
- "url": "https://lemmy.ml/pictrs/image/xl8W7FZfk9.jpg",
"attachment": [
{
"type": "Link",
"content": "test body",
"mediaType": "text/markdown"
},
- "url": "https://lemmy.ml/pictrs/image/xl8W7FZfk9.jpg",
"attachment": [
{
"type": "Link",
{
- "type": "Service",
+ "type": "Application",
"id": "https://enterprise.lemmy.ml/",
"name": "Enterprise",
"summary": "A test instance",
"content": "This is a post in the /c/tenforward community",
"mediaType": "text/markdown"
},
- "url": "https://enterprise.lemmy.ml/pictrs/image/eOtYb9iEiB.png",
"attachment": [
{
"type": "Link",
#[serde(untagged)]
pub enum PageOrNote {
Page(Box<Page>),
- Note(Box<Note>),
+ Note(Note),
}
#[async_trait::async_trait(?Send)]
ApubPost::from_apub(*p, context, request_counter).await?,
)),
PageOrNote::Note(n) => PostOrComment::Comment(Box::new(
- ApubComment::from_apub(*n, context, request_counter).await?,
+ ApubComment::from_apub(n, context, request_counter).await?,
)),
})
}
local_instance,
objects::read_from_string_or_source_opt,
protocol::{
- objects::{
- instance::{Instance, InstanceType},
- LanguageTag,
- },
+ objects::{instance::Instance, LanguageTag},
ImageObject,
Source,
},
traits::{Actor, ApubObject},
utils::verify_domains_match,
};
+use activitystreams_kinds::actor::ApplicationType;
use chrono::NaiveDateTime;
use lemmy_api_common::{context::LemmyContext, utils::local_site_opt_to_slur_regex};
use lemmy_db_schema::{
let language = LanguageTag::new_multiple(langs, data.pool()).await?;
let instance = Instance {
- kind: InstanceType::Service,
+ kind: ApplicationType::Application,
id: ObjectId::new(self.actor_id()),
name: self.name.clone(),
content: self.sidebar.as_ref().map(|d| markdown_to_html(d)),
content: self.body.as_ref().map(|b| markdown_to_html(b)),
media_type: Some(MediaTypeMarkdownOrHtml::Html),
source: self.body.clone().map(Source::new),
- url: self.url.clone().map(Into::into),
attachment: self.url.clone().map(Attachment::new).into_iter().collect(),
image: self.thumbnail_url.clone().map(ImageObject::new),
comments_enabled: Some(!self.locked),
// we cant display videos directly, so insert a link to external video page
Some(page.id.inner().clone())
} else {
- // url sent by lemmy (old)
- page.url
+ None
};
let (metadata_res, thumbnail_url) = if let Some(url) = &url {
fetch_site_data(context.client(), context.settings(), Some(url)).await
.updated(page.updated.map(|u| u.naive_local()))
.build()
};
-
// read existing, local post if any (for generating mod log)
let old_post = ObjectId::<ApubPost>::new(page.id.clone())
.dereference_local(context)
core::{object_id::ObjectId, signatures::PublicKey},
deser::{helpers::deserialize_skip_error, values::MediaTypeHtml},
};
+use activitystreams_kinds::actor::ApplicationType;
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) kind: ApplicationType,
pub(crate) id: ObjectId<ApubSite>,
// site name
pub(crate) name: String,
pub(crate) media_type: Option<MediaTypeMarkdownOrHtml>,
#[serde(deserialize_with = "deserialize_skip_error", default)]
pub(crate) source: Option<Source>,
- /// deprecated, use attachment field
- #[serde(deserialize_with = "deserialize_skip_error", default)]
- pub(crate) url: Option<Url>,
/// most software uses array type for attachment field, so we do the same. nevertheless, we only
/// use the first item
#[serde(default)]