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

add to topic queue_uuid attribute #180

Merged
merged 9 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions WENI-CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.40.2
----------
* Add topic queue uuid

1.40.1
----------
* Refactor meta search
Expand Down
2 changes: 1 addition & 1 deletion core/handlers/ticket_opened_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 5 additions & 1 deletion core/models/topics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
}

Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions core/models/topics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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-staging
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLD
github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2/go.mod h1:WjeM0Oo1eNAjXGDx2yma7uG2XoyRZTq1uv3M/o7imD0=
github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPfx6jb1bBgRFjl5lytqVqZXEaeqWP8lTEao=
github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4=
github.com/weni-ai/goflow v1.5.0 h1:g2tfooIVKdTEGlS/QRqChb0ftRCL1MNf2GkJ/JelztY=
github.com/weni-ai/goflow v1.5.0/go.mod h1:o0xaVWP9qNcauBSlcNLa79Fm2oCPV+BDpheFRa/D40c=
github.com/weni-ai/goflow v1.5.1-staging h1:s4Nf81YuWeqTkevQzepXPbMxwAZYitWzwsKIFw2D+pk=
github.com/weni-ai/goflow v1.5.1-staging/go.mod h1:o0xaVWP9qNcauBSlcNLa79Fm2oCPV+BDpheFRa/D40c=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
Binary file modified mailroom_test.dump
Binary file not shown.
2 changes: 1 addition & 1 deletion services/tickets/wenichats/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
{"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"}
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
{"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"}
Loading