Do not send ParticipantLeft webhook event unless connected successfully. (#1234)

Fixes #1130
This commit is contained in:
David Zhao
2022-12-18 17:37:55 -08:00
committed by GitHub
parent dc3f566f1a
commit 33902a9f2a
9 changed files with 141 additions and 109 deletions
+4 -4
View File
@@ -332,7 +332,7 @@ func (r *RoomManager) StartSession(
pLogger.Errorw("could not store participant", err)
}
updateParticipantCount := func(proto *livekit.Room) {
persistRoomForParticipantCount := func(proto *livekit.Room) {
if !participant.Hidden() {
err = r.roomStore.StoreRoom(ctx, proto, room.Internal())
if err != nil {
@@ -342,7 +342,7 @@ func (r *RoomManager) StartSession(
}
// update room store with new numParticipants
updateParticipantCount(room.ToProto())
persistRoomForParticipantCount(room.ToProto())
clientMeta := &livekit.AnalyticsClientMeta{Region: r.currentNode.Region, Node: r.currentNode.Id}
r.telemetry.ParticipantJoined(ctx, protoRoom, participant.ToProto(), pi.Client, clientMeta)
@@ -353,8 +353,8 @@ func (r *RoomManager) StartSession(
// update room store with new numParticipants
proto := room.ToProto()
updateParticipantCount(proto)
r.telemetry.ParticipantLeft(ctx, proto, p.ToProto())
persistRoomForParticipantCount(proto)
r.telemetry.ParticipantLeft(ctx, proto, p.ToProto(), true)
room.RemoveDisallowedSubscriptions(p, disallowedSubscriptions)
})