mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[bugfix] Ensure pre
renders as expected, fix orderedCollectionPage (#2434)
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user