diff --git a/hooks/msg_created.go b/hooks/msg_created.go index a758f372a..3f111cd52 100644 --- a/hooks/msg_created.go +++ b/hooks/msg_created.go @@ -220,6 +220,9 @@ func handleMsgCreated(ctx context.Context, tx *sqlx.Tx, rp *redis.Pool, oa *mode return errors.Wrapf(err, "error creating outgoing message to %s", event.Msg.URN()) } + // Pass along the session status to courier + msg.SetSessionStatus(scene.Session().Status()) + // set our reply to as well (will be noop in cases when there is no incoming message) msg.SetResponseTo(scene.Session().IncomingMsgID(), scene.Session().IncomingMsgExternalID()) diff --git a/models/msgs.go b/models/msgs.go index a4d62e4d1..ff77a2b0b 100644 --- a/models/msgs.go +++ b/models/msgs.go @@ -130,6 +130,8 @@ type Msg struct { SessionID SessionID `json:"session_id,omitempty"` SessionWaitStartedOn *time.Time `json:"session_wait_started_on,omitempty"` SessionTimeout int `json:"session_timeout,omitempty"` + // Transmit sessionstatus onwards + SessionStatus SessionStatus `json:"session_status,omitempty""` } channel *Channel @@ -407,6 +409,10 @@ func (m *Msg) SetTimeout(id SessionID, start time.Time, timeout time.Duration) { m.m.SessionTimeout = int(timeout / time.Second) } +func (m *Msg) SetSessionStatus (status SessionStatus) { + m.m.SessionStatus = status +} + // InsertMessages inserts the passed in messages in a single query func InsertMessages(ctx context.Context, tx Queryer, msgs []*Msg) error { is := make([]interface{}, len(msgs))