From 6b11011039dca5090c3a7b7b2a01f32b666be380 Mon Sep 17 00:00:00 2001 From: eugenijm Date: Thu, 28 Feb 2019 08:31:33 +0300 Subject: [PATCH] Added deactivated to the user view --- lib/pleroma/web/twitter_api/views/user_view.ex | 7 +++++++ test/web/twitter_api/views/user_view_test.exs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex index c5034cf36..22f33e0b5 100644 --- a/lib/pleroma/web/twitter_api/views/user_view.ex +++ b/lib/pleroma/web/twitter_api/views/user_view.ex @@ -132,6 +132,7 @@ defp do_render("user.json", %{user: user = %User{}} = assigns) do "confirmation_pending" => user_info.confirmation_pending, "tags" => user.tags } + |> maybe_with_activation_status(user, for_user) |> maybe_with_follow_request_count(user, for_user) } @@ -148,6 +149,12 @@ defp do_render("user.json", %{user: user = %User{}} = assigns) do end end + defp maybe_with_activation_status(data, user, %User{info: %{is_admin: true}}) do + Map.put(data, "deactivated", user.info.deactivated) + end + + defp maybe_with_activation_status(data, _, _), do: data + defp maybe_with_follow_request_count(data, %User{id: id, info: %{locked: true}} = user, %User{ id: id }) do diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs index 95e52ca46..114f24a1c 100644 --- a/test/web/twitter_api/views/user_view_test.exs +++ b/test/web/twitter_api/views/user_view_test.exs @@ -239,6 +239,13 @@ test "An admin with hidden role for another user", %{user: user} do assert represented["role"] == nil end + test "A regular user for the admin", %{user: user} do + admin = insert(:user, %{info: %{is_admin: true}}) + represented = UserView.render("show.json", %{user: user, for: admin}) + + assert represented["pleroma"]["deactivated"] == false + end + test "A blocked user for the blocker" do user = insert(:user) blocker = insert(:user)