From 4f42b00ec18cfdf3f97527a6fe91babc03f118aa Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Mon, 2 Jan 2023 13:27:18 -0500 Subject: return ordered collection for outbox instead of page --- views/outbox.go | 48 +++++++++--------------------------------------- 1 file changed, 9 insertions(+), 39 deletions(-) (limited to 'views') diff --git a/views/outbox.go b/views/outbox.go index 4dd5ab5..c2b8015 100644 --- a/views/outbox.go +++ b/views/outbox.go @@ -11,15 +11,15 @@ import ( // RenderOutboxCollection takes a page of ActivityStream objects as JSON strings and concatenates them together to return an // ActivtyStreamsOrderedCollection func RenderOutboxCollection(name, domain string, page []models.OutboxItem) (map[string]interface{}, error) { - id, err := urls.UrlOutboxPage(name, domain) + id, err := urls.UrlOutbox(name, domain) if err != nil { return nil, err } - partOf, err := urls.UrlOutbox(name, domain) - if err != nil { - return nil, err - } + // partOf, err := urls.UrlOutbox(name, domain) + // if err != nil { + // return nil, err + // } publicUrl, err := url.Parse("https://www.w3.org/ns/activitystreams#Public") if err != nil { return nil, err @@ -27,16 +27,12 @@ func RenderOutboxCollection(name, domain string, page []models.OutboxItem) (map[ toProp := streams.NewActivityStreamsToProperty() toProp.AppendIRI(publicUrl) - oc := streams.NewActivityStreamsOrderedCollectionPage() + oc := streams.NewActivityStreamsOrderedCollection() idProp := streams.NewJSONLDIdProperty() idProp.Set(id) oc.SetJSONLDId(idProp) - partOfProp := streams.NewActivityStreamsPartOfProperty() - partOfProp.SetIRI(partOf) - oc.SetActivityStreamsPartOf(partOfProp) - itemsProp := streams.NewActivityStreamsOrderedItemsProperty() for _, v := range page { @@ -52,35 +48,9 @@ func RenderOutboxCollection(name, domain string, page []models.OutboxItem) (map[ itemsProp.AppendActivityStreamsCreate(crea) } + totalProp := streams.NewActivityStreamsTotalItemsProperty() + totalProp.Set(20) + oc.SetActivityStreamsTotalItems(totalProp) oc.SetActivityStreamsOrderedItems(itemsProp) return streams.Serialize(oc) } - -func RenderOutbox(name, domain string, totalItems int) (map[string]interface{}, error) { - id, err := urls.UrlOutbox(name, domain) - - if err != nil { - return nil, err - } - - first, err := urls.UrlOutboxPage(name, domain) - if err != nil { - return nil, err - } - - oc := streams.NewActivityStreamsOrderedCollection() - - idProp := streams.NewJSONLDIdProperty() - idProp.Set(id) - oc.SetJSONLDId(idProp) - - itemsProp := streams.NewActivityStreamsTotalItemsProperty() - itemsProp.Set(totalItems) - oc.SetActivityStreamsTotalItems(itemsProp) - - ocProp := streams.NewActivityStreamsFirstProperty() - ocProp.SetIRI(first) - oc.SetActivityStreamsFirst(ocProp) - - return streams.Serialize(oc) -} -- cgit v1.2.3