onCallEncryptionKeyRequest method

  1. @override
Future<void> onCallEncryptionKeyRequest(
  1. GroupCallSession groupCall,
  2. String userId,
  3. String deviceId,
  4. Map<String, dynamic> content,
)
override

Implementation

@override
Future<void> onCallEncryptionKeyRequest(
  GroupCallSession groupCall,
  String userId,
  String deviceId,
  Map<String, dynamic> content,
) async {
  if (!e2eeEnabled) {
    Logs().w('[VOIP] got sframe key request but we do not support e2ee');
    return;
  }
  final mems = groupCall.room.getCallMembershipsForUser(userId);
  if (mems
      .where(
        (mem) =>
            mem.callId == groupCall.groupCallId &&
            mem.userId == userId &&
            mem.deviceId == deviceId &&
            !mem.isExpired &&
            // sanity checks
            mem.backend.type == groupCall.backend.type &&
            mem.roomId == groupCall.room.id &&
            mem.application == groupCall.application,
      )
      .isNotEmpty) {
    Logs().d(
        '[VOIP] onCallEncryptionKeyRequest: request checks out, sending key on index: $latestLocalKeyIndex to $userId:$deviceId');
    await _sendEncryptionKeysEvent(
      groupCall,
      _latestLocalKeyIndex,
      sendTo: [
        CallParticipant(
          groupCall.voip,
          userId: userId,
          deviceId: deviceId,
        )
      ],
    );
  }
}