diff --git a/core/handlers/ticket_opened_test.go b/core/handlers/ticket_opened_test.go index 5f7941857..84f8443df 100644 --- a/core/handlers/ticket_opened_test.go +++ b/core/handlers/ticket_opened_test.go @@ -69,7 +69,7 @@ func TestTicketOpened(t *testing.T) { actions.NewOpenTicket( handlers.NewActionUUID(), assets.NewTicketerReference(testdata.Mailgun.UUID, "Mailgun (IT Support)"), - assets.NewTopicReference(testdata.SupportTopic.UUID, "Support"), + assets.NewTopicReference(testdata.SupportTopic.UUID, "Support", ""), "Where are my cookies?", assets.NewUserReference(testdata.Admin.Email, "Admin"), "Email Ticket", diff --git a/core/models/topics.go b/core/models/topics.go index 238ebcdaa..c8b1e45e1 100644 --- a/core/models/topics.go +++ b/core/models/topics.go @@ -26,6 +26,7 @@ type Topic struct { OrgID OrgID `json:"org_id"` Name string `json:"name"` IsDefault bool `json:"is_default"` + QueueUUID assets.QueueUUID `json:"queue_uuid"` } } @@ -44,13 +45,16 @@ func (t *Topic) Name() string { return t.t.Name } // Type returns the type func (t *Topic) IsDefault() bool { return t.t.IsDefault } +func (t *Topic) QueueUUID() assets.QueueUUID { return t.t.QueueUUID } + const selectOrgTopicsSQL = ` SELECT ROW_TO_JSON(r) FROM (SELECT t.id as id, t.uuid as uuid, t.org_id as org_id, t.name as name, - t.is_default as is_default + t.is_default as is_default, + t.queue_uuid as queue_uuid FROM tickets_topic t WHERE diff --git a/core/models/topics_test.go b/core/models/topics_test.go index 3053a795e..86750f7f3 100644 --- a/core/models/topics_test.go +++ b/core/models/topics_test.go @@ -3,6 +3,7 @@ package models_test import ( "testing" + "github.com/nyaruka/goflow/assets" "github.com/nyaruka/mailroom/core/models" "github.com/nyaruka/mailroom/testsuite" "github.com/nyaruka/mailroom/testsuite/testdata" @@ -22,6 +23,7 @@ func TestTopics(t *testing.T) { assert.Equal(t, 3, len(topics)) assert.Equal(t, testdata.DefaultTopic.UUID, topics[0].UUID()) + assert.Equal(t, assets.QueueUUID("5c85fdf7-d54a-49dd-97ed-7e10077a1f6a"), topics[0].QueueUUID()) assert.Equal(t, "General", topics[0].Name()) assert.Equal(t, testdata.SalesTopic.UUID, topics[1].UUID()) assert.Equal(t, "Sales", topics[1].Name()) diff --git a/go.mod b/go.mod index 2add9bd8e..10d09b21c 100644 --- a/go.mod +++ b/go.mod @@ -79,4 +79,4 @@ go 1.17 replace github.com/nyaruka/gocommon => github.com/Ilhasoft/gocommon v1.16.2-weni -replace github.com/nyaruka/goflow => github.com/weni-ai/goflow v1.5.0 +replace github.com/nyaruka/goflow => github.com/weni-ai/goflow v1.5.1-b5-staging diff --git a/mailroom_test.dump b/mailroom_test.dump index 860767977..48c76f6b6 100644 Binary files a/mailroom_test.dump and b/mailroom_test.dump differ diff --git a/services/tickets/wenichats/service.go b/services/tickets/wenichats/service.go index 2025355ed..0511702ad 100644 --- a/services/tickets/wenichats/service.go +++ b/services/tickets/wenichats/service.go @@ -112,7 +112,7 @@ func (s *service) Open(session flows.Session, topic *flows.Topic, body string, a } roomData.SectorUUID = s.sectorUUID - roomData.QueueUUID = string(topic.UUID()) + roomData.QueueUUID = string(topic.QueueUUID()) preferredURN := session.Contact().PreferredURN() if preferredURN != nil { roomData.Contact.URN = preferredURN.URN().String() diff --git a/services/tickets/wenichats/testdata/TestOpenAndForward_open_ticket.snap b/services/tickets/wenichats/testdata/TestOpenAndForward_open_ticket.snap index 1f71738a5..862bf15eb 100644 --- a/services/tickets/wenichats/testdata/TestOpenAndForward_open_ticket.snap +++ b/services/tickets/wenichats/testdata/TestOpenAndForward_open_ticket.snap @@ -6,4 +6,4 @@ Authorization: Bearer **************** Content-Type: application/json Accept-Encoding: gzip -{"queue_uuid":"ffc903f7-8cbb-443f-9627-87106842d1aa","sector_uuid":"1a4bae05-993c-4f3b-91b5-80f4e09951f2","contact":{"external_id":"5d76d86b-3bb9-4d5a-b822-c9d86f5d8e4f","name":"Ryan Lewis","urn":"tel:+12024561111?channel=57f1078f-88aa-46f4-a59a-948a5739c03d","groups":[{"uuid":"b7cf0d83-f1c9-411c-96fd-c511a4cfa86d","name":"Testers"},{"uuid":"4f1f98fc-27a7-4a69-bbdb-24744ba739a9","name":"Males"}]},"custom_fields":{"country":"brazil","mood":"angry"},"flow_uuid":"50c3706e-fedb-42c0-8eab-dda3335714b7"} \ No newline at end of file +{"queue_uuid":"5c85fdf7-d54a-49dd-97ed-7e10077a1f6a","sector_uuid":"1a4bae05-993c-4f3b-91b5-80f4e09951f2","contact":{"external_id":"5d76d86b-3bb9-4d5a-b822-c9d86f5d8e4f","name":"Ryan Lewis","urn":"tel:+12024561111?channel=57f1078f-88aa-46f4-a59a-948a5739c03d","groups":[{"uuid":"b7cf0d83-f1c9-411c-96fd-c511a4cfa86d","name":"Testers"},{"uuid":"4f1f98fc-27a7-4a69-bbdb-24744ba739a9","name":"Males"}]},"custom_fields":{"country":"brazil","mood":"angry"},"flow_uuid":"50c3706e-fedb-42c0-8eab-dda3335714b7"} \ No newline at end of file diff --git a/services/tickets/wenichats/testdata/TestOpenAndForward_open_ticket_empty_body.snap b/services/tickets/wenichats/testdata/TestOpenAndForward_open_ticket_empty_body.snap index db59d6cf9..38b6ad482 100644 --- a/services/tickets/wenichats/testdata/TestOpenAndForward_open_ticket_empty_body.snap +++ b/services/tickets/wenichats/testdata/TestOpenAndForward_open_ticket_empty_body.snap @@ -6,4 +6,4 @@ Authorization: Bearer **************** Content-Type: application/json Accept-Encoding: gzip -{"queue_uuid":"ffc903f7-8cbb-443f-9627-87106842d1aa","sector_uuid":"1a4bae05-993c-4f3b-91b5-80f4e09951f2","contact":{"external_id":"5d76d86b-3bb9-4d5a-b822-c9d86f5d8e4f","name":"Ryan Lewis","urn":"tel:+12024561111?channel=57f1078f-88aa-46f4-a59a-948a5739c03d","groups":[{"uuid":"b7cf0d83-f1c9-411c-96fd-c511a4cfa86d","name":"Testers"},{"uuid":"4f1f98fc-27a7-4a69-bbdb-24744ba739a9","name":"Males"}]},"custom_fields":{"activation_****************":"AACC55","age":"23","gender":"Male","join_date":"2017-12-02"},"flow_uuid":"50c3706e-fedb-42c0-8eab-dda3335714b7"} \ No newline at end of file +{"queue_uuid":"5c85fdf7-d54a-49dd-97ed-7e10077a1f6a","sector_uuid":"1a4bae05-993c-4f3b-91b5-80f4e09951f2","contact":{"external_id":"5d76d86b-3bb9-4d5a-b822-c9d86f5d8e4f","name":"Ryan Lewis","urn":"tel:+12024561111?channel=57f1078f-88aa-46f4-a59a-948a5739c03d","groups":[{"uuid":"b7cf0d83-f1c9-411c-96fd-c511a4cfa86d","name":"Testers"},{"uuid":"4f1f98fc-27a7-4a69-bbdb-24744ba739a9","name":"Males"}]},"custom_fields":{"activation_****************":"AACC55","age":"23","gender":"Male","join_date":"2017-12-02"},"flow_uuid":"50c3706e-fedb-42c0-8eab-dda3335714b7"} \ No newline at end of file