2017-09-11 20:45:57 +00:00
|
|
|
package activitypub
|
|
|
|
|
2019-01-22 15:37:30 +00:00
|
|
|
import as "github.com/go-ap/activitystreams"
|
2018-10-11 09:26:00 +00:00
|
|
|
|
2017-09-16 17:53:11 +00:00
|
|
|
type (
|
2018-03-27 14:16:07 +00:00
|
|
|
// LikesCollection is a list of all Like activities with this object as the object property,
|
|
|
|
// added as a side effect. The likes collection MUST be either an OrderedCollection or a Collection
|
|
|
|
// and MAY be filtered on privileges of an authenticated user or as appropriate when
|
|
|
|
// no authentication is given.
|
2017-09-16 17:53:11 +00:00
|
|
|
LikesCollection Likes
|
2017-09-11 20:45:57 +00:00
|
|
|
|
2018-03-27 14:16:07 +00:00
|
|
|
// Likes is a type alias for an Ordered Collection
|
2018-10-11 09:26:00 +00:00
|
|
|
Likes as.OrderedCollection
|
2017-09-16 17:53:11 +00:00
|
|
|
)
|
2018-10-04 19:05:01 +00:00
|
|
|
|
|
|
|
// LikesCollection initializes a new Outbox
|
|
|
|
func LikesNew() *Likes {
|
2018-10-11 09:26:00 +00:00
|
|
|
id := as.ObjectID("likes")
|
2018-10-04 19:05:01 +00:00
|
|
|
|
2018-11-23 14:22:56 +00:00
|
|
|
l := Likes{Parent: as.Parent{ID: id, Type: as.CollectionType}}
|
2019-02-21 17:00:03 +00:00
|
|
|
l.Name = as.NaturalLanguageValuesNew()
|
|
|
|
l.Content = as.NaturalLanguageValuesNew()
|
2018-10-04 19:05:01 +00:00
|
|
|
|
|
|
|
l.TotalItems = 0
|
|
|
|
|
|
|
|
return &l
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append adds an element to an LikesCollection
|
2018-10-11 09:26:00 +00:00
|
|
|
func (l *LikesCollection) Append(o as.Item) error {
|
2018-10-04 19:05:01 +00:00
|
|
|
l.OrderedItems = append(l.OrderedItems, o)
|
|
|
|
l.TotalItems++
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append adds an element to an Outbox
|
2018-10-11 09:26:00 +00:00
|
|
|
func (l *Likes) Append(ob as.Item) error {
|
2018-10-04 19:05:01 +00:00
|
|
|
l.OrderedItems = append(l.OrderedItems, ob)
|
|
|
|
l.TotalItems++
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetID returns the ObjectID corresponding to the LikesCollection
|
2018-10-11 09:26:00 +00:00
|
|
|
func (l LikesCollection) GetID() *as.ObjectID {
|
2018-10-04 19:05:01 +00:00
|
|
|
return l.Collection().GetID()
|
|
|
|
}
|
|
|
|
|
2018-10-11 18:48:38 +00:00
|
|
|
// GetLink returns the IRI corresponding to the current LikesCollection object
|
|
|
|
func (l LikesCollection) GetLink() as.IRI {
|
|
|
|
return as.IRI(l.ID)
|
|
|
|
}
|
|
|
|
|
2018-10-04 19:05:01 +00:00
|
|
|
// GetType returns the LikesCollection's type
|
2018-10-11 09:26:00 +00:00
|
|
|
func (l LikesCollection) GetType() as.ActivityVocabularyType {
|
2018-10-04 19:05:01 +00:00
|
|
|
return l.Type
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsLink returns false for an LikesCollection object
|
|
|
|
func (l LikesCollection) IsLink() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsObject returns true for a LikesCollection object
|
|
|
|
func (l LikesCollection) IsObject() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetID returns the ObjectID corresponding to the Likes
|
2018-10-11 09:26:00 +00:00
|
|
|
func (l Likes) GetID() *as.ObjectID {
|
2018-10-04 19:05:01 +00:00
|
|
|
return l.Collection().GetID()
|
|
|
|
}
|
|
|
|
|
2018-10-11 18:48:38 +00:00
|
|
|
// GetLink returns the IRI corresponding to the current Likes object
|
|
|
|
func (l Likes) GetLink() as.IRI {
|
|
|
|
return as.IRI(l.ID)
|
|
|
|
}
|
|
|
|
|
2018-10-04 19:05:01 +00:00
|
|
|
// GetType returns the Likes's type
|
2018-10-11 09:26:00 +00:00
|
|
|
func (l Likes) GetType() as.ActivityVocabularyType {
|
2018-10-04 19:05:01 +00:00
|
|
|
return l.Type
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsLink returns false for an Likes object
|
|
|
|
func (l Likes) IsLink() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsObject returns true for a Likes object
|
|
|
|
func (l Likes) IsObject() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// Collection returns the underlying Collection type
|
2018-10-11 09:26:00 +00:00
|
|
|
func (l Likes) Collection() as.CollectionInterface {
|
|
|
|
c := as.OrderedCollection(l)
|
2018-10-04 19:05:01 +00:00
|
|
|
return &c
|
|
|
|
}
|
|
|
|
|
|
|
|
// Collection returns the underlying Collection type
|
2018-10-11 09:26:00 +00:00
|
|
|
func (l LikesCollection) Collection() as.CollectionInterface {
|
|
|
|
c := as.OrderedCollection(l)
|
2018-10-04 19:05:01 +00:00
|
|
|
return &c
|
|
|
|
}
|