go-fed / activity

ActivityStreams & ActivityPub in golang, oh my!
BSD 3-Clause "New" or "Revised" License
702 stars 111 forks source link

Clarification: can pub.Database.GetInbox and pub.Database.GetOutbox return an empty collection? #141

Open BenLubar opened 3 years ago

BenLubar commented 3 years ago

Is there any downside to returning an empty collection from GetInbox and GetOutbox without even checking the database? The documentation implies that these functions are only used as a source for a collection object to pass to SetInbox and SetOutbox, and that the modified content will always be additive when used with these two methods.

cjslep commented 3 years ago

You're correct, the GetInbox and GetOutbox on the database is for its own SetInbox and SetOutbox. go-fed will prepend any IRIs to any existing orderedItems property. If you return an OrderedCollection with no orderedItems property, it should create a new one.

Note that the GetInbox on FederatingProtocol and GetOutbox on the CommonBehavior are meant for handling the HTTP requests from peers and sending a OrderedCollection or OrderedCollectionPage in the response.

I'm open to suggestions on improvements (API, documentation, etc).