Skip to content

Commit

Permalink
Remove Proteus replenish in member-join
Browse files Browse the repository at this point in the history
* Replenish only the needed keys on conversation.create
* Minor refactoring
  • Loading branch information
spoonman01 committed Nov 19, 2024
1 parent 2bf10f6 commit 05ce164
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/java/com/wire/xenon/MessageResourceBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit 05ce164

Please sign in to comment.