Documentation ¶
Overview ¶
Package lib contains various libs used within the main app
Index ¶
- Variables
- func ByteCountSI(b uint32) string
- func Connect() *client.Client
- func CreateDir(path string) error
- func DetectTrash(cReader *client.Client) (string, error)
- func FileExists(path string) bool
- func HandleMessage(msg *imap.Message, rule Rule) (string, int, error)
- func InStringSlice(val string, slice []string) bool
- func ListMailboxes(cReader *client.Client)
- func PrettyPrint(i interface{})
- func PrintHdrDetails(msg *imap.Message)
- func ReadConfig(file string)
- func SaveAttachment(b []byte, emailAddress, fileName string, timestamp time.Time) (string, error)
- func Truncate(raw string, length int) string
- func TruncateFromAddress(from []*imap.Address) string
- type DeletedAttachment
- type Rule
- type YamlConfig
Constants ¶
This section is empty.
Variables ¶
var ( // Config module global Config = YamlConfig{} )
var (
// Log global
Log *logger.Logger
)
Functions ¶
func ByteCountSI ¶
ByteCountSI returns a human-readable size from bytes
func DetectTrash ¶
DetectTrash will return the trash folder of a Gmail account, if applicable Gmail only supports moving to the trash
func HandleMessage ¶
HandleMessage will process an imap message
func InStringSlice ¶
InStringSlice returns whether a value is in a string slice
func ListMailboxes ¶
ListMailboxes returns a list of Mailboxes on the server
func PrettyPrint ¶
func PrettyPrint(i interface{})
PrettyPrint outputs a JSON-encoded representation of an interface
func PrintHdrDetails ¶
func PrintHdrDetails(msg *imap.Message)
PrintHdrDetails returns a IMAP search result
func ReadConfig ¶
func ReadConfig(file string)
ReadConfig reads & parses the config into global config
func SaveAttachment ¶
SaveAttachment will save an attachment to <outdir>/<email>/<hash>-<filename> returns the output file path and/or error
func TruncateFromAddress ¶
func TruncateFromAddress(from []*imap.Address) string
TruncateFromAddress returns a formatted and truncated From address
Types ¶
type DeletedAttachment ¶
DeletedAttachment struct
type Rule ¶
type Rule struct { Mailbox string `yaml:"mailbox"` Size uint32 `yaml:"min_size"` // KB OlderThan int `yaml:"older_than"` // days From string `yaml:"from"` To string `yaml:"to"` Subject string `yaml:"subject"` Body string `yaml:"body"` Text string `yaml:"text"` Actions string `yaml:"actions"` IncludeUnread bool `yaml:"include_unread"` IncludeStarred bool `yaml:"include_starred"` }
Rule struct
func (Rule) RemoveAttachments ¶
RemoveAttachments returns whether a rule is set to delete messages
func (Rule) SaveAttachments ¶
SaveAttachments returns whether a rule is set to delete messages
type YamlConfig ¶
type YamlConfig struct { Name string `yaml:"name"` Host string `yaml:"host"` SSL *bool `yaml:"ssl"` Port *int `yaml:"port"` User string `yaml:"user"` Pass string `yaml:"pass"` SavePath string `yaml:"save_path"` UseTrash bool `yaml:"use_trash"` Rules []Rule `yaml:"rules"` }
YamlConfig config struct