Skip to content

Commit

Permalink
On second thoughts, better to just bundle the note with the open tick…
Browse files Browse the repository at this point in the history
…et event
  • Loading branch information
rowanseymour committed Aug 6, 2024
1 parent a8f5ee7 commit bddf0c2
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 101 deletions.
28 changes: 4 additions & 24 deletions flows/actions/testdata/open_ticket.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,7 @@
"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"
},
{
Expand Down Expand Up @@ -234,12 +229,7 @@
"uuid": "0d9a2c56-6fc2-4f27-93c5-a6322e26b740",
"name": "General"
}
}
},
{
"type": "ticket_note_added",
"created_on": "2018-10-18T14:20:30.000123456Z",
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
},
"note": "Last message: Hi everybody"
},
{
Expand Down Expand Up @@ -342,12 +332,7 @@
"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"
},
{
Expand Down Expand Up @@ -463,12 +448,7 @@
"uuid": "472a7a73-96cb-4736-b567-056d987cc5b4",
"name": "Weather"
}
}
},
{
"type": "ticket_note_added",
"created_on": "2018-10-18T14:20:30.000123456Z",
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
},
"note": "Last message: Hi everybody"
},
{
Expand Down
13 changes: 3 additions & 10 deletions flows/events/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,15 +611,7 @@ 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),
events.NewTicketOpened(ticket, "this is weird"),
`{
"type": "ticket_opened",
"created_on": "2018-10-18T14:20:30.000123456Z",
Expand All @@ -633,7 +625,8 @@ func TestEventMarshaling(t *testing.T) {
"email": "[email protected]",
"name": "Bob"
}
}
},
"note": "this is weird"
}`,
},
}
Expand Down
35 changes: 0 additions & 35 deletions flows/events/ticket_note_added.go

This file was deleted.

7 changes: 5 additions & 2 deletions flows/events/ticket_opened.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,27 @@ type Ticket struct {
// "name": "Weather"
// },
// "assignee": {"email": "[email protected]", "name": "Bob"}
// }
// },
// "note": "this is weird"
// }
//
// @event ticket_opened
type TicketOpenedEvent struct {
BaseEvent

Ticket *Ticket `json:"ticket"`
Note string `json:"note,omitempty"`
}

// NewTicketOpened returns a new ticket opened event
func NewTicketOpened(ticket *flows.Ticket) *TicketOpenedEvent {
func NewTicketOpened(ticket *flows.Ticket, note string) *TicketOpenedEvent {
return &TicketOpenedEvent{
BaseEvent: NewBaseEvent(TypeTicketOpened),
Ticket: &Ticket{
UUID: ticket.UUID(),
Topic: ticket.Topic().Reference(),
Assignee: ticket.Assignee().Reference(),
},
Note: note,
}
}
6 changes: 1 addition & 5 deletions flows/modifiers/testdata/ticket.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@
"email": "[email protected]",
"name": "Bob"
}
}
},
{
"type": "ticket_note_added",
"created_on": "2018-10-18T14:20:30.000123456Z",
},
"note": "this is a note"
}
]
Expand Down
5 changes: 1 addition & 4 deletions flows/modifiers/ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ func (m *TicketModifier) Apply(eng flows.Engine, env envs.Environment, sa flows.
}

ticket := flows.OpenTicket(m.topic, m.assignee)
log(events.NewTicketOpened(ticket))
if m.note != "" {
log(events.NewTicketNoteAdded(m.note))
}
log(events.NewTicketOpened(ticket, m.note))

contact.SetTicket(ticket)
return true
Expand Down
32 changes: 11 additions & 21 deletions test/testdata/runner/ticketing.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
},
{
"created_on": "2018-07-06T12:30:18.123456789Z",
"note": "Last message: Rats",
"step_uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623",
"ticket": {
"topic": {
Expand All @@ -171,23 +172,17 @@
},
"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:24.123456789Z",
"created_on": "2018-07-06T12:30:22.123456789Z",
"name": "Ticket",
"step_uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623",
"type": "run_result_changed",
"value": "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:28.123456789Z",
"created_on": "2018-07-06T12:30:26.123456789Z",
"step_uuid": "312d3af0-a565-4c96-ba00-bd7f0d08e671",
"subject": "New ticket: 5ecda5fc-951c-437b-a17e-f85e49829fb9",
"to": [
Expand All @@ -211,7 +206,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:26.123456789Z"
"time": "2018-07-06T12:30:24.123456789Z"
}
],
"session": {
Expand Down Expand Up @@ -297,6 +292,7 @@
},
{
"created_on": "2018-07-06T12:30:18.123456789Z",
"note": "Last message: Rats",
"step_uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623",
"ticket": {
"topic": {
Expand All @@ -307,23 +303,17 @@
},
"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:24.123456789Z",
"created_on": "2018-07-06T12:30:22.123456789Z",
"name": "Ticket",
"step_uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623",
"type": "run_result_changed",
"value": "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:28.123456789Z",
"created_on": "2018-07-06T12:30:26.123456789Z",
"step_uuid": "312d3af0-a565-4c96-ba00-bd7f0d08e671",
"subject": "New ticket: 5ecda5fc-951c-437b-a17e-f85e49829fb9",
"to": [
Expand All @@ -332,12 +322,12 @@
"type": "email_sent"
}
],
"exited_on": "2018-07-06T12:30:30.123456789Z",
"exited_on": "2018-07-06T12:30:28.123456789Z",
"flow": {
"name": "Support",
"uuid": "3486fc59-d417-4189-93cd-e0aa8e3112ac"
},
"modified_on": "2018-07-06T12:30:30.123456789Z",
"modified_on": "2018-07-06T12:30:28.123456789Z",
"path": [
{
"arrived_on": "2018-07-06T12:30:01.123456789Z",
Expand All @@ -358,7 +348,7 @@
"uuid": "970b8069-50f5-4f6f-8f41-6b2d9f33d623"
},
{
"arrived_on": "2018-07-06T12:30:27.123456789Z",
"arrived_on": "2018-07-06T12:30:25.123456789Z",
"exit_uuid": "b6562dea-d21c-4a99-b904-0fb9583fb5ab",
"node_uuid": "ac3fcd8e-e7bb-4545-865d-39424a8f1d7b",
"uuid": "312d3af0-a565-4c96-ba00-bd7f0d08e671"
Expand All @@ -375,7 +365,7 @@
},
"ticket": {
"category": "Success",
"created_on": "2018-07-06T12:30:22.123456789Z",
"created_on": "2018-07-06T12:30:20.123456789Z",
"name": "Ticket",
"node_uuid": "145eb3d3-b841-4e66-abac-297ae525c7ad",
"value": "5ecda5fc-951c-437b-a17e-f85e49829fb9"
Expand Down

0 comments on commit bddf0c2

Please sign in to comment.