From a3a7178b604d8bc589a8e3ac06abac094cce5e17 Mon Sep 17 00:00:00 2001 From: lain Date: Tue, 4 Jun 2019 13:58:36 +0200 Subject: [PATCH] Participations: Filter out participations without activities. --- lib/pleroma/conversation/participation.ex | 1 + test/conversation/participation_test.exs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/pleroma/conversation/participation.ex b/lib/pleroma/conversation/participation.ex index 2a11f9069..2c13c4b40 100644 --- a/lib/pleroma/conversation/participation.ex +++ b/lib/pleroma/conversation/participation.ex @@ -79,5 +79,6 @@ def for_user_with_last_activity_id(user, params \\ %{}) do | last_activity_id: activity_id } end) + |> Enum.filter(& &1.last_activity_id) end end diff --git a/test/conversation/participation_test.exs b/test/conversation/participation_test.exs index 568953b07..0e60bfca5 100644 --- a/test/conversation/participation_test.exs +++ b/test/conversation/participation_test.exs @@ -86,4 +86,17 @@ test "gets all the participations for a user, ordered by updated at descending" 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