From: lain Date: Wed, 29 Jan 2020 10:43:36 +0000 (+0100) Subject: Emoji Reactions: Correctly handle deleted users X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=b3a877d6c9f7645c854527fc5bf05d9161c2480b;p=akkoma Emoji Reactions: Correctly handle deleted users --- 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