]> Untitled Git - lemmy.git/commitdiff
Remove to field from follow activities
authorFelix Ableitner <me@nutomic.com>
Tue, 16 Nov 2021 16:27:43 +0000 (17:27 +0100)
committerFelix Ableitner <me@nutomic.com>
Tue, 16 Nov 2021 18:13:05 +0000 (19:13 +0100)
crates/apub/assets/lemmy/activities/following/accept.json
crates/apub/assets/lemmy/activities/following/follow.json
crates/apub/assets/lemmy/activities/following/undo_follow.json
crates/apub/src/activities/following/accept.rs
crates/apub/src/activities/following/follow.rs
crates/apub/src/activities/following/undo_follow.rs
crates/apub/src/protocol/activities/following/accept.rs
crates/apub/src/protocol/activities/following/follow.rs
crates/apub/src/protocol/activities/following/undo_follow.rs

index d5bcfaf486478b8474b4ed590d8a5aa476fed3f0..4097b36754698a48529f4b298243da4a1b6b9115 100644 (file)
@@ -1,13 +1,7 @@
 {
   "actor": "http://enterprise.lemmy.ml/c/main",
-  "to": [
-    "http://ds9.lemmy.ml/u/lemmy_alpha"
-  ],
   "object": {
     "actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
-    "to": [
-      "http://enterprise.lemmy.ml/c/main"
-    ],
     "object": "http://enterprise.lemmy.ml/c/main",
     "type": "Follow",
     "id": "http://ds9.lemmy.ml/activities/follow/6abcd50b-b8ca-4952-86b0-a6dd8cc12866"
index 50cc77dc04da4eea8ba73317e1cde4b75cb9a157..48f3fef8b74cb69aec127abd1cc97d430cf236a4 100644 (file)
@@ -1,8 +1,5 @@
 {
   "actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
-  "to": [
-    "http://enterprise.lemmy.ml/c/main"
-  ],
   "object": "http://enterprise.lemmy.ml/c/main",
   "type": "Follow",
   "id": "http://ds9.lemmy.ml/activities/follow/6abcd50b-b8ca-4952-86b0-a6dd8cc12866"
index d27bec0a4da31937c26dbe65989de5eb2f1f4059..5311bd990b2808a3e76a16ef802fecf5d8f3b574 100644 (file)
@@ -1,13 +1,7 @@
 {
   "actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
-  "to": [
-    "http://enterprise.lemmy.ml/c/main"
-  ],
   "object": {
     "actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
-    "to": [
-      "http://enterprise.lemmy.ml/c/main"
-    ],
     "object": "http://enterprise.lemmy.ml/c/main",
     "type": "Follow",
     "id": "http://ds9.lemmy.ml/activities/follow/dc2f1bc5-f3a0-4daa-a46b-428cbfbd023c"
index 44d6009a299dfd5d6bfb57bd1faf7e20d87ec8a5..15e1f2b4ae1c995bc75f7e89c03f2dae849a17ad 100644 (file)
@@ -28,7 +28,6 @@ impl AcceptFollowCommunity {
       .await?;
     let accept = AcceptFollowCommunity {
       actor: ObjectId::new(community.actor_id()),
-      to: [ObjectId::new(person.actor_id())],
       object: follow,
       kind: AcceptType::Accept,
       id: generate_activity_id(
@@ -52,8 +51,7 @@ impl ActivityHandler for AcceptFollowCommunity {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     verify_activity(&self.id, self.actor.inner(), &context.settings())?;
-    verify_urls_match(self.to[0].inner(), self.object.actor.inner())?;
-    verify_urls_match(self.actor.inner(), self.object.to[0].inner())?;
+    verify_urls_match(self.actor.inner(), self.object.object.inner())?;
     self.object.verify(context, request_counter).await?;
     Ok(())
   }
@@ -63,11 +61,15 @@ impl ActivityHandler for AcceptFollowCommunity {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
-    let actor = self.actor.dereference(context, request_counter).await?;
-    let to = self.to[0].dereference(context, request_counter).await?;
+    let person = self.actor.dereference(context, request_counter).await?;
+    let community = self
+      .object
+      .actor
+      .dereference(context, request_counter)
+      .await?;
     // This will throw an error if no follow was requested
     blocking(context.pool(), move |conn| {
-      CommunityFollower::follow_accepted(conn, actor.id, to.id)
+      CommunityFollower::follow_accepted(conn, person.id, community.id)
     })
     .await??;
 
index 22f3db4ba6154590284699debb66b241d7311abf..43c600284a79cfb53a24b1ee6c9f8d5574a0cca9 100644 (file)
@@ -15,7 +15,6 @@ use lemmy_apub_lib::{
   data::Data,
   object_id::ObjectId,
   traits::{ActivityHandler, ActorType},
-  verify::verify_urls_match,
 };
 use lemmy_db_schema::{
   source::community::{CommunityFollower, CommunityFollowerForm},
@@ -32,7 +31,6 @@ impl FollowCommunity {
   ) -> Result<FollowCommunity, LemmyError> {
     Ok(FollowCommunity {
       actor: ObjectId::new(actor.actor_id()),
-      to: [ObjectId::new(community.actor_id())],
       object: ObjectId::new(community.actor_id()),
       kind: FollowType::Follow,
       id: generate_activity_id(
@@ -72,9 +70,8 @@ impl ActivityHandler for FollowCommunity {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     verify_activity(&self.id, self.actor.inner(), &context.settings())?;
-    verify_urls_match(self.to[0].inner(), self.object.inner())?;
     verify_person(&self.actor, context, request_counter).await?;
-    let community = self.to[0].dereference(context, request_counter).await?;
+    let community = self.object.dereference(context, request_counter).await?;
     verify_person_in_community(&self.actor, &community, context, request_counter).await?;
     Ok(())
   }
@@ -84,11 +81,11 @@ impl ActivityHandler for FollowCommunity {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
-    let actor = self.actor.dereference(context, request_counter).await?;
-    let community = self.to[0].dereference(context, request_counter).await?;
+    let person = self.actor.dereference(context, request_counter).await?;
+    let community = self.object.dereference(context, request_counter).await?;
     let community_follower_form = CommunityFollowerForm {
       community_id: community.id,
-      person_id: actor.id,
+      person_id: person.id,
       pending: false,
     };
 
index ac25fcd5c1bcdd8b3e5e938ecfc543ab8544d962..2a3483d450c191c0f190ec125c98787c44101255 100644 (file)
@@ -27,7 +27,6 @@ impl UndoFollowCommunity {
     let object = FollowCommunity::new(actor, community, context)?;
     let undo = UndoFollowCommunity {
       actor: ObjectId::new(actor.actor_id()),
-      to: [ObjectId::new(community.actor_id())],
       object,
       kind: UndoType::Undo,
       id: generate_activity_id(
@@ -50,7 +49,6 @@ impl ActivityHandler for UndoFollowCommunity {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     verify_activity(&self.id, self.actor.inner(), &context.settings())?;
-    verify_urls_match(self.to[0].inner(), self.object.object.inner())?;
     verify_urls_match(self.actor.inner(), self.object.actor.inner())?;
     verify_person(&self.actor, context, request_counter).await?;
     self.object.verify(context, request_counter).await?;
@@ -62,12 +60,16 @@ impl ActivityHandler for UndoFollowCommunity {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
-    let actor = self.actor.dereference(context, request_counter).await?;
-    let community = self.to[0].dereference(context, request_counter).await?;
+    let person = self.actor.dereference(context, request_counter).await?;
+    let community = self
+      .object
+      .object
+      .dereference(context, request_counter)
+      .await?;
 
     let community_follower_form = CommunityFollowerForm {
       community_id: community.id,
-      person_id: actor.id,
+      person_id: person.id,
       pending: false,
     };
 
index 0c5988bc7a15263bbe84203227f0ea03cb16ed9c..2d5acb3be18b06fbec0ad9400e3a193bef80c9de 100644 (file)
@@ -1,5 +1,5 @@
 use crate::{
-  objects::{community::ApubCommunity, person::ApubPerson},
+  objects::community::ApubCommunity,
   protocol::activities::following::follow::FollowCommunity,
 };
 use activitystreams::{activity::kind::AcceptType, unparsed::Unparsed};
@@ -11,7 +11,6 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct AcceptFollowCommunity {
   pub(crate) actor: ObjectId<ApubCommunity>,
-  pub(crate) to: [ObjectId<ApubPerson>; 1],
   pub(crate) object: FollowCommunity,
   #[serde(rename = "type")]
   pub(crate) kind: AcceptType,
index 9d3f6a823032eecf089df11685e51251a9464007..fe4e4e7b952328091e76b00f3ab60bef6e602392 100644 (file)
@@ -8,7 +8,6 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct FollowCommunity {
   pub(crate) actor: ObjectId<ApubPerson>,
-  pub(crate) to: [ObjectId<ApubCommunity>; 1],
   pub(crate) object: ObjectId<ApubCommunity>,
   #[serde(rename = "type")]
   pub(crate) kind: FollowType,
index 5e9c58946ead996f933403c1103cd50115e830d2..f2feba14b07e4c00dae3e13d67b8ae4392355318 100644 (file)
@@ -1,5 +1,5 @@
 use crate::{
-  objects::{community::ApubCommunity, person::ApubPerson},
+  objects::person::ApubPerson,
   protocol::activities::following::follow::FollowCommunity,
 };
 use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
@@ -11,7 +11,6 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct UndoFollowCommunity {
   pub(crate) actor: ObjectId<ApubPerson>,
-  pub(crate) to: [ObjectId<ApubCommunity>; 1],
   pub(crate) object: FollowCommunity,
   #[serde(rename = "type")]
   pub(crate) kind: UndoType,