feat: Remove unused helper functions

This commit is contained in:
PapaTutuWawa 2023-06-17 23:27:10 +02:00
parent c086579b57
commit ddb4483d4a
3 changed files with 2 additions and 62 deletions

View File

@ -43,23 +43,6 @@ int generateRandom32BitNumber() {
return Random.secure().nextInt(4294967295 /*pow(2, 32) - 1*/); return Random.secure().nextInt(4294967295 /*pow(2, 32) - 1*/);
} }
OmemoPublicKey? decodeKeyIfNotNull(
Map<String, dynamic> map,
String key,
KeyPairType type,
) {
if (map[key] == null) return null;
return OmemoPublicKey.fromBytes(
base64.decode(map[key]! as String),
type,
);
}
int getTimestamp() {
return DateTime.now().millisecondsSinceEpoch;
}
/// Describes the differences between two lists in terms of its items. /// Describes the differences between two lists in terms of its items.
class ListDiff<T> { class ListDiff<T> {
ListDiff(this.added, this.removed); ListDiff(this.added, this.removed);
@ -90,7 +73,8 @@ extension AppendToListOrCreateExtension<K, V> on Map<K, List<V>> {
if (containsKey(key)) { if (containsKey(key)) {
if (!checkExistence) { if (!checkExistence) {
this[key]!.add(value); this[key]!.add(value);
} if (!this[key]!.contains(value)) { }
if (!this[key]!.contains(value)) {
this[key]!.add(value); this[key]!.add(value);
} }
} else { } else {

View File

@ -5,7 +5,6 @@ class OmemoIncomingStanza {
const OmemoIncomingStanza( const OmemoIncomingStanza(
this.bareSenderJid, this.bareSenderJid,
this.senderDeviceId, this.senderDeviceId,
this.timestamp,
this.keys, this.keys,
this.payload, this.payload,
this.isCatchup, this.isCatchup,
@ -17,9 +16,6 @@ class OmemoIncomingStanza {
/// The device ID of the sender. /// The device ID of the sender.
final int senderDeviceId; final int senderDeviceId;
/// The timestamp when the stanza was received.
final int timestamp;
/// The included encrypted keys for our own JID /// The included encrypted keys for our own JID
final List<EncryptedKey> keys; final List<EncryptedKey> keys;

View File

@ -81,7 +81,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult.encryptedKeys[bobJid]!, aliceResult.encryptedKeys[bobJid]!,
base64.encode(aliceResult.ciphertext!), base64.encode(aliceResult.ciphertext!),
false, false,
@ -110,7 +109,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
bobJid, bobJid,
bobDevice.id, bobDevice.id,
DateTime.now().millisecondsSinceEpoch,
bobResult2.encryptedKeys[aliceJid]!, bobResult2.encryptedKeys[aliceJid]!,
base64.encode(bobResult2.ciphertext!), base64.encode(bobResult2.ciphertext!),
false, false,
@ -183,7 +181,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult.encryptedKeys[bobJid]!, aliceResult.encryptedKeys[bobJid]!,
base64.encode(aliceResult.ciphertext!), base64.encode(aliceResult.ciphertext!),
false, false,
@ -199,7 +196,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
bobJid, bobJid,
bobDevice.id, bobDevice.id,
getTimestamp(),
bobEmptyMessage!.encryptedKeys[aliceJid]!, bobEmptyMessage!.encryptedKeys[aliceJid]!,
null, null,
false, false,
@ -222,7 +218,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResultLoop.encryptedKeys[bobJid]!, aliceResultLoop.encryptedKeys[bobJid]!,
base64.encode(aliceResultLoop.ciphertext!), base64.encode(aliceResultLoop.ciphertext!),
false, false,
@ -247,7 +242,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResultFinal.encryptedKeys[bobJid]!, aliceResultFinal.encryptedKeys[bobJid]!,
base64.encode(aliceResultFinal.ciphertext!), base64.encode(aliceResultFinal.ciphertext!),
false, false,
@ -263,7 +257,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
bobJid, bobJid,
bobDevice.id, bobDevice.id,
getTimestamp(),
bobEmptyMessage!.encryptedKeys[aliceJid]!, bobEmptyMessage!.encryptedKeys[aliceJid]!,
null, null,
false, false,
@ -282,7 +275,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
getTimestamp(),
aliceMessagePostFinal.encryptedKeys[bobJid]!, aliceMessagePostFinal.encryptedKeys[bobJid]!,
base64Encode(aliceMessagePostFinal.ciphertext!), base64Encode(aliceMessagePostFinal.ciphertext!),
false, false,
@ -377,7 +369,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult1.encryptedKeys[bobJid]!, aliceResult1.encryptedKeys[bobJid]!,
base64.encode(aliceResult1.ciphertext!), base64.encode(aliceResult1.ciphertext!),
false, false,
@ -402,7 +393,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult2.encryptedKeys[bobJid]!, aliceResult2.encryptedKeys[bobJid]!,
base64.encode(aliceResult2.ciphertext!), base64.encode(aliceResult2.ciphertext!),
false, false,
@ -494,7 +484,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult1.encryptedKeys[bobJid]!, aliceResult1.encryptedKeys[bobJid]!,
base64.encode(aliceResult1.ciphertext!), base64.encode(aliceResult1.ciphertext!),
false, false,
@ -518,7 +507,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
bobJid, bobJid,
bobDevice2.id, bobDevice2.id,
DateTime.now().millisecondsSinceEpoch,
bobResult2.encryptedKeys[aliceJid]!, bobResult2.encryptedKeys[aliceJid]!,
base64.encode(bobResult2.ciphertext!), base64.encode(bobResult2.ciphertext!),
false, false,
@ -602,7 +590,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult1.encryptedKeys[bobJid]!, aliceResult1.encryptedKeys[bobJid]!,
base64.encode(aliceResult1.ciphertext!), base64.encode(aliceResult1.ciphertext!),
false, false,
@ -640,7 +627,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult2.encryptedKeys[bobJid]!, aliceResult2.encryptedKeys[bobJid]!,
base64.encode(aliceResult2.ciphertext!), base64.encode(aliceResult2.ciphertext!),
false, false,
@ -650,7 +636,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult2.encryptedKeys[bobJid]!, aliceResult2.encryptedKeys[bobJid]!,
base64.encode(aliceResult2.ciphertext!), base64.encode(aliceResult2.ciphertext!),
false, false,
@ -673,7 +658,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
bobJid, bobJid,
bobDevice2.id, bobDevice2.id,
DateTime.now().millisecondsSinceEpoch,
bobResult32.encryptedKeys[aliceJid]!, bobResult32.encryptedKeys[aliceJid]!,
base64.encode(bobResult32.ciphertext!), base64.encode(bobResult32.ciphertext!),
false, false,
@ -751,7 +735,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult.encryptedKeys[bobJid]!, aliceResult.encryptedKeys[bobJid]!,
base64.encode(aliceResult.ciphertext!), base64.encode(aliceResult.ciphertext!),
false, false,
@ -761,7 +744,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult.encryptedKeys[cocoJid]!, aliceResult.encryptedKeys[cocoJid]!,
base64.encode(aliceResult.ciphertext!), base64.encode(aliceResult.ciphertext!),
false, false,
@ -823,7 +805,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult1.encryptedKeys[bobJid]!, aliceResult1.encryptedKeys[bobJid]!,
base64.encode(aliceResult1.ciphertext!), base64.encode(aliceResult1.ciphertext!),
false, false,
@ -856,7 +837,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult2.encryptedKeys[bobJid]!, aliceResult2.encryptedKeys[bobJid]!,
base64.encode(aliceResult2.ciphertext!), base64.encode(aliceResult2.ciphertext!),
false, false,
@ -966,7 +946,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult.encryptedKeys[bobJid]!, aliceResult.encryptedKeys[bobJid]!,
base64.encode(aliceResult.ciphertext!), base64.encode(aliceResult.ciphertext!),
false, false,
@ -1024,7 +1003,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceMessage.encryptedKeys[bobJid]!, aliceMessage.encryptedKeys[bobJid]!,
base64.encode(aliceMessage.ciphertext!), base64.encode(aliceMessage.ciphertext!),
false, false,
@ -1052,7 +1030,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
bobJid, bobJid,
bobDevice.id, bobDevice.id,
DateTime.now().millisecondsSinceEpoch,
bobResponseMessage.encryptedKeys[aliceJid]!, bobResponseMessage.encryptedKeys[aliceJid]!,
base64.encode(bobResponseMessage.ciphertext!), base64.encode(bobResponseMessage.ciphertext!),
false, false,
@ -1113,7 +1090,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult1.encryptedKeys[bobJid]!, aliceResult1.encryptedKeys[bobJid]!,
base64.encode(aliceResult1.ciphertext!), base64.encode(aliceResult1.ciphertext!),
false, false,
@ -1139,7 +1115,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
await aliceManager.getDeviceId(), await aliceManager.getDeviceId(),
DateTime.now().millisecondsSinceEpoch,
aliceEmptyMessage!.encryptedKeys[bobJid]!, aliceEmptyMessage!.encryptedKeys[bobJid]!,
null, null,
false, false,
@ -1166,7 +1141,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult3.encryptedKeys[bobJid]!, aliceResult3.encryptedKeys[bobJid]!,
base64.encode(aliceResult3.ciphertext!), base64.encode(aliceResult3.ciphertext!),
false, false,
@ -1189,7 +1163,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
bobJid, bobJid,
bobDevice.id, bobDevice.id,
DateTime.now().millisecondsSinceEpoch,
bobResult4.encryptedKeys[aliceJid]!, bobResult4.encryptedKeys[aliceJid]!,
base64.encode(bobResult4.ciphertext!), base64.encode(bobResult4.ciphertext!),
false, false,
@ -1256,7 +1229,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult1.encryptedKeys[bobJid]!, aliceResult1.encryptedKeys[bobJid]!,
base64.encode(aliceResult1.ciphertext!), base64.encode(aliceResult1.ciphertext!),
false, false,
@ -1287,7 +1259,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
await aliceManager.getDeviceId(), await aliceManager.getDeviceId(),
DateTime.now().millisecondsSinceEpoch,
aliceEmptyMessage!.encryptedKeys[bobJid]!, aliceEmptyMessage!.encryptedKeys[bobJid]!,
null, null,
false, false,
@ -1310,7 +1281,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult3.encryptedKeys[bobJid]!, aliceResult3.encryptedKeys[bobJid]!,
base64.encode(aliceResult3.ciphertext!), base64.encode(aliceResult3.ciphertext!),
false, false,
@ -1333,7 +1303,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
bobJid, bobJid,
bobDevice.id, bobDevice.id,
DateTime.now().millisecondsSinceEpoch,
bobResult4.encryptedKeys[aliceJid]!, bobResult4.encryptedKeys[aliceJid]!,
base64.encode(bobResult4.ciphertext!), base64.encode(bobResult4.ciphertext!),
false, false,
@ -1399,7 +1368,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult1.encryptedKeys[bobJid]!, aliceResult1.encryptedKeys[bobJid]!,
base64.encode(aliceResult1.ciphertext!), base64.encode(aliceResult1.ciphertext!),
false, false,
@ -1436,7 +1404,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult2.encryptedKeys[bobJid]!, aliceResult2.encryptedKeys[bobJid]!,
base64.encode(aliceResult2.ciphertext!), base64.encode(aliceResult2.ciphertext!),
false, false,
@ -1458,7 +1425,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
bobJid, bobJid,
bobDevice.id, bobDevice.id,
DateTime.now().millisecondsSinceEpoch,
bobResult3.encryptedKeys[aliceJid]!, bobResult3.encryptedKeys[aliceJid]!,
base64.encode(bobResult3.ciphertext!), base64.encode(bobResult3.ciphertext!),
false, false,
@ -1489,7 +1455,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult4.encryptedKeys[bobJid]!, aliceResult4.encryptedKeys[bobJid]!,
base64.encode(aliceResult4.ciphertext!), base64.encode(aliceResult4.ciphertext!),
false, false,
@ -1551,7 +1516,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice.id, aliceDevice.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult1.encryptedKeys[bobJid]!, aliceResult1.encryptedKeys[bobJid]!,
base64.encode(aliceResult1.ciphertext!), base64.encode(aliceResult1.ciphertext!),
false, false,
@ -1655,7 +1619,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice1.id, aliceDevice1.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult1.encryptedKeys[bobJid]!, aliceResult1.encryptedKeys[bobJid]!,
base64.encode(aliceResult1.ciphertext!), base64.encode(aliceResult1.ciphertext!),
false, false,
@ -1680,7 +1643,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice2.id, aliceDevice2.id,
getTimestamp(),
aliceResult2.encryptedKeys[bobJid]!, aliceResult2.encryptedKeys[bobJid]!,
base64Encode(aliceResult2.ciphertext!), base64Encode(aliceResult2.ciphertext!),
false, false,
@ -1786,7 +1748,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice1.id, aliceDevice1.id,
DateTime.now().millisecondsSinceEpoch,
aliceResult1.encryptedKeys[bobJid]!, aliceResult1.encryptedKeys[bobJid]!,
base64.encode(aliceResult1.ciphertext!), base64.encode(aliceResult1.ciphertext!),
false, false,
@ -1810,7 +1771,6 @@ void main() {
OmemoIncomingStanza( OmemoIncomingStanza(
aliceJid, aliceJid,
aliceDevice2.id, aliceDevice2.id,
getTimestamp(),
aliceResult2.encryptedKeys[bobJid]!, aliceResult2.encryptedKeys[bobJid]!,
base64Encode(aliceResult2.ciphertext!), base64Encode(aliceResult2.ciphertext!),
false, false,