summaryrefslogtreecommitdiff
path: root/internal/ap
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-12-10 12:36:00 +0100
committerLibravatar GitHub <noreply@github.com>2023-12-10 12:36:00 +0100
commitd60edf7ec61537d70915c41de5526b81dd795a2c (patch)
treebcd69cc2322198828961d71c27444a334894f7fa /internal/ap
parent[bugfix] Fix web media not showing as sensitive (#2433) (diff)
downloadgotosocial-d60edf7ec61537d70915c41de5526b81dd795a2c.tar.xz
[bugfix] Ensure `pre` renders as expected, fix orderedCollectionPage (#2434)
Diffstat (limited to 'internal/ap')
-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