Skip to content

Commit

Permalink
fix share back key by writing dht record once
Browse files Browse the repository at this point in the history
  • Loading branch information
LGro committed May 27, 2024
1 parent 66a684d commit bdd65ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/data/providers/distributed_storage/dht.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ class VeilidDhtStorage extends DistributedStorage {
key: key,
writer: writer,
psk: await cs.randomSharedSecret().then((v) => v.toString())));
// Write once, to make sure it's created and published on the network
await updatePasswordEncryptedDHTRecord(
recordKey: key,
recordWriter: writer,
secret: contact.dhtSettingsForReceiving!.psk!,
content: '');
}

if (contact.dhtSettingsForSharing!.psk == null) {
Expand Down
4 changes: 3 additions & 1 deletion lib/data/repositories/contacts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,9 @@ class ContactsRepository {
// TODO: Can it happen that details are null?
// TODO: When temporary locations are updated, only record an update about added / updated locations / check-ins
await _saveUpdate(ContactUpdate(
oldContact: contact.details!,
// TODO: contact details can be null; handle this more appropriately than the current workaround with empty details
oldContact: contact.details ??
ContactDetails(displayName: '', name: Name()),
newContact: updatedContact.details!,
timestamp: DateTime.now()));
await updateContact(updatedContact);
Expand Down

0 comments on commit bdd65ab

Please sign in to comment.