diff --git a/client/src/main/kotlin/io/flamenet/client/Conversations.kt b/client/src/main/kotlin/io/flamenet/client/Conversations.kt index 40d215e..e3c6995 100644 --- a/client/src/main/kotlin/io/flamenet/client/Conversations.kt +++ b/client/src/main/kotlin/io/flamenet/client/Conversations.kt @@ -613,6 +613,19 @@ class Conversations( val fromUser = opened?.claimedFromUser ?: message.fromUser val content = Content.parse(plaintext) consumeControl(fromUser, content) + // 🔴 An UNSEALED message from a contact we have told our + // delivery key means their copy is gone — a reinstall wiped + // it. Sealing to us requires that key, and a peer who holds + // it seals everything. Un-mark them so the next send re-tells + // it; until then the relay sees their sender on every message + // they write us. Worst case: one redundant control envelope. + if (!sealed && fromUser != 0L) { + vault.loadDelivery()?.let { d -> + if (fromUser in d.toldPeers) { + vault.saveDelivery(d.copy(toldPeers = d.toldPeers - fromUser)) + } + } + } out += Received(message.id, fromUser, fromDevice, content, sealed = sealed, at = message.createdAt) } catch (_: Exception) {