summaryrefslogtreecommitdiff
path: root/internal/ap/serialize.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/ap/serialize.go')
-rw-r--r--internal/ap/serialize.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/internal/ap/serialize.go b/internal/ap/serialize.go
index 944e67407..774e95f2d 100644
--- a/internal/ap/serialize.go
+++ b/internal/ap/serialize.go
@@ -35,13 +35,15 @@ import (
// Currently, the following things will be custom serialized:
//
// - OrderedCollection: 'orderedItems' property will always be made into an array.
+// - OrderedCollectionPage: 'orderedItems' property will always be made into an array.
// - Any Accountable type: 'attachment' property will always be made into an array.
// - Any Statusable type: 'attachment' property will always be made into an array; 'content' and 'contentMap' will be normalized.
// - Any Activityable type: any 'object's set on an activity will be custom serialized as above.
func Serialize(t vocab.Type) (m map[string]interface{}, e error) {
switch tn := t.GetTypeName(); {
- case tn == ObjectOrderedCollection:
- return serializeOrderedCollection(t)
+ case tn == ObjectOrderedCollection ||
+ tn == ObjectOrderedCollectionPage:
+ return serializeWithOrderedItems(t)
case IsAccountable(tn):
return serializeAccountable(t, true)
case IsStatusable(tn):
@@ -54,16 +56,17 @@ func Serialize(t vocab.Type) (m map[string]interface{}, e error) {
}
}
-// serializeOrderedCollection is a custom serializer for an ActivityStreamsOrderedCollection.
-// Unlike the standard streams.Serialize function, this serializer normalizes the orderedItems
-// value to always be an array/slice, regardless of how many items are contained therein.
-//
-// TODO: Remove this function if we can fix the underlying issue in Go-Fed.
+// serializeWithOrderedItems is a custom serializer
+// for any type that has an `orderedItems` property.
+// Unlike the standard streams.Serialize function,
+// this serializer normalizes the orderedItems
+// value to always be an array/slice, regardless
+// of how many items are contained therein.
//
// See:
// - https://github.com/go-fed/activity/issues/139
// - https://github.com/mastodon/mastodon/issues/24225
-func serializeOrderedCollection(t vocab.Type) (map[string]interface{}, error) {
+func serializeWithOrderedItems(t vocab.Type) (map[string]interface{}, error) {
data, err := streams.Serialize(t)
if err != nil {
return nil, err