2019-02-28 07:43:09 -07:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-03-12 21:13:28 -06:00
|
|
|
defmodule Pleroma.Web.AdminAPI.AccountView do
|
2019-02-28 07:43:09 -07:00
|
|
|
use Pleroma.Web, :view
|
|
|
|
|
2019-06-28 06:15:32 -06:00
|
|
|
alias Pleroma.HTML
|
|
|
|
alias Pleroma.User
|
2019-03-12 13:15:28 -06:00
|
|
|
alias Pleroma.User.Info
|
2019-03-12 21:13:28 -06:00
|
|
|
alias Pleroma.Web.AdminAPI.AccountView
|
2019-06-28 06:15:32 -06:00
|
|
|
alias Pleroma.Web.MediaProxy
|
2019-02-28 07:43:09 -07:00
|
|
|
|
|
|
|
def render("index.json", %{users: users, count: count, page_size: page_size}) do
|
|
|
|
%{
|
|
|
|
users: render_many(users, AccountView, "show.json", as: :user),
|
|
|
|
count: count,
|
|
|
|
page_size: page_size
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def render("show.json", %{user: user}) do
|
2019-06-28 06:15:32 -06:00
|
|
|
avatar = User.avatar_url(user) |> MediaProxy.url()
|
|
|
|
display_name = HTML.strip_tags(user.name || user.nickname)
|
|
|
|
|
2019-02-28 07:43:09 -07:00
|
|
|
%{
|
|
|
|
"id" => user.id,
|
2019-06-28 06:15:32 -06:00
|
|
|
"avatar" => avatar,
|
2019-02-28 07:43:09 -07:00
|
|
|
"nickname" => user.nickname,
|
2019-06-28 06:15:32 -06:00
|
|
|
"display_name" => display_name,
|
2019-03-12 13:15:28 -06:00
|
|
|
"deactivated" => user.info.deactivated,
|
2019-03-13 07:04:44 -06:00
|
|
|
"local" => user.local,
|
2019-03-13 16:52:24 -06:00
|
|
|
"roles" => Info.roles(user.info),
|
2019-03-13 18:17:09 -06:00
|
|
|
"tags" => user.tags || []
|
2019-02-28 07:43:09 -07:00
|
|
|
}
|
|
|
|
end
|
2019-04-06 07:25:19 -06:00
|
|
|
|
|
|
|
def render("invite.json", %{invite: invite}) do
|
|
|
|
%{
|
|
|
|
"id" => invite.id,
|
|
|
|
"token" => invite.token,
|
|
|
|
"used" => invite.used,
|
2019-04-08 03:01:28 -06:00
|
|
|
"expires_at" => invite.expires_at,
|
2019-04-06 07:25:19 -06:00
|
|
|
"uses" => invite.uses,
|
|
|
|
"max_use" => invite.max_use,
|
|
|
|
"invite_type" => invite.invite_type
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def render("invites.json", %{invites: invites}) do
|
|
|
|
%{
|
|
|
|
invites: render_many(invites, AccountView, "invite.json", as: :invite)
|
|
|
|
}
|
|
|
|
end
|
2019-02-28 07:43:09 -07:00
|
|
|
end
|