feat: Prevent sending messages if other party has no encryption keys

This commit is contained in:
Krille 2025-01-13 13:57:12 +01:00
commit aa010767de
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652
5 changed files with 60 additions and 1 deletions

View file

@ -0,0 +1,21 @@
import 'package:matrix/matrix.dart';
extension OtherPartyCanReceiveExtension on Room {
bool get otherPartyCanReceiveMessages {
if (!encrypted) return true;
final users = getParticipants()
.map((u) => u.id)
.where((userId) => userId != client.userID)
.toSet();
if (users.isEmpty) return true;
for (final userId in users) {
if (client.userDeviceKeys[userId]?.deviceKeys.values.isNotEmpty == true) {
return true;
}
}
return false;
}
}
class OtherPartyCanNotReceiveMessages implements Exception {}