Compare commits

..
Author SHA1 Message Date
phoenix e4b6b191f0 Added scheduling check 2025-11-29 13:46:14 -05:00
4 changed files with 7 additions and 9 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ jobs:
run: | run: |
echo "Creating version" echo "Creating version"
VERSION="0.0.5" VERSION="0.0.4"
PROJECT_COMMIT_HASH=$(git rev-parse HEAD | cut -c 1-10) PROJECT_COMMIT_HASH=$(git rev-parse HEAD | cut -c 1-10)
BRANCH_REF="${{ gitea.ref }}" BRANCH_REF="${{ gitea.ref }}"
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3) BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
+1 -1
View File
@@ -4,7 +4,7 @@ go 1.25.4
require ( require (
git.kundeng.us/phoenix/textsender-models v0.0.10 git.kundeng.us/phoenix/textsender-models v0.0.10
github.com/twilio/twilio-go v1.28.7 github.com/twilio/twilio-go v1.28.6
) )
require ( require (
+2 -2
View File
@@ -25,8 +25,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/twilio/twilio-go v1.28.7 h1:WzzQDR/rqmNkVs1TwtcHFPYGTdSdPnx/eAZf5UIXzr4= github.com/twilio/twilio-go v1.28.6 h1:L/pikXkARmPOzF/gUMeZPP/Lu5mY/wA4XC7sRzS86W4=
github.com/twilio/twilio-go v1.28.7/go.mod h1:FpgNWMoD8CFnmukpKq9RNpUSGXC0BwnbeKZj2YHlIkw= github.com/twilio/twilio-go v1.28.6/go.mod h1:FpgNWMoD8CFnmukpKq9RNpUSGXC0BwnbeKZj2YHlIkw=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+3 -5
View File
@@ -14,7 +14,6 @@ import (
"git.kundeng.us/phoenix/swoosh/swoop/types" "git.kundeng.us/phoenix/swoosh/swoop/types"
) )
const Schedule_Type = "fixed"
type MessageSender struct { type MessageSender struct {
Config *config.TwiloConfig Config *config.TwiloConfig
@@ -35,9 +34,8 @@ func (m *MessageSender) Send(msg message.Message, number contact.Contact, sendTi
params.SetFrom(m.Config.Number) params.SetFrom(m.Config.Number)
params.SetMessagingServiceSid(m.Config.ServiceSID) params.SetMessagingServiceSid(m.Config.ServiceSID)
params.SetBody(msg.Content) params.SetBody(msg.Content)
if sendTime != nil && isSchedulable(&now, sendTime) { if sendTime != nil && isSchedulable(now, sendTime) {
params.SetSendAt(*sendTime) params.SetSendAt(*sendTime)
params.SetScheduleType(Schedule_Type)
} }
if resp, err := client.Api.CreateMessage(params); err != nil { if resp, err := client.Api.CreateMessage(params); err != nil {
@@ -51,10 +49,10 @@ func (m *MessageSender) Send(msg message.Message, number contact.Contact, sendTi
} }
} }
func isSchedulable(now *time.Time, scheduled *time.Time) bool { func isSchedulable(now *time.Time, scheduled *time.Time) (bool) {
early := now.Add(300 * time.Second) early := now.Add(300 * time.Second)
if scheduled.After(early) { if scheduled.Before(early) && scheduled.After(now) {
return true return true
} else { } else {
return false return false