2019-08-25 19:39:37 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-03 22:44:49 +00:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2019-08-25 19:39:37 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.AdminAPI.ModerationLogView do
|
|
|
|
use Pleroma.Web, :view
|
|
|
|
|
|
|
|
alias Pleroma.ModerationLog
|
|
|
|
|
|
|
|
def render("index.json", %{log: log}) do
|
2019-09-01 18:23:30 +00:00
|
|
|
%{
|
|
|
|
items: render_many(log.items, __MODULE__, "show.json", as: :log_entry),
|
|
|
|
total: log.count
|
|
|
|
}
|
2019-08-25 19:39:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def render("show.json", %{log_entry: log_entry}) do
|
|
|
|
time =
|
|
|
|
log_entry.inserted_at
|
|
|
|
|> DateTime.from_naive!("Etc/UTC")
|
|
|
|
|> DateTime.to_unix()
|
|
|
|
|
|
|
|
%{
|
2021-01-01 17:58:42 +00:00
|
|
|
id: log_entry.id,
|
2019-08-25 19:39:37 +00:00
|
|
|
data: log_entry.data,
|
|
|
|
time: time,
|
|
|
|
message: ModerationLog.get_log_entry_message(log_entry)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|