Participations: Filter out participations without activities.

This commit is contained in:
lain 2019-06-04 13:58:36 +02:00
parent 0eb7464c10
commit a3a7178b60
2 changed files with 14 additions and 0 deletions

View File

@ -79,5 +79,6 @@ defmodule Pleroma.Conversation.Participation do
| last_activity_id: activity_id
}
end)
|> Enum.filter(& &1.last_activity_id)
end
end

View 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