[#1304] Merged `develop`, handled User.Info.invisible.
This commit is contained in:
parent
a11a7176d5
commit
7c7f90bc4f
|
@ -103,6 +103,7 @@ defmodule Pleroma.User do
|
||||||
field(:fields, {:array, :map}, default: nil)
|
field(:fields, {:array, :map}, default: nil)
|
||||||
field(:raw_fields, {:array, :map}, default: [])
|
field(:raw_fields, {:array, :map}, default: [])
|
||||||
field(:discoverable, :boolean, default: false)
|
field(:discoverable, :boolean, default: false)
|
||||||
|
field(:invisible, :boolean, default: false)
|
||||||
field(:skip_thread_containment, :boolean, default: false)
|
field(:skip_thread_containment, :boolean, default: false)
|
||||||
|
|
||||||
field(:notification_settings, :map,
|
field(:notification_settings, :map,
|
||||||
|
@ -142,7 +143,7 @@ def superuser?(%User{local: true, is_admin: true}), do: true
|
||||||
def superuser?(%User{local: true, is_moderator: true}), do: true
|
def superuser?(%User{local: true, 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?(%User{invisible: true}), do: true
|
||||||
def invisible?(_), do: false
|
def invisible?(_), do: false
|
||||||
|
|
||||||
def avatar_url(user, options \\ []) do
|
def avatar_url(user, options \\ []) do
|
||||||
|
@ -264,6 +265,7 @@ def following_count(%User{} = user) do
|
||||||
:fields,
|
:fields,
|
||||||
:raw_fields,
|
:raw_fields,
|
||||||
:discoverable,
|
:discoverable,
|
||||||
|
:invisible,
|
||||||
:skip_thread_containment,
|
:skip_thread_containment,
|
||||||
:notification_settings
|
:notification_settings
|
||||||
]
|
]
|
||||||
|
@ -321,7 +323,8 @@ def remote_user_creation(params) do
|
||||||
:follower_count,
|
:follower_count,
|
||||||
:fields,
|
:fields,
|
||||||
:following_count,
|
:following_count,
|
||||||
:discoverable
|
:discoverable,
|
||||||
|
:invisible
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|> validate_required([:name, :ap_id])
|
|> validate_required([:name, :ap_id])
|
||||||
|
@ -2021,4 +2024,13 @@ def remove_reblog_mute(user, ap_id) do
|
||||||
|> cast(params, [:muted_reblogs])
|
|> cast(params, [:muted_reblogs])
|
||||||
|> update_and_set_cache()
|
|> update_and_set_cache()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_invisible(user, invisible) do
|
||||||
|
params = %{invisible: invisible}
|
||||||
|
|
||||||
|
user
|
||||||
|
|> cast(params, [:invisible])
|
||||||
|
|> validate_required([:invisible])
|
||||||
|
|> update_and_set_cache()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ def get_actor do
|
||||||
"#{Pleroma.Web.Endpoint.url()}/relay"
|
"#{Pleroma.Web.Endpoint.url()}/relay"
|
||||||
|> User.get_or_create_service_actor_by_ap_id()
|
|> User.get_or_create_service_actor_by_ap_id()
|
||||||
|
|
||||||
{:ok, actor} = User.update_info(actor, &User.Info.set_invisible(&1, true))
|
{:ok, actor} = User.set_invisible(actor, true)
|
||||||
actor
|
actor
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ defmodule Pleroma.Repo.Migrations.CopyUsersInfoFieldsToUsers do
|
||||||
:fields,
|
:fields,
|
||||||
:raw_fields,
|
:raw_fields,
|
||||||
:discoverable,
|
:discoverable,
|
||||||
|
:invisible,
|
||||||
:skip_thread_containment,
|
:skip_thread_containment,
|
||||||
:notification_settings
|
:notification_settings
|
||||||
]
|
]
|
||||||
|
@ -77,6 +78,7 @@ defmodule Pleroma.Repo.Migrations.CopyUsersInfoFieldsToUsers do
|
||||||
:hide_follows,
|
:hide_follows,
|
||||||
:hide_favorites,
|
:hide_favorites,
|
||||||
:discoverable,
|
:discoverable,
|
||||||
|
:invisible,
|
||||||
:skip_thread_containment
|
:skip_thread_containment
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -132,6 +134,7 @@ def change do
|
||||||
add(:fields, {:array, :map}, default: nil)
|
add(:fields, {:array, :map}, default: nil)
|
||||||
add(:raw_fields, {:array, :map}, default: [])
|
add(:raw_fields, {:array, :map}, default: [])
|
||||||
add(:discoverable, :boolean, default: false, null: false)
|
add(:discoverable, :boolean, default: false, null: false)
|
||||||
|
add(:invisible, :boolean, default: false, null: false)
|
||||||
add(:notification_settings, :map, default: %{})
|
add(:notification_settings, :map, default: %{})
|
||||||
add(:skip_thread_containment, :boolean, default: false, null: false)
|
add(:skip_thread_containment, :boolean, default: false, null: false)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
defmodule Pleroma.Repo.Migrations.DropWebsubTables do
|
defmodule Pleroma.Repo.Migrations.DropWebsubTables do
|
||||||
use Ecto.Migration
|
use Ecto.Migration
|
||||||
|
|
||||||
def change do
|
def up do
|
||||||
drop_if_exists(table(:websub_client_subscriptions))
|
drop_if_exists(table(:websub_client_subscriptions))
|
||||||
drop_if_exists(table(:websub_server_subscriptions))
|
drop_if_exists(table(:websub_server_subscriptions))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def down, do: :noop
|
||||||
end
|
end
|
||||||
|
|
|
@ -1233,7 +1233,7 @@ test "returns true for local admins" do
|
||||||
|
|
||||||
describe "invisible?/1" do
|
describe "invisible?/1" do
|
||||||
test "returns true for an invisible user" do
|
test "returns true for an invisible user" do
|
||||||
user = insert(:user, local: true, info: %{invisible: true})
|
user = insert(:user, local: true, invisible: true)
|
||||||
|
|
||||||
assert User.invisible?(user)
|
assert User.invisible?(user)
|
||||||
end
|
end
|
||||||
|
|
|
@ -75,7 +75,7 @@ test "Does not add an avatar image if the user hasn't set one" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "renders an invisible user with the invisible property set to true" do
|
test "renders an invisible user with the invisible property set to true" do
|
||||||
user = insert(:user, %{info: %{invisible: true}})
|
user = insert(:user, invisible: true)
|
||||||
|
|
||||||
assert %{"invisible" => true} = UserView.render("service.json", %{user: user})
|
assert %{"invisible" => true} = UserView.render("service.json", %{user: user})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue