mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-08-07 09:12:57 +02:00
fix(contacts): Use full public key for contact deletion
Problem: - meshcli's remove_contact command requires full public key - We were sending only 12-char prefix, causing 'Unknown contact' errors - Contacts appeared in list but couldn't be deleted Solution: - API now includes full_public_key in /api/contacts/detailed response - Frontend uses full_public_key when available, falls back to prefix - Added detailed logging to track deletion attempts This fixes the issue where contacts (especially with last_seen=4) could not be removed from the device.
This commit is contained in:
+3
-1
@@ -1219,6 +1219,7 @@ def get_contacts_detailed_api():
|
||||
{
|
||||
"name": "TK Zalesie Test 🦜",
|
||||
"public_key_prefix": "df2027d3f2ef",
|
||||
"full_public_key": "df2027d3f2ef1a2b3c4d...", // Full key (64 chars)
|
||||
"type_label": "REP",
|
||||
"path_or_mode": "Flood",
|
||||
"last_seen": 1735429453, // Unix timestamp from last_advert
|
||||
@@ -1253,8 +1254,9 @@ def get_contacts_detailed_api():
|
||||
# Find matching contact in detailed data
|
||||
for full_key, details in contacts_detailed.items():
|
||||
if full_key.lower().startswith(prefix):
|
||||
# Add last_seen timestamp
|
||||
# Add last_seen timestamp AND full public key
|
||||
contact['last_seen'] = details.get('last_advert', None)
|
||||
contact['full_public_key'] = full_key
|
||||
break
|
||||
else:
|
||||
# If detailed fetch failed, log warning but still return contacts without last_seen
|
||||
|
||||
@@ -1042,13 +1042,16 @@ async function confirmDelete() {
|
||||
}
|
||||
|
||||
try {
|
||||
// Use full public key if available, otherwise fall back to prefix
|
||||
const selector = contactToDelete.full_public_key || contactToDelete.public_key_prefix;
|
||||
|
||||
const response = await fetch('/api/contacts/delete', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
selector: contactToDelete.public_key_prefix // Use prefix for reliability
|
||||
selector: selector
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user