After code review

Use patern matching to see if someone was superuser before
This commit is contained in:
Ilja 2022-03-07 14:00:42 +01:00 committed by Sam Therapy
parent d3ad9e927d
commit e49d8aba86
Signed by: sam
GPG key ID: 4D8B07C18F31ACBD

View file

@ -1136,11 +1136,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