defmodule Pleroma.Web.AdminAPI.AccountView do
use Pleroma.Web, :view
- alias Pleroma.User.Info
+ alias Pleroma.HTML
+ alias Pleroma.User
alias Pleroma.Web.AdminAPI.AccountView
+ alias Pleroma.Web.MediaProxy
def render("index.json", %{users: users, count: count, page_size: page_size}) do
%{
}
end
+ def render("index.json", %{users: users}) do
+ %{
+ users: render_many(users, AccountView, "show.json", as: :user)
+ }
+ end
+
def render("show.json", %{user: user}) do
+ avatar = User.avatar_url(user) |> MediaProxy.url()
+ display_name = HTML.strip_tags(user.name || user.nickname)
+
%{
"id" => user.id,
+ "avatar" => avatar,
"nickname" => user.nickname,
- "deactivated" => user.info.deactivated,
+ "display_name" => display_name,
+ "deactivated" => user.deactivated,
"local" => user.local,
- "roles" => Info.roles(user.info),
+ "roles" => User.roles(user),
"tags" => user.tags || []
}
end
def render("created.json", %{user: user}) do
%{
type: "success",
- code: 201,
+ code: 200,
data: %{
nickname: user.nickname,
email: user.email