2019-10-02 06:16:34 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-12 23:49:20 -07:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2019-10-02 06:16:34 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.MastodonAPI.CustomEmojiView do
|
|
|
|
use Pleroma.Web, :view
|
|
|
|
|
|
|
|
alias Pleroma.Emoji
|
2021-05-31 14:09:11 -06:00
|
|
|
alias Pleroma.Web.Endpoint
|
2019-10-02 06:16:34 -06:00
|
|
|
|
|
|
|
def render("index.json", %{custom_emojis: custom_emojis}) do
|
|
|
|
render_many(custom_emojis, __MODULE__, "show.json")
|
|
|
|
end
|
|
|
|
|
|
|
|
def render("show.json", %{custom_emoji: {shortcode, %Emoji{file: relative_url, tags: tags}}}) do
|
2021-05-31 14:09:11 -06:00
|
|
|
url = Endpoint.url() |> URI.merge(relative_url) |> to_string()
|
2019-10-02 06:16:34 -06:00
|
|
|
|
|
|
|
%{
|
|
|
|
"shortcode" => shortcode,
|
|
|
|
"static_url" => url,
|
|
|
|
"visible_in_picker" => true,
|
|
|
|
"url" => url,
|
|
|
|
"tags" => tags,
|
|
|
|
# Assuming that a comma is authorized in the category name
|
|
|
|
"category" => tags |> List.delete("Custom") |> Enum.join(",")
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|