mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-09 09:52:13 +00:00
Exclude deactivated users from emoji reaction lists
This commit is contained in:
parent
8c956bc671
commit
8fe29bf5d2
|
@ -41,6 +41,17 @@ defmodule Pleroma.Web.PleromaAPI.EmojiReactionController do
|
|||
end
|
||||
end
|
||||
|
||||
defp filter_allowed_user_by_ap_id(ap_ids, excluded_ap_ids) do
|
||||
Enum.reject(ap_ids, fn ap_id ->
|
||||
with false <- ap_id in excluded_ap_ids,
|
||||
%{is_active: true} <- User.get_cached_by_ap_id(ap_id) do
|
||||
false
|
||||
else
|
||||
_ -> true
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
def filter_allowed_users(reactions, user, with_muted) do
|
||||
exclude_ap_ids =
|
||||
if is_nil(user) do
|
||||
|
@ -51,7 +62,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiReactionController do
|
|||
end
|
||||
|
||||
filter_emoji = fn emoji, users, url ->
|
||||
case Enum.reject(users, &(&1 in exclude_ap_ids)) do
|
||||
case filter_allowed_user_by_ap_id(users, exclude_ap_ids) do
|
||||
[] -> nil
|
||||
users -> {emoji, users, url}
|
||||
end
|
||||
|
|
|
@ -1960,6 +1960,10 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
{:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, "🎅")
|
||||
User.mute(user, other_user)
|
||||
|
||||
deactivated_user = insert(:user)
|
||||
{:ok, _} = CommonAPI.react_with_emoji(activity.id, deactivated_user, "🎅")
|
||||
User.set_activation(deactivated_user, false)
|
||||
|
||||
result =
|
||||
conn
|
||||
|> get("/api/v1/statuses/?ids[]=#{activity.id}")
|
||||
|
@ -1967,6 +1971,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
assert [
|
||||
%{
|
||||
"emoji_reactions" => [],
|
||||
"pleroma" => %{
|
||||
"emoji_reactions" => []
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue