From 05ce16451af554e18c6d8256f33ded48dfad7fab Mon Sep 17 00:00:00 2001 From: spoonman01 Date: Tue, 19 Nov 2024 17:38:52 +0100 Subject: [PATCH] Remove Proteus replenish in member-join * Replenish only the needed keys on conversation.create * Minor refactoring --- .../java/com/wire/xenon/MessageResourceBase.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/wire/xenon/MessageResourceBase.java b/src/main/java/com/wire/xenon/MessageResourceBase.java index 547ace7..6d48c24 100644 --- a/src/main/java/com/wire/xenon/MessageResourceBase.java +++ b/src/main/java/com/wire/xenon/MessageResourceBase.java @@ -80,9 +80,8 @@ protected void handleMessage(UUID eventId, Payload payload, WireClient client) t return; } - // Check if we still have some prekeys and keyPackages available. Upload them if needed + // Check if we still have some prekeys available. Upload them if needed handler.validatePreKeys(client, participants.size()); - client.checkAndReplenishKeyPackages(); SystemMessage systemMessage = getSystemMessage(eventId, payload); systemMessage.users = data.userIds; @@ -117,9 +116,9 @@ protected void handleMessage(UUID eventId, Payload payload, WireClient client) t Logger.debug("conversation.create: bot: %s", botId); systemMessage = getSystemMessage(eventId, payload); - Integer otherMembers = PREKEYS_DEFAULT_REPLENISH; + Integer preKeysUserCount = PREKEYS_DEFAULT_REPLENISH; if (systemMessage.conversation.members != null) { - otherMembers = systemMessage.conversation.members.others.size(); + preKeysUserCount = systemMessage.conversation.members.others.size(); Member self = new Member(); String selfDomain = null; if (systemMessage.conversation.id != null) { @@ -130,8 +129,11 @@ protected void handleMessage(UUID eventId, Payload payload, WireClient client) t } // Check if we still have some prekeys and keyPackages available. Upload them if needed - handler.validatePreKeys(client, otherMembers); - client.checkAndReplenishKeyPackages(); + if (systemMessage.conversation.protocol == Conversation.Protocol.PROTEUS) + handler.validatePreKeys(client, preKeysUserCount); + else { + client.checkAndReplenishKeyPackages(); + } handler.onNewConversation(client, systemMessage); break;