Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ticketer twilio flex #61

Merged
merged 24 commits into from
Apr 4, 2022
Merged
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b7df743
add twilioflex ticketer client base
rasoro Jan 21, 2022
9694ddb
add twilioflex ticketer service base
rasoro Jan 21, 2022
63dc542
Add ticketer twilio flex Open Implementation
rasoro Jan 26, 2022
603d1ff
add twiliflex ticketer Forward implementation
rasoro Jan 27, 2022
0546e7e
add twilioflex ticketer web service for webhook callback events
rasoro Jan 27, 2022
b567a78
add twilio flex ticketer client CompleteTask to close ticket
rasoro Feb 1, 2022
add08bd
add twilio flex service Close method implementation
rasoro Feb 1, 2022
e47f870
add case for twilio channel update event callback to close ticket
rasoro Feb 1, 2022
3b49379
update db dump to add twilio flex dummy ticketer
rasoro Mar 11, 2022
c1a6904
add twilio flex ticketer test constant
rasoro Mar 11, 2022
38a1843
twilioflex client test
rasoro Mar 11, 2022
d04f571
twilioflex ticketer service test
rasoro Mar 11, 2022
6da5613
add twilioflex ticketer testdata
rasoro Mar 11, 2022
6fbb3e8
twilioflex ticketer web test
rasoro Mar 11, 2022
0d62683
refactor twilioflex ticketer web
rasoro Mar 11, 2022
f631afc
support to media message
rasoro Mar 16, 2022
40d90a0
adjust twilio flex ticketer client test
rasoro Mar 17, 2022
3e4dd99
add in ticketer twilioflex the custom fields to flex channel TaskAttr…
rasoro Mar 18, 2022
0fe4d35
twilioflex ticketer history
rasoro Mar 24, 2022
b717727
twilioflex ticketer service_test tweaks
rasoro Mar 24, 2022
a4dd956
fix twilioflex createFlexChannelParams in service
rasoro Mar 25, 2022
da6bde0
fix fetchUrl from twilioflex ticketer client FetchMedia
rasoro Mar 31, 2022
a5b23aa
update twilioflex web_test
rasoro Apr 1, 2022
c40b752
test select contact messages
rasoro Apr 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/mailroom/main.go
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ import (
_ "github.com/nyaruka/mailroom/services/tickets/intern"
_ "github.com/nyaruka/mailroom/services/tickets/mailgun"
_ "github.com/nyaruka/mailroom/services/tickets/rocketchat"
_ "github.com/nyaruka/mailroom/services/tickets/twilioflex"
_ "github.com/nyaruka/mailroom/services/tickets/zendesk"
_ "github.com/nyaruka/mailroom/web/contact"
_ "github.com/nyaruka/mailroom/web/docs"
53 changes: 53 additions & 0 deletions core/models/msgs.go
Original file line number Diff line number Diff line change
@@ -441,6 +441,59 @@ func LoadMessages(ctx context.Context, db Queryer, orgID OrgID, direction MsgDir
return msgs, nil
}

var selectContactMessagesSQL = `
SELECT
id,
broadcast_id,
uuid,
text,
created_on,
direction,
status,
visibility,
msg_count,
error_count,
next_attempt,
external_id,
attachments,
metadata,
channel_id,
connection_id,
contact_id,
contact_urn_id,
response_to_id,
org_id,
topup_id
FROM
msgs_msg
WHERE
contact_id = $1 AND
created_on >= $2
ORDER BY
id ASC`

// SelectContactMessages loads the given messages for the passed in contact, created after the passed in time
func SelectContactMessages(ctx context.Context, db Queryer, contactID int, after time.Time) ([]*Msg, error) {
rows, err := db.QueryxContext(ctx, selectContactMessagesSQL, contactID, after)
if err != nil {
return nil, errors.Wrapf(err, "error querying msgs for contact: %d", contactID)
}
defer rows.Close()

msgs := make([]*Msg, 0)
for rows.Next() {
msg := &Msg{}
err = rows.StructScan(&msg.m)
if err != nil {
return nil, errors.Wrapf(err, "error scanning msg row")
}

msgs = append(msgs, msg)
}

return msgs, nil
}

// NormalizeAttachment will turn any relative URL in the passed in attachment and normalize it to
// include the full host for attachment domains
func NormalizeAttachment(cfg *runtime.Config, attachment utils.Attachment) utils.Attachment {
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ require (
)

require (
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/antlr/antlr4 v0.0.0-20200701161529-3d9351f61e0f // indirect
github.com/blevesearch/segment v0.9.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
@@ -43,6 +44,7 @@ require (
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/gofrs/uuid v3.3.0+incompatible // indirect
github.com/google/go-querystring v1.1.0
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@@ -80,6 +82,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/schema v1.1.0 h1:CamqUDOFUBqzrvxuz2vEwo8+SUdwsluFh7IlzJh30LY=
github.com/gorilla/schema v1.1.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU=
Binary file modified mailroom_test.dump
Binary file not shown.
Loading