Documentation
¶
Index ¶
- Variables
- type Attachment
- type AttachmentRepositoryPort
- type AttachmentType
- type AuthServicePort
- type Bridge
- type BridgeServicePort
- type Database
- 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 ( ErrAttachmentInvalid = fmt.Errorf("invalid attachment") ErrAttachmentNotFound = fmt.Errorf("attachment not found") )
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 conflict") )
View Source
var ( ErrMessageNotFound = fmt.Errorf("message not found") ErrMessageAlreadyExists = fmt.Errorf("message already exists") )
View Source
var ErrAuthInvalid = fmt.Errorf("invalid credentials")
View Source
var ErrBridgesNotFound = fmt.Errorf("bridges not found")
View Source
var ErrNotImplemented = errors.New("not implemented")
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct {
UUID string
Name string
Type AttachmentType
MessageUUID string
Data []byte
}
func (*Attachment) File ¶
func (a *Attachment) File() string
type AttachmentRepositoryPort ¶
type AttachmentRepositoryPort interface {
// Create saves a new attachment.
Create(att *Attachment) error
// Get returns an attachment by it's UUID without data.
Get(uuid string) (*Attachment, error)
// GetData returns the data for an attachment.
GetData(att *Attachment) ([]byte, error)
// GetFS returns the attachment file system.
GetFS() fs.FS
// ListByMessage returns a list of attachments for a message without data.
ListByMessage(msg *Message) ([]Attachment, error)
// DeleteData deletes the data for an attachment.
DeleteData(att *Attachment) error
}
type AttachmentType ¶
type AttachmentType string
const ( TypePNG AttachmentType = "png" TypeJPEG AttachmentType = "jpeg" )
func AttachmentDataValid ¶
func AttachmentDataValid(data []byte) (AttachmentType, error)
AttachmentDataValid returns the type of the attachment data.
type AuthServicePort ¶
type Bridge ¶
type Bridge struct {
Name string
Endpoints []string
OnlyText bool
OnlyAttachments bool
Filters []Filter
}
func (*Bridge) EndpointMessage ¶
func (b *Bridge) EndpointMessage(msg *Message) *EndpointMessage
type BridgeServicePort ¶
type Database ¶
type Database interface {
Close() error
AttachmentRepository() AttachmentRepositoryPort
MessageRepository() MessageRepositoryPort
}
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
}
type EndpointRepositoryPort ¶
type EndpointServicePort ¶
type EndpointServicePort interface {
SendByEndpointNames(emsg *EndpointMessage, endpointNames []string) error
}
type Message ¶
type Message struct {
UUID string // UUID of the message.
From string // From is the email address of the sender.
To map[string]struct{} // To is the email addresses of the recipients.
Subject string // Subject of the message.
Text string // Text is the message body.
Attachments []Attachment // Attachment is the attachments of the message.
Status Status // Status is the status of the message.
CreatedAt time.Time // Time message was received.
}
func NewMessage ¶
func (*Message) NewAttachment ¶
func (m *Message) NewAttachment(name string, data []byte) (*Attachment, error)
type MessageRepositoryPort ¶
type MessageRepositoryPort interface {
// Create saves a message.
Create(msg *Message) error
// Count returns the number of messages.
Count() (int, error)
// Get returns a message by it's UUID.
Get(uuid string) (*Message, error)
// List messages.
List(limit, offset int) ([]Message, error)
// Update a message.
Update(msg *Message, updateFN func(msg *Message) (*Message, error)) error
// Delete a message.
Delete(msg *Message) error
}
type MessageServicePort ¶
type MessageServicePort interface {
// Create a new message and saves it.
Create(subject, from string, to map[string]struct{}, text string) (*Message, error)
// CreateAttachment adds an attachment to a message and saves it.
CreateAttachment(msg *Message, name string, data []byte) (*Attachment, error)
// Get a message with attachments.
Get(uuid string) (*Message, error)
// List messages with attachments.
List(limit, offset int) ([]Message, error)
// Process handles sending message to bridge's endpoints.
Process(msg *Message, bridges []*Bridge) error
// UpdateStatus updates the status of a message.
UpdateStatus(msg *Message, status Status) error
}
Click to show internal directories.
Click to hide internal directories.