feat: Add more documentation

This commit is contained in:
PapaTutuWawa 2022-12-26 13:21:47 +01:00
parent 5bc1136ec0
commit caf841c53e
2 changed files with 31 additions and 4 deletions

View File

@ -42,8 +42,14 @@ class OmemoManager {
final Logger _log = Logger('OmemoManager');
/// Functions for connecting with the OMEMO library
/// Send an empty OMEMO:2 message using the encrypted payload [result] to [recipientJid].
final Future<void> Function(EncryptionResult result, String recipientJid) sendEmptyOmemoMessage;
/// Fetch the list of device ids associated with [jid].
final Future<List<int>> Function(String jid) fetchDeviceList;
/// Fetch the device bundle for the device with id [id] of [jid]. If it cannot be fetched, return null.
final Future<OmemoBundle?> Function(String jid, int id) fetchDeviceBundle;
/// Map bare JID to its known devices
@ -588,11 +594,16 @@ class OmemoManager {
Future<void> ratchetAcknowledged(String jid, int deviceId, { bool enterCriticalSection = true }) async {
if (enterCriticalSection) await _enterRatchetCriticalSection(jid);
final ratchet = _ratchetMap[RatchetMapKey(jid, deviceId)]!
..acknowledged = true;
final key = RatchetMapKey(jid, deviceId);
if (_ratchetMap.containsKey(key)) {
final ratchet = _ratchetMap[key]!
..acknowledged = true;
// Commit it
_eventStreamController.add(RatchetModifiedEvent(jid, deviceId, ratchet, false));
// Commit it
_eventStreamController.add(RatchetModifiedEvent(jid, deviceId, ratchet, false));
} else {
_log.severe('Attempted to acknowledge ratchet ${key.toJsonKey()}, even though it does not exist');
}
if (enterCriticalSection) await _leaveRatchetCriticalSection(jid);
}

View File

@ -1,5 +1,6 @@
import 'package:omemo_dart/src/omemo/encrypted_key.dart';
/// Describes a stanza that was received by the underlying XMPP library.
class OmemoIncomingStanza {
const OmemoIncomingStanza(
this.bareSenderJid,
@ -8,18 +9,33 @@ class OmemoIncomingStanza {
this.keys,
this.payload,
);
/// The bare JID of the sender of the stanza.
final String bareSenderJid;
/// The device ID of the sender.
final int senderDeviceId;
/// The timestamp when the stanza was received.
final int timestamp;
/// The included encrypted keys
final List<EncryptedKey> keys;
/// The string payload included in the <encrypted /> element.
final String payload;
}
/// Describes a stanza that is to be sent out
class OmemoOutgoingStanza {
const OmemoOutgoingStanza(
this.recipientJids,
this.payload,
);
/// The JIDs the stanza will be sent to.
final List<String> recipientJids;
/// The serialised XML data that should be encrypted.
final String payload;
}