Compare commits
2 Commits
62001c1e29
...
596693c206
Author | SHA1 | Date | |
---|---|---|---|
596693c206 | |||
22aa07c4ba |
@ -13,11 +13,10 @@ import 'package:moxxmpp/src/xeps/xep_0030/xep_0030.dart';
|
|||||||
import 'package:moxxmpp/src/xeps/xep_0297.dart';
|
import 'package:moxxmpp/src/xeps/xep_0297.dart';
|
||||||
|
|
||||||
class CarbonsManager extends XmppManagerBase {
|
class CarbonsManager extends XmppManagerBase {
|
||||||
|
CarbonsManager() : super();
|
||||||
CarbonsManager() : _isEnabled = false, _supported = false, _gotSupported = false, super();
|
bool _isEnabled = false;
|
||||||
bool _isEnabled;
|
bool _supported = false;
|
||||||
bool _supported;
|
bool _gotSupported = false;
|
||||||
bool _gotSupported;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String getId() => carbonsManager;
|
String getId() => carbonsManager;
|
||||||
@ -159,6 +158,9 @@ class CarbonsManager extends XmppManagerBase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// True if Message Carbons are enabled. False, if not.
|
||||||
|
bool get isEnabled => _isEnabled;
|
||||||
|
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
void forceEnable() {
|
void forceEnable() {
|
||||||
_isEnabled = true;
|
_isEnabled = true;
|
||||||
|
@ -16,6 +16,7 @@ import 'package:moxxmpp/src/xeps/xep_0030/types.dart';
|
|||||||
import 'package:moxxmpp/src/xeps/xep_0030/xep_0030.dart';
|
import 'package:moxxmpp/src/xeps/xep_0030/xep_0030.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0060/errors.dart';
|
import 'package:moxxmpp/src/xeps/xep_0060/errors.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0060/xep_0060.dart';
|
import 'package:moxxmpp/src/xeps/xep_0060/xep_0060.dart';
|
||||||
|
import 'package:moxxmpp/src/xeps/xep_0280.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0334.dart';
|
import 'package:moxxmpp/src/xeps/xep_0334.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0380.dart';
|
import 'package:moxxmpp/src/xeps/xep_0380.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0384/crypto.dart';
|
import 'package:moxxmpp/src/xeps/xep_0384/crypto.dart';
|
||||||
@ -337,15 +338,31 @@ abstract class BaseOmemoManager extends XmppManagerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.finest('Beginning encryption');
|
logger.finest('Beginning encryption');
|
||||||
|
final carbonsEnabled = getAttributes()
|
||||||
|
.getManagerById<CarbonsManager>(carbonsManager)?.isEnabled ?? false;
|
||||||
final om = await getOmemoManager();
|
final om = await getOmemoManager();
|
||||||
final result = await om.onOutgoingStanza(
|
final result = await om.onOutgoingStanza(
|
||||||
OmemoOutgoingStanza(
|
OmemoOutgoingStanza(
|
||||||
[toJid.toString()],
|
[
|
||||||
|
toJid.toString(),
|
||||||
|
if (carbonsEnabled)
|
||||||
|
getAttributes().getFullJID().toBare().toString(),
|
||||||
|
],
|
||||||
_buildEnvelope(toEncrypt, toJid.toString()),
|
_buildEnvelope(toEncrypt, toJid.toString()),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
logger.finest('Encryption done');
|
logger.finest('Encryption done');
|
||||||
|
|
||||||
|
if (!result.isSuccess(2)) {
|
||||||
|
final other = Map<String, dynamic>.from(state.other);
|
||||||
|
other['encryption_error_jids'] = result.jidEncryptionErrors;
|
||||||
|
other['encryption_error_devices'] = result.deviceEncryptionErrors;
|
||||||
|
return state.copyWith(
|
||||||
|
other: other,
|
||||||
|
cancel: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
final encrypted = _buildEncryptedElement(
|
final encrypted = _buildEncryptedElement(
|
||||||
result,
|
result,
|
||||||
toJid.toString(),
|
toJid.toString(),
|
||||||
|
@ -20,7 +20,7 @@ dependencies:
|
|||||||
version: ^0.1.5
|
version: ^0.1.5
|
||||||
omemo_dart:
|
omemo_dart:
|
||||||
hosted: https://git.polynom.me/api/packages/PapaTutuWawa/pub
|
hosted: https://git.polynom.me/api/packages/PapaTutuWawa/pub
|
||||||
version: ^0.4.0
|
version: ^0.4.1
|
||||||
random_string: ^2.3.1
|
random_string: ^2.3.1
|
||||||
saslprep: ^1.0.2
|
saslprep: ^1.0.2
|
||||||
synchronized: ^3.0.0+2
|
synchronized: ^3.0.0+2
|
||||||
|
Loading…
Reference in New Issue
Block a user