From 04805d87f8a8419579330026cda9f61f1420461e Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Tue, 6 Aug 2024 15:12:02 -0500 Subject: [PATCH 1/2] Replace ticket body with initial note --- flows/actions/base_test.go | 2 +- flows/actions/open_ticket.go | 8 +++--- flows/actions/testdata/open_ticket.json | 26 ++++++++--------- flows/contact_test.go | 2 +- flows/engine/testdata/templates.json | 9 ++---- flows/events/base_test.go | 17 ++++++----- flows/events/ticket_opened.go | 8 +++--- .../inspect/issues/testdata/legacy_vars.json | 4 +-- flows/modifiers/testdata/ticket.json | 21 +++++++------- flows/modifiers/ticket.go | 21 +++++++++----- flows/tickets.go | 28 ++++++++----------- flows/tickets_test.go | 16 +++++------ flows/triggers/base_test.go | 2 +- .../TestTriggerMarshaling_ticket_closed.snap | 4 +-- flows/triggers/testdata/optin.json | 8 +++--- flows/triggers/testdata/ticket.json | 4 +-- test/session.go | 2 -- test/testdata/runner/ticketing.test.json | 10 +++---- 18 files changed, 92 insertions(+), 100 deletions(-) diff --git a/flows/actions/base_test.go b/flows/actions/base_test.go index c3dfcd662..36b926f19 100644 --- a/flows/actions/base_test.go +++ b/flows/actions/base_test.go @@ -172,7 +172,7 @@ func testActionType(t *testing.T, assetsJSON json.RawMessage, typeName string) { if tc.HasTicket { topic := sa.Topics().Get("0d9a2c56-6fc2-4f27-93c5-a6322e26b740") - contact.SetTicket(flows.NewTicket("7f44b065-ec28-4d7a-bbb4-0bda3b75b19d", topic, "Help", nil)) + contact.SetTicket(flows.NewTicket("7f44b065-ec28-4d7a-bbb4-0bda3b75b19d", topic, nil, "Help")) } // and switch their language diff --git a/flows/actions/open_ticket.go b/flows/actions/open_ticket.go index da1a84bb4..73ef6f366 100644 --- a/flows/actions/open_ticket.go +++ b/flows/actions/open_ticket.go @@ -67,9 +67,9 @@ func (a *OpenTicketAction) Execute(run flows.Run, step flows.Step, logModifier f assignee = resolveUser(run, a.Assignee, logEvent) } - evaluatedBody, _ := run.EvaluateTemplate(a.Body, logEvent) + evaluatedNote, _ := run.EvaluateTemplate(a.Body, logEvent) - ticket := a.open(run, topic, evaluatedBody, assignee, logModifier, logEvent) + ticket := a.open(run, topic, assignee, evaluatedNote, logModifier, logEvent) if ticket != nil { a.saveResult(run, step, a.ResultName, string(ticket.UUID()), CategorySuccess, "", "", nil, logEvent) } else { @@ -79,7 +79,7 @@ func (a *OpenTicketAction) Execute(run flows.Run, step flows.Step, logModifier f return nil } -func (a *OpenTicketAction) open(run flows.Run, topic *flows.Topic, body string, assignee *flows.User, logModifier flows.ModifierCallback, logEvent flows.EventCallback) *flows.Ticket { +func (a *OpenTicketAction) open(run flows.Run, topic *flows.Topic, assignee *flows.User, note string, logModifier flows.ModifierCallback, logEvent flows.EventCallback) *flows.Ticket { if run.Session().BatchStart() { logEvent(events.NewErrorf("can't open tickets during batch starts")) return nil @@ -90,7 +90,7 @@ func (a *OpenTicketAction) open(run flows.Run, topic *flows.Topic, body string, return nil } - mod := modifiers.NewTicket(topic, body, assignee) + mod := modifiers.NewTicket(topic, assignee, note) if a.applyModifier(run, mod, logModifier, logEvent) { // if we were able to open a ticket, return it diff --git a/flows/actions/testdata/open_ticket.json b/flows/actions/testdata/open_ticket.json index ff9f06f5b..1ad420c10 100644 --- a/flows/actions/testdata/open_ticket.json +++ b/flows/actions/testdata/open_ticket.json @@ -116,11 +116,11 @@ "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather" }, - "body": "Last message: Hi everybody", "assignee": { "email": "bob@nyaruka.com", "name": "Bob" - } + }, + "note": "Last message: Hi everybody" } }, { @@ -180,11 +180,11 @@ "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather" }, - "body": "Last message: Hi everybody", "assignee": { "email": "bob@nyaruka.com", "name": "Bob" - } + }, + "note": "Last message: Hi everybody" } }, "templates": [ @@ -230,7 +230,7 @@ "uuid": "0d9a2c56-6fc2-4f27-93c5-a6322e26b740", "name": "General" }, - "body": "Last message: Hi everybody" + "note": "Last message: Hi everybody" } }, { @@ -290,7 +290,7 @@ "uuid": "0d9a2c56-6fc2-4f27-93c5-a6322e26b740", "name": "General" }, - "body": "Last message: Hi everybody" + "note": "Last message: Hi everybody" } }, "templates": [ @@ -330,11 +330,11 @@ "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather" }, - "body": "Last message: Hi everybody", "assignee": { "email": "jim@nyaruka.com", "name": "Jim" - } + }, + "note": "Last message: Hi everybody" } }, { @@ -394,11 +394,11 @@ "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather" }, - "body": "Last message: Hi everybody", "assignee": { "email": "jim@nyaruka.com", "name": "Jim" - } + }, + "note": "Last message: Hi everybody" } }, "templates": [ @@ -451,7 +451,7 @@ "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather" }, - "body": "Last message: Hi everybody" + "note": "Last message: Hi everybody" } }, { @@ -511,7 +511,7 @@ "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather" }, - "body": "Last message: Hi everybody" + "note": "Last message: Hi everybody" } }, "templates": [ @@ -559,7 +559,7 @@ "uuid": "0d9a2c56-6fc2-4f27-93c5-a6322e26b740", "name": "General" }, - "body": "Where are my cookies? " + "note": "Where are my cookies? " } }, { diff --git a/flows/contact_test.go b/flows/contact_test.go index ba7aa0ea6..3b1b234e3 100644 --- a/flows/contact_test.go +++ b/flows/contact_test.go @@ -139,7 +139,7 @@ func TestContact(t *testing.T) { assert.Nil(t, contact.Ticket()) weather := sa.Topics().Get("472a7a73-96cb-4736-b567-056d987cc5b4") - ticket := flows.OpenTicket(weather, "I have issues", nil) + ticket := flows.OpenTicket(weather, nil, "spam?") contact.SetTicket(ticket) assert.NotNil(t, contact.Ticket()) diff --git a/flows/engine/testdata/templates.json b/flows/engine/testdata/templates.json index 597a5c91f..e55d73d54 100644 --- a/flows/engine/testdata/templates.json +++ b/flows/engine/testdata/templates.json @@ -398,15 +398,15 @@ }, { "template": "@(json(contact.tickets))", - "output": "[{\"assignee\":{\"email\":\"bob@nyaruka.com\",\"first_name\":\"Bob\",\"name\":\"Bob\"},\"body\":\"What day is it?\",\"topic\":{\"name\":\"Weather\",\"uuid\":\"472a7a73-96cb-4736-b567-056d987cc5b4\"},\"uuid\":\"78d1fe0d-7e39-461e-81c3-a6a25f15ed69\"}]" + "output": "[{\"assignee\":{\"email\":\"bob@nyaruka.com\",\"first_name\":\"Bob\",\"name\":\"Bob\"},\"topic\":{\"name\":\"Weather\",\"uuid\":\"472a7a73-96cb-4736-b567-056d987cc5b4\"},\"uuid\":\"78d1fe0d-7e39-461e-81c3-a6a25f15ed69\"}]" }, { "template": "@ticket", - "output": "{assignee: Bob, body: What day is it?, topic: Weather, uuid: 78d1fe0d-7e39-461e-81c3-a6a25f15ed69}" + "output": "{assignee: Bob, topic: Weather, uuid: 78d1fe0d-7e39-461e-81c3-a6a25f15ed69}" }, { "template": "@(json(ticket))", - "output": "{\"assignee\":{\"email\":\"bob@nyaruka.com\",\"first_name\":\"Bob\",\"name\":\"Bob\"},\"body\":\"What day is it?\",\"topic\":{\"name\":\"Weather\",\"uuid\":\"472a7a73-96cb-4736-b567-056d987cc5b4\"},\"uuid\":\"78d1fe0d-7e39-461e-81c3-a6a25f15ed69\"}" + "output": "{\"assignee\":{\"email\":\"bob@nyaruka.com\",\"first_name\":\"Bob\",\"name\":\"Bob\"},\"topic\":{\"name\":\"Weather\",\"uuid\":\"472a7a73-96cb-4736-b567-056d987cc5b4\"},\"uuid\":\"78d1fe0d-7e39-461e-81c3-a6a25f15ed69\"}" }, { "template": "@(json(contact))", @@ -449,7 +449,6 @@ "first_name": "Bob", "name": "Bob" }, - "body": "What day is it?", "topic": { "name": "Weather", "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4" @@ -529,7 +528,6 @@ "first_name": "Bob", "name": "Bob" }, - "body": "What day is it?", "topic": { "name": "Weather", "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4" @@ -750,7 +748,6 @@ "first_name": "Bob", "name": "Bob" }, - "body": "What day is it?", "topic": { "name": "Weather", "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4" diff --git a/flows/events/base_test.go b/flows/events/base_test.go index cf83fcc5b..2e7b756ce 100644 --- a/flows/events/base_test.go +++ b/flows/events/base_test.go @@ -48,7 +48,7 @@ func TestEventMarshaling(t *testing.T) { weather := session.Assets().Topics().Get("472a7a73-96cb-4736-b567-056d987cc5b4") user := session.Assets().Users().Get("bob@nyaruka.com") facebook := session.Assets().Channels().Get("4bb288a0-7fca-4da1-abe8-59a593aff648") - ticket := flows.NewTicket("7481888c-07dd-47dc-bf22-ef7448696ffe", weather, "Where are my cookies?", user) + ticket := flows.NewTicket("7481888c-07dd-47dc-bf22-ef7448696ffe", weather, user, "this is weird") eventTests := []struct { event flows.Event @@ -309,16 +309,15 @@ func TestEventMarshaling(t *testing.T) { "name": "Ryan Lewis", "status": "active", "ticket": { - "assignee": { - "email": "bob@nyaruka.com", - "name": "Bob" - }, - "body": "What day is it?", + "uuid": "78d1fe0d-7e39-461e-81c3-a6a25f15ed69", "topic": { "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather" }, - "uuid": "78d1fe0d-7e39-461e-81c3-a6a25f15ed69" + "assignee": { + "email": "bob@nyaruka.com", + "name": "Bob" + } }, "timezone": "America/Guayaquil", "urns": [ @@ -622,11 +621,11 @@ func TestEventMarshaling(t *testing.T) { "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather" }, - "body": "Where are my cookies?", "assignee": { "email": "bob@nyaruka.com", "name": "Bob" - } + }, + "note": "this is weird" } }`, }, diff --git a/flows/events/ticket_opened.go b/flows/events/ticket_opened.go index 03d08be22..8e6a6185b 100644 --- a/flows/events/ticket_opened.go +++ b/flows/events/ticket_opened.go @@ -15,8 +15,8 @@ const TypeTicketOpened string = "ticket_opened" type Ticket struct { UUID flows.TicketUUID `json:"uuid" validate:"required,uuid4"` Topic *assets.TopicReference `json:"topic" validate:"omitempty"` - Body string `json:"body"` Assignee *assets.UserReference `json:"assignee,omitempty" validate:"omitempty"` + Note string `json:"note,omitempty"` } // TicketOpenedEvent events are created when a new ticket is opened. @@ -30,8 +30,8 @@ type Ticket struct { // "uuid": "add17edf-0b6e-4311-bcd7-a64b2a459157", // "name": "Weather" // }, -// "body": "Where are my cookies?", -// "assignee": {"email": "bob@nyaruka.com", "name": "Bob"} +// "assignee": {"email": "bob@nyaruka.com", "name": "Bob"}, +// "note": "this is weird" // } // } // @@ -49,8 +49,8 @@ func NewTicketOpened(ticket *flows.Ticket) *TicketOpenedEvent { Ticket: &Ticket{ UUID: ticket.UUID(), Topic: ticket.Topic().Reference(), - Body: ticket.Body(), Assignee: ticket.Assignee().Reference(), + Note: ticket.Note(), }, } } diff --git a/flows/inspect/issues/testdata/legacy_vars.json b/flows/inspect/issues/testdata/legacy_vars.json index 71b8701e5..18001d760 100644 --- a/flows/inspect/issues/testdata/legacy_vars.json +++ b/flows/inspect/issues/testdata/legacy_vars.json @@ -35,10 +35,10 @@ }, "issues": [ { + "type": "legacy_vars", + "node_uuid": "a58be63b-907d-4a1a-856b-0bb5579d7507", "action_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "description": "use of expressions instead of contact query", - "node_uuid": "a58be63b-907d-4a1a-856b-0bb5579d7507", - "type": "legacy_vars", "vars": [ "@contact.uuid", "@fields.friend_tel" diff --git a/flows/modifiers/testdata/ticket.json b/flows/modifiers/testdata/ticket.json index 3afca058a..9a9d53e55 100644 --- a/flows/modifiers/testdata/ticket.json +++ b/flows/modifiers/testdata/ticket.json @@ -14,11 +14,12 @@ "uuid": "daa356b6-32af-44f0-9d35-6126d55ec3e9", "name": "Computers" }, - "body": "Where are my keys?", "assignee": { "email": "bob@nyaruka.com", "name": "Bob" - } + }, + "note": "this is a note", + "body": "this is a note" }, "contact_after": { "uuid": "5d76d86b-3bb9-4d5a-b822-c9d86f5d8e4f", @@ -31,11 +32,11 @@ "uuid": "daa356b6-32af-44f0-9d35-6126d55ec3e9", "name": "Computers" }, - "body": "Where are my keys?", "assignee": { "email": "bob@nyaruka.com", "name": "Bob" - } + }, + "note": "this is a note" } }, "events": [ @@ -48,11 +49,11 @@ "uuid": "daa356b6-32af-44f0-9d35-6126d55ec3e9", "name": "Computers" }, - "body": "Where are my keys?", "assignee": { "email": "bob@nyaruka.com", "name": "Bob" - } + }, + "note": "this is a note" } } ] @@ -71,7 +72,7 @@ "uuid": "daa356b6-32af-44f0-9d35-6126d55ec3e9", "name": "Computers" }, - "body": "Where are my keys?", + "body": "this is a note", "assignee": { "email": "bob@nyaruka.com", "name": "Bob" @@ -84,8 +85,9 @@ "uuid": "daa356b6-32af-44f0-9d35-6126d55ec3e9", "name": "Computers" }, - "body": "Should fail", - "assignee": null + "assignee": null, + "note": "Should fail", + "body": "Should fail" }, "contact_after": { "uuid": "5d76d86b-3bb9-4d5a-b822-c9d86f5d8e4f", @@ -98,7 +100,6 @@ "uuid": "daa356b6-32af-44f0-9d35-6126d55ec3e9", "name": "Computers" }, - "body": "Where are my keys?", "assignee": { "email": "bob@nyaruka.com", "name": "Bob" diff --git a/flows/modifiers/ticket.go b/flows/modifiers/ticket.go index 64eded65e..3699916d0 100644 --- a/flows/modifiers/ticket.go +++ b/flows/modifiers/ticket.go @@ -23,17 +23,17 @@ type TicketModifier struct { baseModifier topic *flows.Topic - body string assignee *flows.User + note string } // NewTicket creates a new ticket modifier -func NewTicket(topic *flows.Topic, body string, assignee *flows.User) *TicketModifier { +func NewTicket(topic *flows.Topic, assignee *flows.User, note string) *TicketModifier { return &TicketModifier{ baseModifier: newBaseModifier(TypeTicket), topic: topic, - body: body, assignee: assignee, + note: note, } } @@ -44,7 +44,7 @@ func (m *TicketModifier) Apply(eng flows.Engine, env envs.Environment, sa flows. return false } - ticket := flows.OpenTicket(m.topic, m.body, m.assignee) + ticket := flows.OpenTicket(m.topic, m.assignee, m.note) log(events.NewTicketOpened(ticket)) contact.SetTicket(ticket) @@ -61,8 +61,10 @@ type ticketModifierEnvelope struct { utils.TypedEnvelope Topic *assets.TopicReference `json:"topic" validate:"required"` - Body string `json:"body"` Assignee *assets.UserReference `json:"assignee"` + Note string `json:"note"` + + Body string `json:"body"` // deprecated } func readTicketModifier(assets flows.SessionAssets, data json.RawMessage, missing assets.MissingCallback) (flows.Modifier, error) { @@ -71,6 +73,10 @@ func readTicketModifier(assets flows.SessionAssets, data json.RawMessage, missin return nil, err } + if e.Note == "" && e.Body != "" { + e.Note = e.Body + } + topic := assets.Topics().Get(e.Topic.UUID) if topic == nil { missing(e.Topic, nil) @@ -85,14 +91,15 @@ func readTicketModifier(assets flows.SessionAssets, data json.RawMessage, missin } } - return NewTicket(topic, e.Body, assignee), nil + return NewTicket(topic, assignee, e.Note), nil } func (m *TicketModifier) MarshalJSON() ([]byte, error) { return jsonx.Marshal(&ticketModifierEnvelope{ TypedEnvelope: utils.TypedEnvelope{Type: m.Type()}, Topic: m.topic.Reference(), - Body: m.body, Assignee: m.assignee.Reference(), + Note: m.note, + Body: m.note, }) } diff --git a/flows/tickets.go b/flows/tickets.go index 6d2eb4054..f0cc9d8d5 100644 --- a/flows/tickets.go +++ b/flows/tickets.go @@ -16,42 +16,41 @@ type TicketUUID uuids.UUID type Ticket struct { uuid TicketUUID topic *Topic - body string assignee *User + note string } // NewTicket creates a new ticket -func NewTicket(uuid TicketUUID, topic *Topic, body string, assignee *User) *Ticket { +func NewTicket(uuid TicketUUID, topic *Topic, assignee *User, note string) *Ticket { return &Ticket{ uuid: uuid, topic: topic, - body: body, assignee: assignee, + note: note, } } // OpenTicket creates a new ticket. Used by ticketing services to open a new ticket. -func OpenTicket(topic *Topic, body string, assignee *User) *Ticket { - return NewTicket(TicketUUID(uuids.NewV4()), topic, body, assignee) +func OpenTicket(topic *Topic, assignee *User, note string) *Ticket { + return NewTicket(TicketUUID(uuids.NewV4()), topic, assignee, note) } func (t *Ticket) UUID() TicketUUID { return t.uuid } func (t *Ticket) Topic() *Topic { return t.topic } -func (t *Ticket) Body() string { return t.body } func (t *Ticket) Assignee() *User { return t.assignee } +func (t *Ticket) Note() string { return t.note } // Context returns the properties available in expressions // // uuid:text -> the UUID of the ticket -// subject:text -> the subject of the ticket -// body:text -> the body of the ticket +// topic:any -> the topic of the ticket +// assignee:any -> the assignee of the ticket // // @context ticket func (t *Ticket) Context(env envs.Environment) map[string]types.XValue { return map[string]types.XValue{ "uuid": types.NewXText(string(t.uuid)), "topic": Context(env, t.topic), - "body": types.NewXText(t.body), "assignee": Context(env, t.assignee), } } @@ -63,8 +62,8 @@ func (t *Ticket) Context(env envs.Environment) map[string]types.XValue { type ticketEnvelope struct { UUID TicketUUID `json:"uuid" validate:"required,uuid4"` Topic *assets.TopicReference `json:"topic" validate:"omitempty"` - Body string `json:"body"` Assignee *assets.UserReference `json:"assignee,omitempty" validate:"omitempty"` + Note string `json:"note,omitempty"` } // ReadTicket decodes a contact from the passed in JSON. If the topic or assigned user can't @@ -92,12 +91,7 @@ func ReadTicket(sa SessionAssets, data []byte, missing assets.MissingCallback) ( } } - return &Ticket{ - uuid: e.UUID, - topic: topic, - body: e.Body, - assignee: assignee, - }, nil + return &Ticket{uuid: e.UUID, topic: topic, assignee: assignee, note: e.Note}, nil } // MarshalJSON marshals this ticket into JSON @@ -115,7 +109,7 @@ func (t *Ticket) MarshalJSON() ([]byte, error) { return jsonx.Marshal(&ticketEnvelope{ UUID: t.uuid, Topic: topicRef, - Body: t.body, Assignee: assigneeRef, + Note: t.note, }) } diff --git a/flows/tickets_test.go b/flows/tickets_test.go index 37aea83e8..974871c57 100644 --- a/flows/tickets_test.go +++ b/flows/tickets_test.go @@ -68,16 +68,15 @@ func TestTickets(t *testing.T) { ticket1, err := flows.ReadTicket(sa, []byte(`{ "uuid": "349c851f-3f8e-4353-8bf2-8e90b6d73530", "topic": {"uuid": "fd3ffcf3-c609-423e-b40f-f7f291a91cc6", "name": "Deleted"}, - "subject": "Very Old Ticket", - "body": "Topic and assignee gone!", - "assignee": {"email": "dave@nyaruka.com", "name": "Dave"} + "assignee": {"email": "dave@nyaruka.com", "name": "Dave"}, + "note": "this is weird" }`), missing) require.NoError(t, err) assert.Equal(t, flows.TicketUUID("349c851f-3f8e-4353-8bf2-8e90b6d73530"), ticket1.UUID()) assert.Nil(t, ticket1.Topic()) - assert.Equal(t, "Topic and assignee gone!", ticket1.Body()) assert.Nil(t, ticket1.Assignee()) + assert.Equal(t, "this is weird", ticket1.Note()) // check that missing topic and assignee are logged as a missing dependencies assert.Equal(t, 2, len(missingRefs)) @@ -89,19 +88,18 @@ func TestTickets(t *testing.T) { ticket2, err := flows.ReadTicket(sa, []byte(`{ "uuid": "5a4af021-d2c2-47fc-9abc-abbb8635d8c0", "topic": {"uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather"}, - "subject": "Old Ticket", - "body": "Where are my shoes?", - "assignee": {"email": "bob@nyaruka.com", "name": "Bob"} + "assignee": {"email": "bob@nyaruka.com", "name": "Bob"}, + "note": "this is weird" }`), missing) require.NoError(t, err) assert.Equal(t, 0, len(missingRefs)) assert.Equal(t, "Bob", ticket2.Assignee().Name()) - ticket3 := flows.OpenTicket(weather, "Where are my pants?", bob) + ticket3 := flows.OpenTicket(weather, bob, "spam?") assert.Equal(t, flows.TicketUUID("1ae96956-4b34-433e-8d1a-f05fe6923d6d"), ticket3.UUID()) assert.Equal(t, weather, ticket3.Topic()) - assert.Equal(t, "Where are my pants?", ticket3.Body()) assert.Equal(t, "Bob", ticket2.Assignee().Name()) + assert.Equal(t, ticket3.Note(), "spam?") } diff --git a/flows/triggers/base_test.go b/flows/triggers/base_test.go index ddecb704b..33a4e0f42 100644 --- a/flows/triggers/base_test.go +++ b/flows/triggers/base_test.go @@ -184,7 +184,7 @@ func TestTriggerMarshaling(t *testing.T) { jotd := sa.OptIns().Get("248be71d-78e9-4d71-a6c4-9981d369e5cb") weather := sa.Topics().Get("472a7a73-96cb-4736-b567-056d987cc5b4") user := sa.Users().Get("bob@nyaruka.com") - ticket := flows.NewTicket("276c2e43-d6f9-4c36-8e54-b5af5039acf6", weather, "Where are my shoes?", user) + ticket := flows.NewTicket("276c2e43-d6f9-4c36-8e54-b5af5039acf6", weather, user, "this is weird") contact := flows.NewEmptyContact(sa, "Bob", i18n.Language("eng"), nil) contact.AddURN(urns.URN("tel:+12065551212"), nil) diff --git a/flows/triggers/testdata/TestTriggerMarshaling_ticket_closed.snap b/flows/triggers/testdata/TestTriggerMarshaling_ticket_closed.snap index 112a6e5a7..71a53f577 100644 --- a/flows/triggers/testdata/TestTriggerMarshaling_ticket_closed.snap +++ b/flows/triggers/testdata/TestTriggerMarshaling_ticket_closed.snap @@ -31,11 +31,11 @@ "ticket": { "uuid": "276c2e43-d6f9-4c36-8e54-b5af5039acf6", "topic": null, - "body": "Where are my shoes?", "assignee": { "email": "bob@nyaruka.com", "name": "Bob McTickets" - } + }, + "note": "this is weird" } } } \ No newline at end of file diff --git a/flows/triggers/testdata/optin.json b/flows/triggers/testdata/optin.json index 6abcdd4c0..1928b0e06 100644 --- a/flows/triggers/testdata/optin.json +++ b/flows/triggers/testdata/optin.json @@ -46,22 +46,22 @@ "status": "active", "created_on": "2018-01-01T12:00:00Z" }, + "triggered_on": "2000-01-01T00:00:00Z", "event": { "type": "started", "optin": { "uuid": "248be71d-78e9-4d71-a6c4-9981d369e5cb", "name": "Joke Of The Day" } - }, - "triggered_on": "2000-01-01T00:00:00Z" + } }, "events": [], "context": { "campaign": null, "keyword": "", "optin": { - "uuid": "248be71d-78e9-4d71-a6c4-9981d369e5cb", - "name": "Joke Of The Day" + "name": "Joke Of The Day", + "uuid": "248be71d-78e9-4d71-a6c4-9981d369e5cb" }, "origin": "", "params": {}, diff --git a/flows/triggers/testdata/ticket.json b/flows/triggers/testdata/ticket.json index f2f4af366..e56fcc98b 100644 --- a/flows/triggers/testdata/ticket.json +++ b/flows/triggers/testdata/ticket.json @@ -39,8 +39,7 @@ "topic": { "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather" - }, - "body": "Where are my shoes?" + } } } }, @@ -53,7 +52,6 @@ "params": {}, "ticket": { "assignee": null, - "body": "Where are my shoes?", "topic": { "name": "Weather", "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4" diff --git a/test/session.go b/test/session.go index ec9ef04f1..70f1c1ef8 100644 --- a/test/session.go +++ b/test/session.go @@ -327,8 +327,6 @@ var sessionTrigger = `{ }, "ticket": { "uuid": "78d1fe0d-7e39-461e-81c3-a6a25f15ed69", - "subject": "Question", - "body": "What day is it?", "topic": { "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather" diff --git a/test/testdata/runner/ticketing.test.json b/test/testdata/runner/ticketing.test.json index fd846e557..e9078661d 100644 --- a/test/testdata/runner/ticketing.test.json +++ b/test/testdata/runner/ticketing.test.json @@ -163,7 +163,7 @@ "created_on": "2018-07-06T12:30:18.123456789Z", "step_uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623", "ticket": { - "body": "Last message: Rats", + "note": "Last message: Rats", "topic": { "name": "Weather", "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4" @@ -181,7 +181,7 @@ "value": "5ecda5fc-951c-437b-a17e-f85e49829fb9" }, { - "body": "[{\"assignee\":null,\"body\":\"Last message: Rats\",\"topic\":{\"name\":\"Weather\",\"uuid\":\"472a7a73-96cb-4736-b567-056d987cc5b4\"},\"uuid\":\"5ecda5fc-951c-437b-a17e-f85e49829fb9\"}]", + "body": "[{\"assignee\":null,\"topic\":{\"name\":\"Weather\",\"uuid\":\"472a7a73-96cb-4736-b567-056d987cc5b4\"},\"uuid\":\"5ecda5fc-951c-437b-a17e-f85e49829fb9\"}]", "created_on": "2018-07-06T12:30:26.123456789Z", "step_uuid": "312d3af0-a565-4c96-ba00-bd7f0d08e671", "subject": "New ticket: 5ecda5fc-951c-437b-a17e-f85e49829fb9", @@ -218,7 +218,7 @@ "name": "Ben Haggerty", "status": "active", "ticket": { - "body": "Last message: Rats", + "note": "Last message: Rats", "topic": { "name": "Weather", "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4" @@ -295,7 +295,7 @@ "created_on": "2018-07-06T12:30:18.123456789Z", "step_uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623", "ticket": { - "body": "Last message: Rats", + "note": "Last message: Rats", "topic": { "name": "Weather", "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4" @@ -313,7 +313,7 @@ "value": "5ecda5fc-951c-437b-a17e-f85e49829fb9" }, { - "body": "[{\"assignee\":null,\"body\":\"Last message: Rats\",\"topic\":{\"name\":\"Weather\",\"uuid\":\"472a7a73-96cb-4736-b567-056d987cc5b4\"},\"uuid\":\"5ecda5fc-951c-437b-a17e-f85e49829fb9\"}]", + "body": "[{\"assignee\":null,\"topic\":{\"name\":\"Weather\",\"uuid\":\"472a7a73-96cb-4736-b567-056d987cc5b4\"},\"uuid\":\"5ecda5fc-951c-437b-a17e-f85e49829fb9\"}]", "created_on": "2018-07-06T12:30:26.123456789Z", "step_uuid": "312d3af0-a565-4c96-ba00-bd7f0d08e671", "subject": "New ticket: 5ecda5fc-951c-437b-a17e-f85e49829fb9", From f09a719ff793d5e88c394733675666fb589f19f1 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Tue, 6 Aug 2024 15:34:02 -0500 Subject: [PATCH 2/2] Implement opening ticket with note as two events --- flows/actions/base_test.go | 2 +- flows/actions/open_ticket.go | 5 +- flows/actions/testdata/open_ticket.json | 57 ++++++++++++------- flows/contact_test.go | 2 +- flows/events/base_test.go | 13 ++++- flows/events/ticket_note_added.go | 35 ++++++++++++ flows/events/ticket_opened.go | 5 +- flows/modifiers/testdata/ticket.json | 11 ++-- flows/modifiers/ticket.go | 5 +- flows/tickets.go | 13 ++--- flows/tickets_test.go | 10 +--- flows/triggers/base_test.go | 2 +- .../TestTriggerMarshaling_ticket_closed.snap | 3 +- test/testdata/runner/ticketing.test.json | 33 +++++++---- 14 files changed, 129 insertions(+), 67 deletions(-) create mode 100644 flows/events/ticket_note_added.go diff --git a/flows/actions/base_test.go b/flows/actions/base_test.go index 36b926f19..14d777a4b 100644 --- a/flows/actions/base_test.go +++ b/flows/actions/base_test.go @@ -172,7 +172,7 @@ func testActionType(t *testing.T, assetsJSON json.RawMessage, typeName string) { if tc.HasTicket { topic := sa.Topics().Get("0d9a2c56-6fc2-4f27-93c5-a6322e26b740") - contact.SetTicket(flows.NewTicket("7f44b065-ec28-4d7a-bbb4-0bda3b75b19d", topic, nil, "Help")) + contact.SetTicket(flows.NewTicket("7f44b065-ec28-4d7a-bbb4-0bda3b75b19d", topic, nil)) } // and switch their language diff --git a/flows/actions/open_ticket.go b/flows/actions/open_ticket.go index 73ef6f366..ecba7289d 100644 --- a/flows/actions/open_ticket.go +++ b/flows/actions/open_ticket.go @@ -1,6 +1,8 @@ package actions import ( + "strings" + "github.com/nyaruka/goflow/assets" "github.com/nyaruka/goflow/flows" "github.com/nyaruka/goflow/flows/events" @@ -34,7 +36,7 @@ type OpenTicketAction struct { onlineAction Topic *assets.TopicReference `json:"topic" validate:"omitempty"` - Body string `json:"body" engine:"evaluated"` + Body string `json:"body" engine:"evaluated"` // TODO will become "note" in future migration Assignee *assets.UserReference `json:"assignee" validate:"omitempty"` ResultName string `json:"result_name" validate:"required"` } @@ -68,6 +70,7 @@ func (a *OpenTicketAction) Execute(run flows.Run, step flows.Step, logModifier f } evaluatedNote, _ := run.EvaluateTemplate(a.Body, logEvent) + evaluatedNote = strings.TrimSpace(evaluatedNote) ticket := a.open(run, topic, assignee, evaluatedNote, logModifier, logEvent) if ticket != nil { diff --git a/flows/actions/testdata/open_ticket.json b/flows/actions/testdata/open_ticket.json index 1ad420c10..e6d44153c 100644 --- a/flows/actions/testdata/open_ticket.json +++ b/flows/actions/testdata/open_ticket.json @@ -119,10 +119,15 @@ "assignee": { "email": "bob@nyaruka.com", "name": "Bob" - }, - "note": "Last message: Hi everybody" + } } }, + { + "type": "ticket_note_added", + "created_on": "2018-10-18T14:20:30.000123456Z", + "step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c", + "note": "Last message: Hi everybody" + }, { "type": "contact_groups_changed", "created_on": "2018-10-18T14:20:30.000123456Z", @@ -183,8 +188,7 @@ "assignee": { "email": "bob@nyaruka.com", "name": "Bob" - }, - "note": "Last message: Hi everybody" + } } }, "templates": [ @@ -229,10 +233,15 @@ "topic": { "uuid": "0d9a2c56-6fc2-4f27-93c5-a6322e26b740", "name": "General" - }, - "note": "Last message: Hi everybody" + } } }, + { + "type": "ticket_note_added", + "created_on": "2018-10-18T14:20:30.000123456Z", + "step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c", + "note": "Last message: Hi everybody" + }, { "type": "contact_groups_changed", "created_on": "2018-10-18T14:20:30.000123456Z", @@ -289,8 +298,7 @@ "topic": { "uuid": "0d9a2c56-6fc2-4f27-93c5-a6322e26b740", "name": "General" - }, - "note": "Last message: Hi everybody" + } } }, "templates": [ @@ -333,10 +341,15 @@ "assignee": { "email": "jim@nyaruka.com", "name": "Jim" - }, - "note": "Last message: Hi everybody" + } } }, + { + "type": "ticket_note_added", + "created_on": "2018-10-18T14:20:30.000123456Z", + "step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c", + "note": "Last message: Hi everybody" + }, { "type": "contact_groups_changed", "created_on": "2018-10-18T14:20:30.000123456Z", @@ -397,8 +410,7 @@ "assignee": { "email": "jim@nyaruka.com", "name": "Jim" - }, - "note": "Last message: Hi everybody" + } } }, "templates": [ @@ -450,10 +462,15 @@ "topic": { "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather" - }, - "note": "Last message: Hi everybody" + } } }, + { + "type": "ticket_note_added", + "created_on": "2018-10-18T14:20:30.000123456Z", + "step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c", + "note": "Last message: Hi everybody" + }, { "type": "contact_groups_changed", "created_on": "2018-10-18T14:20:30.000123456Z", @@ -510,8 +527,7 @@ "topic": { "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather" - }, - "note": "Last message: Hi everybody" + } } }, "templates": [ @@ -533,12 +549,12 @@ } }, { - "description": "Error events if subject or body contain expression errors", + "description": "Error events if note contains expression errors", "action": { "type": "open_ticket", "uuid": "ad154980-7bf7-4ab8-8728-545fd6378912", "topic": null, - "body": "Where are my cookies? @(1/ 0)", + "body": "@(1/ 0)", "assignee": null, "result_name": "Ticket" }, @@ -558,8 +574,7 @@ "topic": { "uuid": "0d9a2c56-6fc2-4f27-93c5-a6322e26b740", "name": "General" - }, - "note": "Where are my cookies? " + } } }, { @@ -583,7 +598,7 @@ } ], "templates": [ - "Where are my cookies? @(1/ 0)" + "@(1/ 0)" ], "inspection": { "dependencies": [], diff --git a/flows/contact_test.go b/flows/contact_test.go index 3b1b234e3..39d0ed81a 100644 --- a/flows/contact_test.go +++ b/flows/contact_test.go @@ -139,7 +139,7 @@ func TestContact(t *testing.T) { assert.Nil(t, contact.Ticket()) weather := sa.Topics().Get("472a7a73-96cb-4736-b567-056d987cc5b4") - ticket := flows.OpenTicket(weather, nil, "spam?") + ticket := flows.OpenTicket(weather, nil) contact.SetTicket(ticket) assert.NotNil(t, contact.Ticket()) diff --git a/flows/events/base_test.go b/flows/events/base_test.go index 2e7b756ce..1f2d3d44c 100644 --- a/flows/events/base_test.go +++ b/flows/events/base_test.go @@ -48,7 +48,7 @@ func TestEventMarshaling(t *testing.T) { weather := session.Assets().Topics().Get("472a7a73-96cb-4736-b567-056d987cc5b4") user := session.Assets().Users().Get("bob@nyaruka.com") facebook := session.Assets().Channels().Get("4bb288a0-7fca-4da1-abe8-59a593aff648") - ticket := flows.NewTicket("7481888c-07dd-47dc-bf22-ef7448696ffe", weather, user, "this is weird") + ticket := flows.NewTicket("7481888c-07dd-47dc-bf22-ef7448696ffe", weather, user) eventTests := []struct { event flows.Event @@ -610,6 +610,14 @@ func TestEventMarshaling(t *testing.T) { } }`, }, + { + events.NewTicketNoteAdded("this is weird"), + `{ + "type": "ticket_note_added", + "created_on": "2018-10-18T14:20:30.000123456Z", + "note": "this is weird" + }`, + }, { events.NewTicketOpened(ticket), `{ @@ -624,8 +632,7 @@ func TestEventMarshaling(t *testing.T) { "assignee": { "email": "bob@nyaruka.com", "name": "Bob" - }, - "note": "this is weird" + } } }`, }, diff --git a/flows/events/ticket_note_added.go b/flows/events/ticket_note_added.go new file mode 100644 index 000000000..7dad5eceb --- /dev/null +++ b/flows/events/ticket_note_added.go @@ -0,0 +1,35 @@ +package events + +import ( + "github.com/nyaruka/goflow/flows" +) + +func init() { + registerType(TypeTicketNoteAdded, func() flows.Event { return &TicketNoteAddedEvent{} }) +} + +// TypeTicketNoteAdded is the type for our ticket note added events +const TypeTicketNoteAdded string = "ticket_note_added" + +// TicketNoteAddedEvent events are created when a note is added to the currently open ticket. +// +// { +// "type": "ticket_note_added", +// "created_on": "2006-01-02T15:04:05Z", +// "note": "this is weird" +// } +// +// @event ticket_note_added +type TicketNoteAddedEvent struct { + BaseEvent + + Note string `json:"note"` +} + +// NewTicketNoteAdded returns a new ticket note added event +func NewTicketNoteAdded(note string) *TicketNoteAddedEvent { + return &TicketNoteAddedEvent{ + BaseEvent: NewBaseEvent(TypeTicketNoteAdded), + Note: note, + } +} diff --git a/flows/events/ticket_opened.go b/flows/events/ticket_opened.go index 8e6a6185b..3e87ebd34 100644 --- a/flows/events/ticket_opened.go +++ b/flows/events/ticket_opened.go @@ -16,7 +16,6 @@ type Ticket struct { UUID flows.TicketUUID `json:"uuid" validate:"required,uuid4"` Topic *assets.TopicReference `json:"topic" validate:"omitempty"` Assignee *assets.UserReference `json:"assignee,omitempty" validate:"omitempty"` - Note string `json:"note,omitempty"` } // TicketOpenedEvent events are created when a new ticket is opened. @@ -30,8 +29,7 @@ type Ticket struct { // "uuid": "add17edf-0b6e-4311-bcd7-a64b2a459157", // "name": "Weather" // }, -// "assignee": {"email": "bob@nyaruka.com", "name": "Bob"}, -// "note": "this is weird" +// "assignee": {"email": "bob@nyaruka.com", "name": "Bob"} // } // } // @@ -50,7 +48,6 @@ func NewTicketOpened(ticket *flows.Ticket) *TicketOpenedEvent { UUID: ticket.UUID(), Topic: ticket.Topic().Reference(), Assignee: ticket.Assignee().Reference(), - Note: ticket.Note(), }, } } diff --git a/flows/modifiers/testdata/ticket.json b/flows/modifiers/testdata/ticket.json index 9a9d53e55..89a4916b8 100644 --- a/flows/modifiers/testdata/ticket.json +++ b/flows/modifiers/testdata/ticket.json @@ -35,8 +35,7 @@ "assignee": { "email": "bob@nyaruka.com", "name": "Bob" - }, - "note": "this is a note" + } } }, "events": [ @@ -52,9 +51,13 @@ "assignee": { "email": "bob@nyaruka.com", "name": "Bob" - }, - "note": "this is a note" + } } + }, + { + "type": "ticket_note_added", + "created_on": "2018-10-18T14:20:30.000123456Z", + "note": "this is a note" } ] }, diff --git a/flows/modifiers/ticket.go b/flows/modifiers/ticket.go index 3699916d0..be8aa5da0 100644 --- a/flows/modifiers/ticket.go +++ b/flows/modifiers/ticket.go @@ -44,8 +44,11 @@ func (m *TicketModifier) Apply(eng flows.Engine, env envs.Environment, sa flows. return false } - ticket := flows.OpenTicket(m.topic, m.assignee, m.note) + ticket := flows.OpenTicket(m.topic, m.assignee) log(events.NewTicketOpened(ticket)) + if m.note != "" { + log(events.NewTicketNoteAdded(m.note)) + } contact.SetTicket(ticket) return true diff --git a/flows/tickets.go b/flows/tickets.go index f0cc9d8d5..ba6ee8af2 100644 --- a/flows/tickets.go +++ b/flows/tickets.go @@ -17,28 +17,25 @@ type Ticket struct { uuid TicketUUID topic *Topic assignee *User - note string } // NewTicket creates a new ticket -func NewTicket(uuid TicketUUID, topic *Topic, assignee *User, note string) *Ticket { +func NewTicket(uuid TicketUUID, topic *Topic, assignee *User) *Ticket { return &Ticket{ uuid: uuid, topic: topic, assignee: assignee, - note: note, } } // OpenTicket creates a new ticket. Used by ticketing services to open a new ticket. -func OpenTicket(topic *Topic, assignee *User, note string) *Ticket { - return NewTicket(TicketUUID(uuids.NewV4()), topic, assignee, note) +func OpenTicket(topic *Topic, assignee *User) *Ticket { + return NewTicket(TicketUUID(uuids.NewV4()), topic, assignee) } func (t *Ticket) UUID() TicketUUID { return t.uuid } func (t *Ticket) Topic() *Topic { return t.topic } func (t *Ticket) Assignee() *User { return t.assignee } -func (t *Ticket) Note() string { return t.note } // Context returns the properties available in expressions // @@ -63,7 +60,6 @@ type ticketEnvelope struct { UUID TicketUUID `json:"uuid" validate:"required,uuid4"` Topic *assets.TopicReference `json:"topic" validate:"omitempty"` Assignee *assets.UserReference `json:"assignee,omitempty" validate:"omitempty"` - Note string `json:"note,omitempty"` } // ReadTicket decodes a contact from the passed in JSON. If the topic or assigned user can't @@ -91,7 +87,7 @@ func ReadTicket(sa SessionAssets, data []byte, missing assets.MissingCallback) ( } } - return &Ticket{uuid: e.UUID, topic: topic, assignee: assignee, note: e.Note}, nil + return &Ticket{uuid: e.UUID, topic: topic, assignee: assignee}, nil } // MarshalJSON marshals this ticket into JSON @@ -110,6 +106,5 @@ func (t *Ticket) MarshalJSON() ([]byte, error) { UUID: t.uuid, Topic: topicRef, Assignee: assigneeRef, - Note: t.note, }) } diff --git a/flows/tickets_test.go b/flows/tickets_test.go index 974871c57..26072fd6b 100644 --- a/flows/tickets_test.go +++ b/flows/tickets_test.go @@ -68,15 +68,13 @@ func TestTickets(t *testing.T) { ticket1, err := flows.ReadTicket(sa, []byte(`{ "uuid": "349c851f-3f8e-4353-8bf2-8e90b6d73530", "topic": {"uuid": "fd3ffcf3-c609-423e-b40f-f7f291a91cc6", "name": "Deleted"}, - "assignee": {"email": "dave@nyaruka.com", "name": "Dave"}, - "note": "this is weird" + "assignee": {"email": "dave@nyaruka.com", "name": "Dave"} }`), missing) require.NoError(t, err) assert.Equal(t, flows.TicketUUID("349c851f-3f8e-4353-8bf2-8e90b6d73530"), ticket1.UUID()) assert.Nil(t, ticket1.Topic()) assert.Nil(t, ticket1.Assignee()) - assert.Equal(t, "this is weird", ticket1.Note()) // check that missing topic and assignee are logged as a missing dependencies assert.Equal(t, 2, len(missingRefs)) @@ -88,18 +86,16 @@ func TestTickets(t *testing.T) { ticket2, err := flows.ReadTicket(sa, []byte(`{ "uuid": "5a4af021-d2c2-47fc-9abc-abbb8635d8c0", "topic": {"uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather"}, - "assignee": {"email": "bob@nyaruka.com", "name": "Bob"}, - "note": "this is weird" + "assignee": {"email": "bob@nyaruka.com", "name": "Bob"} }`), missing) require.NoError(t, err) assert.Equal(t, 0, len(missingRefs)) assert.Equal(t, "Bob", ticket2.Assignee().Name()) - ticket3 := flows.OpenTicket(weather, bob, "spam?") + ticket3 := flows.OpenTicket(weather, bob) assert.Equal(t, flows.TicketUUID("1ae96956-4b34-433e-8d1a-f05fe6923d6d"), ticket3.UUID()) assert.Equal(t, weather, ticket3.Topic()) assert.Equal(t, "Bob", ticket2.Assignee().Name()) - assert.Equal(t, ticket3.Note(), "spam?") } diff --git a/flows/triggers/base_test.go b/flows/triggers/base_test.go index 33a4e0f42..a5ba4daad 100644 --- a/flows/triggers/base_test.go +++ b/flows/triggers/base_test.go @@ -184,7 +184,7 @@ func TestTriggerMarshaling(t *testing.T) { jotd := sa.OptIns().Get("248be71d-78e9-4d71-a6c4-9981d369e5cb") weather := sa.Topics().Get("472a7a73-96cb-4736-b567-056d987cc5b4") user := sa.Users().Get("bob@nyaruka.com") - ticket := flows.NewTicket("276c2e43-d6f9-4c36-8e54-b5af5039acf6", weather, user, "this is weird") + ticket := flows.NewTicket("276c2e43-d6f9-4c36-8e54-b5af5039acf6", weather, user) contact := flows.NewEmptyContact(sa, "Bob", i18n.Language("eng"), nil) contact.AddURN(urns.URN("tel:+12065551212"), nil) diff --git a/flows/triggers/testdata/TestTriggerMarshaling_ticket_closed.snap b/flows/triggers/testdata/TestTriggerMarshaling_ticket_closed.snap index 71a53f577..c5d1fa818 100644 --- a/flows/triggers/testdata/TestTriggerMarshaling_ticket_closed.snap +++ b/flows/triggers/testdata/TestTriggerMarshaling_ticket_closed.snap @@ -34,8 +34,7 @@ "assignee": { "email": "bob@nyaruka.com", "name": "Bob McTickets" - }, - "note": "this is weird" + } } } } \ No newline at end of file diff --git a/test/testdata/runner/ticketing.test.json b/test/testdata/runner/ticketing.test.json index e9078661d..a53baff64 100644 --- a/test/testdata/runner/ticketing.test.json +++ b/test/testdata/runner/ticketing.test.json @@ -163,7 +163,6 @@ "created_on": "2018-07-06T12:30:18.123456789Z", "step_uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623", "ticket": { - "note": "Last message: Rats", "topic": { "name": "Weather", "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4" @@ -172,9 +171,15 @@ }, "type": "ticket_opened" }, + { + "created_on": "2018-07-06T12:30:20.123456789Z", + "note": "Last message: Rats", + "step_uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623", + "type": "ticket_note_added" + }, { "category": "Success", - "created_on": "2018-07-06T12:30:22.123456789Z", + "created_on": "2018-07-06T12:30:24.123456789Z", "name": "Ticket", "step_uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623", "type": "run_result_changed", @@ -182,7 +187,7 @@ }, { "body": "[{\"assignee\":null,\"topic\":{\"name\":\"Weather\",\"uuid\":\"472a7a73-96cb-4736-b567-056d987cc5b4\"},\"uuid\":\"5ecda5fc-951c-437b-a17e-f85e49829fb9\"}]", - "created_on": "2018-07-06T12:30:26.123456789Z", + "created_on": "2018-07-06T12:30:28.123456789Z", "step_uuid": "312d3af0-a565-4c96-ba00-bd7f0d08e671", "subject": "New ticket: 5ecda5fc-951c-437b-a17e-f85e49829fb9", "to": [ @@ -206,7 +211,7 @@ "flow_uuid": "3486fc59-d417-4189-93cd-e0aa8e3112ac", "node_uuid": "145eb3d3-b841-4e66-abac-297ae525c7ad", "operand": "5ecda5fc-951c-437b-a17e-f85e49829fb9", - "time": "2018-07-06T12:30:24.123456789Z" + "time": "2018-07-06T12:30:26.123456789Z" } ], "session": { @@ -218,7 +223,6 @@ "name": "Ben Haggerty", "status": "active", "ticket": { - "note": "Last message: Rats", "topic": { "name": "Weather", "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4" @@ -295,7 +299,6 @@ "created_on": "2018-07-06T12:30:18.123456789Z", "step_uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623", "ticket": { - "note": "Last message: Rats", "topic": { "name": "Weather", "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4" @@ -304,9 +307,15 @@ }, "type": "ticket_opened" }, + { + "created_on": "2018-07-06T12:30:20.123456789Z", + "note": "Last message: Rats", + "step_uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623", + "type": "ticket_note_added" + }, { "category": "Success", - "created_on": "2018-07-06T12:30:22.123456789Z", + "created_on": "2018-07-06T12:30:24.123456789Z", "name": "Ticket", "step_uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623", "type": "run_result_changed", @@ -314,7 +323,7 @@ }, { "body": "[{\"assignee\":null,\"topic\":{\"name\":\"Weather\",\"uuid\":\"472a7a73-96cb-4736-b567-056d987cc5b4\"},\"uuid\":\"5ecda5fc-951c-437b-a17e-f85e49829fb9\"}]", - "created_on": "2018-07-06T12:30:26.123456789Z", + "created_on": "2018-07-06T12:30:28.123456789Z", "step_uuid": "312d3af0-a565-4c96-ba00-bd7f0d08e671", "subject": "New ticket: 5ecda5fc-951c-437b-a17e-f85e49829fb9", "to": [ @@ -323,12 +332,12 @@ "type": "email_sent" } ], - "exited_on": "2018-07-06T12:30:28.123456789Z", + "exited_on": "2018-07-06T12:30:30.123456789Z", "flow": { "name": "Support", "uuid": "3486fc59-d417-4189-93cd-e0aa8e3112ac" }, - "modified_on": "2018-07-06T12:30:28.123456789Z", + "modified_on": "2018-07-06T12:30:30.123456789Z", "path": [ { "arrived_on": "2018-07-06T12:30:01.123456789Z", @@ -349,7 +358,7 @@ "uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623" }, { - "arrived_on": "2018-07-06T12:30:25.123456789Z", + "arrived_on": "2018-07-06T12:30:27.123456789Z", "exit_uuid": "b6562dea-d21c-4a99-b904-0fb9583fb5ab", "node_uuid": "ac3fcd8e-e7bb-4545-865d-39424a8f1d7b", "uuid": "312d3af0-a565-4c96-ba00-bd7f0d08e671" @@ -366,7 +375,7 @@ }, "ticket": { "category": "Success", - "created_on": "2018-07-06T12:30:20.123456789Z", + "created_on": "2018-07-06T12:30:22.123456789Z", "name": "Ticket", "node_uuid": "145eb3d3-b841-4e66-abac-297ae525c7ad", "value": "5ecda5fc-951c-437b-a17e-f85e49829fb9"