Skip to content

Commit b6a79c0

Browse files
committed
Fix some defaults
1 parent b86edfc commit b6a79c0

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

api/pkg/entities/phone.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ type Phone struct {
2626

2727
// MessageExpirationDuration returns the message expiration as time.Duration
2828
func (phone *Phone) MessageExpirationDuration() time.Duration {
29-
return time.Duration(phone.MessageExpirationSeconds) * time.Second
29+
return time.Duration(int(phone.MessageExpirationSecondsSanitized())) * time.Second
3030
}
3131

3232
// MessageExpirationSecondsSanitized returns the message expiration seconds with default of 1 hour
3333
func (phone *Phone) MessageExpirationSecondsSanitized() uint {
3434
if phone.MessageExpirationSeconds == 0 {
35-
return 60 * 60 // 1 hour
35+
return 10 * 60 // 10 minutes
3636
}
3737
return phone.MessageExpirationSeconds
3838
}
3939

40-
// MaxSendAttemptsSanitized returns the max send attempts replacing 0 with 1
40+
// MaxSendAttemptsSanitized returns the max send attempts replacing 0 with 2
4141
func (phone *Phone) MaxSendAttemptsSanitized() uint {
4242
if phone.MaxSendAttempts == 0 {
43-
return 1
43+
return 2
4444
}
4545
return phone.MaxSendAttempts
4646
}

api/pkg/services/message_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ func (service *MessageService) HandleMessageSending(ctx context.Context, params
408408
return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
409409
}
410410

411-
ctxLogger.Info(fmt.Sprintf("message with id [%s] in after adding send attempt", message.ID))
411+
ctxLogger.Info(fmt.Sprintf("message with id [%s] updated after adding send attempt", message.ID))
412412
return nil
413413
}
414414

api/pkg/services/phone_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func (service *PhoneService) createPhone(ctx context.Context, params PhoneUpsert
174174
// Android has a limit of 30 SMS messages per minute without user permission, to be safe let's use 10 messages per minute
175175
// https://android.googlesource.com/platform/frameworks/opt/telephony/+/master/src/java/com/android/internal/telephony/SmsUsageMonitor.java#80
176176
MessagesPerMinute: 10,
177-
MessageExpirationSeconds: 15 * 60, // 15 minutes
177+
MessageExpirationSeconds: 10 * 60, // 10 minutes
178178
MaxSendAttempts: 2,
179179
SIM: params.SIM,
180180
PhoneNumber: phonenumbers.Format(&params.PhoneNumber, phonenumbers.E164),
@@ -202,7 +202,7 @@ func (service *PhoneService) update(phone *entities.Phone, params PhoneUpsertPar
202202
if phone.FcmToken != nil {
203203
phone.FcmToken = params.FcmToken
204204
}
205-
if params.MessagesPerMinute != nil {
205+
if params.MessagesPerMinute != nil && *params.MessagesPerMinute > 0 {
206206
phone.MessagesPerMinute = *params.MessagesPerMinute
207207
}
208208

0 commit comments

Comments
 (0)