Documentation
¶
Index ¶
Constants ¶
const ( // BoxRoot is the root box when we want to add boxes without a parent ID BoxRoot = iota // BoxInbox is the mandatory inbox where all incoming messages are stored BoxInbox // Always box 1 // BoxOutbox is the mandatory outbox where send messages are stored BoxOutbox // Always box 2 // BoxTrash is the mandatory trashcan where deleted messages are stored (before actual deletion) BoxTrash // Always box 3 )
const MaxMandatoryBoxID = 99
MaxMandatoryBoxID is the largest box that must be present. Everything below this box (including this box) is mandatory and cannot be removed.
Variables ¶
var MandatoryBoxes = []int{BoxInbox, BoxOutbox, BoxTrash}
MandatoryBoxes is a list of all boxes that are mandatory. Makes it easier to range on them
Functions ¶
This section is empty.
Types ¶
type AddressRepository ¶
type AddressRepository interface { Create(addr hash.Hash, pubKey bmcrypto.PubKey) error Exists(addr hash.Hash) bool Delete(addr hash.Hash) error }
AddressRepository creates, checks or deletes complete accounts. Address is not the correct word for this.
type BoxInfo ¶
type BoxInfo struct { ID int `json:"id"` Total int `json:"total"` Messages []string `json:"messages"` }
BoxInfo returns information about the given message box
type BoxRepository ¶
type BoxRepository interface { CreateBox(addr hash.Hash, parentBox int) error ExistsBox(addr hash.Hash, box int) bool DeleteBox(addr hash.Hash, box int) error GetBoxInfo(addr hash.Hash, box int) (*BoxInfo, error) GetAllBoxes(addr hash.Hash) ([]BoxInfo, error) }
BoxRepository deals with message boxes insides an account
type KeyRepository ¶
type KeyRepository interface { // Public key StoreKey(addr hash.Hash, key bmcrypto.PubKey) error FetchKeys(addr hash.Hash) ([]bmcrypto.PubKey, error) }
KeyRepository gets and sets public keys into an account
type MessageList ¶
type MessageList struct { Meta MetaType Messages []MessageType `json:"messages"` }
MessageList is a list of messages we return
type MessageRepository ¶
type MessageRepository interface { CreateMessage(addr hash.Hash, msgID string) error RemoveMessage(addr hash.Hash, msgID string) error AddToBox(addr hash.Hash, boxID int, msgID string) error RemoveFromBox(addr hash.Hash, boxID int, msgID string) error // Message boxes FetchListFromBox(addr hash.Hash, box int, since time.Time, offset, limit int) (*MessageList, error) // Fetch specific message contents FetchMessageHeader(addr hash.Hash, messageID string) (*message.Header, error) FetchMessageCatalog(addr hash.Hash, messageID string) ([]byte, error) FetchMessageBlock(addr hash.Hash, messageID, blockID string) ([]byte, error) FetchMessageAttachment(addr hash.Hash, messageID, attachmentID string) (r io.ReadCloser, size int64, err error) }
MessageRepository deals with message within boxes
type MessageType ¶
type MessageType struct { ID string `json:"id"` Header message.Header `json:"header"` Catalog []byte `json:"catalog"` }
MessageType is a simple message structure that we return as a list
type MetaType ¶
type MetaType struct { Total int `json:"total"` Returned int `json:"returned"` Limit int `json:"limit"` Offset int `json:"offset"` }
MetaType is a structure that holds meta information about a list
type OrganisationRepository ¶ added in v0.0.1
type OrganisationRepository interface { StoreOrganisationSettings(addr hash.Hash, settings OrganisationSettings) error FetchOrganisationSettings(addr hash.Hash) (*OrganisationSettings, error) }
OrganisationRepository gets and sets organisation settings into an account
type OrganisationSettings ¶
type OrganisationSettings struct {
OnlyAllowAccountsOnMainServer bool `json:"only_allow_main_server_accounts"`
}
OrganisationSettings defines settings for organisations
type Repository ¶
type Repository interface { AddressRepository KeyRepository BoxRepository MessageRepository OrganisationRepository }
Repository is the main repository that needs to be implemented. It's pretty big
func NewFileRepository ¶
func NewFileRepository(basePath string) Repository
NewFileRepository returns a new file repository
func NewMockRepository ¶
func NewMockRepository() Repository
NewMockRepository returns a new mock repository by creating a file system with the afero memory mapped fs