contacts work

This commit is contained in:
Christien Rioux 2023-08-03 00:49:48 -04:00
parent f52094c105
commit 95ed8b28a0
6 changed files with 162 additions and 105 deletions

View file

@ -87,7 +87,7 @@ class ActiveAccountInfo {
/// Get the active account info
@riverpod
Future<ActiveAccountInfo?> fetchActiveAccount(FetchAccountRef ref) async {
Future<ActiveAccountInfo?> fetchActiveAccount(FetchActiveAccountRef ref) async {
// See if we've logged into this account or if it is locked
final activeUserLogin = await ref.watch(loginsProvider.future
.select((value) async => (await value).activeUserLogin));

View file

@ -130,7 +130,7 @@ class FetchAccountProvider extends AutoDisposeFutureProvider<AccountInfo> {
}
String _$fetchActiveAccountHash() =>
r'8c7e571c135deeb5cacf56c61459d71f7447baaf';
r'd074ab2c160bab41ed3dd979b7054603b7d5b2b1';
/// Get the active account info
///

View file

@ -1,19 +1,18 @@
import 'dart:typed_data';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:fixnum/fixnum.dart';
import '../entities/local_account.dart';
import '../entities/proto.dart' as proto;
import '../entities/user_login.dart';
import '../tools/tools.dart';
import '../veilid_support/veilid_support.dart';
import 'account.dart';
Future<Uint8List> createContactInvitation(
ActiveAccountInfo activeAccountInfo,
EncryptionKeyType encryptionKeyType,
String encryptionKey,
Timestamp expiration) async {
{required ActiveAccountInfo activeAccountInfo,
required EncryptionKeyType encryptionKeyType,
required String encryptionKey,
required Timestamp? expiration}) async {
final pool = await DHTRecordPool.instance();
final accountRecordKey =
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
@ -46,7 +45,7 @@ Future<Uint8List> createContactInvitation(
..accountMasterRecordKey =
activeAccountInfo.userLogin.accountMasterRecordKey.toProto()
..chatRecordKey = localChatRecord.key.toProto()
..expiration = expiration.toInt64();
..expiration = expiration?.toInt64() ?? Int64.ZERO;
final crprivbytes = crpriv.writeToBuffer();
final encryptedContactRequestPrivate =
await cs.encryptNoAuthWithNonce(crprivbytes, writer.secret);
@ -83,10 +82,11 @@ Future<Uint8List> createContactInvitation(
..writerKey = writer.key.toProto()
..writerSecret = writer.secret.toProto()
..chatRecordKey = localChatRecord.key.toProto()
..expiration = expiration.toInt64()
..expiration = expiration?.toInt64() ?? Int64.ZERO
..invitation = signedContactInvitationBytes;
// Add ContactInvitationRecord to local table
// Add ContactInvitationRecord to local table if possible
// if this fails, don't keep retrying, user can try again later
await (await DHTShortArray.openOwned(
proto.OwnedDHTRecordPointerProto.fromProto(
activeAccountInfo.account.contactInvitationRecords),