Participations: Filter out participations without activities.
authorlain <lain@soykaf.club>
Tue, 4 Jun 2019 11:58:36 +0000 (13:58 +0200)
committerlain <lain@soykaf.club>
Tue, 4 Jun 2019 11:58:36 +0000 (13:58 +0200)
lib/pleroma/conversation/participation.ex
test/conversation/participation_test.exs

index 2a11f9069940d221aec41bb39d6f758fa4dd71aa..2c13c4b408a3ac9a434be385b1cd77ee23dea016 100644 (file)
@@ -79,5 +79,6 @@ defmodule Pleroma.Conversation.Participation do
         | last_activity_id: activity_id
       }
     end)
+    |> Enum.filter(& &1.last_activity_id)
   end
 end
index 568953b07268611ec0688f458a28e3b8b00804ca..0e60bfca539e51e162129acff922b08761835f77 100644 (file)
@@ -86,4 +86,17 @@ defmodule Pleroma.Conversation.ParticipationTest do
 
     assert participation_one.last_activity_id == activity_three.id
   end
+
+  test "Doesn't die when the conversation gets empty" do
+    user = insert(:user)
+
+    {:ok, activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
+    [participation] = Participation.for_user_with_last_activity_id(user)
+
+    assert participation.last_activity_id == activity.id
+
+    {:ok, _} = CommonAPI.delete(activity.id, user)
+
+    [] = Participation.for_user_with_last_activity_id(user)
+  end
 end