Documentation
¶
Index ¶
- Variables
- type Attachment
- type AttachmentRepositoryPort
- type AttachmentType
- type AuthServicePort
- type Bridge
- type BridgeServicePort
- type Config
- type ConfigDB
- type ConfigEndpoint
- type ConfigHTTP
- type ConfigSMTP
- type DAO
- type EndpointAttachment
- type EndpointMessage
- type EndpointPort
- type EndpointRepositoryPort
- type EndpointServicePort
- type Filter
- type Message
- type MessageRepositoryPort
- type MessageServicePort
- type Status
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrEndpointSendFailed = fmt.Errorf("endpoint send failed") ErrEndpointInvalidType = fmt.Errorf("invalid endpoint type") ErrEndpointInvalidConfig = fmt.Errorf("invalid endpoint config") ErrEndpointNotFound = fmt.Errorf("endpoint not found") ErrEndpointNameConflict = fmt.Errorf("endpoint name conflit") ErrBridgesNotFound = fmt.Errorf("bridges not found") ErrMessageNotFound = fmt.Errorf("message not found") ErrMessageAlreadyExists = fmt.Errorf("message already exists") ErrAttachmentInvalid = fmt.Errorf("invalid attachment") ErrAuthInvalid = fmt.Errorf("invalid credentials") ErrNotImplemented = fmt.Errorf("not implemented") )
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct {
UUID string `json:"uuid" storm:"id"`
Name string `json:"name"`
Type AttachmentType `json:"type"`
MessageUUID string `json:"message_uuid" storm:"index"`
Data []byte `json:"-"`
}
func NewAttachment ¶
func NewAttachment(msg *Message, name string, data []byte) (*Attachment, error)
func (*Attachment) File ¶
func (a *Attachment) File() string
type AttachmentRepositoryPort ¶
type AttachmentRepositoryPort interface {
// CreateAttachment saves a new attachment.
CreateAttachment(att *Attachment) error
// GetAttachment returns an attachment by it's UUID.
GetAttachment(uuid string) (*Attachment, error)
// GetAttachmentData returns the data for an attachment.
GetAttachmentData(att *Attachment) ([]byte, error)
// GetAttachments returns a list of attachments for a message.
GetAttachments(msg *Message) ([]Attachment, error)
// GetFS returns the attachment file system
GetAttachmentFS() fs.FS
}
type AttachmentType ¶
type AttachmentType string
const ( TypePNG AttachmentType = "png" TypeJPEG AttachmentType = "jpeg" )
type AuthServicePort ¶
AuthServicePort handles authenticating users.
type Bridge ¶
type Bridge struct {
Name string `json:"name" mapstructure:"name"`
Endpoints []string `json:"endpoints" mapstructure:"endpoints"`
OnlyText bool `json:"only_text" mapstructure:"only_text"`
OnlyAttachments bool `json:"only_attachments" mapstructure:"only_attachments"`
Filters []Filter `json:"filters" mapstructure:"filters"`
}
func (*Bridge) EndpointMessage ¶
func (b *Bridge) EndpointMessage(msg *Message) *EndpointMessage
type BridgeServicePort ¶
type BridgeServicePort interface {
// GetBridges returns a list of bridges that the message belongs to.
GetBridges(msg *Message) []Bridge
}
BridgeServicePort handles finding endpoints for messages.
type Config ¶
type Config struct {
DB ConfigDB `json:"database" mapstructure:"database"`
SMTP ConfigSMTP `json:"smtp" mapstructure:"smtp"`
HTTP ConfigHTTP `json:"http" mapstructure:"http"`
Bridges []Bridge `json:"bridges" mapstructure:"bridges"`
Endpoints []ConfigEndpoint `json:"endpoints" mapstructure:"endpoints"`
}
type ConfigDB ¶
type ConfigEndpoint ¶
type ConfigHTTP ¶
type ConfigSMTP ¶
type ConfigSMTP struct {
Host string `json:"host" mapstructure:"host"`
Port uint16 `json:"port" mapstructure:"port"`
PortStr string `json:"-" mapstructure:"-"`
Size int `json:"size" mapstructure:"size"`
Auth bool `json:"auth" mapstructure:"auth"`
Username string `json:"username" mapstructure:"username"`
Password string `json:"password" mapstructure:"password"`
}
type DAO ¶
type DAO struct {
Attachment AttachmentRepositoryPort
Message MessageRepositoryPort
Endpoint EndpointRepositoryPort
}
type EndpointAttachment ¶
type EndpointAttachment struct {
Name string
Type AttachmentType
Data []byte
}
func NewEndpointAttachments ¶
func NewEndpointAttachments(atts []Attachment) []EndpointAttachment
type EndpointMessage ¶
type EndpointMessage struct {
Text string // Text is the message body.
Attachments []EndpointAttachment // Attachments is a list of attachments.
}
func (*EndpointMessage) IsEmpty ¶
func (em *EndpointMessage) IsEmpty() bool
type EndpointPort ¶
type EndpointPort interface {
// Send sends the message to the endpoint.
Send(msg *EndpointMessage) error
}
EndpointPort handles sending messages to an endpoint.
type EndpointRepositoryPort ¶
type EndpointServicePort ¶
type Filter ¶
type Message ¶
type Message struct {
CreatedAt time.Time `json:"created_at"` // Time message was received.
UUID string `json:"uuid" storm:"id"` // UUID of the message.
Subject string `json:"subject"` // Subject of the message.
From string `json:"from"` // From is the email address of the sender.
To map[string]bool `json:"to"` // To is the email addresses of the recipients.
Text string `json:"text"` // Text is the message body.
Attachments []Attachment `json:"-"` // Attachment is the attachments of the message.
Status Status `json:"status"` // Status is the status of the message.
}
type MessageRepositoryPort ¶
type MessageRepositoryPort interface {
// CreateMessage saves a new message.
CreateMessage(msg *Message) error
// GetMessage returns a message by it's UUID.
GetMessage(uuid string) (*Message, error)
// DeleteMessage deletes a message.
DeleteMessage(msg *Message) error
// GetMessages returns a list of messages.
GetMessages(limit, offset int) ([]Message, error)
// CountMessages returns the number of messages.
CountMessages() (int, error)
// UpdateMessage updates a message.
UpdateMessage(msg *Message, updateFN func(msg *Message) (*Message, error)) error
}
MessageRepositoryPort handles storing messages.
type MessageServicePort ¶
type MessageServicePort interface {
// Create creates a new message and saves it.
Create(subject, from string, to map[string]bool, text string) (*Message, error)
// CreateAttachment adds an attachment to a message.
CreateAttachment(msg *Message, name string, data []byte) (*Attachment, error)
// UpdateStatus updates the status of a message.
UpdateStatus(msg *Message, status Status) error
// List messages with attachments.
List(limit, offset int) ([]Message, error)
// Get a message with attachments.
Get(uuid string) (*Message, error)
}
MessageServicePort handles creating and sending messages.
Click to show internal directories.
Click to hide internal directories.