lib

package
v0.0.0-...-85b5027 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package lib contains various libs used within the main app

Index

Constants

This section is empty.

Variables

View Source
var (
	// Config module global
	Config = YamlConfig{}
)
View Source
var (
	// Log global
	Log *logger.Logger
)

Functions

func ByteCountSI

func ByteCountSI(b uint32) string

ByteCountSI returns a human-readable size from bytes

func Connect

func Connect() *client.Client

Connect returns a *client.Client

func CreateDir

func CreateDir(path string) error

CreateDir will check if a directory exists, and create it if not

func DetectTrash

func DetectTrash(cReader *client.Client) (string, error)

DetectTrash will return the trash folder of a Gmail account, if applicable Gmail only supports moving to the trash

func FileExists

func FileExists(path string) bool

FileExists checks if a file exists

func HandleMessage

func HandleMessage(msg *imap.Message, rule Rule) (string, int, error)

HandleMessage will process an imap message

func InStringSlice

func InStringSlice(val string, slice []string) bool

InStringSlice returns whether a value is in a string slice

func ListMailboxes

func ListMailboxes(cReader *client.Client)

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

func SaveAttachment(b []byte, emailAddress, fileName string, timestamp time.Time) (string, error)

SaveAttachment will save an attachment to <outdir>/<email>/<hash>-<filename> returns the output file path and/or error

func Truncate

func Truncate(raw string, length int) string

Truncate will return a truncates string

func TruncateFromAddress

func TruncateFromAddress(from []*imap.Address) string

TruncateFromAddress returns a formatted and truncated From address

Types

type DeletedAttachment

type DeletedAttachment struct {
	Filename string
	MimeType string
	Size     string
}

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) Delete

func (r Rule) Delete() bool

Delete returns whether a rule is set to delete messages

func (Rule) RemoveAttachments

func (r Rule) RemoveAttachments() bool

RemoveAttachments returns whether a rule is set to delete messages

func (Rule) SaveAttachments

func (r Rule) SaveAttachments() bool

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

Directories

Path Synopsis
Package updater handles all internal package updating
Package updater handles all internal package updating

Jump to

Keyboard shortcuts

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