git » sdk » commit 09a0bc0

Do not downgrade from OMEMO-supporting to plain-only

author Stephen Paul Weber
2026-07-13 16:05:35 UTC
committer Stephen Paul Weber
2026-07-13 16:05:35 UTC
parent 011f1fd5ceb35c314bb71891e8ada644e2cb59c3

Do not downgrade from OMEMO-supporting to plain-only

Because if we used to send E2EE to this contact even with a safety
number change notice, suddenly sending without E2EE would be rather unexpected.

borogove/OMEMO.hx +3 -3

diff --git a/borogove/OMEMO.hx b/borogove/OMEMO.hx
index faec0da..ab2e7e4 100644
--- a/borogove/OMEMO.hx
+++ b/borogove/OMEMO.hx
@@ -596,7 +596,7 @@ class OMEMO {
 		var identifier = contact.asBare().asString();
 		var chat = client.getDirectChat(identifier);
 		var devices = deviceIdsFromPubsubItems(items);
-		if(devices != null) {
+		if(devices != null && (chat.omemoContactDeviceIDs == null || chat.omemoContactDeviceIDs.length < 1 || devices.length > 0)) {
 			chat.omemoContactDeviceIDs = devices;
 			chat.omemoDeviceListRefreshed = true;
 			persistence.storeChats(client.accountId(), [chat]);
@@ -1062,11 +1062,11 @@ class OMEMO {
 			deviceListGet.onFinished(() -> {
 				final devices = deviceIdsFromPubsubItems(deviceListGet.getResult());
 				chat.omemoDeviceListRefreshed = true;
-				if(devices != null) {
+				if(devices != null && (chat.omemoContactDeviceIDs == null || chat.omemoContactDeviceIDs.length < 1 || devices.length > 0)) {
 					chat.omemoContactDeviceIDs = devices;
 					resolve(devices.map(rid -> new SignalProtocolAddress(jidBareStr, rid)));
 				} else {
-					chat.omemoContactDeviceIDs = [];
+					chat.omemoContactDeviceIDs = null;
 					reject("no-devices");
 				}
 			});