From f286ddb7131508d097348493d837248b79343786 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Sat, 18 Jul 2026 12:09:59 -0400 Subject: [PATCH] Omit empty First value and only set on New with items>0 Supports fixing writefreely/writefreely#1698 --- activitystreams/data.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/activitystreams/data.go b/activitystreams/data.go index 956b835..20f70c2 100644 --- a/activitystreams/data.go +++ b/activitystreams/data.go @@ -30,7 +30,7 @@ type ( type OrderedCollection struct { BaseObject TotalItems int `json:"totalItems"` - First string `json:"first"` + First string `json:"first,omitempty"` Last string `json:"last,omitempty"` } @@ -43,9 +43,13 @@ func NewOrderedCollection(accountRoot, collType string, items int) *OrderedColle ID: accountRoot + "/" + collType, Type: "OrderedCollection", }, - First: accountRoot + "/" + collType + "?page=1", TotalItems: items, } + if items > 0 { + // Next page should only be indicated if there are potentially items on it. NOTE: with no knowledge of items- + // per-page, this still may need to be altered by the func caller. + oc.First = accountRoot + "/" + collType + "?page=1" + } return &oc }