From 12a55ce63f9a5e37dfc8cde6dc972def4b81bd3a Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sat, 14 Aug 2021 17:36:21 +0200 Subject: [PATCH] When receiving delete reason as empty string, change to none --- crates/apub/src/activities/deletion/delete.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/apub/src/activities/deletion/delete.rs b/crates/apub/src/activities/deletion/delete.rs index eaf89ae28..093919b88 100644 --- a/crates/apub/src/activities/deletion/delete.rs +++ b/crates/apub/src/activities/deletion/delete.rs @@ -94,10 +94,17 @@ impl ActivityHandler for Delete { request_counter: &mut i32, ) -> Result<(), LemmyError> { if let Some(reason) = self.summary { + // We set reason to empty string if it doesn't exist, to distinguish between delete and + // remove. Here we change it back to option, so we don't write it to db. + let reason = if reason.is_empty() { + None + } else { + Some(reason) + }; receive_remove_action( &self.common.actor, &self.object, - Some(reason), + reason, context, request_counter, ) @@ -152,7 +159,6 @@ impl Delete { } } -// TODO: reason is optional for compat with v0.11, make it mandatory after removing the migration pub(in crate::activities) async fn receive_remove_action( actor: &Url, object: &Url,