Skip to content

Commit

Permalink
fix: set reply to as source if not present
Browse files Browse the repository at this point in the history
  • Loading branch information
iamKunalGupta committed Mar 12, 2024
1 parent 970fc5f commit 396d281
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 2 additions & 9 deletions flow/alerting/alerting.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,10 @@ func (a *Alerter) registerSendersFromPool(ctx context.Context) ([]AlertSenderCon

alertSenderConfigs = append(alertSenderConfigs, AlertSenderConfig{Id: id, Sender: newSlackAlertSender(&slackServiceConfig)})
case EMAIL:
var replyToAddresses []string
if envReplyToAddresses := strings.Split(peerdbenv.PeerDBAlertingEmailSenderReplyToAddresses(), ","); len(envReplyToAddresses) != 0 {
// AWS SDK does not like empty slice
replyToAddresses = envReplyToAddresses
} else {
replyToAddresses = nil
}
emailServiceConfig := EmailAlertSenderConfig{
sourceEmail: peerdbenv.PeerDBAlertingEmailSenderSourceEmail(),
configurationSetName: peerdbenv.PeerDBAlertingEmailSenderConfigurationSet(),
replyToAddresses: replyToAddresses,
replyToAddresses: strings.Split(peerdbenv.PeerDBAlertingEmailSenderReplyToAddresses(), ","),
}
if emailServiceConfig.sourceEmail == "" {
return errors.New("missing sourceEmail for Email alerting service")
Expand Down Expand Up @@ -247,7 +240,7 @@ func (a *Alerter) checkAndAddAlertToCatalog(ctx context.Context, alertConfigId i
}

logger.LoggerFromCtx(ctx).Info(
fmt.Sprintf("Skipeed sending alerts: last alert was sent at %s, which was >=%s ago",
fmt.Sprintf("Skipped sending alerts: last alert was sent at %s, which was >=%s ago",
createdTimestamp.String(), dur.String()))
return false
}
Expand Down
6 changes: 5 additions & 1 deletion flow/alerting/email_alert_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,15 @@ func NewEmailAlertSenderWithNewClient(ctx context.Context, region *string, confi
}

func NewEmailAlertSender(client *ses.Client, config *EmailAlertSenderConfig) *EmailAlertSender {
replyToAddresses := config.replyToAddresses
if len(replyToAddresses) == 0 {
replyToAddresses = []string{config.sourceEmail}
}
return &EmailAlertSender{
client: client,
sourceEmail: config.sourceEmail,
configurationSetName: config.configurationSetName,
replyToAddresses: config.replyToAddresses,
replyToAddresses: replyToAddresses,
slotLagMBAlertThreshold: config.SlotLagMBAlertThreshold,
openConnectionsAlertThreshold: config.OpenConnectionsAlertThreshold,
emailAddresses: config.EmailAddresses,
Expand Down

0 comments on commit 396d281

Please sign in to comment.