akkoma/lib/pleroma/web/mastodon_api/views/filter_view.ex

32 lines
817 B
Elixir
Raw Normal View History

# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# 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("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
expires_at =
if filter.expires_at do
Utils.to_masto_date(filter.expires_at)
else
nil
end
2018-08-14 02:27:28 +00:00
%{
id: to_string(filter.filter_id),
phrase: filter.phrase,
context: filter.context,
expires_at: expires_at,
2018-08-14 02:27:28 +00:00
irreversible: filter.hide,
whole_word: filter.whole_word
2018-08-14 02:27:28 +00:00
}
end
end