Fix error in outbox when no activities exist

This commit is contained in:
Shadowfacts 2021-08-25 23:15:30 -04:00
parent 4851b5fd61
commit 5b7a0dba6d
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 11 additions and 2 deletions

View File

@ -50,13 +50,22 @@ defmodule ClacksWeb.OutboxController do
end end
defp outbox_page(conn, pagination_params, activities) do defp outbox_page(conn, pagination_params, activities) do
next =
case activities do
[] ->
# todo: is nil the right thing here?
nil
_ ->
last_id = List.last(activities).id last_id = List.last(activities).id
current_url(conn, %{max_id: last_id})
end
%{ %{
"type" => "OrderedColletionPage", "type" => "OrderedColletionPage",
"partOf" => current_url(conn, %{}), "partOf" => current_url(conn, %{}),
"id" => current_url(conn, pagination_params), "id" => current_url(conn, pagination_params),
"next" => current_url(conn, %{max_id: last_id}), "next" => next,
"orderedItems" => Enum.map(activities, & &1.data) "orderedItems" => Enum.map(activities, & &1.data)
} }
end end