Compare commits

..
Author SHA1 Message Date
phoenix ae0df7ef0a tsk-9: Build fixes after package update 2025-12-31 18:35:20 -05:00
phoenix 0ec0b3dece tsk-9: textsender-models version bump 2025-12-31 18:34:58 -05:00
phoenixandphoenix 5ba61caee3 Syntax bug fix (#8)
Reviewed-on: #8
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-12-22 22:30:41 +00:00
phoenixandphoenix 1218921cc3 twilio-go version bump (#7)
Reviewed-on: #7
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-12-04 02:53:53 +00:00
phoenixandphoenix 92a492cb06 textsender-models version bump (#6)
Reviewed-on: #6
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-12-01 19:04:35 +00:00
phoenixandphoenix 4bba8d6b3c Added scheduling check (#5)
Reviewed-on: #5
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-11-29 19:22:29 +00:00
4 changed files with 16 additions and 12 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ jobs:
run: |
echo "Creating version"
VERSION="0.0.4"
VERSION="0.0.8"
PROJECT_COMMIT_HASH=$(git rev-parse HEAD | cut -c 1-10)
BRANCH_REF="${{ gitea.ref }}"
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
+2 -2
View File
@@ -3,8 +3,8 @@ module git.kundeng.us/phoenix/swoosh
go 1.25.4
require (
git.kundeng.us/phoenix/textsender-models v0.0.10
github.com/twilio/twilio-go v1.28.6
git.kundeng.us/phoenix/textsender-models v0.1.6-30-f4e2336771-556
github.com/twilio/twilio-go v1.28.8
)
require (
+6 -4
View File
@@ -1,5 +1,7 @@
git.kundeng.us/phoenix/textsender-models v0.0.10 h1:0AMe/zm4Xte2BcuqqhRP7+42m+4To+rUnHkR2a9eXlI=
git.kundeng.us/phoenix/textsender-models v0.0.10/go.mod h1:9iPDQJg1Tc6WMNoW5+f8YKmnosMwlWHJ++hmxNLDEe0=
git.kundeng.us/phoenix/textsender-models v0.0.12 h1:ps9H3FS5LyCwQhAiIvg4vYyfLZZ64dex1y9ytb0o9C4=
git.kundeng.us/phoenix/textsender-models v0.0.12/go.mod h1:9iPDQJg1Tc6WMNoW5+f8YKmnosMwlWHJ++hmxNLDEe0=
git.kundeng.us/phoenix/textsender-models v0.1.6-30-f4e2336771-556 h1:869mq7lyB+XaNqJOMOGWdfHs97sC2OrreIxW4zkIjkQ=
git.kundeng.us/phoenix/textsender-models v0.1.6-30-f4e2336771-556/go.mod h1:9iPDQJg1Tc6WMNoW5+f8YKmnosMwlWHJ++hmxNLDEe0=
github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -25,8 +27,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/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/twilio/twilio-go v1.28.6 h1:L/pikXkARmPOzF/gUMeZPP/Lu5mY/wA4XC7sRzS86W4=
github.com/twilio/twilio-go v1.28.6/go.mod h1:FpgNWMoD8CFnmukpKq9RNpUSGXC0BwnbeKZj2YHlIkw=
github.com/twilio/twilio-go v1.28.8 h1:wbFz7Wt4S5mCEaes6FcM/ddcJGIhdjwp/9CHb9e+4fk=
github.com/twilio/twilio-go v1.28.8/go.mod h1:FpgNWMoD8CFnmukpKq9RNpUSGXC0BwnbeKZj2YHlIkw=
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-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+7 -5
View File
@@ -5,7 +5,7 @@ import (
"fmt"
"time"
"git.kundeng.us/phoenix/textsender-models/tx0/config"
auxcfg "git.kundeng.us/phoenix/textsender-models/tx0/config/auxiliary"
"git.kundeng.us/phoenix/textsender-models/tx0/contact"
"git.kundeng.us/phoenix/textsender-models/tx0/message"
"github.com/twilio/twilio-go"
@@ -14,9 +14,10 @@ import (
"git.kundeng.us/phoenix/swoosh/swoop/types"
)
const Schedule_Type = "fixed"
type MessageSender struct {
Config *config.TwiloConfig
Config *auxcfg.TwilioConfig
}
func (m *MessageSender) Send(msg message.Message, number contact.Contact, sendTime *time.Time) (*types.TwilioResult, error) {
@@ -34,8 +35,9 @@ func (m *MessageSender) Send(msg message.Message, number contact.Contact, sendTi
params.SetFrom(m.Config.Number)
params.SetMessagingServiceSid(m.Config.ServiceSID)
params.SetBody(msg.Content)
if sendTime != nil && isSchedulable(now, sendTime) {
if sendTime != nil && isSchedulable(&now, sendTime) {
params.SetSendAt(*sendTime)
params.SetScheduleType(Schedule_Type)
}
if resp, err := client.Api.CreateMessage(params); err != nil {
@@ -49,10 +51,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)
if scheduled.Before(early) && scheduled.After(now) {
if scheduled.After(early) {
return true
} else {
return false