Emoji Reactions: Correctly handle deleted users
authorlain <lain@soykaf.club>
Wed, 29 Jan 2020 10:43:36 +0000 (11:43 +0100)
committerlain <lain@soykaf.club>
Wed, 29 Jan 2020 10:43:36 +0000 (11:43 +0100)
lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex
test/web/pleroma_api/controllers/pleroma_api_controller_test.exs

index e6e2385b21e2faa65e8a3a9573d2afc4986f7b47..d76e39795a84d706b066dd8bac2f2924e05970c6 100644 (file)
@@ -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,
index bc676c99a7e87eee77c62621d9db227547bd0e35..be5007de52b00acbaa8a256b9a84693ec207a2fc 100644 (file)
@@ -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