1
0
Fork 0
forked from mirrors/akkoma

user: factor out illogical User.Info.superuser?/1.

any actual callee will be dealing with a User struct to begin with, so
just check the child struct inside User.superuser?/1 with pattern matching.
This commit is contained in:
William Pitcock 2019-01-09 06:41:25 +00:00
parent 74f48beec3
commit 0015d43e13
2 changed files with 2 additions and 3 deletions

View file

@ -63,7 +63,8 @@ def visible_for?(%User{} = user, for_user) do
def visible_for?(_, _), do: false def visible_for?(_, _), do: false
def superuser?(%User{info: %User.Info{} = info}), do: User.Info.superuser?(info) def superuser?(%User{local: true, info: %User.Info{is_admin: true}}), do: true
def superuser?(%User{local: true, info: %User.Info{is_moderator: true}}), do: true
def superuser?(_), do: false def superuser?(_), do: false
def avatar_url(user) do def avatar_url(user) do

View file

@ -41,8 +41,6 @@ defmodule Pleroma.User.Info do
# subject _> Where is this used? # subject _> Where is this used?
end end
def superuser?(info), do: info.is_admin || info.is_moderator
def set_activation_status(info, deactivated) do def set_activation_status(info, deactivated) do
params = %{deactivated: deactivated} params = %{deactivated: deactivated}