2017-09-11 20:45:57 +00:00
|
|
|
package activitypub
|
|
|
|
|
2017-09-16 17:53:11 +00:00
|
|
|
type (
|
2018-03-27 14:16:07 +00:00
|
|
|
// 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).
|
2019-05-18 21:13:00 +00:00
|
|
|
OutboxStream = Outbox
|
2017-09-11 20:45:57 +00:00
|
|
|
|
2018-03-27 14:16:07 +00:00
|
|
|
// Outbox is a type alias for an Ordered Collection
|
2019-12-03 16:23:59 +00:00
|
|
|
Outbox OrderedCollection
|
2017-09-16 17:53:11 +00:00
|
|
|
)
|
2018-07-13 08:16:06 +00:00
|
|
|
|
|
|
|
// OutboxNew initializes a new Outbox
|
|
|
|
func OutboxNew() *Outbox {
|
2019-12-03 16:23:59 +00:00
|
|
|
id := ObjectID("outbox")
|
2018-07-13 08:16:06 +00:00
|
|
|
|
2019-12-03 16:23:59 +00:00
|
|
|
i := Outbox{ID: id, Type: CollectionType}
|
|
|
|
i.Name = NaturalLanguageValuesNew()
|
|
|
|
i.Content = NaturalLanguageValuesNew()
|
2018-07-13 08:16:06 +00:00
|
|
|
|
|
|
|
i.TotalItems = 0
|
|
|
|
|
|
|
|
return &i
|
|
|
|
}
|
2018-07-16 13:48:37 +00:00
|
|
|
|
|
|
|
// Append adds an element to an Outbox
|
2019-12-03 16:23:59 +00:00
|
|
|
func (o *Outbox) Append(ob Item) error {
|
2018-07-16 13:48:37 +00:00
|
|
|
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
|
2019-12-03 16:23:59 +00:00
|
|
|
func (o Outbox) GetID() ObjectID {
|
2018-09-01 09:54:52 +00:00
|
|
|
return o.Collection().GetID()
|
2018-07-18 19:23:23 +00:00
|
|
|
}
|
|
|
|
|
2018-10-11 18:48:38 +00:00
|
|
|
// GetLink returns the IRI corresponding to the current Outbox object
|
2019-12-03 16:23:59 +00:00
|
|
|
func (o Outbox) GetLink() IRI {
|
|
|
|
return IRI(o.ID)
|
2018-10-11 18:48:38 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 19:23:23 +00:00
|
|
|
// GetType returns the Outbox's type
|
2019-12-03 16:23:59 +00:00
|
|
|
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
|
|
|
|
}
|
2018-07-24 21:11:08 +00:00
|
|
|
|
|
|
|
// UnmarshalJSON
|
|
|
|
func (o *Outbox) UnmarshalJSON(data []byte) error {
|
2019-12-03 16:23:59 +00:00
|
|
|
c := OrderedCollection(*o)
|
2018-07-24 21:11:08 +00:00
|
|
|
err := c.UnmarshalJSON(data)
|
|
|
|
|
|
|
|
*o = Outbox(c)
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|
2018-09-01 09:54:52 +00:00
|
|
|
|
|
|
|
// Collection returns the underlying Collection type
|
2019-12-03 16:23:59 +00:00
|
|
|
func (o Outbox) Collection() CollectionInterface {
|
|
|
|
c := OrderedCollection(o)
|
2018-09-01 09:54:52 +00:00
|
|
|
return &c
|
|
|
|
}
|