X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Ftwitter_api%2Fviews%2Fuser_view.ex;h=22f33e0b5d984bae61ad0269f1103705ec5b932d;hb=f38c316e6edbc88f1808a0c39488231ce17e4f35;hp=df73844761af4cfb3e02044ca8b8da7ef827e6af;hpb=c0ecbf6669948740a091bdf5b5441fb6ee55f4fc;p=akkoma diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex index df7384476..22f33e0b5 100644 --- a/lib/pleroma/web/twitter_api/views/user_view.ex +++ b/lib/pleroma/web/twitter_api/views/user_view.ex @@ -9,6 +9,7 @@ defmodule Pleroma.Web.TwitterAPI.UserView do alias Pleroma.User alias Pleroma.Web.CommonAPI.Utils alias Pleroma.Web.MediaProxy + alias Pleroma.Web.TwitterAPI.UserView def render("show.json", %{user: user = %User{}} = assigns) do render_one(user, Pleroma.Web.TwitterAPI.UserView, "user.json", assigns) @@ -26,6 +27,19 @@ defmodule Pleroma.Web.TwitterAPI.UserView do else: %{} end + def render("index_for_admin.json", %{users: users} = opts) do + users + |> render_many(UserView, "show_for_admin.json", opts) + end + + def render("show_for_admin.json", %{user: user}) do + %{ + "id" => user.id, + "nickname" => user.nickname, + "deactivated" => user.info.deactivated + } + end + def render("short.json", %{ user: %User{ nickname: nickname, @@ -118,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) } @@ -134,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