Added deactivated to the user view
authoreugenijm <eugenijm@protonmail.com>
Thu, 28 Feb 2019 05:31:33 +0000 (08:31 +0300)
committereugenijm <eugenijm@protonmail.com>
Thu, 28 Feb 2019 06:08:34 +0000 (09:08 +0300)
lib/pleroma/web/twitter_api/views/user_view.ex
test/web/twitter_api/views/user_view_test.exs

index c5034cf3674b9236fb240b3d0044c9dd9c11f215..22f33e0b5d984bae61ad0269f1103705ec5b932d 100644 (file)
@@ -132,6 +132,7 @@ defmodule Pleroma.Web.TwitterAPI.UserView 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 @@ defmodule Pleroma.Web.TwitterAPI.UserView 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
index 95e52ca46a988d7fea21a72f53af9dd44ae5deff..114f24a1c5582a7e3784278c5bc574ff6e22c929 100644 (file)
@@ -239,6 +239,13 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest 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)