]> Untitled Git - lemmy.git/commitdiff
Activitypub breaking changes for Lemmy 0.18 (#2705)
authorNutomic <me@nutomic.com>
Wed, 7 Jun 2023 19:18:17 +0000 (21:18 +0200)
committerGitHub <noreply@github.com>
Wed, 7 Jun 2023 19:18:17 +0000 (15:18 -0400)
* Remove deprecated field `group.moderators`

* Drop column local_site.federation_debug

* Remove backwards compatibility code for feature/lock post

https://github.com/LemmyNet/lemmy/pull/2716

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
19 files changed:
crates/api_crud/src/site/create.rs
crates/api_crud/src/site/update.rs
crates/apub/assets/lemmy/activities/community/update_community.json
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/collections/group_featured_posts.json
crates/apub/assets/lemmy/objects/group.json
crates/apub/assets/lemmy/objects/page.json
crates/apub/src/activities/community/collection_add.rs
crates/apub/src/activities/community/lock_page.rs
crates/apub/src/activities/create_or_update/post.rs
crates/apub/src/objects/community.rs
crates/apub/src/objects/post.rs
crates/apub/src/protocol/objects/group.rs
crates/apub/src/protocol/objects/page.rs
crates/db_schema/src/schema.rs
crates/db_schema/src/source/local_site.rs
migrations/2023-02-05-102549_drop-site-federation-debug/down.sql [new file with mode: 0644]
migrations/2023-02-05-102549_drop-site-federation-debug/up.sql [new file with mode: 0644]

index c16f3bc56a82f5762d983302c302906e655978ac..af8540669862d330a1cb27e7b1eef6f17847a6d6 100644 (file)
@@ -115,7 +115,6 @@ impl PerformCrud for CreateSite {
       .slur_filter_regex(diesel_option_overwrite(&data.slur_filter_regex))
       .actor_name_max_length(data.actor_name_max_length)
       .federation_enabled(data.federation_enabled)
-      .federation_debug(data.federation_debug)
       .federation_worker_count(data.federation_worker_count)
       .captcha_enabled(data.captcha_enabled)
       .captcha_difficulty(data.captcha_difficulty.clone())
index b1b2981675d3b646f0c6f6c29b295f0ae135118d..b3e8657592969666dfebdbca016a87730113e998 100644 (file)
@@ -113,7 +113,6 @@ impl PerformCrud for EditSite {
       .slur_filter_regex(diesel_option_overwrite(&data.slur_filter_regex))
       .actor_name_max_length(data.actor_name_max_length)
       .federation_enabled(data.federation_enabled)
-      .federation_debug(data.federation_debug)
       .federation_worker_count(data.federation_worker_count)
       .captcha_enabled(data.captcha_enabled)
       .captcha_difficulty(data.captcha_difficulty.clone())
index 88129282ec7c93abbdf989a87c656a420c8bee08..873b03b76233a1be46433ffd331df27a823f9a76 100644 (file)
       "mediaType": "text/markdown"
     },
     "sensitive": false,
-    "moderators": "http://enterprise.lemmy.ml/c/main/moderators",
     "postingRestrictedToMods": false,
     "inbox": "http://enterprise.lemmy.ml/c/main/inbox",
     "outbox": "http://enterprise.lemmy.ml/c/main/outbox",
     "followers": "http://enterprise.lemmy.ml/c/main/followers",
+    "attributedTo": "https://enterprise.lemmy.ml/c/main/moderators",
     "endpoints": {
       "sharedInbox": "http://enterprise.lemmy.ml/inbox"
     },
index 2f345245bee267c2b20a81e8f7f80956ea5e1fed..1729a8bdd289d6c88418aff5336e7ec28fa1f075 100644 (file)
@@ -25,7 +25,6 @@
     ],
     "commentsEnabled": true,
     "sensitive": false,
-    "stickied": false,
     "language": {
       "identifier": "ko",
       "name": "한국어"
index 606904fc44ef0db82f63d9962d23681b810a8674..2e1007638c4759b4c73bc38d7dd134ae17f228ee 100644 (file)
@@ -25,7 +25,6 @@
     ],
     "commentsEnabled": true,
     "sensitive": false,
-    "stickied": false,
     "published": "2021-10-29T15:10:51.557399+00:00",
     "updated": "2021-10-29T15:11:35.976374+00:00"
   },
