Skip to content

Commit

Permalink
Merge pull request #35 from Ilhasoft/update-rp/v5.7.24
Browse files Browse the repository at this point in the history
Update master-rp to v5.7.24
  • Loading branch information
matmsa27 authored Nov 13, 2020
2 parents 48e62d8 + c1b9c57 commit bd0eed9
Show file tree
Hide file tree
Showing 129 changed files with 3,157 additions and 2,083 deletions.
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
v5.7.24
----------
* Add SessionStatus to messages queued to courier

v5.7.23
----------
* Make defining new task types easier and drier
* Better locking when handling
* Fix and simplify creation of channel logs in IVR handlers

v5.7.22
----------
* Update to latest goflow v0.104.1

v5.7.21
----------
* Simplify test-smtp cmd using smtpx package
* Create new dbutil package with generic DB stuff
* Add task to calculate fires for new campaign event

v5.7.20
----------
* Fix incoming attachments from Zendesk

v5.7.19
----------
* Update to latest goflow
* Empty contact names and languages should be saved as NULL
* Delete no longer used utils/celery package

v5.7.18
----------
* Update to latest goflow
* Add support for incoming attachments on ticketing services

v5.7.17
----------
* Use status for elastic queries that need to filter out non-active contacts

v5.7.16
----------
* Add support for excluding contacts from searches by ids
* Rework utils/storage to be generic and moveable to gocommon

v5.7.15
----------
* Add create contact endpoint which uses modifiers to add fields and groups to contacts
* Rework contact creation functions to support creation with multiple URNs

