envelope

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachmentIDFromFileName

func AttachmentIDFromFileName(fileName string) (int64, error)

Types

type Attachment

type Attachment struct {
	ID        int64
	MessageID int64
	Name      string
	Mime      string
	Extension string
}

func NewAttachment

func NewAttachment(name string, data []byte) *Attachment

func (*Attachment) FileName

func (a *Attachment) FileName() string

func (*Attachment) IsImage

func (a *Attachment) IsImage() bool

type CreateAttachmentRequest

type CreateAttachmentRequest struct {
	Name string
	Data []byte
}

type CreateEnvelopeRequest

type CreateEnvelopeRequest struct {
	Date       time.Time
	Subject    string
	From       string
	To         []string
	Text       string
	HTML       string
	Attachment []CreateAttachmentRequest
}

type DataStore

type DataStore interface {
	ForceCreateData(ctx context.Context, att *Attachment, data []byte) error
	GetData(ctx context.Context, att *Attachment) ([]byte, error)
	DeleteData(ctx context.Context, att *Attachment) error
	GetDataSize(ctx context.Context) (int64, error)
}

type Envelope

type Envelope struct {
	Message     Message
	Attachments []Attachment
}

type EnvelopeService

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

func NewEnvelopeService

func NewEnvelopeService(store Store, dataStore DataStore) *EnvelopeService

func (*EnvelopeService) CreateEnvelope

func (es *EnvelopeService) CreateEnvelope(ctx context.Context, req *CreateEnvelopeRequest) (int64, error)

func (*EnvelopeService) DeleteEnvelope

func (es *EnvelopeService) DeleteEnvelope(ctx context.Context, msgID int64) error

func (*EnvelopeService) GetData

func (es *EnvelopeService) GetData(ctx context.Context, att *Attachment) ([]byte, error)

func (*EnvelopeService) GetDataSize

func (es *EnvelopeService) GetDataSize(ctx context.Context) (int64, error)

func (*EnvelopeService) GetEnvelope

func (es *EnvelopeService) GetEnvelope(ctx context.Context, msgID int64) (*Envelope, error)

func (*EnvelopeService) ListAttachment

func (es *EnvelopeService) ListAttachment(ctx context.Context, page *paginate.Page) ([]Attachment, error)

func (*EnvelopeService) ListEnvelope

func (es *EnvelopeService) ListEnvelope(ctx context.Context, page *paginate.Page) ([]Envelope, error)

type LocalDataStore

type LocalDataStore interface {
	DataFS() fs.FS
}

type Message

type Message struct {
	ID        int64
	CreatedAt time.Time
	Date      time.Time
	Subject   string
	From      string
	To        map[string]struct{}
	Text      string
	HTML      string
}

func NewMessage

func NewMessage(from string, to []string, subject, text, html string, date time.Time) *Message

type Service

type Service interface {
	ListAttachment(ctx context.Context, page *paginate.Page) ([]Attachment, error)
	ListEnvelope(ctx context.Context, page *paginate.Page) ([]Envelope, error)
	GetEnvelope(ctx context.Context, msgID int64) (*Envelope, error)
	CreateEnvelope(ctx context.Context, req *CreateEnvelopeRequest) (int64, error)
	DeleteEnvelope(ctx context.Context, msgID int64) error
	GetData(ctx context.Context, att *Attachment) ([]byte, error)
	GetDataSize(ctx context.Context) (int64, error)
}

type Store

type Store interface {
	CountAttachment(ctx context.Context) (int, error)
	ListAttachment(ctx context.Context, offset, limit int, ascending bool) ([]Attachment, int, error)
	ListEnvelope(ctx context.Context, offset, limit int, ascending bool) ([]Envelope, int, error)
	CreateEnvelope(ctx context.Context, msg *Message, atts []Attachment) (int64, error)
	CountEnvelope(ctx context.Context) (int, error)
	GetEnvelope(ctx context.Context, msgID int64) (*Envelope, error)
	DeleteEnvelope(ctx context.Context, msgID int64, fn func(env *Envelope) error) error
}

Jump to

Keyboard shortcuts

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