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
|
|
|
// InboxStream contains all activities received by the actor.
|
|
|
|
// The server SHOULD filter content according to the requester's permission.
|
|
|
|
// In general, the owner of an inbox is likely to be able to access all of their inbox contents.
|
|
|
|
// Depending on access control, some other content may be public, whereas other content may
|
|
|
|
// require authentication for non-owner users, if they can access the inbox at all.
|
2019-05-18 21:13:00 +00:00
|
|
|
InboxStream = Inbox
|
2017-09-11 20:45:57 +00:00
|
|
|
|
2018-03-27 14:16:07 +00:00
|
|
|
// Inbox is a type alias for an Ordered Collection
|
2019-12-03 16:23:59 +00:00
|
|
|
Inbox OrderedCollection
|
2017-09-16 17:53:11 +00:00
|
|
|
)
|
2018-04-09 11:10:27 +00:00
|
|
|
|
|
|
|
// InboxNew initializes a new Inbox
|
2019-12-03 16:23:59 +00:00
|
|
|
func InboxNew() *OrderedCollection {
|
|
|
|
id := ObjectID("inbox")
|
2018-04-09 11:10:27 +00:00
|
|
|
|
2019-12-03 16:23:59 +00:00
|
|
|
i := OrderedCollection{ID: id, Type: CollectionType}
|
|
|
|
i.Name = NaturalLanguageValuesNew()
|
|
|
|
i.Content = NaturalLanguageValuesNew()
|
2018-06-09 12:05:46 +00:00
|
|
|
|
2018-04-09 11:10:27 +00:00
|
|
|
i.TotalItems = 0
|
|
|
|
|
|
|
|
return &i
|
|
|
|
}
|
|
|
|
|
2018-07-16 13:48:37 +00:00
|
|
|
// Append adds an element to an Inbox
|
2019-12-03 16:23:59 +00:00
|
|
|
func (i *Inbox) Append(ob Item) error {
|
2018-07-18 19:23:23 +00:00
|
|
|
i.OrderedItems = append(i.OrderedItems, ob)
|
|
|
|
i.TotalItems++
|
2018-07-16 13:48:37 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-07-18 19:23:23 +00:00
|
|
|
// GetID returns the ObjectID corresponding to Inbox
|
2019-12-03 16:23:59 +00:00
|
|
|
func (i Inbox) GetID() ObjectID {
|
2018-09-01 09:54:52 +00:00
|
|
|
return i.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 Inbox object
|
2019-12-03 16:23:59 +00:00
|
|
|
func (i Inbox) GetLink() IRI {
|
|
|
|
return IRI(i.ID)
|
2018-10-11 18:48:38 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 19:23:23 +00:00
|
|
|
// GetType returns the Inbox's type
|
2019-12-03 16:23:59 +00:00
|
|
|
func (i Inbox) GetType() ActivityVocabularyType {
|
2018-07-18 19:23:23 +00:00
|
|
|
return i.Type
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsLink returns false for an Inbox object
|
2018-10-04 19:04:31 +00:00
|
|
|
func (i Inbox) IsLink() bool {
|
2018-07-18 19:23:23 +00:00
|
|
|
return false
|
|
|
|
}
|
2018-07-18 19:34:08 +00:00
|
|
|
|
|
|
|
// IsObject returns true for a Inbox object
|
2018-10-04 19:04:31 +00:00
|
|
|
func (i Inbox) IsObject() bool {
|
2018-07-18 19:34:08 +00:00
|
|
|
return true
|
|
|
|
}
|
2018-07-24 21:11:08 +00:00
|
|
|
|
|
|
|
// UnmarshalJSON
|
|
|
|
func (i *Inbox) UnmarshalJSON(data []byte) error {
|
2019-12-03 16:23:59 +00:00
|
|
|
if ItemTyperFunc == nil {
|
|
|
|
ItemTyperFunc = JSONGetItemByType
|
2019-05-18 21:13:00 +00:00
|
|
|
}
|
2019-12-03 16:23:59 +00:00
|
|
|
c := OrderedCollection(*i)
|
2018-07-24 21:11:08 +00:00
|
|
|
err := c.UnmarshalJSON(data)
|
|
|
|
|
|
|
|
*i = Inbox(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 (i Inbox) Collection() CollectionInterface {
|
|
|
|
c := OrderedCollection(i)
|
2018-10-04 18:33:32 +00:00
|
|
|
return &c
|
2018-09-01 09:54:52 +00:00
|
|
|
}
|