fix: route call accept across pods
This commit is contained in:
+30
-3
@@ -330,6 +330,23 @@ func (call *videoCall) isStaleUnanswered(now time.Time, timeoutSeconds int) bool
|
||||
return now.Sub(call.startedAt) > time.Duration(timeoutSeconds)*time.Second
|
||||
}
|
||||
|
||||
func (call *videoCall) hasPartySessionOrUser(sid string, uid types.Uid) bool {
|
||||
if call == nil {
|
||||
return false
|
||||
}
|
||||
if sid != "" {
|
||||
if _, ok := call.parties[sid]; ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
for _, party := range call.parties {
|
||||
if party.uid == uid {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *Topic) auditCallCreate(call *videoCall, caller types.Uid) {
|
||||
if store.Calls == nil || call == nil || call.callID == "" || caller.IsZero() {
|
||||
return
|
||||
@@ -645,8 +662,14 @@ func (t *Topic) handleCallEvent(msg *ClientComMessage) {
|
||||
case constCallEventHangUp:
|
||||
switch len(t.currentCall.parties) {
|
||||
case 2:
|
||||
// If it's a call in progress, hangup may arrive only from a call participant session.
|
||||
if _, ok := t.currentCall.parties[msg.sess.sid]; !ok {
|
||||
// If it's a call in progress, hangup may arrive from any current
|
||||
// session of a call participant. This also covers rtc-join
|
||||
// auto-accept, where the accepting HTTP request has no WebSocket sid.
|
||||
sid := ""
|
||||
if msg.sess != nil {
|
||||
sid = msg.sess.sid
|
||||
}
|
||||
if !t.currentCall.hasPartySessionOrUser(sid, asUid) {
|
||||
return
|
||||
}
|
||||
case 1:
|
||||
@@ -654,7 +677,11 @@ func (t *Topic) handleCallEvent(msg *ClientComMessage) {
|
||||
originatorUid, originator := t.getCallOriginator()
|
||||
// Hangup may come from either the originating session or
|
||||
// any callee user session.
|
||||
if asUid == originatorUid && originator.sid != msg.sess.sid {
|
||||
sid := ""
|
||||
if msg.sess != nil {
|
||||
sid = msg.sess.sid
|
||||
}
|
||||
if asUid == originatorUid && originator.sid != sid {
|
||||
return
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user