1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.PleromaAPI.EmojiReactionView do
8 alias Pleroma.Web.MastodonAPI.AccountView
10 def emoji_name(emoji, nil), do: emoji
12 def emoji_name(emoji, url) do
15 if url.host == Pleroma.Web.Endpoint.host() do
18 "#{emoji}@#{url.host}"
22 def render("index.json", %{emoji_reactions: emoji_reactions} = opts) do
23 render_many(emoji_reactions, __MODULE__, "show.json", opts)
26 def render("show.json", %{emoji_reaction: {emoji, user_ap_ids, url}, user: user}) do
27 users = fetch_users(user_ap_ids)
30 name: emoji_name(emoji, url),
32 accounts: render(AccountView, "index.json", users: users, for: user),
33 url: Pleroma.Web.MediaProxy.url(url),
34 me: !!(user && user.ap_id in user_ap_ids)
38 defp fetch_users(user_ap_ids) do
40 |> Enum.map(&Pleroma.User.get_cached_by_ap_id/1)
42 %{is_active: true} -> true