2018-12-23 20:04:54 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-03 22:44:49 +00:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2018-12-23 20:04:54 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-08-14 02:27:28 +00:00
|
|
|
defmodule Pleroma.Web.MastodonAPI.FilterView do
|
|
|
|
use Pleroma.Web, :view
|
|
|
|
alias Pleroma.Web.CommonAPI.Utils
|
2019-02-03 17:44:18 +00:00
|
|
|
alias Pleroma.Web.MastodonAPI.FilterView
|
2018-08-14 02:27:28 +00:00
|
|
|
|
2020-04-27 19:54:11 +00:00
|
|
|
def render("index.json", %{filters: filters}) do
|
|
|
|
render_many(filters, FilterView, "show.json")
|
2018-08-14 02:27:28 +00:00
|
|
|
end
|
|
|
|
|
2020-04-14 14:36:32 +00:00
|
|
|
def render("show.json", %{filter: filter}) do
|
2018-08-21 18:35:14 +00:00
|
|
|
expires_at =
|
|
|
|
if filter.expires_at do
|
|
|
|
Utils.to_masto_date(filter.expires_at)
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
2018-08-21 17:45:58 +00:00
|
|
|
|
2018-08-14 02:27:28 +00:00
|
|
|
%{
|
|
|
|
id: to_string(filter.filter_id),
|
|
|
|
phrase: filter.phrase,
|
|
|
|
context: filter.context,
|
2018-08-21 17:45:58 +00:00
|
|
|
expires_at: expires_at,
|
2018-08-14 02:27:28 +00:00
|
|
|
irreversible: filter.hide,
|
2020-08-05 02:01:27 +00:00
|
|
|
whole_word: filter.whole_word
|
2018-08-14 02:27:28 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|