harrowMail

package
v0.0.0-...-a8e4d9d Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const ProgramName = "mail"

Variables

View Source
var (
	ActivityHandlers = map[string]NotificationHandler{}
)
View Source
var (
	TemplateFunctions = template.FuncMap{
		"indent": func(with string, text string) string {
			source := bytes.NewBufferString(text)
			result := bytes.NewBufferString("")
			lines := bufio.NewScanner(source)
			for lines.Scan() {
				fmt.Fprintf(result, "%s%s\n", with, lines.Text())
			}

			return result.String()
		},
	}
)

Functions

func Main

func Main()

func RegisterHandler

func RegisterHandler(name string, handler NotificationHandler)

Types

type Context

type Context struct {
	ToAddress   string
	FromAddress string
	UrlHost     string

	Activity  *domain.Activity
	Project   *domain.Project
	Job       *domain.Job
	Operation *domain.Operation
	Notifier  struct {
		Type     string
		Notifier interface{}
	}
}

func NewContext

func NewContext(fromAddress string) *Context

func (*Context) LoadFromDirectory

func (self *Context) LoadFromDirectory(dir File) error

func (*Context) MailTemplateDir

func (self *Context) MailTemplateDir(basedir string) (File, error)

func (*Context) ToMailContext

func (self *Context) ToMailContext() (*hmail.MailContext, error)

type File

type File interface {
	Name() string
	Open() (io.ReadCloser, error)
	Children() ([]File, error)
}

type Mail

type Mail struct {
	TemplateDir    File
	AttachmentsDir File
	From           *mail.Address
}

func NewMail

func NewMail(from string, templateDir, attachmentsDir File) (*Mail, error)

func (*Mail) Compose

func (self *Mail) Compose(ctxt *hmail.MailContext, to string) (*mail.Message, error)

type NotificationHandler

type NotificationHandler func(*Context) (*hmail.MailContext, error)

func OnOperation

func OnOperation(actionName string) NotificationHandler

type OSFile

type OSFile struct {
	File *os.File
}

func NewOSFile

func NewOSFile(f *os.File) *OSFile

func (*OSFile) Children

func (self *OSFile) Children() ([]File, error)

func (*OSFile) Name

func (self *OSFile) Name() string

func (*OSFile) Open

func (self *OSFile) Open() (io.ReadCloser, error)

Jump to

Keyboard shortcuts

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