v5.7.14
----------
* Stop writing is_blocked and is_stopped
Expand Down
16 changes: 7 additions & 9 deletions cmd/mailroom/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import (
"runtime"
"syscall"

_ "github.com/lib/pq"
"github.com/nyaruka/ezconf"
"github.com/nyaruka/goflow/utils/uuids"
"github.com/nyaruka/gocommon/uuids"
"github.com/nyaruka/logrus_sentry"
"github.com/nyaruka/mailroom"
"github.com/nyaruka/mailroom/config"
"github.com/sirupsen/logrus"

_ "github.com/nyaruka/mailroom/hooks"
_ "github.com/nyaruka/mailroom/ivr/nexmo"
_ "github.com/nyaruka/mailroom/ivr/twiml"
_ "github.com/nyaruka/mailroom/services/tickets/mailgun"
_ "github.com/nyaruka/mailroom/services/tickets/zendesk"
_ "github.com/nyaruka/mailroom/tasks/broadcasts"
_ "github.com/nyaruka/mailroom/tasks/campaigns"
_ "github.com/nyaruka/mailroom/tasks/expirations"
Expand All @@ -25,7 +27,6 @@ import (
_ "github.com/nyaruka/mailroom/tasks/starts"
_ "github.com/nyaruka/mailroom/tasks/stats"
_ "github.com/nyaruka/mailroom/tasks/timeouts"

_ "github.com/nyaruka/mailroom/web/contact"
_ "github.com/nyaruka/mailroom/web/docs"
_ "github.com/nyaruka/mailroom/web/expression"
Expand All @@ -37,11 +38,8 @@ import (
_ "github.com/nyaruka/mailroom/web/surveyor"
_ "github.com/nyaruka/mailroom/web/ticket"

_ "github.com/nyaruka/mailroom/services/tickets/mailgun"
_ "github.com/nyaruka/mailroom/services/tickets/zendesk"

_ "github.com/nyaruka/mailroom/ivr/nexmo"
_ "github.com/nyaruka/mailroom/ivr/twiml"
_ "github.com/lib/pq"
"github.com/sirupsen/logrus"
)

var version = "Dev"
Expand Down
54 changes: 7 additions & 47 deletions cmd/test-smtp/main.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package main

import (
"net/url"
"strconv"

"github.com/nyaruka/ezconf"
"github.com/nyaruka/goflow/utils/smtpx"

"github.com/sirupsen/logrus"
"gopkg.in/mail.v2"
)

type Config struct {
type config struct {
URL string `help:"the SMTP formatted URL to use to test sending"`
To string `help:"the email address to send to"`
Subject string `help:"the email subject to send"`
Expand All @@ -18,7 +16,7 @@ type Config struct {

func main() {
// get our smtp server config
options := &Config{
options := &config{
URL: "smtp://foo%40zap.com:[email protected]:587/?from=foo%40zap.com&tls=true",
To: "[email protected]",
Subject: "Test Email",
Expand All @@ -31,52 +29,14 @@ func main() {
)
loader.MustLoad()

// parse it
url, err := url.Parse(options.URL)
client, err := smtpx.NewClientFromURL(options.URL)
if err != nil {
logrus.WithError(err).Fatalf("unable to parse smtp config: %s", options.URL)
}

// figure out our port
sPort := url.Port()
if sPort == "" {
sPort = "25"
}
port, err := strconv.Atoi(sPort)
if err != nil {
logrus.WithError(err).Fatalf("invalid port configuration: %s", options.URL)
}

// and our user and password
if url.User == nil {
logrus.Fatalf("no user set for smtp server: %s", options.URL)
}
password, _ := url.User.Password()

// get our from
from := url.Query()["from"]
if len(from) == 0 {
from = []string{url.User.Username()}
}

// create our dialer for our org
d := mail.NewDialer(url.Hostname(), port, url.User.Username(), password)

// send each of our emails, errors are logged but don't stop us from trying to send our other emails
m := mail.NewMessage()
m.SetHeader("From", from[0])
m.SetHeader("To", options.To)
m.SetHeader("Subject", options.Subject)
m.SetBody("text/plain", options.Body)

logrus.WithFields(logrus.Fields{
"hostname": url.Hostname(),
"port": port,
"username": url.User.Username(),
"password": password,
}).Info("attempting to send email")
m := smtpx.NewMessage([]string{options.To}, options.Subject, options.Body, "")

err = d.DialAndSend(m)
err = smtpx.Send(client, m)
if err != nil {
logrus.WithError(err).Fatal("error sending email")
}
Expand Down
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ module github.com/nyaruka/mailroom
require (
github.com/Masterminds/semver v1.5.0
github.com/apex/log v1.1.4
github.com/aws/aws-sdk-go v1.30.17
github.com/buger/jsonparser v0.0.0-20200322175846-f7e751efca13
github.com/certifi/gocertifi v0.0.0-20200211180108-c7c1fbc02894 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/edganiukov/fcm v0.4.0
github.com/getsentry/raven-go v0.1.2-0.20190125112653-238ebd86338d // indirect
github.com/go-chi/chi v3.3.3+incompatible
github.com/go-chi/chi v4.1.2+incompatible
github.com/golang/protobuf v1.4.0
github.com/gomodule/redigo v2.0.0+incompatible
github.com/gorilla/schema v1.1.0
Expand All @@ -18,8 +17,8 @@ require (
github.com/lib/pq v1.4.0
github.com/mattn/go-sqlite3 v1.10.0 // indirect
github.com/nyaruka/ezconf v0.2.1
github.com/nyaruka/gocommon v1.3.0
github.com/nyaruka/goflow v0.102.1
github.com/nyaruka/gocommon v1.5.1
github.com/nyaruka/goflow v0.104.1
github.com/nyaruka/librato v1.0.0
github.com/nyaruka/logrus_sentry v0.8.2-0.20190129182604-c2962b80ba7d
github.com/nyaruka/null v1.2.0
Expand All @@ -32,7 +31,6 @@ require (
github.com/sirupsen/logrus v1.5.0
github.com/stretchr/testify v1.5.1
gopkg.in/go-playground/validator.v9 v9.31.0
gopkg.in/mail.v2 v2.3.1
)

go 1.14
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a/go.mod h1:3NqKYiepwy
github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys=
github.com/aws/aws-sdk-go v1.20.6 h1:kmy4Gvdlyez1fV4kw5RYxZzWKVyuHZHgPWeU/YvRsV4=
github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.30.17 h1:Y8cyVjc7RWSJwt9uymwnsKZI4qnmamMkfYJJ806wHtA=
github.com/aws/aws-sdk-go v1.30.17/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aws/aws-sdk-go v1.34.17 h1:9OzUgRrLmYm2mbfFx4v+2nBEg+Cvape1cvn9C3RNWTE=
github.com/aws/aws-sdk-go v1.34.17/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand All @@ -39,8 +39,8 @@ github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHqu
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/getsentry/raven-go v0.1.2-0.20190125112653-238ebd86338d h1:CIp8WnfXz70wJVQ0ytr3dswFYGoJbAxWgNvaLpiu3sY=
github.com/getsentry/raven-go v0.1.2-0.20190125112653-238ebd86338d/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
github.com/go-chi/chi v3.3.3+incompatible h1:KHkmBEMNkwKuK4FdQL7N2wOeB9jnIx7jR5wsuSBEFI8=
github.com/go-chi/chi v3.3.3+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec=
github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
Expand All @@ -55,8 +55,8 @@ github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84=
github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down Expand Up @@ -128,19 +128,18 @@ github.com/naoina/toml v0.1.1 h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8=
github.com/naoina/toml v0.1.1/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E=
github.com/nyaruka/ezconf v0.2.1 h1:TDXWoqjqYya1uhou1mAJZg7rgFYL98EB0Tb3+BWtUh0=
github.com/nyaruka/ezconf v0.2.1/go.mod h1:ey182kYkw2MIi4XiWe1FR/mzI33WCmTWuceDYYxgnQw=
github.com/nyaruka/gocommon v1.3.0 h1:IqaPT4KQ2oVq/2Ivp/c+RVCs8v71+RzPU2VhMoRrgpU=
github.com/nyaruka/gocommon v1.3.0/go.mod h1:w7lKxIkm/qLAoO9Y3aI1LV7EiYogn6+1C8MTEjxTC9M=
github.com/nyaruka/goflow v0.102.1 h1:7QX2jTwV7uIbaGnkkpmB+ao+E7Cmyar9g7sRQH4Bu3M=
github.com/nyaruka/goflow v0.102.1/go.mod h1:wuvXZTs6a6S1rjSRLaQGVxDfKomDJ/1XQoLXCqFekK4=
github.com/nyaruka/gocommon v1.5.1 h1:2R6uo6EVSTHOerupAmVm6h5fyufO189dlv/5gwHj3lM=
github.com/nyaruka/gocommon v1.5.1/go.mod h1:6XoaOsVk6z+294hM6pZxX3fDgT2IyLV8hFU4FoQz9Aw=
github.com/nyaruka/goflow v0.104.1 h1:uFmB4dDJwuVJxgcJFEnbXzFOYrqNiiJLnlxd0t6yXxg=
github.com/nyaruka/goflow v0.104.1/go.mod h1:dZBsFXFQ9EzcDlEupM7rcbMdDpIGUNOCMndSCRo7Ofo=
github.com/nyaruka/librato v1.0.0 h1:Vznj9WCeC1yZXbBYyYp40KnbmXLbEkjKmHesV/v2SR0=
github.com/nyaruka/librato v1.0.0/go.mod h1:pkRNLFhFurOz0QqBz6/DuTFhHHxAubWxs4Jx+J7yUgg=
github.com/nyaruka/logrus_sentry v0.8.2-0.20190129182604-c2962b80ba7d h1:hyp9u36KIwbTCo2JAJ+TuJcJBc+UZzEig7RI/S5Dvkc=
github.com/nyaruka/logrus_sentry v0.8.2-0.20190129182604-c2962b80ba7d/go.mod h1:FGdPJVDTNqbRAD+2RvnK9YoO2HcEW7ogSMPzc90b638=
github.com/nyaruka/null v1.2.0 h1:uEbkyy4Z+zPB2Pr3ryQh/0N2965I9kEsXq/cGpyJ7PA=
github.com/nyaruka/null v1.2.0/go.mod h1:HSAFbLNOaEhHnoU0VCveCPz0GDtJ3GEtFWhvnBNkhPE=
github.com/nyaruka/phonenumbers v1.0.34/go.mod h1:GQ0cTHlrxPrhoLwyQ1blyN1hO794ygt6FTHWrFB5SSc=
github.com/nyaruka/phonenumbers v1.0.55 h1:bj0nTO88Y68KeUQ/n3Lo2KgK7lM1hF7L9NFuwcCl3yg=
github.com/nyaruka/phonenumbers v1.0.55/go.mod h1:sDaTZ/KPX5f8qyV9qN+hIm+4ZBARJrupC6LuhshJq1U=
github.com/nyaruka/phonenumbers v1.0.57 h1:V4FNPs061PSUOEzQaLH0+pfzEdqoiMH/QJWryx/0hfs=
github.com/nyaruka/phonenumbers v1.0.57/go.mod h1:sDaTZ/KPX5f8qyV9qN+hIm+4ZBARJrupC6LuhshJq1U=
github.com/olivere/elastic v6.2.33+incompatible h1:SRPB2w2OhJ7iULftDEHsNPRoL2GLREqPMRalVmbZaEw=
github.com/olivere/elastic v6.2.33+incompatible/go.mod h1:J+q1zQJTgAz9woqsbVRqGeB5G1iqDKVBWLNSYW8yfJ8=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down Expand Up @@ -198,7 +197,6 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180921000356-2f5d2388922f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
Expand All @@ -223,6 +221,8 @@ golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
2 changes: 1 addition & 1 deletion goflow/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"sync"

"github.com/nyaruka/gocommon/urns"
"github.com/nyaruka/gocommon/uuids"
"github.com/nyaruka/goflow/flows"
"github.com/nyaruka/goflow/flows/engine"
"github.com/nyaruka/goflow/services/webhooks"
"github.com/nyaruka/goflow/utils/uuids"
"github.com/nyaruka/mailroom/config"

"github.com/shopspring/decimal"
Expand Down
2 changes: 1 addition & 1 deletion goflow/flows.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"encoding/json"
"sync"

"github.com/nyaruka/gocommon/uuids"
"github.com/nyaruka/goflow/flows"
"github.com/nyaruka/goflow/flows/definition"
"github.com/nyaruka/goflow/flows/definition/migrations"
"github.com/nyaruka/goflow/utils/uuids"
"github.com/nyaruka/mailroom/config"

"github.com/Masterminds/semver"
Expand Down
2 changes: 1 addition & 1 deletion goflow/flows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package goflow_test
import (
"testing"

"github.com/nyaruka/gocommon/uuids"
"github.com/nyaruka/goflow/assets"
"github.com/nyaruka/goflow/envs"
"github.com/nyaruka/goflow/flows"
"github.com/nyaruka/goflow/test"
"github.com/nyaruka/goflow/utils/uuids"
"github.com/nyaruka/mailroom/goflow"

"github.com/Masterminds/semver"
Expand Down
2 changes: 1 addition & 1 deletion hooks/campaigns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package hooks
import (
"testing"

"github.com/nyaruka/gocommon/uuids"
"github.com/nyaruka/goflow/assets"
"github.com/nyaruka/goflow/flows"
"github.com/nyaruka/goflow/flows/actions"
"github.com/nyaruka/goflow/utils/uuids"
"github.com/nyaruka/mailroom/models"
"github.com/nyaruka/mailroom/testsuite"
)
Expand Down
4 changes: 2 additions & 2 deletions hooks/contact_field_changed.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ func (h *CommitFieldChangesHook) Apply(ctx context.Context, tx *sqlx.Tx, rp *red
// first apply our deletes
// in pg9.6 we need to do this as one query per field type, in pg10 we can rewrite this to be a single query
for _, fds := range fieldDeletes {
err := models.BulkSQL(ctx, "deleting contact field values", tx, deleteContactFieldsSQL, fds)
err := models.BulkQuery(ctx, "deleting contact field values", tx, deleteContactFieldsSQL, fds)
if err != nil {
return errors.Wrapf(err, "error deleting contact fields")
}
}

// then our updates
if len(fieldUpdates) > 0 {
err := models.BulkSQL(ctx, "updating contact field values", tx, updateContactFieldsSQL, fieldUpdates)
err := models.BulkQuery(ctx, "updating contact field values", tx, updateContactFieldsSQL, fieldUpdates)
if err != nil {
return errors.Wrapf(err, "error updating contact fields")
}
Expand Down
7 changes: 4 additions & 3 deletions hooks/contact_language_changed.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/nyaruka/goflow/flows"
"github.com/nyaruka/goflow/flows/events"
"github.com/nyaruka/mailroom/models"
"github.com/nyaruka/null"
"github.com/sirupsen/logrus"
)

Expand All @@ -27,11 +28,11 @@ func (h *CommitLanguageChangesHook) Apply(ctx context.Context, tx *sqlx.Tx, rp *
for s, e := range scenes {
// we only care about the last name change
event := e[len(e)-1].(*events.ContactLanguageChangedEvent)
updates = append(updates, &languageUpdate{s.ContactID(), event.Language})
updates = append(updates, &languageUpdate{s.ContactID(), null.String(event.Language)})
}

// do our update
return models.BulkSQL(ctx, "updating contact language", tx, updateContactLanguageSQL, updates)
return models.BulkQuery(ctx, "updating contact language", tx, updateContactLanguageSQL, updates)
}

// handleContactLanguageChanged is called when we process a contact language change
Expand All @@ -50,7 +51,7 @@ func handleContactLanguageChanged(ctx context.Context, tx *sqlx.Tx, rp *redis.Po
// struct used for our bulk update
type languageUpdate struct {
ContactID models.ContactID `db:"id"`
Language string `db:"language"`
Language null.String `db:"language"`
}

const updateContactLanguageSQL = `
Expand Down
Loading

0 comments on commit bd0eed9

Please sign in to comment.