Remove federation backwards compatibility with 0.16.x (#2183)

* Breaking: remove compatiblity with page.url field (ref #2182)

* Breaking: change type of Instance to `Application` (ref #2200)

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
pull/2585/head
Nutomic 2022-12-09 16:21:17 +00:00 committed by GitHub
parent 2732a5bf07
commit 0ecf256ce3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 9 additions and 25 deletions

View File

@ -19,7 +19,6 @@
"content": "test body",
"mediaType": "text/markdown"
},
"url": "https://lemmy.ml/pictrs/image/xl8W7FZfk9.jpg",
"attachment": [
{
"type": "Link",

View File

@ -19,7 +19,6 @@
"content": "test body",
"mediaType": "text/markdown"
},
"url": "https://lemmy.ml/pictrs/image/xl8W7FZfk9.jpg",
"attachment": [
{
"type": "Link",

View File

@ -1,5 +1,5 @@
{
"type": "Service",
"type": "Application",
"id": "https://enterprise.lemmy.ml/",
"name": "Enterprise",
"summary": "A test instance",

View File

@ -14,7 +14,6 @@
"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",

View File

@ -26,7 +26,7 @@ pub enum PostOrComment {
#[serde(untagged)]
pub enum PageOrNote {
Page(Box<Page>),
Note(Box<Note>),
Note(Note),
}
#[async_trait::async_trait(?Send)]
@ -91,7 +91,7 @@ impl ApubObject for PostOrComment {
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?,
)),
})
}

View File

@ -4,10 +4,7 @@ use crate::{
local_instance,
objects::read_from_string_or_source_opt,
protocol::{
objects::{
instance::{Instance, InstanceType},
LanguageTag,
},
objects::{instance::Instance, LanguageTag},
ImageObject,
Source,
},
@ -19,6 +16,7 @@ use activitypub_federation::{
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::{
@ -88,7 +86,7 @@ impl ApubObject for ApubSite {
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)),

View File

@ -112,7 +112,6 @@ impl ApubObject for ApubPost {
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),
@ -179,8 +178,7 @@ impl ApubObject for ApubPost {
// 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
@ -231,7 +229,6 @@ impl ApubObject for ApubPost {
.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)

View File

@ -6,23 +6,18 @@ use activitypub_federation::{
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,

View File

@ -54,9 +54,6 @@ pub struct Page {
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)]