mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-23 17:54:22 +00:00
user: remove entirely redundant remote_or_auth_active?/1.
auth_active?/1 can check remote users and return true directly.
This commit is contained in:
parent
2af67353c5
commit
74f48beec3
|
@ -44,6 +44,8 @@ defmodule Pleroma.User do
|
||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def auth_active?(%User{local: false}), do: false
|
||||||
|
|
||||||
def auth_active?(%User{info: %User.Info{confirmation_pending: false}}), do: true
|
def auth_active?(%User{info: %User.Info{confirmation_pending: false}}), do: true
|
||||||
|
|
||||||
def auth_active?(%User{info: %User.Info{confirmation_pending: true}}),
|
def auth_active?(%User{info: %User.Info{confirmation_pending: true}}),
|
||||||
|
@ -51,15 +53,12 @@ defmodule Pleroma.User do
|
||||||
|
|
||||||
def auth_active?(_), do: false
|
def auth_active?(_), do: false
|
||||||
|
|
||||||
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, for_user \\ nil)
|
def visible_for?(user, for_user \\ nil)
|
||||||
|
|
||||||
def visible_for?(%User{id: user_id}, %User{id: for_id}) when user_id == for_id, do: true
|
def visible_for?(%User{id: user_id}, %User{id: for_id}) when user_id == for_id, do: true
|
||||||
|
|
||||||
def visible_for?(%User{} = user, for_user) do
|
def visible_for?(%User{} = user, for_user) do
|
||||||
remote_or_auth_active?(user) || superuser?(for_user)
|
auth_active?(user) || superuser?(for_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible_for?(_, _), do: false
|
def visible_for?(_, _), do: false
|
||||||
|
|
|
@ -768,16 +768,16 @@ defmodule Pleroma.UserTest do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "remote_or_auth_active?/1 works correctly" do
|
test "auth_active?/1 works correctly" do
|
||||||
Pleroma.Config.put([:instance, :account_activation_required], true)
|
Pleroma.Config.put([:instance, :account_activation_required], true)
|
||||||
|
|
||||||
local_user = insert(:user, local: true, info: %{confirmation_pending: true})
|
local_user = insert(:user, local: true, info: %{confirmation_pending: true})
|
||||||
confirmed_user = insert(:user, local: true, info: %{confirmation_pending: false})
|
confirmed_user = insert(:user, local: true, info: %{confirmation_pending: false})
|
||||||
remote_user = insert(:user, local: false)
|
remote_user = insert(:user, local: false)
|
||||||
|
|
||||||
refute User.remote_or_auth_active?(local_user)
|
refute User.auth_active?(local_user)
|
||||||
assert User.remote_or_auth_active?(confirmed_user)
|
assert User.auth_active?(confirmed_user)
|
||||||
assert User.remote_or_auth_active?(remote_user)
|
assert User.auth_active?(remote_user)
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :account_activation_required], false)
|
Pleroma.Config.put([:instance, :account_activation_required], false)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue