-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1279 from nyaruka/open_ticket_with_note
Replace ticket body with initial note
- Loading branch information
Showing
19 changed files
with
161 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,13 +116,18 @@ | |
"uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", | ||
"name": "Weather" | ||
}, | ||
"body": "Last message: Hi everybody", | ||
"assignee": { | ||
"email": "[email protected]", | ||
"name": "Bob" | ||
} | ||
} | ||
}, | ||
{ | ||
"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", | ||
|
@@ -180,7 +185,6 @@ | |
"uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", | ||
"name": "Weather" | ||
}, | ||
"body": "Last message: Hi everybody", | ||
"assignee": { | ||
"email": "[email protected]", | ||
"name": "Bob" | ||
|
@@ -229,10 +233,15 @@ | |
"topic": { | ||
"uuid": "0d9a2c56-6fc2-4f27-93c5-a6322e26b740", | ||
"name": "General" | ||
}, | ||
"body": "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" | ||
}, | ||
"body": "Last message: Hi everybody" | ||
} | ||
} | ||
}, | ||
"templates": [ | ||
|
@@ -330,13 +338,18 @@ | |
"uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", | ||
"name": "Weather" | ||
}, | ||
"body": "Last message: Hi everybody", | ||
"assignee": { | ||
"email": "[email protected]", | ||
"name": "Jim" | ||
} | ||
} | ||
}, | ||
{ | ||
"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", | ||
|
@@ -394,7 +407,6 @@ | |
"uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", | ||
"name": "Weather" | ||
}, | ||
"body": "Last message: Hi everybody", | ||
"assignee": { | ||
"email": "[email protected]", | ||
"name": "Jim" | ||
|
@@ -450,10 +462,15 @@ | |
"topic": { | ||
"uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", | ||
"name": "Weather" | ||
}, | ||
"body": "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" | ||
}, | ||
"body": "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" | ||
}, | ||
"body": "Where are my cookies? " | ||
} | ||
} | ||
}, | ||
{ | ||
|
@@ -583,7 +598,7 @@ | |
} | ||
], | ||
"templates": [ | ||
"Where are my cookies? @(1/ 0)" | ||
"@(1/ 0)" | ||
], | ||
"inspection": { | ||
"dependencies": [], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -398,15 +398,15 @@ | |
}, | ||
{ | ||
"template": "@(json(contact.tickets))", | ||
"output": "[{\"assignee\":{\"email\":\"[email protected]\",\"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\":\"[email protected]\",\"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\":\"[email protected]\",\"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\":\"[email protected]\",\"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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ func TestEventMarshaling(t *testing.T) { | |
weather := session.Assets().Topics().Get("472a7a73-96cb-4736-b567-056d987cc5b4") | ||
user := session.Assets().Users().Get("[email protected]") | ||
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) | ||
|
||
eventTests := []struct { | ||
event flows.Event | ||
|
@@ -309,16 +309,15 @@ func TestEventMarshaling(t *testing.T) { | |
"name": "Ryan Lewis", | ||
"status": "active", | ||
"ticket": { | ||
"assignee": { | ||
"email": "[email protected]", | ||
"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": "[email protected]", | ||
"name": "Bob" | ||
} | ||
}, | ||
"timezone": "America/Guayaquil", | ||
"urns": [ | ||
|
@@ -611,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), | ||
`{ | ||
|
@@ -622,7 +629,6 @@ func TestEventMarshaling(t *testing.T) { | |
"uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", | ||
"name": "Weather" | ||
}, | ||
"body": "Where are my cookies?", | ||
"assignee": { | ||
"email": "[email protected]", | ||
"name": "Bob" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ 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"` | ||
} | ||
|
||
|
@@ -30,7 +29,6 @@ type Ticket struct { | |
// "uuid": "add17edf-0b6e-4311-bcd7-a64b2a459157", | ||
// "name": "Weather" | ||
// }, | ||
// "body": "Where are my cookies?", | ||
// "assignee": {"email": "[email protected]", "name": "Bob"} | ||
// } | ||
// } | ||
|
@@ -49,7 +47,6 @@ func NewTicketOpened(ticket *flows.Ticket) *TicketOpenedEvent { | |
Ticket: &Ticket{ | ||
UUID: ticket.UUID(), | ||
Topic: ticket.Topic().Reference(), | ||
Body: ticket.Body(), | ||
Assignee: ticket.Assignee().Reference(), | ||
}, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.