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/followers.go

75 lines
1.5 KiB
Go
Raw Normal View History

2017-09-11 20:45:57 +00:00
package activitypub
2017-09-16 17:53:11 +00:00
type (
2018-03-25 18:54:51 +00:00
// FollowersCollection is a collection of followers
FollowersCollection = Followers
2017-09-11 20:45:57 +00:00
2018-03-25 18:54:51 +00:00
// Followers is a Collection type
Followers Collection
2017-09-16 17:53:11 +00:00
)
// FollowersNew initializes a new Followers
func FollowersNew() *Followers {
id := ObjectID("followers")
i := Followers{ID: id, Type: CollectionType}
i.Name = NaturalLanguageValuesNew()
i.Content = NaturalLanguageValuesNew()
i.Summary = NaturalLanguageValuesNew()
i.TotalItems = 0
return &i
}
// Append adds an element to an Followers
func (f *Followers) Append(ob Item) error {
f.Items = append(f.Items, ob)
f.TotalItems++
return nil
}
// GetID returns the ObjectID corresponding to Followers
func (f Followers) GetID() ObjectID {
return f.Collection().GetID()
}
// GetLink returns the IRI corresponding to the current Followers object
func (f Followers) GetLink() IRI {
return IRI(f.ID)
}
// GetType returns the Followers's type
func (f Followers) GetType() ActivityVocabularyType {
return f.Type
}
// IsLink returns false for an Followers object
func (f Followers) IsLink() bool {
return false
}
// IsObject returns true for a Followers object
func (f Followers) IsObject() bool {
return true
}
// UnmarshalJSON
func (f *Followers) UnmarshalJSON(data []byte) error {
if ItemTyperFunc == nil {
ItemTyperFunc = JSONGetItemByType
}
c := Collection(*f)
err := c.UnmarshalJSON(data)
*f = Followers(c)
return err
}
// Collection returns the underlying Collection type
func (f Followers) Collection() CollectionInterface {
c := Collection(f)
return &c
}