logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

custom_emoji_view.ex (875B)


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