mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-08-03 03:36:23 -04:00
updates and refactor protobuf
This commit is contained in:
parent
e8046e9a89
commit
d3ecae0113
16 changed files with 266 additions and 248 deletions
|
@ -225,7 +225,7 @@ class _$LocalAccountImpl implements _LocalAccount {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$LocalAccountImpl &&
|
||||
|
|
|
@ -146,7 +146,7 @@ class _$LockPreferenceImpl implements _LockPreference {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$LockPreferenceImpl &&
|
||||
|
@ -332,7 +332,7 @@ class _$ThemePreferencesImpl implements _ThemePreferences {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ThemePreferencesImpl &&
|
||||
|
@ -541,7 +541,7 @@ class _$PreferencesImpl implements _Preferences {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PreferencesImpl &&
|
||||
|
|
|
@ -182,7 +182,7 @@ class _$UserLoginImpl implements _UserLogin {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$UserLoginImpl &&
|
||||
|
@ -358,7 +358,7 @@ class _$ActiveLoginsImpl implements _ActiveLogins {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ActiveLoginsImpl &&
|
||||
|
|
|
@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../proto/proto.dart' as proto;
|
||||
import '../proto/proto.dart' show Chat, ChatType;
|
||||
|
||||
import '../veilid_support/veilid_support.dart';
|
||||
import 'account.dart';
|
||||
|
@ -19,8 +18,8 @@ Future<void> getOrCreateChatSingleContact({
|
|||
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
||||
|
||||
// Create conversation type Chat
|
||||
final chat = Chat()
|
||||
..type = ChatType.SINGLE_CONTACT
|
||||
final chat = proto.Chat()
|
||||
..type = proto.ChatType.SINGLE_CONTACT
|
||||
..remoteConversationKey = remoteConversationRecordKey.toProto();
|
||||
|
||||
// Add Chat to account's list
|
||||
|
@ -35,7 +34,7 @@ Future<void> getOrCreateChatSingleContact({
|
|||
if (cbuf == null) {
|
||||
throw Exception('Failed to get chat');
|
||||
}
|
||||
final c = Chat.fromBuffer(cbuf);
|
||||
final c = proto.Chat.fromBuffer(cbuf);
|
||||
if (c == chat) {
|
||||
return;
|
||||
}
|
||||
|
@ -68,7 +67,7 @@ Future<void> deleteChat(
|
|||
if (cbuf == null) {
|
||||
throw Exception('Failed to get chat');
|
||||
}
|
||||
final c = Chat.fromBuffer(cbuf);
|
||||
final c = proto.Chat.fromBuffer(cbuf);
|
||||
if (c.remoteConversationKey == remoteConversationKey) {
|
||||
await chatList.tryRemoveItem(i);
|
||||
|
||||
|
@ -84,7 +83,7 @@ Future<void> deleteChat(
|
|||
|
||||
/// Get the active account contact list
|
||||
@riverpod
|
||||
Future<IList<Chat>?> fetchChatList(FetchChatListRef ref) async {
|
||||
Future<IList<proto.Chat>?> fetchChatList(FetchChatListRef ref) async {
|
||||
// See if we've logged into this account or if it is locked
|
||||
final activeAccountInfo = await ref.watch(fetchActiveAccountProvider.future);
|
||||
if (activeAccountInfo == null) {
|
||||
|
@ -94,7 +93,7 @@ Future<IList<Chat>?> fetchChatList(FetchChatListRef ref) async {
|
|||
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
||||
|
||||
// Decode the chat list from the DHT
|
||||
IList<Chat> out = const IListConst([]);
|
||||
IList<proto.Chat> out = const IListConst([]);
|
||||
await (await DHTShortArray.openOwned(
|
||||
proto.OwnedDHTRecordPointerProto.fromProto(
|
||||
activeAccountInfo.account.chatList),
|
||||
|
@ -105,7 +104,7 @@ Future<IList<Chat>?> fetchChatList(FetchChatListRef ref) async {
|
|||
if (cir == null) {
|
||||
throw Exception('Failed to get chat');
|
||||
}
|
||||
out = out.add(Chat.fromBuffer(cir));
|
||||
out = out.add(proto.Chat.fromBuffer(cir));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ class _$ConnectionStateImpl extends _ConnectionState {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ConnectionStateImpl &&
|
||||
|
|
|
@ -4,7 +4,6 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
|||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../proto/proto.dart' as proto;
|
||||
import '../proto/proto.dart' show Contact;
|
||||
|
||||
import '../veilid_support/veilid_support.dart';
|
||||
import '../tools/tools.dart';
|
||||
|
@ -24,7 +23,7 @@ Future<void> createContact({
|
|||
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
||||
|
||||
// Create Contact
|
||||
final contact = Contact()
|
||||
final contact = proto.Contact()
|
||||
..editedProfile = profile
|
||||
..remoteProfile = profile
|
||||
..identityMasterJson = jsonEncode(remoteIdentity.toJson())
|
||||
|
@ -51,7 +50,7 @@ Future<void> createContact({
|
|||
|
||||
Future<void> deleteContact(
|
||||
{required ActiveAccountInfo activeAccountInfo,
|
||||
required Contact contact}) async {
|
||||
required proto.Contact contact}) async {
|
||||
final pool = await DHTRecordPool.instance();
|
||||
final accountRecordKey =
|
||||
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
||||
|
@ -104,7 +103,7 @@ Future<void> deleteContact(
|
|||
|
||||
/// Get the active account contact list
|
||||
@riverpod
|
||||
Future<IList<Contact>?> fetchContactList(FetchContactListRef ref) async {
|
||||
Future<IList<proto.Contact>?> fetchContactList(FetchContactListRef ref) async {
|
||||
// See if we've logged into this account or if it is locked
|
||||
final activeAccountInfo = await ref.watch(fetchActiveAccountProvider.future);
|
||||
if (activeAccountInfo == null) {
|
||||
|
@ -114,7 +113,7 @@ Future<IList<Contact>?> fetchContactList(FetchContactListRef ref) async {
|
|||
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
||||
|
||||
// Decode the contact list from the DHT
|
||||
IList<Contact> out = const IListConst([]);
|
||||
IList<proto.Contact> out = const IListConst([]);
|
||||
await (await DHTShortArray.openOwned(
|
||||
proto.OwnedDHTRecordPointerProto.fromProto(
|
||||
activeAccountInfo.account.contactList),
|
||||
|
@ -125,7 +124,7 @@ Future<IList<Contact>?> fetchContactList(FetchContactListRef ref) async {
|
|||
if (cir == null) {
|
||||
throw Exception('Failed to get contact');
|
||||
}
|
||||
out = out.add(Contact.fromBuffer(cir));
|
||||
out = out.add(proto.Contact.fromBuffer(cir));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -6,14 +6,14 @@ part of 'contact.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$fetchContactListHash() => r'f75cb33fbc664404bba122f1e128e437e0f0b2da';
|
||||
String _$fetchContactListHash() => r'03e5b90435c331be87495d999a62a97af5b74d9e';
|
||||
|
||||
/// Get the active account contact list
|
||||
///
|
||||
/// Copied from [fetchContactList].
|
||||
@ProviderFor(fetchContactList)
|
||||
final fetchContactListProvider =
|
||||
AutoDisposeFutureProvider<IList<Contact>?>.internal(
|
||||
AutoDisposeFutureProvider<IList<proto.Contact>?>.internal(
|
||||
fetchContactList,
|
||||
name: r'fetchContactListProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
|
@ -23,6 +23,7 @@ final fetchContactListProvider =
|
|||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef FetchContactListRef = AutoDisposeFutureProviderRef<IList<Contact>?>;
|
||||
typedef FetchContactListRef
|
||||
= AutoDisposeFutureProviderRef<IList<proto.Contact>?>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||
|
|
|
@ -6,15 +6,6 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|||
|
||||
import '../entities/local_account.dart';
|
||||
import '../proto/proto.dart' as proto;
|
||||
import '../proto/proto.dart'
|
||||
show
|
||||
ContactInvitation,
|
||||
ContactInvitationRecord,
|
||||
ContactRequest,
|
||||
ContactRequestPrivate,
|
||||
ContactResponse,
|
||||
SignedContactInvitation,
|
||||
SignedContactResponse;
|
||||
import '../tools/tools.dart';
|
||||
import '../veilid_support/veilid_support.dart';
|
||||
import 'account.dart';
|
||||
|
@ -48,7 +39,7 @@ class AcceptedOrRejectedContact {
|
|||
|
||||
Future<AcceptedOrRejectedContact?> checkAcceptRejectContact(
|
||||
{required ActiveAccountInfo activeAccountInfo,
|
||||
required ContactInvitationRecord contactInvitationRecord}) async {
|
||||
required proto.ContactInvitationRecord contactInvitationRecord}) async {
|
||||
// Open the contact request inbox
|
||||
try {
|
||||
final pool = await DHTRecordPool.instance();
|
||||
|
@ -68,15 +59,17 @@ Future<AcceptedOrRejectedContact?> checkAcceptRejectContact(
|
|||
defaultSubkey: 1))
|
||||
.scope((contactRequestInbox) async {
|
||||
//
|
||||
final signedContactResponse = await contactRequestInbox
|
||||
.getProtobuf(SignedContactResponse.fromBuffer, forceRefresh: true);
|
||||
final signedContactResponse = await contactRequestInbox.getProtobuf(
|
||||
proto.SignedContactResponse.fromBuffer,
|
||||
forceRefresh: true);
|
||||
if (signedContactResponse == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final contactResponseBytes =
|
||||
Uint8List.fromList(signedContactResponse.contactResponse);
|
||||
final contactResponse = ContactResponse.fromBuffer(contactResponseBytes);
|
||||
final contactResponse =
|
||||
proto.ContactResponse.fromBuffer(contactResponseBytes);
|
||||
final contactIdentityMasterRecordKey = proto.TypedKeyProto.fromProto(
|
||||
contactResponse.identityMasterRecordKey);
|
||||
final cs = await pool.veilid.getCryptoSystem(recordKey.kind);
|
||||
|
@ -154,7 +147,7 @@ Future<AcceptedOrRejectedContact?> checkAcceptRejectContact(
|
|||
Future<void> deleteContactInvitation(
|
||||
{required bool accepted,
|
||||
required ActiveAccountInfo activeAccountInfo,
|
||||
required ContactInvitationRecord contactInvitationRecord}) async {
|
||||
required proto.ContactInvitationRecord contactInvitationRecord}) async {
|
||||
final pool = await DHTRecordPool.instance();
|
||||
final accountRecordKey =
|
||||
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
||||
|
@ -235,7 +228,7 @@ Future<Uint8List> createContactInvitation(
|
|||
.deleteScope((localConversation) async {
|
||||
// dont bother reopening localConversation with writer
|
||||
// Make ContactRequestPrivate and encrypt with the writer secret
|
||||
final crpriv = ContactRequestPrivate()
|
||||
final crpriv = proto.ContactRequestPrivate()
|
||||
..writerKey = contactRequestWriter.key.toProto()
|
||||
..profile = activeAccountInfo.account.profile
|
||||
..identityMasterRecordKey =
|
||||
|
@ -247,7 +240,7 @@ Future<Uint8List> createContactInvitation(
|
|||
await cs.encryptAeadWithNonce(crprivbytes, contactRequestWriter.secret);
|
||||
|
||||
// Create ContactRequest and embed contactrequestprivate
|
||||
final creq = ContactRequest()
|
||||
final creq = proto.ContactRequest()
|
||||
..encryptionKeyType = encryptionKeyType.toProto()
|
||||
..private = encryptedContactRequestPrivate;
|
||||
|
||||
|
@ -263,18 +256,18 @@ Future<Uint8List> createContactInvitation(
|
|||
await contactRequestInbox.eventualWriteProtobuf(creq);
|
||||
|
||||
// Create ContactInvitation and SignedContactInvitation
|
||||
final cinv = ContactInvitation()
|
||||
final cinv = proto.ContactInvitation()
|
||||
..contactRequestInboxKey = contactRequestInbox.key.toProto()
|
||||
..writerSecret = encryptedSecret;
|
||||
final cinvbytes = cinv.writeToBuffer();
|
||||
final scinv = SignedContactInvitation()
|
||||
final scinv = proto.SignedContactInvitation()
|
||||
..contactInvitation = cinvbytes
|
||||
..identitySignature =
|
||||
(await cs.sign(identityKey, identitySecret, cinvbytes)).toProto();
|
||||
signedContactInvitationBytes = scinv.writeToBuffer();
|
||||
|
||||
// Create ContactInvitationRecord
|
||||
final cinvrec = ContactInvitationRecord()
|
||||
final cinvrec = proto.ContactInvitationRecord()
|
||||
..contactRequestInbox =
|
||||
contactRequestInbox.ownedDHTRecordPointer.toProto()
|
||||
..writerKey = contactRequestWriter.key.toProto()
|
||||
|
@ -311,11 +304,11 @@ class ValidContactInvitation {
|
|||
required this.contactIdentityMaster,
|
||||
required this.writer});
|
||||
|
||||
SignedContactInvitation signedContactInvitation;
|
||||
ContactInvitation contactInvitation;
|
||||
proto.SignedContactInvitation signedContactInvitation;
|
||||
proto.ContactInvitation contactInvitation;
|
||||
TypedKey contactRequestInboxKey;
|
||||
ContactRequest contactRequest;
|
||||
ContactRequestPrivate contactRequestPrivate;
|
||||
proto.ContactRequest contactRequest;
|
||||
proto.ContactRequestPrivate contactRequestPrivate;
|
||||
IdentityMaster contactIdentityMaster;
|
||||
KeyPair writer;
|
||||
}
|
||||
|
@ -327,7 +320,7 @@ typedef GetEncryptionKeyCallback = Future<SecretKey?> Function(
|
|||
|
||||
Future<ValidContactInvitation?> validateContactInvitation(
|
||||
{required ActiveAccountInfo activeAccountInfo,
|
||||
required IList<ContactInvitationRecord>? contactInvitationRecords,
|
||||
required IList<proto.ContactInvitationRecord>? contactInvitationRecords,
|
||||
required Uint8List inviteData,
|
||||
required GetEncryptionKeyCallback getEncryptionKeyCallback}) async {
|
||||
final accountRecordKey =
|
||||
|
@ -434,7 +427,7 @@ Future<AcceptedContact?> acceptContactInvitation(
|
|||
remoteIdentityPublicKey: validContactInvitation.contactIdentityMaster
|
||||
.identityPublicTypedKey(),
|
||||
callback: (localConversation) async {
|
||||
final contactResponse = ContactResponse()
|
||||
final contactResponse = proto.ContactResponse()
|
||||
..accept = true
|
||||
..remoteConversationRecordKey = localConversation.key.toProto()
|
||||
..identityMasterRecordKey = activeAccountInfo
|
||||
|
@ -450,13 +443,14 @@ Future<AcceptedContact?> acceptContactInvitation(
|
|||
activeAccountInfo.userLogin.identitySecret.value,
|
||||
contactResponseBytes);
|
||||
|
||||
final signedContactResponse = SignedContactResponse()
|
||||
final signedContactResponse = proto.SignedContactResponse()
|
||||
..contactResponse = contactResponseBytes
|
||||
..identitySignature = identitySignature.toProto();
|
||||
|
||||
// Write the acceptance to the inbox
|
||||
if (await contactRequestInbox.tryWriteProtobuf(
|
||||
SignedContactResponse.fromBuffer, signedContactResponse,
|
||||
proto.SignedContactResponse.fromBuffer,
|
||||
signedContactResponse,
|
||||
subkey: 1) !=
|
||||
null) {
|
||||
throw Exception('failed to accept contact invitation');
|
||||
|
@ -494,7 +488,7 @@ Future<bool> rejectContactInvitation(ActiveAccountInfo activeAccountInfo,
|
|||
final cs = await pool.veilid
|
||||
.getCryptoSystem(validContactInvitation.contactRequestInboxKey.kind);
|
||||
|
||||
final contactResponse = ContactResponse()
|
||||
final contactResponse = proto.ContactResponse()
|
||||
..accept = false
|
||||
..identityMasterRecordKey = activeAccountInfo
|
||||
.localAccount.identityMaster.masterRecordKey
|
||||
|
@ -506,13 +500,13 @@ Future<bool> rejectContactInvitation(ActiveAccountInfo activeAccountInfo,
|
|||
activeAccountInfo.userLogin.identitySecret.value,
|
||||
contactResponseBytes);
|
||||
|
||||
final signedContactResponse = SignedContactResponse()
|
||||
final signedContactResponse = proto.SignedContactResponse()
|
||||
..contactResponse = contactResponseBytes
|
||||
..identitySignature = identitySignature.toProto();
|
||||
|
||||
// Write the rejection to the inbox
|
||||
if (await contactRequestInbox.tryWriteProtobuf(
|
||||
SignedContactResponse.fromBuffer, signedContactResponse,
|
||||
proto.SignedContactResponse.fromBuffer, signedContactResponse,
|
||||
subkey: 1) !=
|
||||
null) {
|
||||
log.error('failed to reject contact invitation');
|
||||
|
@ -524,7 +518,7 @@ Future<bool> rejectContactInvitation(ActiveAccountInfo activeAccountInfo,
|
|||
|
||||
/// Get the active account contact invitation list
|
||||
@riverpod
|
||||
Future<IList<ContactInvitationRecord>?> fetchContactInvitationRecords(
|
||||
Future<IList<proto.ContactInvitationRecord>?> fetchContactInvitationRecords(
|
||||
FetchContactInvitationRecordsRef ref) async {
|
||||
// See if we've logged into this account or if it is locked
|
||||
final activeAccountInfo = await ref.watch(fetchActiveAccountProvider.future);
|
||||
|
@ -535,7 +529,7 @@ Future<IList<ContactInvitationRecord>?> fetchContactInvitationRecords(
|
|||
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
||||
|
||||
// Decode the contact invitation list from the DHT
|
||||
IList<ContactInvitationRecord> out = const IListConst([]);
|
||||
IList<proto.ContactInvitationRecord> out = const IListConst([]);
|
||||
|
||||
try {
|
||||
await (await DHTShortArray.openOwned(
|
||||
|
@ -548,7 +542,7 @@ Future<IList<ContactInvitationRecord>?> fetchContactInvitationRecords(
|
|||
if (cir == null) {
|
||||
throw Exception('Failed to get contact invitation record');
|
||||
}
|
||||
out = out.add(ContactInvitationRecord.fromBuffer(cir));
|
||||
out = out.add(proto.ContactInvitationRecord.fromBuffer(cir));
|
||||
}
|
||||
});
|
||||
} on VeilidAPIExceptionTryAgain catch (_) {
|
||||
|
|
|
@ -4,7 +4,6 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
|||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../proto/proto.dart' as proto;
|
||||
import '../proto/proto.dart' show Conversation, Message;
|
||||
|
||||
import '../tools/tools.dart';
|
||||
import '../veilid_init.dart';
|
||||
|
@ -79,7 +78,7 @@ Future<T> createConversation<T>(
|
|||
parent: localConversation.key, crypto: crypto, smplWriter: writer))
|
||||
.deleteScope((messages) async {
|
||||
// Write local conversation key
|
||||
final conversation = Conversation()
|
||||
final conversation = proto.Conversation()
|
||||
..profile = activeAccountInfo.account.profile
|
||||
..identityMasterJson =
|
||||
jsonEncode(activeAccountInfo.localAccount.identityMaster.toJson())
|
||||
|
@ -87,7 +86,7 @@ Future<T> createConversation<T>(
|
|||
|
||||
//
|
||||
final update = await localConversation.tryWriteProtobuf(
|
||||
Conversation.fromBuffer, conversation);
|
||||
proto.Conversation.fromBuffer, conversation);
|
||||
if (update != null) {
|
||||
throw Exception('Failed to write local conversation');
|
||||
}
|
||||
|
@ -96,7 +95,7 @@ Future<T> createConversation<T>(
|
|||
});
|
||||
}
|
||||
|
||||
Future<Conversation?> readRemoteConversation({
|
||||
Future<proto.Conversation?> readRemoteConversation({
|
||||
required ActiveAccountInfo activeAccountInfo,
|
||||
required TypedKey remoteConversationRecordKey,
|
||||
required TypedKey remoteIdentityPublicKey,
|
||||
|
@ -113,16 +112,16 @@ Future<Conversation?> readRemoteConversation({
|
|||
.scope((remoteConversation) async {
|
||||
//
|
||||
final conversation =
|
||||
await remoteConversation.getProtobuf(Conversation.fromBuffer);
|
||||
await remoteConversation.getProtobuf(proto.Conversation.fromBuffer);
|
||||
return conversation;
|
||||
});
|
||||
}
|
||||
|
||||
Future<Conversation?> writeLocalConversation({
|
||||
Future<proto.Conversation?> writeLocalConversation({
|
||||
required ActiveAccountInfo activeAccountInfo,
|
||||
required TypedKey localConversationRecordKey,
|
||||
required TypedKey remoteIdentityPublicKey,
|
||||
required Conversation conversation,
|
||||
required proto.Conversation conversation,
|
||||
}) async {
|
||||
final accountRecordKey =
|
||||
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
||||
|
@ -138,7 +137,7 @@ Future<Conversation?> writeLocalConversation({
|
|||
.scope((localConversation) async {
|
||||
//
|
||||
final update = await localConversation.tryWriteProtobuf(
|
||||
Conversation.fromBuffer, conversation);
|
||||
proto.Conversation.fromBuffer, conversation);
|
||||
if (update != null) {
|
||||
return update;
|
||||
}
|
||||
|
@ -146,7 +145,7 @@ Future<Conversation?> writeLocalConversation({
|
|||
});
|
||||
}
|
||||
|
||||
Future<Conversation?> readLocalConversation({
|
||||
Future<proto.Conversation?> readLocalConversation({
|
||||
required ActiveAccountInfo activeAccountInfo,
|
||||
required TypedKey localConversationRecordKey,
|
||||
required TypedKey remoteIdentityPublicKey,
|
||||
|
@ -163,7 +162,8 @@ Future<Conversation?> readLocalConversation({
|
|||
parent: accountRecordKey, crypto: crypto))
|
||||
.scope((localConversation) async {
|
||||
//
|
||||
final update = await localConversation.getProtobuf(Conversation.fromBuffer);
|
||||
final update =
|
||||
await localConversation.getProtobuf(proto.Conversation.fromBuffer);
|
||||
if (update != null) {
|
||||
return update;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ Future<void> addLocalConversationMessage(
|
|||
{required ActiveAccountInfo activeAccountInfo,
|
||||
required TypedKey localConversationRecordKey,
|
||||
required TypedKey remoteIdentityPublicKey,
|
||||
required Message message}) async {
|
||||
required proto.Message message}) async {
|
||||
final conversation = await readLocalConversation(
|
||||
activeAccountInfo: activeAccountInfo,
|
||||
localConversationRecordKey: localConversationRecordKey,
|
||||
|
@ -201,7 +201,7 @@ Future<bool> mergeLocalConversationMessages(
|
|||
{required ActiveAccountInfo activeAccountInfo,
|
||||
required TypedKey localConversationRecordKey,
|
||||
required TypedKey remoteIdentityPublicKey,
|
||||
required IList<Message> newMessages}) async {
|
||||
required IList<proto.Message> newMessages}) async {
|
||||
final conversation = await readLocalConversation(
|
||||
activeAccountInfo: activeAccountInfo,
|
||||
localConversationRecordKey: localConversationRecordKey,
|
||||
|
@ -262,7 +262,7 @@ Future<bool> mergeLocalConversationMessages(
|
|||
return changed;
|
||||
}
|
||||
|
||||
Future<IList<Message>?> getLocalConversationMessages({
|
||||
Future<IList<proto.Message>?> getLocalConversationMessages({
|
||||
required ActiveAccountInfo activeAccountInfo,
|
||||
required TypedKey localConversationRecordKey,
|
||||
required TypedKey remoteIdentityPublicKey,
|
||||
|
@ -283,9 +283,9 @@ Future<IList<Message>?> getLocalConversationMessages({
|
|||
return (await DHTShortArray.openRead(messagesRecordKey,
|
||||
parent: localConversationRecordKey, crypto: crypto))
|
||||
.scope((messages) async {
|
||||
var out = IList<Message>();
|
||||
var out = IList<proto.Message>();
|
||||
for (var i = 0; i < messages.length; i++) {
|
||||
final msg = await messages.getItemProtobuf(Message.fromBuffer, i);
|
||||
final msg = await messages.getItemProtobuf(proto.Message.fromBuffer, i);
|
||||
if (msg == null) {
|
||||
throw Exception('Failed to get message');
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ Future<IList<Message>?> getLocalConversationMessages({
|
|||
});
|
||||
}
|
||||
|
||||
Future<IList<Message>?> getRemoteConversationMessages({
|
||||
Future<IList<proto.Message>?> getRemoteConversationMessages({
|
||||
required ActiveAccountInfo activeAccountInfo,
|
||||
required TypedKey remoteConversationRecordKey,
|
||||
required TypedKey remoteIdentityPublicKey,
|
||||
|
@ -316,9 +316,9 @@ Future<IList<Message>?> getRemoteConversationMessages({
|
|||
return (await DHTShortArray.openRead(messagesRecordKey,
|
||||
parent: remoteConversationRecordKey, crypto: crypto))
|
||||
.scope((messages) async {
|
||||
var out = IList<Message>();
|
||||
var out = IList<proto.Message>();
|
||||
for (var i = 0; i < messages.length; i++) {
|
||||
final msg = await messages.getItemProtobuf(Message.fromBuffer, i);
|
||||
final msg = await messages.getItemProtobuf(proto.Message.fromBuffer, i);
|
||||
if (msg == null) {
|
||||
throw Exception('Failed to get message');
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ Future<IList<Message>?> getRemoteConversationMessages({
|
|||
class ActiveConversationMessages extends _$ActiveConversationMessages {
|
||||
/// Get message for active conversation
|
||||
@override
|
||||
FutureOr<IList<Message>?> build() async {
|
||||
FutureOr<IList<proto.Message>?> build() async {
|
||||
await eventualVeilid.future;
|
||||
|
||||
final activeChat = ref.watch(activeChatStateProvider);
|
||||
|
|
|
@ -156,7 +156,7 @@ class _$DHTRecordPoolAllocationsImpl implements _DHTRecordPoolAllocations {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$DHTRecordPoolAllocationsImpl &&
|
||||
|
@ -327,7 +327,7 @@ class _$OwnedDHTRecordPointerImpl implements _OwnedDHTRecordPointer {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$OwnedDHTRecordPointerImpl &&
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:veilid/veilid.dart';
|
||||
|
||||
Future<VeilidConfig> getVeilidChatConfig() async {
|
||||
|
@ -18,8 +19,32 @@ Future<VeilidConfig> getVeilidChatConfig() async {
|
|||
config.copyWith(blockStore: config.blockStore.copyWith(delete: true));
|
||||
}
|
||||
|
||||
// ignore: do_not_use_environment
|
||||
const envNetwork = String.fromEnvironment('NETWORK');
|
||||
if (envNetwork.isNotEmpty) {
|
||||
final bootstrap = kIsWeb
|
||||
? ['ws://bootstrap.$envNetwork.veilid.net:5150/ws']
|
||||
: ['bootstrap.$envNetwork.veilid.net'];
|
||||
config = config.copyWith(
|
||||
network: config.network.copyWith(
|
||||
routingTable:
|
||||
config.network.routingTable.copyWith(bootstrap: bootstrap)));
|
||||
}
|
||||
|
||||
// ignore: do_not_use_environment
|
||||
const envBootstrap = String.fromEnvironment('BOOTSTRAP');
|
||||
if (envBootstrap.isNotEmpty) {
|
||||
final bootstrap = envBootstrap.split(',').map((e) => e.trim()).toList();
|
||||
config = config.copyWith(
|
||||
network: config.network.copyWith(
|
||||
routingTable:
|
||||
config.network.routingTable.copyWith(bootstrap: bootstrap)));
|
||||
}
|
||||
|
||||
return config.copyWith(
|
||||
capabilities: const VeilidConfigCapabilities(disable: ['DHTV', 'TUNL']),
|
||||
capabilities:
|
||||
// XXX: Remove DHTV and DHTW when we get background sync implemented
|
||||
const VeilidConfigCapabilities(disable: ['DHTV', 'DHTW', 'TUNL']),
|
||||
protectedStore: config.protectedStore.copyWith(allowInsecureFallback: true),
|
||||
// network: config.network.copyWith(
|
||||
// dht: config.network.dht.copyWith(
|
||||
|
|
|
@ -126,7 +126,7 @@ class _$AccountRecordInfoImpl implements _AccountRecordInfo {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AccountRecordInfoImpl &&
|
||||
|
@ -268,7 +268,7 @@ class _$IdentityImpl implements _Identity {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$IdentityImpl &&
|
||||
|
@ -503,7 +503,7 @@ class _$IdentityMasterImpl implements _IdentityMaster {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$IdentityMasterImpl &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue