maildav

package module
v0.0.0-...-b9f2268 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

maildav

IMAP polling service that uploads attachments to a WebDav server.

Scope

For now I built this only for myself. If you want to help making it useful for everybody feel free to open a pull request. :)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Filename        string
	Content         []byte
	DestinationInfo *DestinationInfo
}

type Config

type Config struct {
	Sources      []*SourceConfig      `yaml:"sources"`
	Destinations []*DestinationConfig `yaml:"destinations"`
	Pollers      []*PollerConfig      `yaml:"pollers"`
}

func ParseConfig

func ParseConfig(rdr io.Reader) (*Config, error)

type ConnectionPool

type ConnectionPool struct {
	// contains filtered or unexported fields
}
var DefaultConnectionPool *ConnectionPool

func NewConnectionPool

func NewConnectionPool() *ConnectionPool

func (*ConnectionPool) ConnectAndLock

func (cp *ConnectionPool) ConnectAndLock(cfg *SourceConfig) (IMAPClient, error)

func (*ConnectionPool) Unlock

func (cp *ConnectionPool) Unlock(cfg *SourceConfig)

type DestinationConfig

type DestinationConfig struct {
	Name     string `yaml:"name"`
	BaseURL  string `yaml:"baseURL"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type DestinationInfo

type DestinationInfo struct {
	Config    *DestinationConfig
	Directory string
}

type IMAPClient

type IMAPClient interface {
	Login() error
	Unlock()

	Select(name string, readOnly bool) (*imap.MailboxStatus, error)
	Search(criteria *imap.SearchCriteria) (seqNums []uint32, err error)
	Fetch(seqset *imap.SeqSet, items []imap.FetchItem, ch chan *imap.Message) error
}

func NewIMAPClient

func NewIMAPClient(cfg *SourceConfig, cp *ConnectionPool) (IMAPClient, error)

type Poller

type Poller struct {
	// contains filtered or unexported fields
}

func NewPoller

func NewPoller(config *PollerConfig) (*Poller, error)

func (*Poller) Poll

func (p *Poller) Poll() ([]*Attachment, error)

func (*Poller) StartPolling

func (p *Poller) StartPolling(ctx context.Context, uploader *Uploader) error

type PollerConfig

type PollerConfig struct {
	SourceName           string `yaml:"source"`
	SourceConfig         *SourceConfig
	SourceDirectories    []string `yaml:"sourceDirectories"`
	DestinationName      string   `yaml:"destination"`
	DestinationConfig    *DestinationConfig
	DestinationDirectory string        `yaml:"destinationDirectory"`
	Timeout              time.Duration `yaml:"timeout"`
}

func (*PollerConfig) String

func (cfg *PollerConfig) String() string

type SourceConfig

type SourceConfig struct {
	Name     string `yaml:"name"`
	Server   string `yaml:"server"`
	Port     int    `yaml:"port"`
	TLS      bool   `yaml:"tls"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type Uploader

type Uploader struct {
}

func (*Uploader) UploadAttachments

func (u *Uploader) UploadAttachments(attachments []*Attachment) error

Directories

Path Synopsis
cmd
maildav command

Jump to

Keyboard shortcuts

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