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

73 lines
1.6 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 (
// OutboxStream contains activities the user has published,
// subject to the ability of the requestor to retrieve the activity (that is,
// the contents of the outbox are filtered by the permissions of the person reading it).
OutboxStream = Outbox
2017-09-11 20:45:57 +00:00
// Outbox is a type alias for an Ordered Collection
Outbox OrderedCollection
2017-09-16 17:53:11 +00:00
)
// OutboxNew initializes a new Outbox
func OutboxNew() *Outbox {
id := ObjectID("outbox")
i := Outbox{ID: id, Type: CollectionType}
i.Name = NaturalLanguageValuesNew()
i.Content = NaturalLanguageValuesNew()
i.TotalItems = 0
return &i
}
// Append adds an element to an Outbox
func (o *Outbox) Append(ob Item) error {
o.OrderedItems = append(o.OrderedItems, ob)
o.TotalItems++
return nil
}
2018-07-18 19:23:23 +00:00
// GetID returns the ObjectID corresponding to Outbox
func (o Outbox) GetID() ObjectID {
return o.Collection().GetID()
2018-07-18 19:23:23 +00:00
}
// GetLink returns the IRI corresponding to the current Outbox object
func (o Outbox) GetLink() IRI {
return IRI(o.ID)
}
2018-07-18 19:23:23 +00:00
// GetType returns the Outbox's type
func (o Outbox) GetType() ActivityVocabularyType {
2018-07-18 19:23:23 +00:00
return o.Type
}
// IsLink returns false for an Outbox object
func (o Outbox) IsLink() bool {
return false
}
2018-07-18 19:34:08 +00:00
// IsObject returns true for a Outbox object
func (o Outbox) IsObject() bool {
return true
}
// UnmarshalJSON
func (o *Outbox) UnmarshalJSON(data []byte) error {
c := OrderedCollection(*o)
err := c.UnmarshalJSON(data)
*o = Outbox(c)
return err
}
// Collection returns the underlying Collection type
func (o Outbox) Collection() CollectionInterface {
c := OrderedCollection(o)
return &c
}