fix: Allow empty OMEMO messages to bypass trust
This commit is contained in:
@@ -224,8 +224,11 @@ class OmemoSessionManager {
|
||||
// We assume that the user already checked if the session exists
|
||||
for (final jid in jids) {
|
||||
for (final deviceId in _deviceMap[jid]!) {
|
||||
// Only encrypt to devices that are trusted
|
||||
if (!(await _trustManager.isTrusted(jid, deviceId))) continue;
|
||||
// Empty OMEMO messages are allowed to bypass trust
|
||||
if (plaintext != null) {
|
||||
// Only encrypt to devices that are trusted
|
||||
if (!(await _trustManager.isTrusted(jid, deviceId))) continue;
|
||||
}
|
||||
|
||||
final ratchetKey = RatchetMapKey(jid, deviceId);
|
||||
final ratchet = _ratchetMap[ratchetKey]!;
|
||||
|
||||
14
lib/src/trust/never.dart
Normal file
14
lib/src/trust/never.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:omemo_dart/src/trust/base.dart';
|
||||
|
||||
/// Only use for testing!
|
||||
/// An implementation of TrustManager that never trusts any device and thus
|
||||
/// has no internal state.
|
||||
@visibleForTesting
|
||||
class NeverTrustingTrustManager extends TrustManager {
|
||||
@override
|
||||
Future<bool> isTrusted(String jid, int deviceId) async => false;
|
||||
|
||||
@override
|
||||
Future<void> onNewSession(String jid, int deviceId) async {}
|
||||
}
|
||||
Reference in New Issue
Block a user