This repository has been archived on 2022-11-27. You can view files and clone it, but cannot push or open issues or pull requests.
activitypub/item.go

21 lines
428 B
Go

package activitypub
// Item struct
type Item ObjectOrLink
const EmptyID = ID("")
const EmptyIRI = IRI("")
// Flatten checks if Item can be flatten to an IRI or array of IRIs and returns it if so
func Flatten(it Item) Item {
if it.IsCollection() {
if c, ok := it.(CollectionInterface); ok {
it = FlattenItemCollection(c.Collection())
}
}
if it != nil && len(it.GetLink()) > 0 {
return it.GetLink()
}
return it
}