Documentation
¶
Overview ¶
Contains a generic interface for backends.
Index ¶
- Constants
- func ArmorMessage(w io.Writer) (io.WriteCloser, error)
- func IsEncrypted(data string) bool
- func MessagesTotalFromCounts(counts []*MessagesCount) (totals *MessagesTotal, unread *MessagesTotal)
- type Address
- type AddressUpdate
- type AddressesBackend
- type Attachment
- type AttachmentKey
- type AttachmentsBackend
- type Backend
- type Contact
- type ContactUpdate
- type ContactsBackend
- type Conversation
- type ConversationLabel
- type ConversationsBackend
- type Domain
- type DomainsBackend
- type Email
- type Event
- func NewContactDeltaEvent(id string, action EventAction, contact *Contact) *Event
- func NewConversationDeltaEvent(id string, action EventAction, conv *Conversation) *Event
- func NewLabelDeltaEvent(id string, action EventAction, label *Label) *Event
- func NewMessageDeltaEvent(id string, action EventAction, msg *Message) *Event
- func NewUserEvent(user *User) *Event
- type EventAction
- type EventContactDelta
- type EventConversationDelta
- type EventDelta
- type EventLabelDelta
- type EventMessageDelta
- type EventsBackend
- type Keypair
- type KeysBackend
- type Label
- type LabelTotal
- type LabelType
- type LabelUpdate
- type LabelsBackend
- type LabelsOperation
- type LocationTotal
- type Message
- type MessagePackage
- type MessageUpdate
- type MessagesBackend
- type MessagesCount
- type MessagesFilter
- type MessagesTotal
- type OutgoingAttachment
- type OutgoingMessage
- type SendBackend
- type User
- type UserUpdate
- type UsersBackend
Constants ¶
const ( InboxLabel string = "0" DraftLabel = "1" SentLabel = "2" TrashLabel = "3" SpamLabel = "4" ArchiveLabel = "6" StarredLabel = "10" )
System labels
const ( DraftType int = 1 SentType = 2 SentToMyselfType = 3 )
Message types.
const ( Unencrypted int = 0 EndToEndEncryptedInternal = 1 EncryptedExternal = 2 EndToEndEncryptedExternal = 3 StoredEncryptedExternal = 4 StoredEncrypted = 5 EndToEndEncryptedExternalReply = 6 EncryptedPgp = 7 EncryptedPgpMime = 8 )
Message encryption types.
const ( InboxLocation int = 0 DraftLocation = 1 SentLocation = 2 TrashLocation = 3 SpamLocation = 4 ArchiveLocation = 6 )
Messages locations.
const ( RoleFreeUser int = iota RolePaidMember RolePaidAdmin )
const PgpMessageType = "PGP MESSAGE"
Variables ¶
This section is empty.
Functions ¶
func ArmorMessage ¶
func ArmorMessage(w io.Writer) (io.WriteCloser, error)
Encode a PGP message armor.
func IsEncrypted ¶
Check if a string contains an encrypted message.
func MessagesTotalFromCounts ¶
func MessagesTotalFromCounts(counts []*MessagesCount) (totals *MessagesTotal, unread *MessagesTotal)
Types ¶
type Address ¶
type Address struct { ID string DomainID string Email string Send int Receive int Status int Type int DisplayName string Signature string MemberID string MemberName string HasKeys int Keys []*Keypair }
A user's address.
type AddressUpdate ¶
type AddressUpdate struct { Address *Address Status bool Type bool DisplayName bool Signature bool }
func (*AddressUpdate) Apply ¶
func (update *AddressUpdate) Apply(address *Address)
type AddressesBackend ¶
type AddressesBackend interface { // Get a user's address. GetAddress(user, id string) (*Address, error) // List all addresses owned by a user. ListAddresses(user string) ([]*Address, error) // Create a new address. InsertAddress(user string, address *Address) (*Address, error) // Update an existing address. UpdateAddress(user string, update *AddressUpdate) (*Address, error) // Delete an address. DeleteAddress(user, id string) error }
type Attachment ¶
type Attachment struct { ID string MessageID string `json:",omitempty"` Name string Size int MIMEType string KeyPackets string `json:",omitempty"` Headers textproto.MIMEHeader DataPacket string `json:",omitempty"` // TODO: remove this from here }
An attachment.
type AttachmentKey ¶
type AttachmentsBackend ¶
type AttachmentsBackend interface { // List all message's attachments. ListAttachments(user, msg string) ([]*Attachment, error) // Get an attachment content. ReadAttachment(user, id string) (*Attachment, []byte, error) // Insert a new attachment. InsertAttachment(user string, attachment *Attachment, contents []byte) (*Attachment, error) // Delete an attachment. DeleteAttachment(user, id string) error }
Stores attachments.
type Backend ¶
type Backend struct { ContactsBackend LabelsBackend ConversationsBackend SendBackend DomainsBackend EventsBackend UsersBackend AddressesBackend KeysBackend AttachmentsBackend }
A backend takes care of storing all mailbox data.
type ContactUpdate ¶
A request to update a contact. Fields set to true will be updated with values in Contact.
func (*ContactUpdate) Apply ¶
func (update *ContactUpdate) Apply(contact *Contact)
Apply this update on a contact.
type ContactsBackend ¶
type ContactsBackend interface { // List all user's contacts. ListContacts(user string) ([]*Contact, error) // Insert a new contact. InsertContact(user string, contact *Contact) (*Contact, error) // Update an existing contact. UpdateContact(user string, update *ContactUpdate) (*Contact, error) // Delete a contact. DeleteContact(user, id string) error // Delete all contacts of a specific user. DeleteAllContacts(user string) error }
Stores contacts data.
type Conversation ¶
type Conversation struct { ID string Order int Subject string Senders []*Email Recipients []*Email NumMessages int NumUnread int NumAttachments int ExpirationTime int TotalSize int Time int64 LabelIDs []string Labels []*ConversationLabel }
A conversation is a sequence of messages.
type ConversationLabel ¶
Contains messages counts by labels.
type ConversationsBackend ¶
type ConversationsBackend interface { MessagesBackend // List all messages belonging to a conversation. ListConversationMessages(user, id string) (msgs []*Message, err error) // Get a specific conversation. GetConversation(user, id string) (conv *Conversation, err error) // List all user's conversations. A message filter can be provided. ListConversations(user string, filter *MessagesFilter) ([]*Conversation, int, error) // Count all user's conversations by label. CountConversations(user string) ([]*MessagesCount, error) // Permanently delete a conversation. DeleteConversation(user, id string) error }
Stores conversations data.
type Domain ¶
type Domain struct { ID string DomainName string State int VerifyState int MxState int SpfState int DkimState int DmarcState int Addresses []*Address }
A domain name.
type DomainsBackend ¶
type DomainsBackend interface { // List all domains. ListDomains() ([]*Domain, error) // Get a domain. GetDomain(id string) (*Domain, error) // Get the domain which has the specified name. GetDomainByName(name string) (*Domain, error) // Insert a new domain. InsertDomain(domain *Domain) (*Domain, error) }
Stores domains data.
type Event ¶
type Event struct { ID string `json:"EventID"` Refresh int Reload int Notices []string // See https://github.com/ProtonMail/WebClient/blob/master/src/app/services/event.js#L274 Messages []*EventMessageDelta `json:",omitempty"` Conversations []*EventConversationDelta `json:",omitempty"` MessageCounts []*MessagesCount `json:",omitempty"` ConversationCounts []*MessagesCount `json:",omitempty"` Total *MessagesTotal `json:",omitempty"` Unread *MessagesTotal `json:",omitempty"` Labels []*EventLabelDelta `json:",omitempty"` Contacts []*EventContactDelta `json:",omitempty"` User *User `json:",omitempty"` UsedSpace int `json:",omitempty"` }
func NewContactDeltaEvent ¶
func NewContactDeltaEvent(id string, action EventAction, contact *Contact) *Event
func NewConversationDeltaEvent ¶
func NewConversationDeltaEvent(id string, action EventAction, conv *Conversation) *Event
func NewLabelDeltaEvent ¶
func NewLabelDeltaEvent(id string, action EventAction, label *Label) *Event
func NewMessageDeltaEvent ¶
func NewMessageDeltaEvent(id string, action EventAction, msg *Message) *Event
func NewUserEvent ¶
type EventAction ¶
type EventAction int
const ( EventDelete EventAction = iota EventCreate EventUpdate )
type EventContactDelta ¶
type EventContactDelta struct { EventDelta Contact *Contact }
type EventConversationDelta ¶
type EventConversationDelta struct { EventDelta Conversation *Conversation }
type EventDelta ¶
type EventDelta struct { ID string Action EventAction }
type EventLabelDelta ¶
type EventLabelDelta struct { EventDelta Label *Label }
type EventMessageDelta ¶
type EventMessageDelta struct { EventDelta Message *Message }
type EventsBackend ¶
type EventsBackend interface { // Insert a new event. InsertEvent(user string, event *Event) error // Get the last event. GetLastEvent(user string) (*Event, error) // Get the sum of all events after a specific one. GetEventsAfter(user, id string) (*Event, error) // Delete all user's events. This happens when the user is no longer connected. DeleteAllEvents(user string) error }
Stores events data.
type Keypair ¶
type Keypair struct { ID string PublicKey string PrivateKey string Fingerprint string // TODO: populate this field }
A keypair contains a private and a public key.
type KeysBackend ¶
type KeysBackend interface { // Get a public key for a user. // If no key is available, an empty string and no error must be returned. GetPublicKey(email string) (string, error) // Get a keypair for a user. Contains public & private key. GetKeypair(email string) (*Keypair, error) // Create a new keypair. InsertKeypair(email string, keypair *Keypair) (*Keypair, error) // Update a user's private key. // PublicKey must be updated only if it isn't empty. UpdateKeypair(email string, keypair *Keypair) (*Keypair, error) }
type Label ¶
type Label struct { ID string Name string Color string Display int Type LabelType Exclusive int Order int }
A message label.
type LabelTotal ¶
type LabelUpdate ¶
A request to update a label. Fields set to true will be updated with values in Label.
func (*LabelUpdate) Apply ¶
func (update *LabelUpdate) Apply(label *Label)
Apply this update on a label.
type LabelsBackend ¶
type LabelsBackend interface { // List all user's labels. ListLabels(user string) ([]*Label, error) // Insert a new label. InsertLabel(user string, label *Label) (*Label, error) // Update an existing label. UpdateLabel(user string, update *LabelUpdate) (*Label, error) // Delete a label. DeleteLabel(user, id string) error }
Stores labels data.
type LabelsOperation ¶
type LabelsOperation int
The operation to apply to labels.
const ( KeepLabels LabelsOperation = iota // Do nothing ReplaceLabels // Replace current labels with new ones AddLabels // Add new labels to current ones RemoveLabels // Remove specified labels from current ones )
type LocationTotal ¶
type Message ¶
type Message struct { ID string Order int ConversationID string Subject string IsRead int Type int SenderAddress string SenderName string Sender *Email ToList []*Email CCList []*Email BCCList []*Email Time int64 Size int HasAttachment int NumAttachments int IsEncrypted int ExpirationTime int IsReplied int IsRepliedAll int IsForwarded int AddressID string Body string `json:",omitempty"` Header string `json:",omitempty"` ReplyTo *Email Attachments []*Attachment Starred int Location int LabelIDs []string }
A message.
type MessagePackage ¶
type MessageUpdate ¶
type MessageUpdate struct { Message *Message ToList bool CCList bool BCCList bool Subject bool IsRead bool Type bool AddressID bool Body bool Time bool Starred bool LabelIDs LabelsOperation }
A request to update a message. Fields set to true will be updated with values in Message.
func (*MessageUpdate) Apply ¶
func (update *MessageUpdate) Apply(msg *Message)
Apply this update on a message.
type MessagesBackend ¶
type MessagesBackend interface { // Get a message. GetMessage(user, id string) (*Message, error) // List all user's messages. A message filter can be provided. ListMessages(user string, filter *MessagesFilter) ([]*Message, int, error) // Count all user's messages by label. CountMessages(user string) ([]*MessagesCount, error) // Insert a new message. InsertMessage(user string, msg *Message) (*Message, error) // Update an existing message. UpdateMessage(user string, update *MessageUpdate) (*Message, error) // Permanently delete a message. DeleteMessage(user, id string) error }
Stores messages data.
type MessagesCount ¶
Contains message counts for one label.
type MessagesFilter ¶
type MessagesFilter struct { Limit int Page int Label string Keyword string Address string // Address ID Attachments bool From string To string Begin int64 // Timestamp End int64 // Timestamp Sort string Desc bool }
Contains fields to filter messages.
type MessagesTotal ¶
type MessagesTotal struct { Locations []*LocationTotal Labels []*LabelTotal Starred int }
Contains a summary of messages counts per location and label.
type OutgoingAttachment ¶
type OutgoingAttachment struct { *Attachment Data []byte }
An attachment that is going to be sent.
type OutgoingMessage ¶
type OutgoingMessage struct { *Message *MessagePackage InReplyTo string References string Attachments []*OutgoingAttachment }
A message that is going to be sent. Message.Body MUST be ignored, MessagePackage.Body MUST be used instead. The recipient is specified in MessagePackage.Address.
type SendBackend ¶
type SendBackend interface { // Send a message to an e-mail address. SendMessage(user string, msg *OutgoingMessage) error }
Sends messages to email addresses.
type User ¶
type User struct { ID string Name string NotificationEmail string Signature string NumMessagePerPage int UsedSpace int Notify int AutoSaveContacts int Language string LogAuth int ComposerMode int MessageButtons int ShowImages int ShowEmbedded int ViewMode int ViewLayout int SwipeLeft int SwipeRight int Theme string Currency string Credit int InvoiceText string AlsoArchive int Hotkeys int PMSignature int TwoFactor int PasswordReset int PasswordMode int News int DisplayName string MaxSpace int MaxUpload int Role int Private int Subscribed int Deliquent int VPN interface{} Addresses []*Address Keys []*Keypair }
A user.
func (*User) GetMainAddress ¶
type UserUpdate ¶
type UserUpdate struct { User *User DisplayName bool Signature bool AutoSaveContacts bool ShowImages bool ComposerMode bool ViewLayout bool MessageButtons bool Theme bool }
A request to update a user. Fields set to true will be updated with values in User.
type UsersBackend ¶
type UsersBackend interface { // Check if a username is available. IsUsernameAvailable(username string) (bool, error) // Get a user. GetUser(id string) (*User, error) // Check if the provided username and password are correct Auth(username, password string) (*User, error) // Insert a new user. Returns the newly created user. InsertUser(user *User, password string) (*User, error) // Update an existing user. UpdateUser(update *UserUpdate) error // Update a user's password. UpdateUserPassword(id, current, new string) error }
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Stores data in files on disk.
|
Stores data in files on disk. |
Provides backends to trigger events.
|
Provides backends to trigger events. |
Stores messages on an IMAP server.
|
Stores messages on an IMAP server. |
Stores data in memory.
|
Stores data in memory. |
Sends messages with a SMTP server.
|
Sends messages with a SMTP server. |
Backend utilities.
|
Backend utilities. |
textproto
Provides utilities to parse and format messages.
|
Provides utilities to parse and format messages. |
textproto/chunksplit
Provides a chunk splitter.
|
Provides a chunk splitter. |