From 5b7a0dba6d2c019f7bee5727dee04f0f8bf8cb27 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 25 Aug 2021 23:15:30 -0400 Subject: [PATCH] Fix error in outbox when no activities exist --- lib/clacks_web/controllers/outbox_controller.ex | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/clacks_web/controllers/outbox_controller.ex b/lib/clacks_web/controllers/outbox_controller.ex index 3b4ba2f..5ee7d83 100644 --- a/lib/clacks_web/controllers/outbox_controller.ex +++ b/lib/clacks_web/controllers/outbox_controller.ex @@ -50,13 +50,22 @@ defmodule ClacksWeb.OutboxController do end defp outbox_page(conn, pagination_params, activities) do - last_id = List.last(activities).id + next = + case activities do + [] -> + # todo: is nil the right thing here? + nil + + _ -> + last_id = List.last(activities).id + current_url(conn, %{max_id: last_id}) + end %{ "type" => "OrderedColletionPage", "partOf" => current_url(conn, %{}), "id" => current_url(conn, pagination_params), - "next" => current_url(conn, %{max_id: last_id}), + "next" => next, "orderedItems" => Enum.map(activities, & &1.data) } end