2018-12-23 20:04:54 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2018-12-31 15:41:47 +00:00
|
|
|
# Copyright © 2017-2019 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
|
|
|
|
|
|
|
def render("filters.json", %{filters: filters} = opts) do
|
|
|
|
render_many(filters, FilterView, "filter.json", opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
def render("filter.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,
|
|
|
|
whole_word: false
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|