diff options
| -rw-r--r-- | lib/pleroma/web/mastodon_api/views/account_view.ex | 8 | ||||
| -rw-r--r-- | test/pleroma/web/mastodon_api/views/account_view_test.exs | 8 | 
2 files changed, 9 insertions, 7 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index 988eedbb1..d3f2245e2 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -398,12 +398,12 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do    defp maybe_put_allow_following_move(data, _, _), do: data -  defp maybe_put_activation_status(data, user, %User{is_admin: true}) do -    Kernel.put_in(data, [:pleroma, :deactivated], !user.is_active) +  defp maybe_put_activation_status(data, user, user_for) do +    if User.privileged?(user_for, :user_activation), +      do: Kernel.put_in(data, [:pleroma, :deactivated], !user.is_active), +      else: data    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      data      |> Kernel.put_in( diff --git a/test/pleroma/web/mastodon_api/views/account_view_test.exs b/test/pleroma/web/mastodon_api/views/account_view_test.exs index 8ed37fe58..d9d3866e7 100644 --- a/test/pleroma/web/mastodon_api/views/account_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/account_view_test.exs @@ -3,7 +3,7 @@  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.Web.MastodonAPI.AccountViewTest do -  use Pleroma.DataCase +  use Pleroma.DataCase, async: false    alias Pleroma.User    alias Pleroma.UserRelationship @@ -214,8 +214,10 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do      assert represented.url == "https://channels.tests.funkwhale.audio/channels/compositions"    end -  test "Represent a deactivated user for an admin" do -    admin = insert(:user, is_admin: true) +  test "Represent a deactivated user for a privileged user" do +    clear_config([:instance, :moderator_privileges], [:user_activation]) + +    admin = insert(:user, is_moderator: true)      deactivated_user = insert(:user, is_active: false)      represented = AccountView.render("show.json", %{user: deactivated_user, for: admin})      assert represented[:pleroma][:deactivated] == true  | 
