Documentation ¶
Index ¶
- type DecoyAgent
- func (a *DecoyAgent) Import(ctx context.Context, address string) (err error)
- func (a *DecoyAgent) Remove(ctx context.Context, email string, reason ops.RemoveReason) error
- func (a *DecoyAgent) Restore(ctx context.Context, email string) error
- func (a *DecoyAgent) Send(ctx context.Context, msg *email.Message, addrs []string) (numSent int, err error)
- func (a *DecoyAgent) Subscribe(ctx context.Context, email string) (ops.OperationResult, error)
- func (a *DecoyAgent) Unsubscribe(ctx context.Context, email string, uid uuid.UUID) (ops.OperationResult, error)
- func (a *DecoyAgent) Validate(_ context.Context, address string) (*email.ValidationFailure, error)
- func (a *DecoyAgent) Verify(ctx context.Context, email string, uid uuid.UUID) (ops.OperationResult, error)
- type ProdAgent
- func (a *ProdAgent) Import(ctx context.Context, address string) (err error)
- func (a *ProdAgent) Remove(ctx context.Context, address string, reason ops.RemoveReason) (err error)
- func (a *ProdAgent) Restore(ctx context.Context, address string) (err error)
- func (a *ProdAgent) Send(ctx context.Context, msg *email.Message, addrs []string) (numSent int, err error)
- func (a *ProdAgent) Subscribe(ctx context.Context, address string) (result ops.OperationResult, err error)
- func (a *ProdAgent) Unsubscribe(ctx context.Context, address string, uid uuid.UUID) (result ops.OperationResult, err error)
- func (a *ProdAgent) Validate(ctx context.Context, address string) (failure *email.ValidationFailure, err error)
- func (a *ProdAgent) Verify(ctx context.Context, address string, uid uuid.UUID) (result ops.OperationResult, err error)
- type SubscriptionAgent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DecoyAgent ¶
type DecoyAgent struct { SenderAddress string EmailSiteTitle string EmailDomainName string UnsubscribeEmail string UnsubscribeUrl string ApiBaseUrl string NewUid func() (uuid.UUID, error) CurrentTime func() time.Time Db db.Database Validator email.AddressValidator Mailer email.Mailer Suppressor email.Suppressor Log *log.Logger }
DecoyAgent is a stub implementation of core EListMan business logic.
The earliest deployments of EListMan used DecoyAgent for smoke testing. It enabled the smoke tests to ensure that the API Gateway and Lambda function were reachable without accessing DynamoDB. It also enabled the smoke test to validate that the API request parser worked in an actual deployment. (The smoke test uncovered the fact that HTTP/2 lowercases all HTTP headers and that API Gateway request bodies are base64 encoded by default.)
EListMan now deploys using ProdAgent, and the smoke tests verify only the responses to invalid requests that wouldn't write to DynamoDB anyway.
DecoyAgent's usefulness now is indeed questionable, but it remains for now.
func (*DecoyAgent) Import ¶
func (a *DecoyAgent) Import(ctx context.Context, address string) (err error)
func (*DecoyAgent) Remove ¶
func (a *DecoyAgent) Remove( ctx context.Context, email string, reason ops.RemoveReason) error
func (*DecoyAgent) Subscribe ¶
func (a *DecoyAgent) Subscribe( ctx context.Context, email string, ) (ops.OperationResult, error)
func (*DecoyAgent) Unsubscribe ¶
func (a *DecoyAgent) Unsubscribe( ctx context.Context, email string, uid uuid.UUID, ) (ops.OperationResult, error)
func (*DecoyAgent) Validate ¶
func (a *DecoyAgent) Validate( _ context.Context, address string, ) (*email.ValidationFailure, error)
type ProdAgent ¶
type ProdAgent struct { SenderAddress string EmailSiteTitle string EmailDomainName string UnsubscribeEmail string UnsubscribeUrl string ApiBaseUrl string NewUid func() (uuid.UUID, error) CurrentTime func() time.Time Db db.Database Validator email.AddressValidator Mailer email.Mailer Suppressor email.Suppressor Log *log.Logger }
ProdAgent is the production implementation of core EListMan business logic.
func (*ProdAgent) Unsubscribe ¶
type SubscriptionAgent ¶
type SubscriptionAgent interface { // Subscribe(ctx context.Context, email string) (ops.OperationResult, error) Verify( ctx context.Context, email string, uid uuid.UUID, ) (ops.OperationResult, error) Unsubscribe( ctx context.Context, email string, uid uuid.UUID, ) (ops.OperationResult, error) Validate( ctx context.Context, address string, ) (failure *email.ValidationFailure, err error) Import(ctx context.Context, address string) (err error) Remove(ctx context.Context, email string, reason ops.RemoveReason) error Restore(ctx context.Context, email string) error Send( ctx context.Context, msg *email.Message, addrs []string, ) (numSent int, err error) }
SubscriptionAgent is the interface for the core EListMan business logic.
Subscribe validates a pending subscriber and sends a verification email.
Verify marks a pending subscriber as verified.
Unsubscribe removes a verified subscriber from the list.
Import adds a new verified subscriber without sending a verification email. It's intended to allow importing of an existing subscriber from another email system. It still performs address validation and will refuse to import addresses that fail.
Remove removes a subscriber from the list. It's used by the SNS handler to automatically remove addresses in response to bounces or complaints.
Restore adds a verified subscriber without verification. It's used by the SNS handler to automatically restore addresses in response to "complaint" messages with feedback type "not-spam". It doesn't perform address validation, since only valid addresses should be capable producing "not-spam" responses. (If that assumption ever proves untrue, it may be replaced by Import.)
Send sends a message to the entire list, or to specified subscribers only. If the `addrs` argument is empty, Send will send the message to the entire list. If `addrs` isn't empty, it will send the message only to those addresses that match verified subscribers. If `addrs` contains invalid addresses, Send will still send to every valid address that it can and report the rest in an error.