Skip to content

Commit

Permalink
Fix email which is sent to users on failed webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
AchoArnold committed Oct 11, 2023
1 parent cff4903 commit 23cfd4b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ buildscript {
}

plugins {
id 'com.android.application' version '8.1.1' apply false
id 'com.android.library' version '8.1.1' apply false
id 'com.android.application' version '8.1.2' apply false
id 'com.android.library' version '8.1.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}

Expand Down
3 changes: 2 additions & 1 deletion api/pkg/emails/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package emails

import (
"fmt"
"net/http"

"github.com/nyaruka/phonenumbers"
)
Expand All @@ -16,7 +17,7 @@ func (factory *factory) formatPhoneNumber(number string) string {
func (factory *factory) formatHTTPResponseCode(code *int) string {
responseCode := "-"
if code != nil {
responseCode = fmt.Sprintf("%d", *code)
responseCode = fmt.Sprintf("%d - %s", *code, http.StatusText(*code))
}
return responseCode
}
2 changes: 1 addition & 1 deletion api/pkg/emails/hermes_user_email_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (factory *hermesUserEmailFactory) PhoneDead(user *entities.User, lastHeartb

return &Email{
ToEmail: user.Email,
Subject: fmt.Sprintf("⚠️ No heartbeat from android phone [%s]", owner),
Subject: fmt.Sprintf("⚠️ No heartbeat from android phone [%s]", factory.formatPhoneNumber(owner)),
HTML: html,
Text: text,
}, nil
Expand Down
4 changes: 2 additions & 2 deletions api/pkg/services/email_notification_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (service *EmailNotificationService) NotifyWebhookSendFailed(ctx context.Con
ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger)
defer span.End()

if !service.canSendEmail(ctx, payload.EventType, payload.Owner) {
if !service.canSendEmail(ctx, events.EventTypeWebhookSendFailed, payload.Owner) {
ctxLogger.Info(fmt.Sprintf("[%s] email already sent to user [%s] with owner [%s]", events.EventTypeWebhookSendFailed, payload.UserID, payload.Owner))
return nil
}
Expand Down Expand Up @@ -158,7 +158,7 @@ func (service *EmailNotificationService) NotifyDiscordSendFailed(ctx context.Con
ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger)
defer span.End()

if !service.canSendEmail(ctx, payload.EventType, payload.Owner) {
if !service.canSendEmail(ctx, events.EventTypeDiscordSendFailed, payload.Owner) {
ctxLogger.Info(fmt.Sprintf("[%s] email already sent to user [%s] with owner [%s]", events.EventTypeWebhookSendFailed, payload.UserID, payload.Owner))
return nil
}
Expand Down

0 comments on commit 23cfd4b

Please sign in to comment.