mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
Enhance contact handling logic in MeshCoreConnector to support conditional addition based on auto-add settings (#268)
This commit is contained in:
parent
c2671ac2ae
commit
b748b96237
1 changed files with 19 additions and 7 deletions
|
|
@ -1926,7 +1926,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||
case pushCodeNewAdvert:
|
||||
debugPrint('Got New CONTACT');
|
||||
// It's the same format as respCodeContact, so we can reuse the handler
|
||||
_handleContact(frame);
|
||||
_handleContact(frame, isContact: false);
|
||||
break;
|
||||
case respCodeContact:
|
||||
debugPrint('Got CONTACT');
|
||||
|
|
@ -2217,7 +2217,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||
}
|
||||
}
|
||||
|
||||
void _handleContact(Uint8List frame) {
|
||||
void _handleContact(Uint8List frame, {bool isContact = true}) {
|
||||
final contact = Contact.fromFrame(frame);
|
||||
if (contact != null) {
|
||||
if (contact.type == advTypeRepeater) {
|
||||
|
|
@ -2256,11 +2256,23 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||
tag: 'Connector',
|
||||
);
|
||||
} else {
|
||||
_contacts.add(contact);
|
||||
appLogger.info(
|
||||
'Added new contact ${contact.name}: pathLen=${contact.pathLength}',
|
||||
tag: 'Connector',
|
||||
);
|
||||
if ((_autoAddUsers && contact.type == advTypeChat) ||
|
||||
(_autoAddRepeaters && contact.type == advTypeRepeater) ||
|
||||
(_autoAddRoomServers && contact.type == advTypeRoom) ||
|
||||
(_autoAddSensors && contact.type == advTypeSensor) ||
|
||||
isContact) {
|
||||
_contacts.add(contact);
|
||||
appLogger.info(
|
||||
'Added new contact ${contact.name}: pathLen=${contact.pathLength}',
|
||||
tag: 'Connector',
|
||||
);
|
||||
} else {
|
||||
appLogger.info(
|
||||
"Discovered contact ${contact.name} (type ${contact.typeLabel}) not added due to auto-add settings",
|
||||
tag: 'Connector',
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
_knownContactKeys.add(contact.publicKeyHex);
|
||||
_loadMessagesForContact(contact.publicKeyHex);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue