When receiving delete reason as empty string, change to none

This commit is contained in:
Felix Ableitner 2021-08-14 17:36:21 +02:00
parent 2d346a1487
commit 12a55ce63f

View file

@ -94,10 +94,17 @@ impl ActivityHandler for Delete {
request_counter: &mut i32, request_counter: &mut i32,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
if let Some(reason) = self.summary { 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( receive_remove_action(
&self.common.actor, &self.common.actor,
&self.object, &self.object,
Some(reason), reason,
context, context,
request_counter, 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( pub(in crate::activities) async fn receive_remove_action(
actor: &Url, actor: &Url,
object: &Url, object: &Url,