Skip to content

Commit 23cfd4b

Browse files
committed
Fix email which is sent to users on failed webhook
1 parent cff4903 commit 23cfd4b

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ buildscript {
1717
}
1818

1919
plugins {
20-
id 'com.android.application' version '8.1.1' apply false
21-
id 'com.android.library' version '8.1.1' apply false
20+
id 'com.android.application' version '8.1.2' apply false
21+
id 'com.android.library' version '8.1.2' apply false
2222
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
2323
}
2424

api/pkg/emails/factory.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package emails
22

33
import (
44
"fmt"
5+
"net/http"
56

67
"github.com/nyaruka/phonenumbers"
78
)
@@ -16,7 +17,7 @@ func (factory *factory) formatPhoneNumber(number string) string {
1617
func (factory *factory) formatHTTPResponseCode(code *int) string {
1718
responseCode := "-"
1819
if code != nil {
19-
responseCode = fmt.Sprintf("%d", *code)
20+
responseCode = fmt.Sprintf("%d - %s", *code, http.StatusText(*code))
2021
}
2122
return responseCode
2223
}

api/pkg/emails/hermes_user_email_factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (factory *hermesUserEmailFactory) PhoneDead(user *entities.User, lastHeartb
157157

158158
return &Email{
159159
ToEmail: user.Email,
160-
Subject: fmt.Sprintf("⚠️ No heartbeat from android phone [%s]", owner),
160+
Subject: fmt.Sprintf("⚠️ No heartbeat from android phone [%s]", factory.formatPhoneNumber(owner)),
161161
HTML: html,
162162
Text: text,
163163
}, nil

api/pkg/services/email_notification_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (service *EmailNotificationService) NotifyWebhookSendFailed(ctx context.Con
125125
ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger)
126126
defer span.End()
127127

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

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

0 commit comments

Comments
 (0)