refactor(BaseChatMesh): extract onDiscoveredAdvert to keep upstream signature

Reverts onDiscoveredContact to the upstream 4-param signature, adding a
separate virtual onDiscoveredAdvert(bool was_flood) with a default no-op
implementation. Only MyMesh overrides the new virtual; simple_secure_chat
and any future implementors need no changes on upstream merges.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-06-08 20:37:22 +02:00
parent ceea1df196
commit 2d6d35192b
5 changed files with 16 additions and 9 deletions

View File

@@ -144,7 +144,8 @@ void BaseChatMesh::onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id,
if (!shouldAutoAddContactType(parser.getType())) {
ContactInfo ci;
populateContactFromAdvert(ci, id, parser, timestamp);
onDiscoveredContact(ci, true, packet->path_len, packet->path, packet->isRouteFlood()); // let UI know
onDiscoveredContact(ci, true, packet->path_len, packet->path); // let UI know
onDiscoveredAdvert(packet->isRouteFlood());
return;
}
@@ -153,7 +154,8 @@ void BaseChatMesh::onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id,
if (max_hops > 0 && packet->getPathHashCount() >= max_hops) {
ContactInfo ci;
populateContactFromAdvert(ci, id, parser, timestamp);
onDiscoveredContact(ci, true, packet->path_len, packet->path, packet->isRouteFlood()); // let UI know
onDiscoveredContact(ci, true, packet->path_len, packet->path); // let UI know
onDiscoveredAdvert(packet->isRouteFlood());
return;
}
@@ -161,7 +163,8 @@ void BaseChatMesh::onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id,
if (from == NULL) {
ContactInfo ci;
populateContactFromAdvert(ci, id, parser, timestamp);
onDiscoveredContact(ci, true, packet->path_len, packet->path, packet->isRouteFlood());
onDiscoveredContact(ci, true, packet->path_len, packet->path);
onDiscoveredAdvert(packet->isRouteFlood());
onContactsFull();
MESH_DEBUG_PRINTLN("onAdvertRecv: unable to allocate contact slot for new contact");
return;
@@ -183,7 +186,8 @@ void BaseChatMesh::onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id,
from->last_advert_timestamp = timestamp;
from->lastmod = getRTCClock()->getCurrentTime();
onDiscoveredContact(*from, is_new, packet->path_len, packet->path, packet->isRouteFlood()); // let UI know
onDiscoveredContact(*from, is_new, packet->path_len, packet->path); // let UI know
onDiscoveredAdvert(packet->isRouteFlood());
}
int BaseChatMesh::searchPeersByHash(const uint8_t* hash) {