Commit 9843a76f authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Populate room, group, and direct message fields in channel presence events.

parent 1a087f9b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr

### Fixed
- Ensure runtime environment values do not appear multiple times in the devconsole configuration view.
- Channel presence events now populate room, group, and direct message fields.

## [2.11.1] - 2020-03-29
### Changed
+53 −5
Original line number Diff line number Diff line
@@ -778,9 +778,31 @@ func (t *LocalTracker) processEvent(e *PresenceEvent) {
				Leaves: leaves,
			}}}
		case StreamModeChannel:
			fallthrough
			channelID, err := StreamToChannelId(stream)
			if err != nil {
				// Should not happen thanks to previous validation, but guard just in case.
				t.logger.Error("Error converting stream to channel identifier in presence event", zap.Error(err), zap.Any("stream", stream))
				continue
			}
			envelope = &rtapi.Envelope{Message: &rtapi.Envelope_ChannelPresenceEvent{ChannelPresenceEvent: &rtapi.ChannelPresenceEvent{
				ChannelId: channelID,
				Joins:     joins,
				Leaves:    leaves,
				RoomName:  streamWire.Label,
			}}}
		case StreamModeGroup:
			fallthrough
			channelID, err := StreamToChannelId(stream)
			if err != nil {
				// Should not happen thanks to previous validation, but guard just in case.
				t.logger.Error("Error converting stream to channel identifier in presence event", zap.Error(err), zap.Any("stream", stream))
				continue
			}
			envelope = &rtapi.Envelope{Message: &rtapi.Envelope_ChannelPresenceEvent{ChannelPresenceEvent: &rtapi.ChannelPresenceEvent{
				ChannelId: channelID,
				Joins:     joins,
				Leaves:    leaves,
				GroupId:   streamWire.Subject,
			}}}
		case StreamModeDM:
			channelID, err := StreamToChannelId(stream)
			if err != nil {
@@ -792,6 +814,8 @@ func (t *LocalTracker) processEvent(e *PresenceEvent) {
				ChannelId: channelID,
				Joins:     joins,
				Leaves:    leaves,
				UserIdOne: streamWire.Subject,
				UserIdTwo: streamWire.Subcontext,
			}}}
		case StreamModeMatchRelayed:
			fallthrough
@@ -883,9 +907,31 @@ func (t *LocalTracker) processEvent(e *PresenceEvent) {
				Leaves: leaves,
			}}}
		case StreamModeChannel:
			fallthrough
			channelID, err := StreamToChannelId(stream)
			if err != nil {
				// Should not happen thanks to previous validation, but guard just in case.
				t.logger.Error("Error converting stream to channel identifier in presence event", zap.Error(err), zap.Any("stream", stream))
				continue
			}
			envelope = &rtapi.Envelope{Message: &rtapi.Envelope_ChannelPresenceEvent{ChannelPresenceEvent: &rtapi.ChannelPresenceEvent{
				ChannelId: channelID,
				// No joins.
				Leaves:   leaves,
				RoomName: streamWire.Label,
			}}}
		case StreamModeGroup:
			fallthrough
			channelID, err := StreamToChannelId(stream)
			if err != nil {
				// Should not happen thanks to previous validation, but guard just in case.
				t.logger.Error("Error converting stream to channel identifier in presence event", zap.Error(err), zap.Any("stream", stream))
				continue
			}
			envelope = &rtapi.Envelope{Message: &rtapi.Envelope_ChannelPresenceEvent{ChannelPresenceEvent: &rtapi.ChannelPresenceEvent{
				ChannelId: channelID,
				// No joins.
				Leaves:  leaves,
				GroupId: streamWire.Subject,
			}}}
		case StreamModeDM:
			channelID, err := StreamToChannelId(stream)
			if err != nil {
@@ -897,6 +943,8 @@ func (t *LocalTracker) processEvent(e *PresenceEvent) {
				ChannelId: channelID,
				// No joins.
				Leaves:    leaves,
				UserIdOne: streamWire.Subject,
				UserIdTwo: streamWire.Subcontext,
			}}}
		case StreamModeMatchRelayed:
			fallthrough