From 2c6b97b999936c596a27cf5a977d733dce93dea8 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Tue, 6 Aug 2024 15:12:02 -0500 Subject: [PATCH] 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 | 19 +++++++------ 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, 91 insertions(+), 99 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..cf5bcf26b 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": "Where are my keys?", + "body": "Where are my keys?" }, "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": "Where are my keys?" } }, "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": "Where are my keys?" } } ] @@ -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",