user: implement User.invisible?/1
This commit is contained in:
parent
1469a084d4
commit
95871cb462
2 changed files with 17 additions and 0 deletions
|
@ -88,6 +88,9 @@ defmodule Pleroma.User do
|
||||||
def superuser?(%User{local: true, info: %User.Info{is_moderator: 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 invisible?(%User{info: %User.Info{invisible: true}}), do: true
|
||||||
|
def invisible?(_), do: false
|
||||||
|
|
||||||
def avatar_url(user, options \\ []) do
|
def avatar_url(user, options \\ []) do
|
||||||
case user.avatar do
|
case user.avatar do
|
||||||
%{"url" => [%{"href" => href} | _]} -> href
|
%{"url" => [%{"href" => href} | _]} -> href
|
||||||
|
|
|
@ -1232,6 +1232,20 @@ defmodule Pleroma.UserTest do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "invisible?/1" do
|
||||||
|
test "returns true for an invisible user" do
|
||||||
|
user = insert(:user, local: true, info: %{invisible: true})
|
||||||
|
|
||||||
|
assert User.invisible?(user)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "returns false for a non-invisible user" do
|
||||||
|
user = insert(:user, local: true)
|
||||||
|
|
||||||
|
refute User.invisible?(user)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "visible_for?/2" do
|
describe "visible_for?/2" do
|
||||||
test "returns true when the account is itself" do
|
test "returns true when the account is itself" do
|
||||||
user = insert(:user, local: true)
|
user = insert(:user, local: true)
|
||||||
|
|
Loading…
Reference in a new issue