From b3a877d6c9f7645c854527fc5bf05d9161c2480b Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 29 Jan 2020 11:43:36 +0100 Subject: [PATCH] Emoji Reactions: Correctly handle deleted users --- .../web/pleroma_api/controllers/pleroma_api_controller.ex | 4 +++- .../pleroma_api/controllers/pleroma_api_controller_test.exs | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex index e6e2385b2..d76e39795 100644 --- a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex @@ -48,7 +48,9 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIController do reactions = emoji_reactions |> Enum.map(fn [emoji, user_ap_ids] -> - users = Enum.map(user_ap_ids, &User.get_cached_by_ap_id/1) + users = + Enum.map(user_ap_ids, &User.get_cached_by_ap_id/1) + |> Enum.filter(& &1) %{ emoji: emoji, diff --git a/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs b/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs index bc676c99a..be5007de5 100644 --- a/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs +++ b/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs @@ -59,6 +59,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do test "GET /api/v1/pleroma/statuses/:id/emoji_reactions_by", %{conn: conn} do user = insert(:user) other_user = insert(:user) + doomed_user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"}) @@ -70,6 +71,9 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do assert result == [] {:ok, _, _} = CommonAPI.react_with_emoji(activity.id, other_user, "🎅") + {:ok, _, _} = CommonAPI.react_with_emoji(activity.id, doomed_user, "🎅") + + User.perform(:delete, doomed_user) result = conn