From 0d4ab84f911408c007db89633649eb6711eeba41 Mon Sep 17 00:00:00 2001 From: otsmr Date: Mon, 3 Nov 2025 16:59:19 +0100 Subject: [PATCH] send my public key to new members --- lib/src/services/api/client2client/groups.c2c.dart | 3 +++ lib/src/services/group.services.dart | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/src/services/api/client2client/groups.c2c.dart b/lib/src/services/api/client2client/groups.c2c.dart index 5eb5399..003e9c4 100644 --- a/lib/src/services/api/client2client/groups.c2c.dart +++ b/lib/src/services/api/client2client/groups.c2c.dart @@ -165,6 +165,9 @@ Future handleGroupJoin( if (await twonlyDB.contactsDao.getContactById(fromUserId) == null) { if (!await addNewHiddenContact(fromUserId)) { Log.error('Got group join, but could not load contact.'); + // This can happen in case the group join was received before the group create. + // In this case return false, which will cause the receipt to fail and the user + // will resend this message. return false; } } diff --git a/lib/src/services/group.services.dart b/lib/src/services/group.services.dart index 9d24c39..ffe6d56 100644 --- a/lib/src/services/group.services.dart +++ b/lib/src/services/group.services.dart @@ -261,6 +261,20 @@ Future<(int, EncryptedGroupState)?> fetchGroupState(Group group) async { ), ); } + + // Send the new user my public group key + if (group.myGroupPrivateKey != null) { + final keyPair = + IdentityKeyPair.fromSerialized(group.myGroupPrivateKey!); + await sendCipherText( + memberId.toInt(), + EncryptedContent( + groupJoin: EncryptedContent_GroupJoin( + groupPublicKey: keyPair.getPublicKey().serialize(), + ), + ), + ); + } } // check if there is a member which is not in the server list...