26 lines
819 B
Elixir
26 lines
819 B
Elixir
# Pleroma: A lightweight social networking server
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
defmodule Pleroma.Web.OAuth.TokenView do
|
|
use Pleroma.Web, :view
|
|
|
|
def render("index.json", %{tokens: tokens, current_token: current_token}) do
|
|
tokens
|
|
|> render_many(Pleroma.Web.OAuth.TokenView, "show.json", %{
|
|
current_token: current_token
|
|
})
|
|
|> Enum.filter(&Enum.any?/1)
|
|
end
|
|
|
|
def render("show.json", %{token: token_entry, current_token: current_token}) do
|
|
%{
|
|
id: token_entry.id,
|
|
valid_until: token_entry.valid_until,
|
|
last_active: token_entry.last_active,
|
|
app_name: token_entry.app.client_name,
|
|
scopes: token_entry.scopes,
|
|
is_current_token: token_entry.id == current_token.id
|
|
}
|
|
end
|
|
end
|