fix(audio): stuck unmute due to borked callerId(Num)

FreeSWITCH incorrectly generates callerNum headers in its ESL events
when specific, special characters are in place. e.g.:
w_etc_0-bbbID-User;Semi (notice the semicolon) will be generated by
FS as w_etc_0-bbbID-User (everything after the semicolon is ignored).
This breaks callerId comparision for session matching in a few places -
one of the is the unmute/unhold toggle control.

Compare callerNum as prefixes instead of exact strings to match those
scenarios.
This is a temporary fix; we should review callerNum generation in the
future (use Caller-Id-Name in FSESL), as well as stop relying on it
for session matching (use UUIDs and/or client session numbers instead).
Both of these are more involved changes, though.
This commit is contained in:
prlanzarin 2024-07-03 00:10:14 -03:00
parent 6918d4e090
commit 437c684423

View File

@ -16,7 +16,15 @@ object VoiceUsers {
} }
def findWithIntIdAndCallerNum(users: VoiceUsers, intId: String, callerNum: String): Option[VoiceUserState] = { def findWithIntIdAndCallerNum(users: VoiceUsers, intId: String, callerNum: String): Option[VoiceUserState] = {
users.toVector.find(u => u.callerNum == callerNum && u.intId == intId) // prlanzarin: This is a hack to allow for partial matching of callerNums.
// This is needed because the callerNums are incorrectly generated by
// FREESWITCH's ESL events when special characters are in place.
// e.g.: w_etc_0-bbbID-User;Semi (notice the semicolon) will be generated by
// FS as w_etc_0-bbbID-User (everything after the semicolon is ignored).
// We should review callerNum generation in the future as well as stop
// relying on it for session matching (use UUIDs or client session numbers instead).
users.toVector.find(u => u.intId == intId &&
(u.callerNum.startsWith(callerNum) || callerNum.startsWith(u.callerNum)))
} }
def findAll(users: VoiceUsers): Vector[VoiceUserState] = users.toVector def findAll(users: VoiceUsers): Vector[VoiceUserState] = users.toVector