index c5bc5fd9f55b3620347a4afd6b7507895ca38a41..227c6f8775543d8b4f50f6f0e35e171d38b57283 100644 (file)
@@ -17,7 +17,6 @@
       "attachment": [],
       "commentsEnabled": true,
       "sensitive": false,
-      "stickied": true,
       "published": "2023-02-06T06:42:41.939437+00:00",
       "language": {
         "identifier": "de",
@@ -39,7 +38,6 @@
       "attachment": [],
       "commentsEnabled": true,
       "sensitive": false,
-      "stickied": true,
       "published": "2023-02-06T06:42:37.119567+00:00",
       "language": {
         "identifier": "de",
index 10c46640c5f4c7ae5be9c3197fcc961b221898f4..66dfe144bb8cbb363467ae86828d1fa36781d893 100644 (file)
@@ -19,7 +19,6 @@
   },
   "inbox": "https://enterprise.lemmy.ml/c/tenforward/inbox",
   "followers": "https://enterprise.lemmy.ml/c/tenforward/followers",
-  "moderators": "https://enterprise.lemmy.ml/c/tenforward/moderators",
   "attributedTo": "https://enterprise.lemmy.ml/c/tenforward/moderators",
   "featured": "https://enterprise.lemmy.ml/c/tenforward//featured",
   "postingRestrictedToMods": false,
index bbe7e6d277d5e2a2f3e1ca17f9f244e974e3735b..b3e9b480b5753349b8e57744eefc31c076bb8df5 100644 (file)
@@ -26,7 +26,6 @@
   },
   "sensitive": false,
   "commentsEnabled": true,
-  "stickied": true,
   "language": {
     "identifier": "fr",
     "name": "Français"
index afe8387f2c6e68e5e9e4bb7eba572afed69df7b1..be5dd0fe34c242a5da0eb762324447768cee00bb 100644 (file)
@@ -10,11 +10,7 @@ use crate::{
   insert_activity,
   objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost},
   protocol::{
-    activities::{
-      community::{collection_add::CollectionAdd, collection_remove::CollectionRemove},
-      create_or_update::page::CreateOrUpdatePage,
-      CreateOrUpdateType,
-    },
+    activities::community::{collection_add::CollectionAdd, collection_remove::CollectionRemove},
     InCommunity,
   },
   SendActivity,
@@ -214,14 +210,6 @@ impl SendActivity for FeaturePost {
     context: &Data<LemmyContext>,
   ) -> Result<(), LemmyError> {
     let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
-    // Deprecated, for backwards compatibility with 0.17
-    CreateOrUpdatePage::send(
-      &response.post_view.post,
-      local_user_view.person.id,
-      CreateOrUpdateType::Update,
-      context,
-    )
-    .await?;
     let community = Community::read(context.pool(), response.post_view.community.id)
       .await?
       .into();
index 26326efcbd9a810d8c3c4d7e091dee414b85fde6..5e4eefb8173f7ebf63d24d173cec476bcf882cab 100644 (file)
@@ -10,11 +10,7 @@ use crate::{
   activity_lists::AnnouncableActivities,
   insert_activity,
   protocol::{
-    activities::{
-      community::lock_page::{LockPage, LockType, UndoLockPage},
-      create_or_update::page::CreateOrUpdatePage,
-      CreateOrUpdateType,
-    },
+    activities::community::lock_page::{LockPage, LockType, UndoLockPage},
     InCommunity,
   },
   SendActivity,
@@ -116,14 +112,6 @@ impl SendActivity for LockPost {
     context: &Data<LemmyContext>,
   ) -> Result<(), LemmyError> {
     let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
-    // For backwards compat with 0.17
-    CreateOrUpdatePage::send(
-      &response.post_view.post,
-      local_user_view.person.id,
-      CreateOrUpdateType::Update,
-      context,
-    )
-    .await?;
     let id = generate_activity_id(
       LockType::Lock,
       &context.settings().get_protocol_and_hostname(),
index b545f523948a1b3a7931b4fc2e9b01c057a9adcc..f2923bfbdcbb0d4d125a2ecef33b1345a8b1d301 100644 (file)
@@ -152,16 +152,13 @@ impl ActivityHandler for CreateOrUpdatePage {
       CreateOrUpdateType::Create => {
         verify_domains_match(self.actor.inner(), self.object.id.inner())?;
         verify_urls_match(self.actor.inner(), self.object.creator()?.inner())?;
-        // Check that the post isnt locked or stickied, as that isnt possible for newly created posts.
+        // Check that the post isnt locked, as that isnt possible for newly created posts.
         // However, when fetching a remote post we generate a new create activity with the current
-        // locked/stickied value, so this check may fail. So only check if its a local community,
+        // locked value, so this check may fail. So only check if its a local community,
         // because then we will definitely receive all create and update activities separately.
-        let is_featured_or_locked =
-          self.object.stickied == Some(true) || self.object.comments_enabled == Some(false);
-        if community.local && is_featured_or_locked {
-          return Err(LemmyError::from_message(
-            "New post cannot be stickied or locked",
-          ));
+        let is_locked = self.object.comments_enabled == Some(false);
+        if community.local && is_locked {
+          return Err(LemmyError::from_message("New post cannot be locked"));
         }
       }
       CreateOrUpdateType::Update => {
index 396c2af870e45be386f6f0a53d52f83b15ebbdfe..6526d2d26eff08f05b9dad3bf3930733bf593714 100644 (file)
@@ -96,7 +96,6 @@ impl Object for ApubCommunity {
       icon: self.icon.clone().map(ImageObject::new),
       image: self.banner.clone().map(ImageObject::new),
       sensitive: Some(self.nsfw),
-      moderators: Some(generate_moderators_url(&self.actor_id)?.into()),
       featured: Some(generate_featured_url(&self.actor_id)?.into()),
       inbox: self.inbox_url.clone().into(),
       outbox: generate_outbox_url(&self.actor_id)?.into(),
@@ -148,7 +147,7 @@ impl Object for ApubCommunity {
       .map_err(|e| debug!("{}", e))
       .ok();
 
-    if let Some(moderators) = group.attributed_to.or(group.moderators) {
+    if let Some(moderators) = group.attributed_to {
       moderators
         .dereference(&community, context)
         .await
@@ -231,7 +230,6 @@ pub(crate) mod tests {
     let context2 = context.reset_request_count();
     let mut json: Group = file_to_json_object("assets/lemmy/objects/group.json").unwrap();
     // change these links so they dont fetch over the network
-    json.moderators = None;
     json.attributed_to = None;
     json.outbox =
       CollectionId::parse("https://enterprise.lemmy.ml/c/tenforward/not_outbox").unwrap();
index 5b1583a27a2581efc86c7e0c70dda588e00a5dbb..b255ffb9b66efe93b7cd968a12b39fe1d486f395 100644 (file)
@@ -32,7 +32,7 @@ use lemmy_db_schema::{
   source::{
     community::Community,
     local_site::LocalSite,
-    moderator::{ModFeaturePost, ModFeaturePostForm, ModLockPost, ModLockPostForm},
+    moderator::{ModLockPost, ModLockPostForm},
     person::Person,
     post::{Post, PostInsertForm, PostUpdateForm},
   },
@@ -121,7 +121,6 @@ impl Object for ApubPost {
       image: self.thumbnail_url.clone().map(ImageObject::new),
       comments_enabled: Some(!self.locked),
       sensitive: Some(self.nsfw),
-      stickied: Some(self.featured_community),
       language,
       published: Some(convert_datetime(self.published)),
       updated: self.updated.map(convert_datetime),
@@ -236,7 +235,7 @@ impl Object for ApubPost {
         ap_id: Some(page.id.clone().into()),
         local: Some(false),
         language_id,
-        featured_community: page.stickied,
+        featured_community: None,
         featured_local: None,
       }
     } else {
@@ -247,23 +246,13 @@ impl Object for ApubPost {
         .community_id(community.id)
         .ap_id(Some(page.id.clone().into()))
         .locked(page.comments_enabled.map(|e| !e))
-        .featured_community(page.stickied)
         .updated(page.updated.map(|u| u.naive_local()))
         .build()
     };
 
     let post = Post::create(context.pool(), &form).await?;
 
-    // write mod log entries for feature/lock
-    if Page::is_featured_changed(&old_post, &page.stickied) {
-      let form = ModFeaturePostForm {
-        mod_person_id: creator.id,
-        post_id: post.id,
-        featured: post.featured_community,
-        is_featured_community: true,
-      };
-      ModFeaturePost::create(context.pool(), &form).await?;
-    }
+    // write mod log entry for lock
     if Page::is_locked_changed(&old_post, &page.comments_enabled) {
       let form = ModLockPostForm {
         mod_person_id: creator.id,
@@ -309,7 +298,7 @@ mod tests {
     assert!(post.body.is_some());
     assert_eq!(post.body.as_ref().unwrap().len(), 45);
     assert!(!post.locked);
-    assert!(post.featured_community);
+    assert!(!post.featured_community);
     assert_eq!(context.request_count(), 0);
 
     Post::delete(context.pool(), post.id).await.unwrap();
index 520070cc6c44c2b849e34a830b0b0ba793d3b26c..8149e67121840b0b1189409400a076125c9c23ba 100644 (file)
@@ -61,8 +61,6 @@ pub struct Group {
   pub(crate) image: Option<ImageObject>,
   // lemmy extension
   pub(crate) sensitive: Option<bool>,
-  // deprecated, use attributed_to instead
-  pub(crate) moderators: Option<CollectionId<ApubCommunityModerators>>,
   #[serde(deserialize_with = "deserialize_skip_error", default)]
   pub(crate) attributed_to: Option<CollectionId<ApubCommunityModerators>>,
   // lemmy extension
@@ -122,7 +120,7 @@ impl Group {
       followers_url: Some(self.followers.into()),
       inbox_url: Some(self.inbox.into()),
       shared_inbox_url: self.endpoints.map(|e| e.shared_inbox.into()),
-      moderators_url: self.moderators.map(Into::into),
+      moderators_url: self.attributed_to.map(Into::into),
       posting_restricted_to_mods: self.posting_restricted_to_mods,
       instance_id,
       featured_url: self.featured.map(Into::into),
@@ -153,7 +151,7 @@ impl Group {
       followers_url: Some(self.followers.into()),
       inbox_url: Some(self.inbox.into()),
       shared_inbox_url: Some(self.endpoints.map(|e| e.shared_inbox.into())),
-      moderators_url: self.moderators.map(Into::into),
+      moderators_url: self.attributed_to.map(Into::into),
       posting_restricted_to_mods: self.posting_restricted_to_mods,
       featured_url: self.featured.map(Into::into),
     }
index 9bf8dbe59eafc857d44e5bfbd062ffb66402f10a..ad89cf35b04607869957553e02a878f22cb564e4 100644 (file)
@@ -63,8 +63,6 @@ pub struct Page {
   pub(crate) image: Option<ImageObject>,
   pub(crate) comments_enabled: Option<bool>,
   pub(crate) sensitive: Option<bool>,
-  /// Deprecated, for compatibility with Lemmy 0.17
-  pub(crate) stickied: Option<bool>,
   pub(crate) published: Option<DateTime<FixedOffset>>,
   pub(crate) updated: Option<DateTime<FixedOffset>>,
   pub(crate) language: Option<LanguageTag>,
@@ -131,32 +129,16 @@ pub(crate) struct AttributedToPeertube {
 }
 
 impl Page {
-  /// Only mods can change the post's stickied/locked status. So if either of these is changed from
-  /// the current value, it is a mod action and needs to be verified as such.
+  /// Only mods can change the post's locked status. So if it is changed from the default value,
+  /// it is a mod action and needs to be verified as such.
   ///
-  /// Both stickied and locked need to be false on a newly created post (verified in [[CreatePost]].
+  /// Locked needs to be false on a newly created post (verified in [[CreatePost]].
   pub(crate) async fn is_mod_action(
     &self,
     context: &Data<LemmyContext>,
   ) -> Result<bool, LemmyError> {
     let old_post = self.id.clone().dereference_local(context).await;
-
-    let featured_changed = Page::is_featured_changed(&old_post, &self.stickied);
-    let locked_changed = Page::is_locked_changed(&old_post, &self.comments_enabled);
-    Ok(featured_changed || locked_changed)
-  }
-
-  pub(crate) fn is_featured_changed<E>(
-    old_post: &Result<ApubPost, E>,
-    new_featured_community: &Option<bool>,
-  ) -> bool {
-    if let Some(new_featured_community) = new_featured_community {
-      if let Ok(old_post) = old_post {
-        return new_featured_community != &old_post.featured_community;
-      }
-    }
-
-    false
+    Ok(Page::is_locked_changed(&old_post, &self.comments_enabled))
   }
 
   pub(crate) fn is_locked_changed<E>(
index 2753a0d64a3fff4d99434a330c26d8e65a2f2c79..6fe1391269ae6ea7e6d76d61b2a0666d5e5d3f95 100644 (file)
@@ -337,7 +337,6 @@ diesel::table! {
         slur_filter_regex -> Nullable<Text>,
         actor_name_max_length -> Int4,
         federation_enabled -> Bool,
-        federation_debug -> Bool,
         federation_worker_count -> Int4,
         captcha_enabled -> Bool,
         #[max_length = 255]
index 948c9734ac86a4fb2beea949795b5a90fe6cfd2c..e65a615358a29ac497959f224ac4cee32de54c94 100644 (file)
@@ -50,7 +50,6 @@ pub struct LocalSite {
   pub actor_name_max_length: i32,
   /// Whether federation is enabled.
   pub federation_enabled: bool,
-  pub federation_debug: bool,
   /// The number of concurrent federation http workers.
   pub federation_worker_count: i32,
   /// Whether captcha is enabled.
@@ -86,7 +85,6 @@ pub struct LocalSiteInsertForm {
   pub slur_filter_regex: Option<String>,
   pub actor_name_max_length: Option<i32>,
   pub federation_enabled: Option<bool>,
-  pub federation_debug: Option<bool>,
   pub federation_worker_count: Option<i32>,
   pub captcha_enabled: Option<bool>,
   pub captcha_difficulty: Option<String>,
@@ -114,7 +112,6 @@ pub struct LocalSiteUpdateForm {
   pub slur_filter_regex: Option<Option<String>>,
   pub actor_name_max_length: Option<i32>,
   pub federation_enabled: Option<bool>,
-  pub federation_debug: Option<bool>,
   pub federation_worker_count: Option<i32>,
   pub captcha_enabled: Option<bool>,
   pub captcha_difficulty: Option<String>,
diff --git a/migrations/2023-02-05-102549_drop-site-federation-debug/down.sql b/migrations/2023-02-05-102549_drop-site-federation-debug/down.sql
new file mode 100644 (file)
index 0000000..1ac320f
--- /dev/null
@@ -0,0 +1 @@
+alter table local_site add column federation_debug int default 0;
\ No newline at end of file
diff --git a/migrations/2023-02-05-102549_drop-site-federation-debug/up.sql b/migrations/2023-02-05-102549_drop-site-federation-debug/up.sql
new file mode 100644 (file)
index 0000000..c7286d0
--- /dev/null
@@ -0,0 +1 @@
+alter table local_site drop column federation_debug;
\ No newline at end of file