]> Untitled Git - lemmy.git/commitdiff
Remove federation backwards compatibility with 0.16.x (#2183)
authorNutomic <me@nutomic.com>
Fri, 9 Dec 2022 16:21:17 +0000 (16:21 +0000)
committerGitHub <noreply@github.com>
Fri, 9 Dec 2022 16:21:17 +0000 (11:21 -0500)
* 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>
crates/apub/assets/lemmy/activities/create_or_update/create_page.json
crates/apub/assets/lemmy/activities/create_or_update/update_page.json
crates/apub/assets/lemmy/objects/instance.json
crates/apub/assets/lemmy/objects/page.json
crates/apub/src/fetcher/post_or_comment.rs
crates/apub/src/objects/instance.rs
crates/apub/src/objects/post.rs
crates/apub/src/protocol/objects/instance.rs
crates/apub/src/protocol/objects/page.rs

index 907faa5ca72e04d055571ebf73ef3d413f8602a1..e9dd80140e71ecf828f7352a797644c4bd855970 100644 (file)
@@ -19,7 +19,6 @@
       "content": "test body",
       "mediaType": "text/markdown"
     },
-    "url": "https://lemmy.ml/pictrs/image/xl8W7FZfk9.jpg",
     "attachment": [
       {
         "type": "Link",
index 46cb0e2ae531868ed2e4c7d4e850f3d8279e0825..daaf76bfcba681d32abfbf01d16e74c47ed3be18 100644 (file)
@@ -19,7 +19,6 @@
       "content": "test body",
       "mediaType": "text/markdown"
     },
-    "url": "https://lemmy.ml/pictrs/image/xl8W7FZfk9.jpg",
     "attachment": [
       {
         "type": "Link",
index 03c4e37533b6a9a43123547b219d951350aa2b8c..1ac6939c126200b696e6c4032e92485164de645f 100644 (file)
@@ -1,5 +1,5 @@
 {
-  "type": "Service",
+  "type": "Application",
   "id": "https://enterprise.lemmy.ml/",
   "name": "Enterprise",
   "summary": "A test instance",
index 0f514bc013a02ece2a132b1569df62600ef5bcf5..bbe7e6d277d5e2a2f3e1ca17f9f244e974e3735b 100644 (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",
index 68e176b0145ccc8ca1b078c89e2d90f42fbbbb7a..f8a260b9823b784c39dc8c50f44988902f563ff9 100644 (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?,
       )),
     })
   }
index 5ec4fe9097d64ec7982e76ca156c676df3ab346b..e3cb8b4636a40fd067a29d009d6d139200dcc32e 100644 (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)),
index afe025ce263bf4b6ce6f57c7b320a650a9eec76e..ecad2e4649b1c1fa96ab430861573253fb8a9ae9 100644 (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)
index 2df9dcc9547f4fff8de595a9a93ee0c2a52746c5..00c9c8be11b896eaf3a0c975afd0bcb0c37aebfc 100644 (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,
index a62fb8e57d878a8de695dea561897ea0e15601cd..65df30e42e6c9b5c8374fc1538ea2ca39ea85a13 100644 (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)]