Documentation
¶
Overview ¶
Package email implements the email capability adapter.
Index ¶
- Constants
- func CatalogSpec() capability.Spec
- func NewPoller() capability.PollingResource
- func Register(app string, svc Service) error
- type Adapter
- func (a *Adapter) Get(ctx context.Context, id string) (*MailMessage, error)
- func (a *Adapter) HealthCheck(ctx context.Context) (bool, error)
- func (a *Adapter) List(ctx context.Context, in ListInput) (*capability.ListResult[MailMessage], error)
- func (a *Adapter) ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)
- func (a *Adapter) MarkEmittedSeen(ctx context.Context, ids []string) error
- func (a *Adapter) MarkRead(ctx context.Context, id string) error
- func (a *Adapter) MarkUnread(ctx context.Context, id string) error
- func (a *Adapter) Search(ctx context.Context, in SearchInput) (*capability.ListResult[MailMessage], error)
- func (a *Adapter) Send(ctx context.Context, in SendInput) error
- type ListInput
- type MailAttachment
- type MailMessage
- type MessagePoller
- func (p *MessagePoller) AfterEmit(ctx context.Context, items []any) error
- func (*MessagePoller) Capability() string
- func (*MessagePoller) ContentHash(item any) string
- func (*MessagePoller) CursorField() string
- func (*MessagePoller) DefaultInterval() time.Duration
- func (*MessagePoller) DiffKey(item any) string
- func (p *MessagePoller) List(ctx context.Context, cursor string) (capability.PollResult, error)
- func (*MessagePoller) ResourceName() string
- type SearchInput
- type SendInput
- type Service
Constants ¶
const ( OpSend = "send" OpList = "list" OpGet = "get" OpSearch = "search" OpMarkRead = "mark_read" OpMarkUnread = "mark_unread" OpHealth = "health" )
Operation name constants for the email capability.
Variables ¶
This section is empty.
Functions ¶
func CatalogSpec ¶
func CatalogSpec() capability.Spec
CatalogSpec returns capability metadata for documentation.
func NewPoller ¶
func NewPoller() capability.PollingResource
NewPoller creates a MessagePoller. Returns nil when the provider is not configured.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements Service using the email provider client.
func (*Adapter) List ¶
func (a *Adapter) List(ctx context.Context, in ListInput) (*capability.ListResult[MailMessage], error)
func (*Adapter) ListRawEvents ¶
func (*Adapter) MarkEmittedSeen ¶
func (*Adapter) Search ¶
func (a *Adapter) Search(ctx context.Context, in SearchInput) (*capability.ListResult[MailMessage], error)
type ListInput ¶
type ListInput struct {
Mailbox string
UnseenOnly *bool
Page capability.PageRequest
}
ListInput holds parameters for listing messages.
type MailAttachment ¶
type MailAttachment = capability.MailAttachment
MailAttachment describes an attachment without binary payload.
type MailMessage ¶
type MailMessage = capability.MailMessage
MailMessage is the capability-facing email message type.
type MessagePoller ¶
type MessagePoller struct {
// contains filtered or unexported fields
}
MessagePoller polls IMAP for new/updated messages.
func NewPollerWithService ¶
func NewPollerWithService(svc Service) *MessagePoller
NewPollerWithService creates a MessagePoller with a specific service.
func (*MessagePoller) AfterEmit ¶
func (p *MessagePoller) AfterEmit(ctx context.Context, items []any) error
AfterEmit marks emitted messages as seen when mark_seen_after_emit is enabled.
func (*MessagePoller) Capability ¶
func (*MessagePoller) Capability() string
func (*MessagePoller) ContentHash ¶
func (*MessagePoller) ContentHash(item any) string
func (*MessagePoller) CursorField ¶
func (*MessagePoller) CursorField() string
func (*MessagePoller) DefaultInterval ¶
func (*MessagePoller) DefaultInterval() time.Duration
func (*MessagePoller) DiffKey ¶
func (*MessagePoller) DiffKey(item any) string
func (*MessagePoller) List ¶
func (p *MessagePoller) List(ctx context.Context, cursor string) (capability.PollResult, error)
func (*MessagePoller) ResourceName ¶
func (*MessagePoller) ResourceName() string
type SearchInput ¶
type SearchInput struct {
Mailbox string
From string
To string
Subject string
Since *time.Time
Before *time.Time
Unseen *bool
Page capability.PageRequest
}
SearchInput holds parameters for searching messages.
type SendInput ¶
type SendInput struct {
To []string
Cc []string
Bcc []string
Subject string
Text string
HTML string
FromName string
}
SendInput holds parameters for sending an email.
type Service ¶
type Service interface {
Send(ctx context.Context, in SendInput) error
List(ctx context.Context, in ListInput) (*capability.ListResult[MailMessage], error)
Get(ctx context.Context, id string) (*MailMessage, error)
Search(ctx context.Context, in SearchInput) (*capability.ListResult[MailMessage], error)
MarkRead(ctx context.Context, id string) error
MarkUnread(ctx context.Context, id string) error
HealthCheck(ctx context.Context) (bool, error)
ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)
MarkEmittedSeen(ctx context.Context, ids []string) error
}
Service defines the email capability contract.
func New ¶
func New() Service
New creates an Adapter from YAML config. Returns nil when not configured.
func NewWithClient ¶
func NewWithClient(c client) Service
NewWithClient creates an Adapter with a specific client (tests).