Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
Fix some defaults
Acho Arnoldb6a79c0a8f55
diff --git a/api/pkg/entities/phone.go b/api/pkg/entities/phone.goindex 218f17ae..b92ab1ab 100644--- a/api/pkg/entities/phone.go+++ b/api/pkg/entities/phone.go@@ -26,21 +26,21 @@ type Phone struct {// MessageExpirationDuration returns the message expiration as time.Durationfunc (phone *Phone) MessageExpirationDuration() time.Duration {- return time.Duration(phone.MessageExpirationSeconds) * time.Second+ return time.Duration(int(phone.MessageExpirationSecondsSanitized())) * time.Second}// MessageExpirationSecondsSanitized returns the message expiration seconds with default of 1 hourfunc (phone *Phone) MessageExpirationSecondsSanitized() uint {if phone.MessageExpirationSeconds == 0 {- return 60 * 60 // 1 hour+ return 10 * 60 // 10 minutes}return phone.MessageExpirationSeconds}-// MaxSendAttemptsSanitized returns the max send attempts replacing 0 with 1+// MaxSendAttemptsSanitized returns the max send attempts replacing 0 with 2func (phone *Phone) MaxSendAttemptsSanitized() uint {if phone.MaxSendAttempts == 0 {- return 1+ return 2}return phone.MaxSendAttempts}diff --git a/api/pkg/services/message_service.go b/api/pkg/services/message_service.goindex 081b2228..d77ce6b6 100644--- a/api/pkg/services/message_service.go+++ b/api/pkg/services/message_service.go@@ -408,7 +408,7 @@ func (service *MessageService) HandleMessageSending(ctx context.Context, paramsreturn service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))}- ctxLogger.Info(fmt.Sprintf("message with id [%s] in after adding send attempt", message.ID))+ ctxLogger.Info(fmt.Sprintf("message with id [%s] updated after adding send attempt", message.ID))return nil}diff --git a/api/pkg/services/phone_service.go b/api/pkg/services/phone_service.goindex c3a99db2..cf8749a1 100644--- a/api/pkg/services/phone_service.go+++ b/api/pkg/services/phone_service.go@@ -174,7 +174,7 @@ func (service *PhoneService) createPhone(ctx context.Context, params PhoneUpsert// Android has a limit of 30 SMS messages per minute without user permission, to be safe let's use 10 messages per minute// https://android.googlesource.com/platform/frameworks/opt/telephony/+/master/src/java/com/android/internal/telephony/SmsUsageMonitor.java#80MessagesPerMinute: 10,- MessageExpirationSeconds: 15 * 60, // 15 minutes+ MessageExpirationSeconds: 10 * 60, // 10 minutesMaxSendAttempts: 2,SIM: params.SIM,PhoneNumber: phonenumbers.Format(¶ms.PhoneNumber, phonenumbers.E164),@@ -202,7 +202,7 @@ func (service *PhoneService) update(phone *entities.Phone, params PhoneUpsertParif phone.FcmToken != nil {phone.FcmToken = params.FcmToken}- if params.MessagesPerMinute != nil {+ if params.MessagesPerMinute != nil && *params.MessagesPerMinute > 0 {phone.MessagesPerMinute = *params.MessagesPerMinute}