Fix error in outbox when no activities exist
This commit is contained in:
parent
4851b5fd61
commit
5b7a0dba6d
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue