send my public key to new members

This commit is contained in:
otsmr 2025-11-03 16:59:19 +01:00
parent 5235a01626
commit 0d4ab84f91
2 changed files with 17 additions and 0 deletions

View file

@ -165,6 +165,9 @@ Future<bool> handleGroupJoin(
if (await twonlyDB.contactsDao.getContactById(fromUserId) == null) { if (await twonlyDB.contactsDao.getContactById(fromUserId) == null) {
if (!await addNewHiddenContact(fromUserId)) { if (!await addNewHiddenContact(fromUserId)) {
Log.error('Got group join, but could not load contact.'); 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; return false;
} }
} }

View file

@ -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... // check if there is a member which is not in the server list...