-
-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Prevent sending messages if other party has no encryption keys
- Loading branch information
1 parent
8cb06d6
commit aa01076
Showing
5 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 {} |