storage

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package storage handles all database actions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close will close the database, and delete if a temporary table

func CountRead

func CountRead() int

CountRead returns the number of emails in the database that are read.

func CountTotal

func CountTotal() int

CountTotal returns the number of emails in the database

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

func DeleteOneMessage(id string) error

DeleteOneMessage will delete a single message from a mailbox

func GetAttachmentPart

func GetAttachmentPart(id, partID string) (*enmime.Part, error)

GetAttachmentPart returns an *enmime.Part (attachment or inline) from a message

func GetMessageRaw

func GetMessageRaw(id string) ([]byte, error)

GetMessageRaw returns an []byte of the full message

func InitDB

func InitDB() error

InitDB will initialise the database

func IsUnread

func IsUnread(id string) bool

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 MarkAllRead

func MarkAllRead() error

MarkAllRead will mark all messages as read

func MarkAllUnread

func MarkAllUnread() error

MarkAllUnread will mark all messages as unread

func MarkRead

func MarkRead(id string) error

MarkRead will mark a message as read

func MarkUnread

func MarkUnread(id string) error

MarkUnread will mark a message as unread

func SetTags added in v1.2.8

func SetTags(id string, tags []string) error

SetTags will set the tags for a given message ID, used via API

func Store

func Store(body []byte) (string, error)

Store will save an email to the database tables

Types

type Attachment

type Attachment struct {
	PartID      string
	FileName    string
	ContentType string
	ContentID   string
	Size        int
}

Attachment struct for inline and attachments

func AttachmentSummary

func AttachmentSummary(a *enmime.Part) Attachment

AttachmentSummary returns a summary of the attachment without any binary data

type DBMailSummary

type DBMailSummary struct {
	Created     time.Time
	From        *mail.Address
	To          []*mail.Address
	Cc          []*mail.Address
	Bcc         []*mail.Address
	Subject     string
	Size        int
	Inline      int
	Attachments int
}

DBMailSummary struct for storing mail summary

type MailboxStats

type MailboxStats struct {
	Total  int
	Unread int
	Tags   []string
}

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 {
	ID          string
	Read        bool
	From        *mail.Address
	To          []*mail.Address
	Cc          []*mail.Address
	Bcc         []*mail.Address
	Subject     string
	Date        time.Time
	Tags        []string
	Text        string
	HTML        string
	Size        int
	Inline      []Attachment
	Attachments []Attachment
}

Message struct for loading messages. It does not include physical attachments.

func GetMessage

func GetMessage(id string) (*Message, error)

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 {
	ID          string
	Read        bool
	From        *mail.Address
	To          []*mail.Address
	Cc          []*mail.Address
	Bcc         []*mail.Address
	Subject     string
	Created     time.Time
	Tags        []string
	Size        int
	Attachments int
}

MessageSummary struct for frontend messages

func List

func List(start, limit int) ([]MessageSummary, error)

List returns a subset of messages from the mailbox, sorted latest to oldest

func Search(search string, start, limit int) ([]MessageSummary, error)

Search will search a mailbox for search terms. The search is broken up by segments (exact phrases can be quoted), and interprits 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 `!`

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL