mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-30 09:02:28 +00:00
6f5f7af607
Made `Pleroma.Web.MastodonAPI.AccountView.render("show.json", _)` demand :for or :force option in order to prevent incorrect rendering of empty map instead of expected user representation with truish :restrict_unauthenticated setting.
34 lines
938 B
Elixir
34 lines
938 B
Elixir
# Pleroma: A lightweight social networking server
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
defmodule Pleroma.Web.PleromaAPI.EmojiReactionView do
|
|
use Pleroma.Web, :view
|
|
|
|
alias Pleroma.Web.MastodonAPI.AccountView
|
|
|
|
def render("index.json", %{emoji_reactions: emoji_reactions} = opts) do
|
|
render_many(emoji_reactions, __MODULE__, "show.json", opts)
|
|
end
|
|
|
|
def render("show.json", %{emoji_reaction: [emoji, user_ap_ids], user: user}) do
|
|
users = fetch_users(user_ap_ids)
|
|
|
|
%{
|
|
name: emoji,
|
|
count: length(users),
|
|
accounts: render(AccountView, "index.json", users: users, for: user),
|
|
me: !!(user && user.ap_id in user_ap_ids)
|
|
}
|
|
end
|
|
|
|
defp fetch_users(user_ap_ids) do
|
|
user_ap_ids
|
|
|> Enum.map(&Pleroma.User.get_cached_by_ap_id/1)
|
|
|> Enum.filter(fn
|
|
%{deactivated: false} -> true
|
|
_ -> false
|
|
end)
|
|
end
|
|
end
|