Documentation ¶
Overview ¶
Package storage handles all database actions
Index ¶
- func BroadcastMailboxStats()
- func Close()
- func CountRead() int
- func CountTotal() int
- func CountUnread() int
- func DeleteAllMessages() error
- func DeleteOneMessage(id string) error
- func DeleteSearch(search string) error
- func GetAllTags() []string
- func GetAttachmentPart(id, partID string) (*enmime.Part, error)
- func GetMessageRaw(id string) ([]byte, error)
- func InitDB() error
- func IsUnread(id string) bool
- func MarkAllRead() error
- func MarkAllUnread() error
- func MarkRead(id string) error
- func MarkUnread(id string) error
- func MessageIDExists(id string) bool
- func Reindex(id string) error
- func ReindexAll()
- func SetTags(id string, tags []string) error
- func Store(body []byte) (string, error)
- type Attachment
- type DBMailSummary
- type MailboxStats
- type Message
- type MessageSummary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BroadcastMailboxStats ¶
func BroadcastMailboxStats()
BroadcastMailboxStats broadcasts the total number of messages displayed to the web UI, as well as the total unread messages. The lookup is very fast (< 10ms / 100k messages under load). Rate limited to 4x per second.
func CountRead ¶
func CountRead() int
CountRead returns the number of emails in the database that are read.
func CountUnread ¶
func CountUnread() int
CountUnread returns the number of emails in the database that are unread.
func DeleteAllMessages ¶
func DeleteAllMessages() error
DeleteAllMessages will delete all messages from a mailbox
func DeleteOneMessage ¶
DeleteOneMessage will delete a single message from a mailbox
func DeleteSearch ¶
DeleteSearch will delete all messages for search terms. The search is broken up by segments (exact phrases can be quoted), and interprets specific terms such as: is:read, is:unread, has:attachment, to:<term>, from:<term> & subject:<term> Negative searches also also included by prefixing the search term with a `-` or `!`
func GetAttachmentPart ¶
GetAttachmentPart returns an *enmime.Part (attachment or inline) from a message
func GetMessageRaw ¶
GetMessageRaw returns an []byte of the full message
func IsUnread ¶
IsUnread returns the number of emails in the database that are unread. If an ID is supplied, then it is just limited to that message.
func MessageIDExists ¶
MessageIDExists checks whether a Message-ID exists in the DB
func Reindex ¶ added in v1.9.5
Reindex will regenerate the search text and snippet for a message and update the database.
func ReindexAll ¶ added in v1.9.5
func ReindexAll()
ReindexAll will regenerate the search text and snippet for a message and update the database.
Types ¶
type Attachment ¶
type Attachment struct { // Attachment part ID PartID string // File name FileName string // Content type ContentType string // Content ID ContentID string // Size in bytes Size int }
Attachment struct for inline and attachments
swagger:model Attachment
func AttachmentSummary ¶
func AttachmentSummary(a *enmime.Part) Attachment
AttachmentSummary returns a summary of the attachment without any binary data
type DBMailSummary ¶
type DBMailSummary struct { From *mail.Address To []*mail.Address Cc []*mail.Address Bcc []*mail.Address }
DBMailSummary struct for storing mail summary
type MailboxStats ¶
MailboxStats struct for quick mailbox total/read lookups
func StatsGet ¶
func StatsGet() MailboxStats
StatsGet returns the total/unread statistics for a mailbox
type Message ¶
type Message struct { // Database ID ID string // Message ID MessageID string // From address From *mail.Address // To addresses To []*mail.Address // Cc addresses Cc []*mail.Address // Bcc addresses Bcc []*mail.Address // ReplyTo addresses ReplyTo []*mail.Address // Return-Path ReturnPath string // Message subject Subject string // Message date if set, else date received Date time.Time // Message tags Tags []string // Message body text Text string // Message body HTML HTML string // Message size in bytes Size int // Inline message attachments Inline []Attachment // Message attachments Attachments []Attachment }
Message data excluding physical attachments
swagger:model Message
func GetMessage ¶
GetMessage returns a Message generated from the mailbox_data collection. If the message lacks a date header, then the received datetime is used.
type MessageSummary ¶
type MessageSummary struct { // Database ID ID string // Message ID MessageID string // Read status Read bool // From address From *mail.Address // To address To []*mail.Address // Cc addresses Cc []*mail.Address // Bcc addresses Bcc []*mail.Address // Email subject Subject string // Created time Created time.Time // Message tags Tags []string // Message size in bytes (total) Size int // Whether the message has any attachments Attachments int // Message snippet includes up to 250 characters Snippet string }
MessageSummary struct for frontend messages
swagger:model MessageSummary
func List ¶
func List(start, limit int) ([]MessageSummary, error)
List returns a subset of messages from the mailbox, sorted latest to oldest
func Search ¶
func Search(search string, start, limit int) ([]MessageSummary, int, error)
Search will search a mailbox for search terms. The search is broken up by segments (exact phrases can be quoted), and interprets specific terms such as: is:read, is:unread, has:attachment, to:<term>, from:<term> & subject:<term> Negative searches also also included by prefixing the search term with a `-` or `!`