Skip to content

Commit 5bf5693

Browse files
committed
Increase send time to 20 days into the future
1 parent 3fad1b3 commit 5bf5693

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

api/pkg/requests/message_send_request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type MessageSend struct {
2222
Encrypted bool `json:"encrypted" example:"false" validate:"optional"`
2323
// RequestID is an optional parameter used to track a request from the client's perspective
2424
RequestID string `json:"request_id" example:"153554b5-ae44-44a0-8f4f-7bbac5657ad4" validate:"optional"`
25-
// SendAt is an optional parameter used to schedule a message to be sent in the future. The time is considered to be in your profile's local timezone.
25+
// SendAt is an optional parameter used to schedule a message to be sent in the future. The time is considered to be in your profile's local timezone and you can queue messages for up to 20 days (480 hours) in the future.
2626
SendAt *time.Time `json:"send_at" example:"2022-06-05T14:26:09.527976+03:00" validate:"optional"`
2727
}
2828

api/pkg/validators/bulk_message_handler_validator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ func (v *BulkMessageHandlerValidator) validateMessages(messages []*requests.Bulk
224224
result.Add("document", fmt.Sprintf("Row [%d]: The message content must be less than 1024 characters.", index+2))
225225
}
226226

227-
if message.SendTime != nil && message.SendTime.After(time.Now().Add(24*time.Hour)) {
228-
result.Add("document", fmt.Sprintf("Row [%d]: The SendTime [%s] cannot be more than 24 hours in the future.", index+2, message.SendTime.Format(time.RFC3339)))
227+
if message.SendTime != nil && message.SendTime.After(time.Now().Add(420*time.Hour)) {
228+
result.Add("document", fmt.Sprintf("Row [%d]: The SendTime [%s] cannot be more than 20 days (420 hours) in the future.", index+2, message.SendTime.Format(time.RFC3339)))
229229
}
230230
}
231231
return result

api/pkg/validators/message_handler_validator.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"net/url"
77
"strings"
8+
"time"
89

910
"github.com/NdoleStudio/httpsms/pkg/repositories"
1011
"github.com/NdoleStudio/httpsms/pkg/services"
@@ -105,6 +106,10 @@ func (validator MessageHandlerValidator) ValidateMessageSend(ctx context.Context
105106
return result
106107
}
107108

109+
if request.SendAt != nil && request.SendAt.After(time.Now().Add(480*time.Hour)) {
110+
result.Add("send_at", "the scheduled time cannot be more than 20 days (480 hours) in the future")
111+
}
112+
108113
_, err := validator.phoneService.Load(ctx, userID, request.From)
109114
if stacktrace.GetCode(err) == repositories.ErrCodeNotFound {
110115
result.Add("from", fmt.Sprintf("no phone found with with 'from' number [%s]. install the android app on your phone to start sending messages", request.From))

0 commit comments

Comments
 (0)