From 2432e9717edc433ff762c7542cdd94c380acff51 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 25 Jun 2018 13:37:08 -0400 Subject: [PATCH] Make OrderedCollection{Page} funcs generalized for any collection --- activitystreams/data.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/activitystreams/data.go b/activitystreams/data.go index e96528a..7c26588 100644 --- a/activitystreams/data.go +++ b/activitystreams/data.go @@ -30,16 +30,16 @@ type OrderedCollection struct { Last string `json:"last,omitempty"` } -func NewOrderedCollection(accountRoot string, items int) *OrderedCollection { +func NewOrderedCollection(accountRoot, collType string, items int) *OrderedCollection { oc := OrderedCollection{ BaseObject: BaseObject{ Context: []string{ "https://www.w3.org/ns/activitystreams", }, - ID: accountRoot + "/outbox", + ID: accountRoot + "/" + collType, Type: "OrderedCollection", }, - First: accountRoot + "/outbox?page=1", + First: accountRoot + "/" + collType + "?page=1", TotalItems: items, } return &oc @@ -54,18 +54,18 @@ type OrderedCollectionPage struct { OrderedItems []Activity `json:"orderedItems"` } -func NewOrderedCollectionPage(accountRoot string, items, page int) *OrderedCollectionPage { +func NewOrderedCollectionPage(accountRoot, collType string, items, page int) *OrderedCollectionPage { ocp := OrderedCollectionPage{ BaseObject: BaseObject{ Context: []string{ "https://www.w3.org/ns/activitystreams", }, - ID: fmt.Sprintf("%s/outbox?page=%d", accountRoot, page), + ID: fmt.Sprintf("%s/%s?page=%d", accountRoot, collType, page), Type: "OrderedCollectionPage", }, TotalItems: items, - PartOf: accountRoot + "/outbox", - Next: fmt.Sprintf("%s/outbox?page=%d", accountRoot, page+1), + PartOf: accountRoot + "/" + collType, + Next: fmt.Sprintf("%s/%s?page=%d", accountRoot, collType, page+1), } return &ocp }