akkoma/lib/pleroma/web/admin_api/views/account_view.ex

48 lines
1.2 KiB
Elixir
Raw Normal View History

2019-02-28 14:43:09 +00:00
# Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.AccountView do
2019-02-28 14:43:09 +00:00
use Pleroma.Web, :view
2019-03-12 19:15:28 +00:00
alias Pleroma.User.Info
alias Pleroma.Web.AdminAPI.AccountView
2019-02-28 14:43:09 +00: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
%{
"id" => user.id,
"nickname" => user.nickname,
2019-03-12 19:15:28 +00:00
"deactivated" => user.info.deactivated,
2019-03-13 13:04:44 +00:00
"local" => user.local,
2019-03-13 22:52:24 +00:00
"roles" => Info.roles(user.info),
"tags" => user.tags || []
2019-02-28 14:43:09 +00:00
}
end
2019-04-06 13:25:19 +00:00
def render("invite.json", %{invite: invite}) do
%{
"id" => invite.id,
"token" => invite.token,
"used" => invite.used,
"expire_at" => invite.expire_at,
"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 14:43:09 +00:00
end