git » sdk » commit 011f1fd

Refresh OMEMO device every session

author Stephen Paul Weber
2026-07-06 21:07:36 UTC
committer Stephen Paul Weber
2026-07-06 21:07:36 UTC
parent b5818c54aed3e0743a8cfb95a1a2eca185528965

Refresh OMEMO device every session

Unless we got a PEP push, we don't know that we're up to date. So do a fetch.

borogove/Chat.hx +3 -0
borogove/OMEMO.hx +3 -1

diff --git a/borogove/Chat.hx b/borogove/Chat.hx
index ddf4070..e257625 100644
--- a/borogove/Chat.hx
+++ b/borogove/Chat.hx
@@ -166,6 +166,9 @@ abstract class Chat extends EventEmitter {
 	@:allow(borogove)
 	private var omemoContactDeviceIDs: Null<Array<Int>> = null;
 
+	@:allow(borogove)
+	private var omemoDeviceListRefreshed = false;
+
 	@:allow(borogove)
 	private function new(client:Client, stream:GenericStream, persistence:Persistence, chatId:String, uiState = Open, isBookmarked = false, isBlocked = false, extensions: Null<Stanza> = null, readUpToId: Null<String> = null, readUpToBy: Null<String> = null, omemoContactDeviceIDs: Array<Int> = null) {
 		super();
diff --git a/borogove/OMEMO.hx b/borogove/OMEMO.hx
index 04ff28c..faec0da 100644
--- a/borogove/OMEMO.hx
+++ b/borogove/OMEMO.hx
@@ -598,6 +598,7 @@ class OMEMO {
 		var devices = deviceIdsFromPubsubItems(items);
 		if(devices != null) {
 			chat.omemoContactDeviceIDs = devices;
+			chat.omemoDeviceListRefreshed = true;
 			persistence.storeChats(client.accountId(), [chat]);
 		}
 	}
@@ -1053,13 +1054,14 @@ class OMEMO {
 		final jidBareStr = jid.asBare().asString();
 		// FIXME: Use local storage
 		var chat = client.getDirectChat(jidBareStr, false);
-		if(chat.omemoContactDeviceIDs != null) {
+		if(chat.omemoContactDeviceIDs != null && chat.omemoDeviceListRefreshed) {
 			return Promise.resolve(chat.omemoContactDeviceIDs.map(rid -> new SignalProtocolAddress(jidBareStr, rid)));
 		}
 		return new Promise((resolve, reject) -> {
 			final deviceListGet = new PubsubGet(jidBareStr, "eu.siacs.conversations.axolotl.devicelist");
 			deviceListGet.onFinished(() -> {
 				final devices = deviceIdsFromPubsubItems(deviceListGet.getResult());
+				chat.omemoDeviceListRefreshed = true;
 				if(devices != null) {
 					chat.omemoContactDeviceIDs = devices;
 					resolve(devices.map(rid -> new SignalProtocolAddress(jidBareStr, rid)));