Fix sender key re-distribution on every group message in daemon mode

sendGroupMessageInternalWithSenderKey() calls sender.send() which handles
distribution and delivery, but never calls markSenderKeySharedWith() on
success. SenderKeySharedStore therefore has no record that the distribution
was sent, causing it to re-distribute to all recipients on every subsequent
sendGroupMessage call.

This results in a fresh unidentified TLS connection being opened for each
group message (~6s delay per send), even for back-to-back sends to the
same group. All send modes are affected: DBus daemon, JSON-RPC socket/http,
and CLI send command all share the same code path.

The fix mirrors the existing pattern in resendMessage() (line 307): after
a successful send, record each successful recipient's address+device in
the sender key shared store.
This commit is contained in:
Stefan Meinecke 2026-04-14 18:44:02 +02:00
parent a03d17a9e4
commit 09850afce5

View File

@ -705,6 +705,17 @@ public class SendHelper {
successCount,
addresses.size());
final var successfulAddresses = results.stream()
.filter(SendMessageResult::isSuccess)
.flatMap(r -> r.getSuccess()
.getDevices()
.stream()
.map(device -> new SignalProtocolAddress(r.getAddress().getIdentifier(), device)))
.toList();
if (!successfulAddresses.isEmpty()) {
account.getSenderKeyStore().markSenderKeySharedWith(distributionId, successfulAddresses);
}
return results;
} catch (org.whispersystems.signalservice.api.crypto.UntrustedIdentityException e) {
return null;