add email rotation regarding a limit
This commit is contained in:
@ -43,6 +43,11 @@ func getServiceContainer(conf *config.Config) (*service.Container, error) {
|
||||
cqrs.CommandHandlerFunc(command.HandleStoreEmail),
|
||||
)
|
||||
|
||||
bus.RegisterCommand(
|
||||
cqrs.MatchCommandRequest(&command.RotateEmailRequest{}),
|
||||
cqrs.CommandHandlerFunc(command.HandleRotateEmail),
|
||||
)
|
||||
|
||||
bus.RegisterCommand(
|
||||
cqrs.MatchCommandRequest(&command.ClearInboxRequest{}),
|
||||
cqrs.CommandHandlerFunc(command.HandleClearInbox),
|
||||
|
@ -92,6 +92,18 @@ func (s *Session) Data(r io.Reader) error {
|
||||
}
|
||||
}
|
||||
|
||||
if conf.Data.MaxEmail > 0 {
|
||||
cmd := &command.RotateEmailRequest{
|
||||
MaxEmail: conf.Data.MaxEmail,
|
||||
}
|
||||
|
||||
if _, err := bus.Exec(s.ctx, cmd); err != nil {
|
||||
logger.Error(s.ctx, "could not exec command", logger.E(err))
|
||||
|
||||
return errors.Wrapf(err, "could not exec '%T' command", cmd)
|
||||
}
|
||||
}
|
||||
|
||||
cmd := &command.StoreEmailRequest{
|
||||
Envelope: env,
|
||||
}
|
||||
|
Reference in New Issue
Block a user