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
|
|
|
// 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
|
2018-10-11 09:26:00 +00:00
|
|
|
Outbox as.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 {
|
2018-10-11 09:26:00 +00:00
|
|
|
id := as.ObjectID("outbox")
|
2018-07-13 08:16:06 +00:00
|
|
|
|
2018-11-23 14:22:56 +00:00
|
|
|
i := Outbox{Parent: as.Parent{ID: id, Type: as.CollectionType}}
|
2019-02-21 17:00:03 +00:00
|
|
|
i.Name = as.NaturalLanguageValuesNew()
|
|
|
|
i.Content = as.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
|
2018-10-11 09:26:00 +00:00
|
|
|
func (o *Outbox) Append(ob as.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
|
2018-10-11 09:26:00 +00:00
|
|
|
func (o Outbox) GetID() *as.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
|
|
|
|
func (o Outbox) GetLink() as.IRI {
|
|
|
|
return as.IRI(o.ID)
|
|
|
|
}
|
|
|
|
|
2018-07-18 19:23:23 +00:00
|
|
|
// GetType returns the Outbox's type
|
2018-10-11 09:26:00 +00:00
|
|
|
func (o Outbox) GetType() as.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 {
|
2018-10-11 09:26:00 +00:00
|
|
|
c := as.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
|
2018-10-11 09:26:00 +00:00
|
|
|
func (o Outbox) Collection() as.CollectionInterface {
|
|
|
|
c := as.OrderedCollection(o)
|
2018-09-01 09:54:52 +00:00
|
|
|
return &c
|
|
|
|
}
|