Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Feb 22, 2021
2 parents ccdde26 + 44009d8 commit 72afbe9
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 15 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
v6.1.17
----------
* Should match referral trigger with case insensitive

v6.1.16
----------
* Update to latest goflow
* Add link local ips to default disallowed networks config

v6.1.15
----------
* Update phonenumbers lib
Expand Down
1 change: 1 addition & 0 deletions cmd/mailroom/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
_ "github.com/nyaruka/mailroom/core/tasks/starts"
_ "github.com/nyaruka/mailroom/core/tasks/stats"
_ "github.com/nyaruka/mailroom/core/tasks/timeouts"
_ "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/zendesk"
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func NewMailroomConfig() *Config {
WebhooksInitialBackoff: 5000,
WebhooksBackoffJitter: 0.5,
SMTPServer: "",
DisallowedNetworks: `127.0.0.1,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16`,
DisallowedNetworks: `127.0.0.1,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16,fe80::/10`,
MaxStepsPerSprint: 100,
MaxValueLength: 640,

Expand Down
5 changes: 4 additions & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ func TestParseDisallowedNetworks(t *testing.T) {
privateNetwork2 := &net.IPNet{IP: net.IPv4(172, 16, 0, 0).To4(), Mask: net.CIDRMask(12, 32)}
privateNetwork3 := &net.IPNet{IP: net.IPv4(192, 168, 0, 0).To4(), Mask: net.CIDRMask(16, 32)}

linkLocalIPv4 := &net.IPNet{IP: net.IPv4(169, 254, 0, 0).To4(), Mask: net.CIDRMask(16, 32)}
_, linkLocalIPv6, _ := net.ParseCIDR("fe80::/10")

// test with config defaults
ips, ipNets, err := cfg.ParseDisallowedNetworks()
assert.NoError(t, err)
assert.Equal(t, []net.IP{net.IPv4(127, 0, 0, 1), net.ParseIP(`::1`)}, ips)
assert.Equal(t, []*net.IPNet{privateNetwork1, privateNetwork2, privateNetwork3}, ipNets)
assert.Equal(t, []*net.IPNet{privateNetwork1, privateNetwork2, privateNetwork3, linkLocalIPv4, linkLocalIPv6}, ipNets)

// test with empty
cfg.DisallowedNetworks = ``
Expand Down
3 changes: 3 additions & 0 deletions core/models/test_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ var ZendeskUUID = assets.TicketerUUID("4ee6d4f3-f92b-439b-9718-8da90c05490b")
var RocketChatID = TicketerID(3)
var RocketChatUUID = assets.TicketerUUID("6c50665f-b4ff-4e37-9625-bc464fe6a999")

var InternalID = TicketerID(4)
var InternalUUID = assets.TicketerUUID("8bd48029-6ca1-46a8-aa14-68f7213b82b3")

// constants for org 2, just a few here

var Org2 = OrgID(2)
Expand Down
2 changes: 1 addition & 1 deletion core/models/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func FindMatchingReferralTrigger(org *OrgAssets, channel *Channel, referrerID st
for _, t := range org.Triggers() {
if t.TriggerType() == ReferralTriggerType {
// matches referrer id? that takes top precedence, return right away
if referrerID != "" && referrerID == t.ReferrerID() && (t.ChannelID() == NilChannelID || t.ChannelID() == channel.ID()) {
if strings.ToLower(referrerID) != "" && strings.ToLower(referrerID) == strings.ToLower(t.ReferrerID()) && (t.ChannelID() == NilChannelID || t.ChannelID() == channel.ID()) {
return t
}

Expand Down
2 changes: 2 additions & 0 deletions core/models/triggers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func TestChannelTriggers(t *testing.T) {
{"", TwilioChannelID, NilTriggerID},
{"foo", TwilioChannelID, NilTriggerID},
{"foo", TwitterChannelID, fooID},
{"FOO", TwitterChannelID, fooID},
{"bar", TwilioChannelID, barID},
{"bar", TwitterChannelID, barID},
{"zap", TwilioChannelID, NilTriggerID},
Expand Down Expand Up @@ -106,6 +107,7 @@ func TestTriggers(t *testing.T) {
TriggerID TriggerID
}{
{"join", cathy, joinID},
{"JOIN", cathy, joinID},
{"join this", cathy, joinID},
{"resist", george, resistID},
{"resist", cathy, farmersID},
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ 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.7.1 h1:1x3v1L69svMnmD38pPvEb1QOyMBkP0QKk8WLDCRJW0w=
github.com/nyaruka/gocommon v1.7.1/go.mod h1:r5UqoAdoP9VLb/wmtF1O0v73PQc79tZaVjbXlO16PUA=
github.com/nyaruka/goflow v0.112.0 h1:nmS/Vtavd1LPsRH4hV10YjnyHmHT6iQzP/05aY5xQGs=
github.com/nyaruka/goflow v0.112.0/go.mod h1:FBksI24mzBjwMzUd/xkr1gulklP6bbTKcaEq6qKNQgE=
github.com/nyaruka/goflow v0.112.1 h1:kM7gsXxiP2QvPv+/kduXAzcOX+KJB63l1RpqFZQfccc=
github.com/nyaruka/goflow v0.112.1/go.mod h1:FBksI24mzBjwMzUd/xkr1gulklP6bbTKcaEq6qKNQgE=
github.com/nyaruka/goflow v0.112.2 h1:vizMqpxhDkCv2i9wJjyaHECOaIvvxfPiyvYwfXRnIMw=
github.com/nyaruka/goflow v0.112.2/go.mod h1:FBksI24mzBjwMzUd/xkr1gulklP6bbTKcaEq6qKNQgE=
github.com/nyaruka/librato v1.0.0 h1:Vznj9WCeC1yZXbBYyYp40KnbmXLbEkjKmHesV/v2SR0=
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package internal
package intern

import (
"net/http"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package internal_test
package intern_test

import (
"net/http"
Expand All @@ -12,7 +12,7 @@ import (
"github.com/nyaruka/goflow/test"
"github.com/nyaruka/goflow/utils"
"github.com/nyaruka/mailroom/core/models"
"github.com/nyaruka/mailroom/services/tickets/internal"
intern "github.com/nyaruka/mailroom/services/tickets/intern"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -27,7 +27,7 @@ func TestOpenAndForward(t *testing.T) {

ticketer := flows.NewTicketer(types.NewTicketer(assets.TicketerUUID(uuids.New()), "Support", "internal"))

svc, err := internal.NewService(
svc, err := intern.NewService(
http.DefaultClient,
nil,
ticketer,
Expand All @@ -49,7 +49,7 @@ func TestOpenAndForward(t *testing.T) {

assert.Equal(t, 0, len(logger.Logs))

dbTicket := models.NewTicket(ticket.UUID, models.Org1, models.CathyID, models.MailgunID, "", "Need help", "Where are my cookies?", nil)
dbTicket := models.NewTicket(ticket.UUID, models.Org1, models.CathyID, models.InternalID, "", "Need help", "Where are my cookies?", nil)

logger = &flows.HTTPLogger{}
err = svc.Forward(
Expand All @@ -69,13 +69,13 @@ func TestCloseAndReopen(t *testing.T) {
defer uuids.SetGenerator(uuids.DefaultGenerator)
uuids.SetGenerator(uuids.NewSeededGenerator(12345))

ticketer := flows.NewTicketer(types.NewTicketer(assets.TicketerUUID(uuids.New()), "Support", "mailgun"))
svc, err := internal.NewService(http.DefaultClient, nil, ticketer, nil)
ticketer := flows.NewTicketer(types.NewTicketer(assets.TicketerUUID(uuids.New()), "Support", "internal"))
svc, err := intern.NewService(http.DefaultClient, nil, ticketer, nil)
require.NoError(t, err)

logger := &flows.HTTPLogger{}
ticket1 := models.NewTicket("88bfa1dc-be33-45c2-b469-294ecb0eba90", models.Org1, models.CathyID, models.ZendeskID, "12", "New ticket", "Where my cookies?", nil)
ticket2 := models.NewTicket("645eee60-7e84-4a9e-ade3-4fce01ae28f1", models.Org1, models.BobID, models.ZendeskID, "14", "Second ticket", "Where my shoes?", nil)
ticket1 := models.NewTicket("88bfa1dc-be33-45c2-b469-294ecb0eba90", models.Org1, models.CathyID, models.InternalID, "12", "New ticket", "Where my cookies?", nil)
ticket2 := models.NewTicket("645eee60-7e84-4a9e-ade3-4fce01ae28f1", models.Org1, models.BobID, models.InternalID, "14", "Second ticket", "Where my shoes?", nil)

err = svc.Close([]*models.Ticket{ticket1, ticket2}, logger.Log)

Expand Down
2 changes: 1 addition & 1 deletion web/ticket/ticket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestTicketClose(t *testing.T) {
testsuite.Reset()
db := testsuite.DB()

// create 2 open tickets and 1 closed one for Cathy
// create 2 open tickets and 1 closed one for Cathy across two different ticketers
testdata.InsertOpenTicket(t, db, models.Org1, models.CathyID, models.MailgunID, flows.TicketUUID(uuids.New()), "Need help", "Have you seen my cookies?", "17")
testdata.InsertOpenTicket(t, db, models.Org1, models.CathyID, models.ZendeskID, flows.TicketUUID(uuids.New()), "More help", "Have you seen my cookies?", "21")
testdata.InsertClosedTicket(t, db, models.Org1, models.CathyID, models.ZendeskID, flows.TicketUUID(uuids.New()), "Old question", "Have you seen my cookies?", "34")
Expand Down

0 comments on commit 72afbe9

Please sign in to comment.