Replacing BaseObject with Object in the inheritance chain
This commit is contained in:
parent
92e612676a
commit
7806d1c2de
2 changed files with 21 additions and 8 deletions
|
@ -1,9 +1,11 @@
|
||||||
package activitypub
|
package activitypub
|
||||||
|
|
||||||
|
var validCollectionTypes = [...]string{}
|
||||||
|
|
||||||
type Page ObjectOrLink
|
type Page ObjectOrLink
|
||||||
|
|
||||||
type Collection struct {
|
type Collection struct {
|
||||||
*BaseObject
|
*Object
|
||||||
// A non-negative integer specifying the total number of objects contained by the logical view of the collection.
|
// A non-negative integer specifying the total number of objects contained by the logical view of the collection.
|
||||||
// This number might not reflect the actual number of items serialized within the Collection object instance.
|
// This number might not reflect the actual number of items serialized within the Collection object instance.
|
||||||
TotalItems uint `jsonld:"totalItems"`
|
TotalItems uint `jsonld:"totalItems"`
|
||||||
|
@ -12,7 +14,7 @@ type Collection struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type OrderedCollection struct {
|
type OrderedCollection struct {
|
||||||
*BaseObject
|
*Object
|
||||||
// A non-negative integer specifying the total number of objects contained by the logical view of the collection.
|
// A non-negative integer specifying the total number of objects contained by the logical view of the collection.
|
||||||
// This number might not reflect the actual number of items serialized within the Collection object instance.
|
// This number might not reflect the actual number of items serialized within the Collection object instance.
|
||||||
TotalItems uint `jsonld:"totalItems"`
|
TotalItems uint `jsonld:"totalItems"`
|
||||||
|
@ -50,16 +52,25 @@ type OrderedCollectionPage struct {
|
||||||
StartIndex uint `jsonld:"startIndex"`
|
StartIndex uint `jsonld:"startIndex"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func CollectionNew(id ObjectId) *Collection {
|
func ValidCollectionType(_type string) bool {
|
||||||
o := BaseObject{Id: id, Type: CollectionType}
|
for _, v := range validCollectionTypes {
|
||||||
|
if v == _type {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return &Collection{BaseObject: &o}
|
func CollectionNew(id ObjectId) *Collection {
|
||||||
|
o := ObjectNew(id, CollectionType)
|
||||||
|
|
||||||
|
return &Collection{Object: o}
|
||||||
}
|
}
|
||||||
|
|
||||||
func OrderedCollectionNew(id ObjectId) *OrderedCollection {
|
func OrderedCollectionNew(id ObjectId) *OrderedCollection {
|
||||||
o := BaseObject{Id: id, Type: OrderedCollectionType}
|
o := ObjectNew(id, OrderedCollectionType)
|
||||||
|
|
||||||
return &OrderedCollection{BaseObject: &o}
|
return &OrderedCollection{Object: o}
|
||||||
}
|
}
|
||||||
|
|
||||||
func CollectionPageNew(parent *Collection) *CollectionPage {
|
func CollectionPageNew(parent *Collection) *CollectionPage {
|
||||||
|
|
|
@ -41,6 +41,8 @@ var validGenericTypes = [...]string{
|
||||||
ObjectType,
|
ObjectType,
|
||||||
LinkType,
|
LinkType,
|
||||||
ActorType,
|
ActorType,
|
||||||
|
CollectionType,
|
||||||
|
OrderedCollectionType,
|
||||||
}
|
}
|
||||||
|
|
||||||
var validObjectTypes = [...]string{
|
var validObjectTypes = [...]string{
|
||||||
|
@ -186,7 +188,7 @@ func ValidObjectType(_type string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ValidActivityType(_type) || ValidActorType(_type) || ValidGenericType(_type)
|
return ValidActivityType(_type) || ValidActorType(_type) || ValidCollectionType(_type) || ValidGenericType(_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ObjectNew(id ObjectId, _type string) *Object {
|
func ObjectNew(id ObjectId, _type string) *Object {
|
||||||
|
|
Reference in a new issue