bigbluebutton-Github/bbb-graphql-middleware/internal/hasura/retransmiter/retransmiter.go
Gustavo Trott cccd2d78c7
Refactor the logger to add more context like meetingId, userId and sessionToken. (#21188)
For DEBUG logs it also includes the file/line and function of the caller.
2024-09-18 08:48:36 -04:00

42 lines
1.4 KiB
Go

package retransmiter
import (
"bbb-graphql-middleware/internal/common"
)
func RetransmitSubscriptionStartMessages(hc *common.HasuraConnection) {
hc.BrowserConn.ActiveSubscriptionsMutex.RLock()
defer hc.BrowserConn.ActiveSubscriptionsMutex.RUnlock()
userCurrentlyInMeeting := false
if hasuraRole, exists := hc.BrowserConn.BBBWebSessionVariables["x-hasura-role"]; exists {
userCurrentlyInMeeting = hasuraRole == "bbb_client"
}
for _, subscription := range hc.BrowserConn.ActiveSubscriptions {
//Not retransmitting Mutations
if subscription.Type == common.Mutation {
continue
}
//When user left the meeting, Retransmit only Presence Manager subscriptions
if !userCurrentlyInMeeting &&
subscription.OperationName != "getUserInfo" &&
subscription.OperationName != "getUserCurrent" {
hc.BrowserConn.Logger.Debugf("Skipping retransmit %s because the user is offline", subscription.OperationName)
continue
}
if subscription.LastSeenOnHasuraConnection != hc.Id {
hc.BrowserConn.Logger.Tracef("retransmiting subscription start: %v", string(subscription.Message))
if subscription.Type == common.Streaming && subscription.StreamCursorCurrValue != nil {
hc.BrowserConn.FromBrowserToHasuraChannel.Send(common.PatchQuerySettingLastCursorValue(subscription))
} else {
hc.BrowserConn.FromBrowserToHasuraChannel.Send(subscription.Message)
}
}
}
}