yao/messenger/types/interfaces.go
Max 1843a64ff5 Update dependencies and enhance mailer functionality
- Bump Go version to 1.24.0 and update toolchain to 1.24.3 for improved performance and compatibility.
- Add new dependencies for IMAP and SASL support, enhancing email handling capabilities.
- Refactor messenger service to integrate a new mailer provider, replacing the deprecated SMTP provider.
- Implement automatic mail receiver startup for mailer providers, improving message handling efficiency.
- Update GitHub Actions workflows to include IMAP server configurations for testing email reception.
2025-09-28 09:33:36 +08:00

51 lines
1.5 KiB
Go

package types
import "context"
// Provider defines the interface for message providers
type Provider interface {
// Send sends a message using the provider
Send(ctx context.Context, message *Message) error
// SendBatch sends multiple messages in batch
SendBatch(ctx context.Context, messages []*Message) error
// Receive processes incoming messages/responses from the provider
Receive(ctx context.Context, data map[string]interface{}) error
// GetType returns the provider type (smtp, twilio, mailgun, etc.)
GetType() string
// GetName returns the provider name/identifier
GetName() string
// Validate validates the provider configuration
Validate() error
// Close closes the provider connection if needed
Close() error
}
// Messenger defines the main messenger interface
type Messenger interface {
// Send sends a message using the specified channel or default provider
Send(ctx context.Context, channel string, message *Message) error
// SendWithProvider sends a message using a specific provider
SendWithProvider(ctx context.Context, providerName string, message *Message) error
// SendBatch sends multiple messages in batch
SendBatch(ctx context.Context, channel string, messages []*Message) error
// GetProvider returns a provider by name
GetProvider(name string) (Provider, error)
// GetProviders returns all providers for a channel type
GetProviders(channelType string) []Provider
// GetChannels returns all available channels
GetChannels() []string
// Close closes all provider connections
Close() error
}