Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c2d638adf | ||
|
|
0691ce0adb | ||
|
|
40d92ab7d3 |
@@ -16,7 +16,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: '1.25.4' # You can specify a specific version or 'stable'
|
||||
go-version: '1.26.2'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.25.4 AS builder
|
||||
FROM golang:1.26.2 AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
module git.kundeng.us/phoenix/catapult
|
||||
|
||||
go 1.25.4
|
||||
go 1.26.2
|
||||
|
||||
require (
|
||||
git.kundeng.us/phoenix/swoosh v0.0.12
|
||||
git.kundeng.us/phoenix/textsender-models v0.0.12
|
||||
git.kundeng.us/phoenix/swoosh v0.2.1
|
||||
git.kundeng.us/phoenix/textsender-models v0.2.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/joho/godotenv v1.5.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/twilio/twilio-go v1.28.8 // indirect
|
||||
github.com/twilio/twilio-go v1.30.5 // indirect
|
||||
)
|
||||
|
||||
@@ -1,36 +1,27 @@
|
||||
git.kundeng.us/phoenix/swoosh v0.0.12 h1:OtGUYJzakpzJ0fF2BP/z+maCtEfG+avQUJiCY9LMix8=
|
||||
git.kundeng.us/phoenix/swoosh v0.0.12/go.mod h1:5J/URwiWcjksaPmczelvBEeLdwB1mACFuhUdtWTheDg=
|
||||
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=
|
||||
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=
|
||||
git.kundeng.us/phoenix/swoosh v0.2.1 h1:mJ/zXBOqzi0YTrSm5kxvahzp2WH7lx4R3iIO0s9VFFI=
|
||||
git.kundeng.us/phoenix/swoosh v0.2.1/go.mod h1:81XNzmTmDPuDPmXMUmKTLErNSKKBM+hsW5U60Lm78ww=
|
||||
git.kundeng.us/phoenix/textsender-models v0.2.1 h1:21br4NF58aUFuCx8laKxC5RvZMl4GsSIaMX4bvf5plw=
|
||||
git.kundeng.us/phoenix/textsender-models v0.2.1/go.mod h1:nu5QWy9o+spx/t9NFipaGmF5qiBJS/0QhxyCjoi3Z3E=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
|
||||
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
||||
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
||||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/localtunnel/go-localtunnel v0.0.0-20170326223115-8a804488f275 h1:IZycmTpoUtQK3PD60UYBwjaCUHUP7cML494ao9/O8+Q=
|
||||
github.com/localtunnel/go-localtunnel v0.0.0-20170326223115-8a804488f275/go.mod h1:zt6UU74K6Z6oMOYJbJzYpYucqdcQwSMPBEdSvGiaUMw=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
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.8 h1:wbFz7Wt4S5mCEaes6FcM/ddcJGIhdjwp/9CHb9e+4fk=
|
||||
github.com/twilio/twilio-go v1.28.8/go.mod h1:FpgNWMoD8CFnmukpKq9RNpUSGXC0BwnbeKZj2YHlIkw=
|
||||
github.com/twilio/twilio-go v1.30.5 h1:hi6+2kMte29zrFBsw7VSSNtbF30GPMGz/4LRIUgXng8=
|
||||
github.com/twilio/twilio-go v1.30.5/go.mod h1:QbitvbvtkV77Jn4BABAKVmxabYSjMyQG4tHey9gfPqg=
|
||||
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=
|
||||
@@ -54,7 +45,5 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"git.kundeng.us/phoenix/textsender-models/tx0/config"
|
||||
auxcfg "git.kundeng.us/phoenix/textsender-models/tx0/config/auxiliary"
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ type App struct {
|
||||
AuthUrl string
|
||||
ServiceUsername string
|
||||
ServicePassphrase string
|
||||
TwilioConfig *config.TwilioConfig
|
||||
TwilioConfig *auxcfg.TwilioConfig
|
||||
}
|
||||
|
||||
func Load() (*App, error) {
|
||||
@@ -56,7 +56,7 @@ func Load() (*App, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func loadTwilioConfig() (*config.TwilioConfig, error) {
|
||||
func loadTwilioConfig() (*auxcfg.TwilioConfig, error) {
|
||||
authSid := os.Getenv("TWILIO_AUTH_SID")
|
||||
serviceSid := os.Getenv("TWILIO_SERVICE_SID")
|
||||
authToken := os.Getenv("TWILIO_AUTH_TOKEN")
|
||||
@@ -71,7 +71,7 @@ func loadTwilioConfig() (*config.TwilioConfig, error) {
|
||||
} else if len(phoneNumber) == 0 {
|
||||
return nil, fmt.Errorf("Twilio config phone number not provided")
|
||||
} else {
|
||||
cfg := config.TwilioConfig{}
|
||||
cfg := auxcfg.TwilioConfig{}
|
||||
cfg.AccountSID = authSid
|
||||
cfg.AuthToken = authToken
|
||||
cfg.ServiceSID = serviceSid
|
||||
|
||||
@@ -2,7 +2,6 @@ package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -99,42 +98,23 @@ func (s *Service) worker1() {
|
||||
if msg, err := scheduler.GetMessage(event.MessageId); err != nil {
|
||||
log.Println("Error getting message:", err)
|
||||
} else {
|
||||
if c, err := scheduler.GetContact(event.RecipientId); err != nil {
|
||||
if c, err := scheduler.GetContact(event.ContactId); err != nil {
|
||||
log.Println("Error getting contact:", err)
|
||||
} else {
|
||||
log.Println("Message Id:", msg.Id)
|
||||
log.Println("Contact Id:", c.Id)
|
||||
if res, sent, err := scheduler.ScheduleMessage(*item, *event, *c, *msg); err != nil {
|
||||
if res, resRaw, sent, err := scheduler.ScheduleMessage(*item, *event, *c, *msg); err != nil {
|
||||
log.Println("Failure with scheduling the message:", err)
|
||||
} else {
|
||||
if res != nil {
|
||||
bytes, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
log.Println("Error parsing result:", err)
|
||||
if eventResponse, err := scheduler.RecordEventResponse(event, item.UserId, resRaw, sent); err != nil {
|
||||
log.Println("Failure recording event response:", err)
|
||||
} else {
|
||||
jsonValue := string(bytes)
|
||||
log.Println("Result:", jsonValue)
|
||||
|
||||
if eventResponse, err := scheduler.RecordEventResponse(event, item.UserId, bytes, sent); err != nil {
|
||||
log.Println("Failure recording event response:", err)
|
||||
if len(eventResponse) == 0 {
|
||||
log.Println("No event responses")
|
||||
} else {
|
||||
if len(eventResponse) == 0 {
|
||||
log.Println("No event responses")
|
||||
} else {
|
||||
eventResponse := eventResponse[0]
|
||||
log.Println("Event response saved. Id:", eventResponse.Id)
|
||||
sameJsonValue := string(eventResponse.Response)
|
||||
|
||||
if jsonValue == sameJsonValue {
|
||||
log.Println("Matches")
|
||||
} else if len(jsonValue) == len(sameJsonValue) {
|
||||
log.Println("Same size")
|
||||
log.Println(jsonValue)
|
||||
log.Println(sameJsonValue)
|
||||
} else {
|
||||
log.Println("Not the same")
|
||||
}
|
||||
}
|
||||
eventResponse := eventResponse[0]
|
||||
log.Println("Event response saved. Id:", eventResponse.Id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"git.kundeng.us/phoenix/textsender-models/tx0/message"
|
||||
"git.kundeng.us/phoenix/textsender-models/tx0/message/event"
|
||||
"git.kundeng.us/phoenix/textsender-models/tx0/token"
|
||||
|
||||
"git.kundeng.us/phoenix/catapult/internal/app"
|
||||
@@ -18,11 +18,11 @@ type MessageEventResponse struct {
|
||||
}
|
||||
|
||||
type recordMessageEventResponse struct {
|
||||
Message string `json:"message"`
|
||||
Data []*message.MessageEventResponse `json:"data"`
|
||||
Message string `json:"message"`
|
||||
Data []*event.MessageEventResponse `json:"data"`
|
||||
}
|
||||
|
||||
func (m *MessageEventResponse) RecordEventResponse(mer *message.MessageEventResponse) ([]*message.MessageEventResponse, error) {
|
||||
func (m *MessageEventResponse) RecordEventResponse(mer *event.MessageEventResponse) ([]*event.MessageEventResponse, error) {
|
||||
fullUrl := fmt.Sprintf("%s/api/v1/schedule/message/event/response/record", m.Application.ApiUrl)
|
||||
jsonData, err := json.Marshal(mer)
|
||||
if err != nil {
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"git.kundeng.us/phoenix/swoosh/swoop/types"
|
||||
"git.kundeng.us/phoenix/textsender-models/tx0/contact"
|
||||
"git.kundeng.us/phoenix/textsender-models/tx0/message"
|
||||
evnt "git.kundeng.us/phoenix/textsender-models/tx0/message/event"
|
||||
"git.kundeng.us/phoenix/textsender-models/tx0/message/scheduling"
|
||||
"git.kundeng.us/phoenix/textsender-models/tx0/token"
|
||||
"github.com/google/uuid"
|
||||
@@ -46,18 +47,18 @@ func (s *Scheduler) GetContact(id uuid.UUID) (*contact.Contact, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Scheduler) ScheduleMessage(schMsg scheduling.ScheduledMessage, event scheduling.ScheduledMessageEvent, c contact.Contact, msg message.Message) (*types.TwilioResult, *time.Time, error) {
|
||||
func (s *Scheduler) ScheduleMessage(schMsg scheduling.ScheduledMessage, event scheduling.ScheduledMessageEvent, c contact.Contact, msg message.Message) (*types.TwilioResult, map[string]any, *time.Time, error) {
|
||||
msgSender := send.MessageSender{Config: s.Application.TwilioConfig}
|
||||
if res, err := msgSender.Send(msg, c, &schMsg.Scheduled); err != nil {
|
||||
return nil, nil, err
|
||||
if res, resRaw, err := msgSender.Send(msg, c, &schMsg.Scheduled); err != nil {
|
||||
return nil, nil, nil, err
|
||||
} else {
|
||||
sent := time.Now()
|
||||
return res, &sent, nil
|
||||
return res, resRaw, &sent, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Scheduler) RecordEventResponse(schMsgEvent *scheduling.ScheduledMessageEvent, userId uuid.UUID, bytes []byte, sent *time.Time) ([]*message.MessageEventResponse, error) {
|
||||
mre := message.MessageEventResponse{ScheduledMessageEventId: schMsgEvent.Id, UserId: userId, Response: bytes, Sent: *sent, Status: message.Message_Event_Response_Status_Scheduled}
|
||||
func (s *Scheduler) RecordEventResponse(schMsgEvent *scheduling.ScheduledMessageEvent, userId uuid.UUID, bytes map[string]any, sent *time.Time) ([]*evnt.MessageEventResponse, error) {
|
||||
mre := evnt.MessageEventResponse{ScheduledMessageEventId: schMsgEvent.Id, UserId: userId, Response: bytes, Sent: *sent, Status: evnt.Message_Event_Response_Status_Scheduled}
|
||||
|
||||
msgEventResponse := MessageEventResponse{Application: s.Application, Token: s.Token}
|
||||
if responses, err := msgEventResponse.RecordEventResponse(&mre); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user