Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add session status to message #356

Merged
merged 12 commits into from
Sep 14, 2020
3 changes: 3 additions & 0 deletions hooks/msg_created.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
6 changes: 6 additions & 0 deletions models/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need this comment.. everything here is being transmitted onwards

SessionStatus SessionStatus `json:"session_status,omitempty""`
}

channel *Channel
Expand Down Expand Up @@ -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))
Expand Down