forked from AkkomaGang/akkoma
Exclude deactivated users from emoji reaction lists
This commit is contained in:
parent
8c956bc671
commit
8fe29bf5d2
2 changed files with 17 additions and 1 deletions
|
@ -41,6 +41,17 @@ def index(%{assigns: %{user: user}} = conn, %{id: activity_id} = params) 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 @@ def filter_allowed_users(reactions, user, with_muted) 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 @@ test "index" 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 @@ test "index" do
|
|||
|
||||
assert [
|
||||
%{
|
||||
"emoji_reactions" => [],
|
||||
"pleroma" => %{
|
||||
"emoji_reactions" => []
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue