-
Notifications
You must be signed in to change notification settings - Fork 20
/
msg_created.go
50 lines (42 loc) · 1.28 KB
/
msg_created.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package events
import (
"github.com/nyaruka/goflow/flows"
)
func init() {
RegisterType(TypeMsgCreated, func() flows.Event { return &MsgCreatedEvent{} })
}
// TypeMsgCreated is a constant for incoming messages
const TypeMsgCreated string = "msg_created"
// MsgCreatedEvent events are used for replies to the session contact.
//
// {
// "type": "msg_created",
// "created_on": "2006-01-02T15:04:05Z",
// "msg": {
// "uuid": "2d611e17-fb22-457f-b802-b8f7ec5cda5b",
// "channel": {"uuid": "61602f3e-f603-4c70-8a8f-c477505bf4bf", "name": "Twilio"},
// "urn": "tel:+12065551212",
// "text": "hi there",
// "attachments": ["https://s3.amazon.com/mybucket/attachment.jpg"]
// }
// }
//
// @event msg_created
type MsgCreatedEvent struct {
BaseEvent
engineOnlyEvent
Msg flows.MsgOut `json:"msg" validate:"required,dive"`
}
// NewMsgCreatedEvent creates a new outgoing msg event to a single contact
func NewMsgCreatedEvent(msg *flows.MsgOut) *MsgCreatedEvent {
return &MsgCreatedEvent{
BaseEvent: NewBaseEvent(),
Msg: *msg,
}
}
// Type returns the type of this event
func (e *MsgCreatedEvent) Type() string { return TypeMsgCreated }
// Apply applies this event to the given run
func (e *MsgCreatedEvent) Apply(run flows.FlowRun) error {
return nil
}