aboutsummaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2023-01-02 18:27:18 +0000
committerJulio Capote <jcapote@gmail.com>2023-01-02 18:27:18 +0000
commit4f42b00ec18cfdf3f97527a6fe91babc03f118aa (patch)
tree2fdd7a5fe227846a1b1f3015dcd25cdbdef68d70 /views
parent9027aba0621018caf177611d9105213645efe491 (diff)
downloadcommunique-4f42b00ec18cfdf3f97527a6fe91babc03f118aa.tar.gz
return ordered collection for outbox instead of page
Diffstat (limited to 'views')
-rw-r--r--views/outbox.go48
1 files changed, 9 insertions, 39 deletions
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)
-}