From d06ef2c47e9b596fa4bce6b2d1576d76bfee6fef Mon Sep 17 00:00:00 2001 From: Nutomic Date: Mon, 25 Mar 2024 13:10:09 +0100 Subject: [PATCH] Migrate apub block activity to standard `endTime` property and deprecate `expires` (fixes #2316) (#4541) * Migrate apub block activity to standard `endTime` property (fixes #2316) * add todo --- crates/apub/src/activities/block/block_user.rs | 3 ++- crates/apub/src/activities/block/undo_block_user.rs | 2 +- crates/apub/src/protocol/activities/block/block_user.rs | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/apub/src/activities/block/block_user.rs b/crates/apub/src/activities/block/block_user.rs index 177df2ca5..a2a1f25bf 100644 --- a/crates/apub/src/activities/block/block_user.rs +++ b/crates/apub/src/activities/block/block_user.rs @@ -72,6 +72,7 @@ impl BlockUser { )?, audience, expires, + end_time: expires, }) } @@ -149,7 +150,7 @@ impl ActivityHandler for BlockUser { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { insert_received_activity(&self.id, context).await?; - let expires = self.expires.map(Into::into); + let expires = self.expires.or(self.end_time).map(Into::into); let mod_person = self.actor.dereference(context).await?; let blocked_person = self.object.dereference(context).await?; let target = self.target.dereference(context).await?; diff --git a/crates/apub/src/activities/block/undo_block_user.rs b/crates/apub/src/activities/block/undo_block_user.rs index da25a4af0..756d0a149 100644 --- a/crates/apub/src/activities/block/undo_block_user.rs +++ b/crates/apub/src/activities/block/undo_block_user.rs @@ -98,7 +98,7 @@ impl ActivityHandler for UndoBlockUser { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { insert_received_activity(&self.id, context).await?; - let expires = self.object.expires.map(Into::into); + let expires = self.object.expires.or(self.object.end_time).map(Into::into); let mod_person = self.actor.dereference(context).await?; let blocked_person = self.object.object.dereference(context).await?; match self.object.target.dereference(context).await? { diff --git a/crates/apub/src/protocol/activities/block/block_user.rs b/crates/apub/src/protocol/activities/block/block_user.rs index b958b58e1..c5cb4306c 100644 --- a/crates/apub/src/protocol/activities/block/block_user.rs +++ b/crates/apub/src/protocol/activities/block/block_user.rs @@ -38,7 +38,9 @@ pub struct BlockUser { pub(crate) remove_data: Option, /// block reason, written to mod log pub(crate) summary: Option, + /// TODO: deprecated pub(crate) expires: Option>, + pub(crate) end_time: Option>, } #[async_trait::async_trait]