Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
feat(services): add ExactSendTime bypass in PhoneNotificationService.Schedule
Acho Arnold9af04e339f98
diff --git a/api/pkg/services/phone_notification_service.go b/api/pkg/services/phone_notification_service.goindex ffafa555..24db0de5 100644--- a/api/pkg/services/phone_notification_service.go+++ b/api/pkg/services/phone_notification_service.go@@ -161,14 +161,16 @@ func (service *PhoneNotificationService) Send(ctx context.Context, params *Phone// PhoneNotificationScheduleParams are parameters for sending a notificationtype PhoneNotificationScheduleParams struct {- UserID entities.UserID- Owner string- Source string- Encrypted bool- Contact string- Content string- SIM entities.SIM- MessageID uuid.UUID+ UserID entities.UserID+ Owner string+ Source string+ Encrypted bool+ Contact string+ Content string+ SIM entities.SIM+ MessageID uuid.UUID+ ExactSendTime bool+ ScheduledSendTime *time.Time}// Schedule a notification to be sent to a phone@@ -195,6 +197,35 @@ func (service *PhoneNotificationService) Schedule(ctx context.Context, params *PUpdatedAt: time.Now().UTC(),}+ // Bypass rate-limit and schedule window logic for exact send time+ if params.ExactSendTime && params.ScheduledSendTime != nil {+ scheduledAt := *params.ScheduledSendTime+ if scheduledAt.Before(time.Now().UTC()) {+ scheduledAt = time.Now().UTC()+ }+ notification.ScheduledAt = scheduledAt+ if err = service.phoneNotificationRepository.ScheduleExact(ctx, notification); err != nil {+ msg := fmt.Sprintf("cannot schedule exact notification for message [%s] to phone [%s]", params.MessageID, phone.ID)+ return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))+ }++ if err = service.dispatchMessageNotificationScheduled(ctx, params, notification); err != nil {+ ctxLogger.Error(err)+ }++ if err = service.dispatchMessageNotificationSend(ctx, params.Source, notification); err != nil {+ return service.tracer.WrapErrorSpan(span, err)+ }++ ctxLogger.Info(fmt.Sprintf(+ "message with id [%s] exact notification scheduled for [%s] with id [%s]",+ params.MessageID,+ notification.ScheduledAt,+ notification.ID,+ ))+ return nil+ }+var schedule *entities.MessageSendScheduleif phone.ScheduleID != nil {schedule, err = service.sendScheduleRepository.Load(ctx, params.UserID, *phone.ScheduleID)