From a20d2847e2959d4fce86757057a680f0fcfa87ec Mon Sep 17 00:00:00 2001 From: Ilja Date: Mon, 7 Mar 2022 14:00:42 +0100 Subject: [PATCH] After code review Use patern matching to see if someone was superuser before --- lib/pleroma/user.ex | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 809524f56..27ed9bbc5 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -1099,11 +1099,8 @@ def update_and_set_cache(%{data: %Pleroma.User{} = user} = changeset) do |> maybe_remove_report_notifications(was_superuser_before_update) end - defp maybe_remove_report_notifications( - {:ok, %Pleroma.User{} = user} = result, - was_superuser_before_update - ) do - if was_superuser_before_update and not User.superuser?(user), + defp maybe_remove_report_notifications({:ok, %Pleroma.User{} = user} = result, true) do + if not User.superuser?(user), do: user |> Notification.destroy_multiple_from_types(["pleroma:report"]) result