user: use pattern matching to determine if user is local or remote instead of the previous hairy logic

This commit is contained in:
William Pitcock 2019-01-09 04:46:03 +00:00
parent 4e5b156047
commit 595a970493
1 changed files with 2 additions and 1 deletions

View File

@ -49,7 +49,8 @@ def auth_active?(%User{} = user) do
!Pleroma.Config.get([:instance, :account_activation_required])
end
def remote_or_auth_active?(%User{} = user), do: !user.local || auth_active?(user)
def remote_or_auth_active?(%User{local: false}), do: true
def remote_or_auth_active?(%User{local: true} = user), do: auth_active?(user)
def visible_for?(%User{} = user, for_user \\ nil) do
User.remote_or_auth_active?(user) || (for_user && for_user.id == user.id) ||