Documentation ¶
Index ¶
- Constants
- Variables
- func Start(config *model.Config) error
- type Attachment
- type Log
- func (l *Log) Debug(args ...interface{})
- func (l *Log) Debugf(format string, v ...interface{})
- func (l *Log) Error(args ...interface{})
- func (l *Log) Errorf(format string, v ...interface{})
- func (l *Log) Info(args ...interface{})
- func (l *Log) Infof(format string, v ...interface{})
- func (l *Log) Write(p []byte) (n int, err error)
- type Logger
- type MailHandler
- type MailMessage
- type MailProvider
- type MailProviderImap
- type MatterMail
- type MattermostProvider
- type MattermostProviderV3
- type MattermostProviderV4
- type UIDCache
- type UIDCacheFile
Constants ¶
const ( EmailTypeHTML = iota EmailTypeText )
Emails content type
const MailBox = "INBOX"
MailBox default mail box
Variables ¶
var ErrEmptyUID = errors.New("Empty UID stored or invalid UIDVALIDITY")
ErrEmptyUID error when is empty UID stored or invalid UIDVALIDITY
var ErrUIDValidityZero = errors.New("uidvalidity need to be greater than zero")
ErrUIDValidityZero error when UIDVALIDITY is zero
Functions ¶
Types ¶
type Attachment ¶
Attachment filename and content
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log implements Logger interface
type Logger ¶
type Logger interface { Info(args ...interface{}) Debug(args ...interface{}) Error(args ...interface{}) Debugf(format string, v ...interface{}) Infof(format string, v ...interface{}) Errorf(format string, v ...interface{}) Write(p []byte) (n int, err error) }
Logger default interface logger with info/debug/error
type MailHandler ¶
MailHandler function called to handle mail message
type MailMessage ¶
type MailMessage struct { From string To string Subject string EmailText string EmailBody string EmailType int Attachments []*Attachment }
MailMessage mail message with fields used in mattermail
func ReadMailMessage ¶
func ReadMailMessage(r io.Reader) (*MailMessage, error)
ReadMailMessage convert net/mail in MailMessage
type MailProvider ¶
type MailProvider interface { // CheckNewMessage gets new email from server CheckNewMessage(handler MailHandler) error // WaitNewMessage waits for a new message (idle or time.Sleep) WaitNewMessage(timeout int) error // Terminate mail connection Terminate() error }
MailProvider interface to abstract email connection
type MailProviderImap ¶
type MailProviderImap struct {
// contains filtered or unexported fields
}
MailProviderImap implements MailProvider using imap
func NewMailProviderImap ¶
func NewMailProviderImap(cfg *model.Email, log Logger, cache UIDCache, debug bool) *MailProviderImap
NewMailProviderImap creates a new MailProviderImap implementing MailProvider
func (*MailProviderImap) CheckNewMessage ¶
func (m *MailProviderImap) CheckNewMessage(handler MailHandler) error
CheckNewMessage gets new email from server
func (*MailProviderImap) Terminate ¶
func (m *MailProviderImap) Terminate() error
Terminate imap connection
func (*MailProviderImap) WaitNewMessage ¶
func (m *MailProviderImap) WaitNewMessage(timeout int) error
WaitNewMessage waits for a new message (idle or time.Sleep)
type MatterMail ¶
type MatterMail struct {
// contains filtered or unexported fields
}
MatterMail struct with configurations, loggers and Mattemost user
func NewMatterMail ¶
func NewMatterMail(cfg *model.Profile, log Logger, mailProvider MailProvider, mmProvider MattermostProvider) *MatterMail
NewMatterMail creates a new MatterMail instance
func (*MatterMail) PostMailMessage ¶
func (m *MatterMail) PostMailMessage(msg *MailMessage) error
PostMailMessage MailMessage in Mattermost
func (*MatterMail) PostNetMail ¶
func (m *MatterMail) PostNetMail(mailReader io.Reader) error
PostNetMail read net/mail.Message and post in Mattermost
type MattermostProvider ¶
type MattermostProvider interface { // Login log in Mattermost Login() error // Logout terminate connection with Mattermost Logout() error // GetChannelID gets channel id by channel name return empty string if not exists GetChannelID(channelName string) string // PostMessage posts a message in Mattermost PostMessage(message, channelID string, attachments []*Attachment) error }
MattermostProvider interface to abstract Mattermost functions
func NewMattermostProvider ¶
func NewMattermostProvider(cfg *model.Mattermost, log Logger) MattermostProvider
NewMattermostProvider creates a new instance of Mattermost
type MattermostProviderV3 ¶
type MattermostProviderV3 struct {
// contains filtered or unexported fields
}
MattermostProviderV3 default implementation of MattermostProvider
func NewMattermostProviderV3 ¶
func NewMattermostProviderV3(cfg *model.Mattermost, log Logger) *MattermostProviderV3
NewMattermostProviderV3 creates a new instance of Mattermost api V3
func (*MattermostProviderV3) GetChannelID ¶
func (m *MattermostProviderV3) GetChannelID(channelName string) string
GetChannelID gets channel id by channel name return empty string if not exists
func (*MattermostProviderV3) Login ¶
func (m *MattermostProviderV3) Login() error
Login log in Mattermost
func (*MattermostProviderV3) Logout ¶
func (m *MattermostProviderV3) Logout() (err error)
Logout terminate connection with Mattermost
func (*MattermostProviderV3) PostMessage ¶
func (m *MattermostProviderV3) PostMessage(message, channelID string, attachments []*Attachment) error
PostMessage posts a message in Mattermost
type MattermostProviderV4 ¶
type MattermostProviderV4 struct {
// contains filtered or unexported fields
}
MattermostProviderV4 default implementation of MattermostProvider
func NewMattermostProviderV4 ¶
func NewMattermostProviderV4(cfg *model.Mattermost, log Logger) *MattermostProviderV4
NewMattermostProviderV4 creates a new instance of Mattermost api V4
func (*MattermostProviderV4) GetChannelID ¶
func (m *MattermostProviderV4) GetChannelID(channelName string) string
GetChannelID gets channel id by channel name return empty string if not exists
func (*MattermostProviderV4) Login ¶
func (m *MattermostProviderV4) Login() error
Login log in Mattermost
func (*MattermostProviderV4) Logout ¶
func (m *MattermostProviderV4) Logout() (err error)
Logout terminate connection with Mattermost
func (*MattermostProviderV4) PostMessage ¶
func (m *MattermostProviderV4) PostMessage(message, channelID string, attachments []*Attachment) error
PostMessage posts a message in Mattermost
type UIDCache ¶
type UIDCache interface { // GetNextUID returns the next uid for the uidvalidity, if empty or is an invalid uidvalidity returns ErrEmptyUID GetNextUID(uidvalidity uint32) (uint32, error) // SaveNextUID stores the uid and uidvalidity SaveNextUID(uidvalidity, uid uint32) error }
UIDCache is a cache of uid for account + mailbox
type UIDCacheFile ¶
type UIDCacheFile struct {
// contains filtered or unexported fields
}
UIDCacheFile implements UIDCache using filesystem to store
func NewUIDCacheFile ¶
func NewUIDCacheFile(directory, account, mailbox string) *UIDCacheFile
NewUIDCacheFile return a new UIDCacheFile
func (*UIDCacheFile) GetNextUID ¶
func (u *UIDCacheFile) GetNextUID(uidvalidity uint32) (uint32, error)
GetNextUID returns the next uid for the uidvalidity, if empty or is an invalid uidvalidity returns ErrEmptyUID
func (*UIDCacheFile) SaveNextUID ¶
func (u *UIDCacheFile) SaveNextUID(uidvalidity, uid uint32) error
SaveNextUID stores the uid and uidvalidity