Add deactivated status for privileged users
Deactivated users are only visible to users privileged with :user_activation since fc317f3b17 Here we also make sure the users who are deactivated get the status deactivated for users who are allowed to see these users
This commit is contained in:
parent
e21ef5aef3
commit
143ea7b80a
|
@ -398,12 +398,12 @@ defp maybe_put_allow_following_move(data, %User{id: user_id} = user, %User{id: u
|
||||||
|
|
||||||
defp maybe_put_allow_following_move(data, _, _), do: data
|
defp maybe_put_allow_following_move(data, _, _), do: data
|
||||||
|
|
||||||
defp maybe_put_activation_status(data, user, %User{is_admin: true}) do
|
defp maybe_put_activation_status(data, user, user_for) do
|
||||||
Kernel.put_in(data, [:pleroma, :deactivated], !user.is_active)
|
if User.privileged?(user_for, :user_activation),
|
||||||
|
do: Kernel.put_in(data, [:pleroma, :deactivated], !user.is_active),
|
||||||
|
else: data
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_put_activation_status(data, _, _), do: data
|
|
||||||
|
|
||||||
defp maybe_put_unread_conversation_count(data, %User{id: user_id} = user, %User{id: user_id}) do
|
defp maybe_put_unread_conversation_count(data, %User{id: user_id} = user, %User{id: user_id}) do
|
||||||
data
|
data
|
||||||
|> Kernel.put_in(
|
|> Kernel.put_in(
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
||||||
use Pleroma.DataCase
|
use Pleroma.DataCase, async: false
|
||||||
|
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.UserRelationship
|
alias Pleroma.UserRelationship
|
||||||
|
@ -214,8 +214,10 @@ test "Represent a Funkwhale channel" do
|
||||||
assert represented.url == "https://channels.tests.funkwhale.audio/channels/compositions"
|
assert represented.url == "https://channels.tests.funkwhale.audio/channels/compositions"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "Represent a deactivated user for an admin" do
|
test "Represent a deactivated user for a privileged user" do
|
||||||
admin = insert(:user, is_admin: true)
|
clear_config([:instance, :moderator_privileges], [:user_activation])
|
||||||
|
|
||||||
|
admin = insert(:user, is_moderator: true)
|
||||||
deactivated_user = insert(:user, is_active: false)
|
deactivated_user = insert(:user, is_active: false)
|
||||||
represented = AccountView.render("show.json", %{user: deactivated_user, for: admin})
|
represented = AccountView.render("show.json", %{user: deactivated_user, for: admin})
|
||||||
assert represented[:pleroma][:deactivated] == true
|
assert represented[:pleroma][:deactivated] == true
|
||||||
|
|
Loading…
Reference in New Issue