Merge pull request #1817 from famedly/td/fixUserJoinErrro

fix: minor perm issue typo while setting famedly call member event
This commit is contained in:
td 2024-05-21 15:59:48 +05:30 committed by GitHub
commit f66e14671b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 42 additions and 24 deletions

View File

@ -23,7 +23,8 @@ abstract class CallBackend {
type: type,
);
} else {
throw ArgumentError('Invalid type: $type');
throw MatrixSDKVoipException(
'Invalid type: $type in CallBackend.fromJson');
}
}

View File

@ -80,7 +80,8 @@ class LiveKitBackend extends CallBackend {
final keyProvider = groupCall.voip.delegate.keyProvider;
if (keyProvider == null) {
throw Exception('[VOIP] _ratchetKey called but KeyProvider was null');
throw MatrixSDKVoipException(
'_ratchetKey called but KeyProvider was null');
}
final myKeys = _encryptionKeysMap[groupCall.localParticipant];

View File

@ -87,8 +87,7 @@ class MeshBackend extends CallBackend {
return await groupCall.voip.delegate.mediaDevices
.getDisplayMedia(mediaConstraints);
} catch (e, s) {
Logs().e('[VOIP] _getDisplayMedia failed because,', e, s);
rethrow;
throw MatrixSDKVoipException('_getDisplayMedia failed', stackTrace: s);
}
}
@ -113,7 +112,7 @@ class MeshBackend extends CallBackend {
/// init a peer call from group calls.
Future<void> _initCall(GroupCallSession groupCall, CallSession call) async {
if (call.remoteUserId == null) {
throw Exception(
throw MatrixSDKVoipException(
'Cannot init call without proper invitee user and device Id');
}
@ -156,7 +155,7 @@ class MeshBackend extends CallBackend {
.indexWhere((element) => element.callId == existingCall.callId);
if (existingCallIndex == -1) {
throw Exception('Couldn\'t find call to replace');
throw MatrixSDKVoipException('Couldn\'t find call to replace');
}
_callSessions.removeAt(existingCallIndex);
@ -181,7 +180,7 @@ class MeshBackend extends CallBackend {
Future<void> _disposeCall(GroupCallSession groupCall, CallSession call,
CallErrorCode hangupReason) async {
if (call.remoteUserId == null) {
throw Exception(
throw MatrixSDKVoipException(
'Cannot init call without proper invitee user and device Id');
}
@ -223,7 +222,7 @@ class MeshBackend extends CallBackend {
Future<void> _onStreamsChanged(
GroupCallSession groupCall, CallSession call) async {
if (call.remoteUserId == null) {
throw Exception(
throw MatrixSDKVoipException(
'Cannot init call without proper invitee user and device Id');
}
@ -372,7 +371,8 @@ class MeshBackend extends CallBackend {
(stream) => stream.participant.id == existingStream.participant.id);
if (streamIndex == -1) {
throw Exception('Couldn\'t find screenshare stream to replace');
throw MatrixSDKVoipException(
'Couldn\'t find screenshare stream to replace');
}
_screenshareStreams.replaceRange(streamIndex, 1, [replacementStream]);
@ -390,7 +390,8 @@ class MeshBackend extends CallBackend {
.indexWhere((stream) => stream.participant.id == stream.participant.id);
if (streamIndex == -1) {
throw Exception('Couldn\'t find screenshare stream to remove');
throw MatrixSDKVoipException(
'Couldn\'t find screenshare stream to remove');
}
_screenshareStreams.removeWhere(
@ -451,7 +452,8 @@ class MeshBackend extends CallBackend {
(stream) => stream.participant.id == existingStream.participant.id);
if (streamIndex == -1) {
throw Exception('Couldn\'t find user media stream to replace');
throw MatrixSDKVoipException(
'Couldn\'t find user media stream to replace');
}
_userMediaStreams.replaceRange(streamIndex, 1, [replacementStream]);
@ -469,7 +471,8 @@ class MeshBackend extends CallBackend {
(element) => element.participant.id == stream.participant.id);
if (streamIndex == -1) {
throw Exception('Couldn\'t find user media stream to remove');
throw MatrixSDKVoipException(
'Couldn\'t find user media stream to remove');
}
_userMediaStreams.removeWhere(
@ -527,7 +530,7 @@ class MeshBackend extends CallBackend {
Future<WrappedMediaStream?> initLocalStream(GroupCallSession groupCall,
{WrappedMediaStream? stream}) async {
if (groupCall.state != GroupCallState.localCallFeedUninitialized) {
throw Exception(
throw MatrixSDKVoipException(
'Cannot initialize local call feed in the ${groupCall.state} state.');
}

View File

@ -928,9 +928,10 @@ class CallSession {
if (sender.track != null && sender.track!.kind == 'audio') {
await sender.dtmfSender.insertDTMF(tones);
return;
} else {
Logs().w('[VOIP] Unable to find a track to send DTMF on');
}
}
Logs().e('[VOIP] Unable to find a track to send DTMF on');
}
Future<void> terminate(

View File

@ -112,7 +112,7 @@ class GroupCallSession {
Future<void> enter({WrappedMediaStream? stream}) async {
if (!(state == GroupCallState.localCallFeedUninitialized ||
state == GroupCallState.localCallFeedInitialized)) {
throw Exception('Cannot enter call in the $state state');
throw MatrixSDKVoipException('Cannot enter call in the $state state');
}
if (state == GroupCallState.localCallFeedUninitialized) {

View File

@ -120,7 +120,7 @@ extension FamedlyCallMemberEventsExtension on Room {
}
Future<void> setFamedlyCallMemberEvent(Map<String, List> newContent) async {
if (groupCallsEnabledForEveryone) {
if (canJoinGroupCall) {
await client.setRoomStateWithKey(
id,
EventTypes.GroupCallMember,
@ -128,8 +128,9 @@ extension FamedlyCallMemberEventsExtension on Room {
newContent,
);
} else {
Logs().w(
'[VOIP] cannot send ${EventTypes.GroupCallMember} events in room: $id, fix your PLs');
throw MatrixSDKVoipException(
'User ${client.userID}:${client.deviceID} is not allowed to send famedly call member events in room $id, canJoinGroupCall: $canJoinGroupCall, room.canJoinGroupCall: $groupCallsEnabledForEveryone',
);
}
}
@ -165,3 +166,13 @@ bool isValidMemEvent(Map<String, Object?> event) {
return false;
}
}
class MatrixSDKVoipException implements Exception {
final String cause;
final StackTrace? stackTrace;
MatrixSDKVoipException(this.cause, {this.stackTrace});
@override
String toString() => '[VOIP] $cause, ${super.toString()}, $stackTrace';
}

View File

@ -764,20 +764,21 @@ class VoIP {
String? application,
String? scope,
) async {
if (!room.groupCallsEnabledForEveryone) {
await room.enableGroupCalls();
}
final groupCall = getGroupCallById(room.id, groupCallId);
if (groupCall != null) {
if (!room.canJoinGroupCall) {
throw Exception(
'User is not allowed to join famedly calls in the room');
throw MatrixSDKVoipException(
'User ${client.userID}:${client.deviceID} is not allowed to join famedly calls in room ${room.id}, canJoinGroupCall: ${room.canJoinGroupCall}, room.canJoinGroupCall: ${room.groupCallsEnabledForEveryone}',
);
}
return groupCall;
}
if (!room.groupCallsEnabledForEveryone) {
await room.enableGroupCalls();
}
// The call doesn't exist, but we can create it
return await _newGroupCall(
groupCallId,