Added deactivated to the user view

This commit is contained in:
eugenijm 2019-02-28 08:31:33 +03:00
parent 14bc6bd40f
commit 6b11011039
2 changed files with 14 additions and 0 deletions

View File

@ -132,6 +132,7 @@ defp do_render("user.json", %{user: user = %User{}} = assigns) do
"confirmation_pending" => user_info.confirmation_pending, "confirmation_pending" => user_info.confirmation_pending,
"tags" => user.tags "tags" => user.tags
} }
|> maybe_with_activation_status(user, for_user)
|> maybe_with_follow_request_count(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
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{ defp maybe_with_follow_request_count(data, %User{id: id, info: %{locked: true}} = user, %User{
id: id id: id
}) do }) do

View File

@ -239,6 +239,13 @@ test "An admin with hidden role for another user", %{user: user} do
assert represented["role"] == nil assert represented["role"] == nil
end 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 test "A blocked user for the blocker" do
user = insert(:user) user = insert(:user)
blocker = insert(:user) blocker = insert(:user)