Language code on mastoapi statuses (#433)
[akkoma] / lib / pleroma / web / mastodon_api / views / custom_emoji_view.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.MastodonAPI.CustomEmojiView do
6 use Pleroma.Web, :view
7
8 alias Pleroma.Emoji
9 alias Pleroma.Web.Endpoint
10
11 def render("index.json", %{custom_emojis: custom_emojis}) do
12 render_many(custom_emojis, __MODULE__, "show.json")
13 end
14
15 def render("show.json", %{custom_emoji: {shortcode, %Emoji{file: relative_url, tags: tags}}}) do
16 url = Endpoint.url() |> URI.merge(relative_url) |> to_string()
17
18 %{
19 "shortcode" => shortcode,
20 "static_url" => url,
21 "visible_in_picker" => true,
22 "url" => url,
23 "tags" => tags,
24 # Assuming that a comma is authorized in the category name
25 "category" => tags |> List.delete("Custom") |> Enum.join(",")
26 }
27 end
28 end