diff --git a/README.md b/README.md index dfb59b0..7fc6550 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ A lightweight web interface for meshcore-cli, providing browser-based access to - **Smart filtering:** Search by name/key, filter by contact type (CLI, REP, ROOM, SENS) - **Activity indicators:** Visual status icons (🟢 active, 🟡 recent, 🔴 inactive) based on last advertisement - **GPS location:** View contact location on Google Maps (when GPS coordinates available) - - **Advanced cleanup tool:** Filter and remove contacts by name, type (CLI/REP/ROOM/SENS), inactivity period, and path length with preview before deletion + - **Advanced cleanup tool:** Filter and remove contacts by name, type (CLI/REP/ROOM/SENS), and inactivity period with preview before deletion - 📦 **Message archiving** - Automatic daily archiving with browse-by-date selector - ⚡ **Efficient polling** - Lightweight update checks every 10s, UI refreshes only when needed - 📡 **Network commands** - Send advertisement (advert) or flood advertisement (floodadv) for network management @@ -486,14 +486,12 @@ The advanced cleanup tool allows you to filter and remove contacts based on mult - **Contact Types:** Select which types to include (CLI, REP, ROOM, SENS) - **Date Field:** Choose between "Last Advert" (recommended) or "Last Modified" - **Days of Inactivity:** Contacts inactive for more than X days (0 = ignore) - - **Path Length >:** Contacts with path length greater than X (0 = ignore) 4. Click **Preview Cleanup** to see matching contacts 5. Review the list and confirm deletion **Example use cases:** - Remove all REP contacts inactive for 30+ days: Select REP, set days to 30 - Clean specific contact names: Enter partial name (e.g., "test") -- Remove distant contacts: Set path length > 5 ### Network Commands diff --git a/app/routes/api.py b/app/routes/api.py index 1c0c3d0..5fb505e 100644 --- a/app/routes/api.py +++ b/app/routes/api.py @@ -267,7 +267,6 @@ def _filter_contacts_by_criteria(contacts: list, criteria: dict) -> list: - types (list[int]): Contact types to include [1,2,3,4] - date_field (str): "last_advert" or "lastmod" - days (int): Days of inactivity (0 = ignore) - - path_len (int): Minimum path length, >X (0 = ignore) Returns: List of contacts matching criteria @@ -276,7 +275,6 @@ def _filter_contacts_by_criteria(contacts: list, criteria: dict) -> list: selected_types = criteria.get('types', [1, 2, 3, 4]) date_field = criteria.get('date_field', 'last_advert') days = criteria.get('days', 0) - path_len = criteria.get('path_len', 0) # Calculate timestamp threshold for days filter current_time = int(time.time()) @@ -307,12 +305,6 @@ def _filter_contacts_by_criteria(contacts: list, criteria: dict) -> list: # Still active within threshold continue - # Filter by path length (> path_len) - if path_len > 0: - contact_path_len = contact.get('out_path_len', -1) - if contact_path_len <= path_len: - continue - # Contact matches all criteria filtered.append(contact) @@ -329,8 +321,7 @@ def preview_cleanup_contacts(): "name_filter": "", # Partial name match (empty = ignore) "types": [1, 2, 3, 4], # Contact types (1=CLI, 2=REP, 3=ROOM, 4=SENS) "date_field": "last_advert", # "last_advert" or "lastmod" - "days": 2, # Days of inactivity (0 = ignore) - "path_len": 0 # Path length > X (0 = ignore) + "days": 2 # Days of inactivity (0 = ignore) } Returns: @@ -349,8 +340,7 @@ def preview_cleanup_contacts(): 'name_filter': data.get('name_filter', ''), 'types': data.get('types', [1, 2, 3, 4]), 'date_field': data.get('date_field', 'last_advert'), - 'days': data.get('days', 0), - 'path_len': data.get('path_len', 0) + 'days': data.get('days', 0) } # Validate types @@ -374,12 +364,6 @@ def preview_cleanup_contacts(): 'error': 'Invalid days (must be non-negative integer)' }), 400 - if not isinstance(criteria['path_len'], int) or criteria['path_len'] < 0: - return jsonify({ - 'success': False, - 'error': 'Invalid path_len (must be non-negative integer)' - }), 400 - # Get all contacts success_detailed, contacts_detailed, error_detailed = cli.get_contacts_with_last_seen() if not success_detailed: @@ -433,8 +417,7 @@ def cleanup_contacts(): "name_filter": "", # Partial name match (empty = ignore) "types": [1, 2, 3, 4], # Contact types (1=CLI, 2=REP, 3=ROOM, 4=SENS) "date_field": "last_advert", # "last_advert" or "lastmod" - "days": 2, # Days of inactivity (0 = ignore) - "path_len": 0 # Path length > X (0 = ignore) + "days": 2 # Days of inactivity (0 = ignore) } Returns: @@ -457,8 +440,7 @@ def cleanup_contacts(): 'name_filter': data.get('name_filter', ''), 'types': data.get('types', [1, 2, 3, 4]), 'date_field': data.get('date_field', 'last_advert'), - 'days': data.get('days', 0), - 'path_len': data.get('path_len', 0) + 'days': data.get('days', 0) } # Validate types @@ -482,12 +464,6 @@ def cleanup_contacts(): 'error': 'Invalid days (must be non-negative integer)' }), 400 - if not isinstance(criteria['path_len'], int) or criteria['path_len'] < 0: - return jsonify({ - 'success': False, - 'error': 'Invalid path_len (must be non-negative integer)' - }), 400 - # Get all contacts success_detailed, contacts_detailed, error_detailed = cli.get_contacts_with_last_seen() if not success_detailed: diff --git a/app/static/js/contacts.js b/app/static/js/contacts.js index 4cb8d7e..d851aba 100644 --- a/app/static/js/contacts.js +++ b/app/static/js/contacts.js @@ -156,7 +156,7 @@ function collectCleanupCriteria() { * Collect cleanup filter criteria from form inputs. * * Returns: - * Object with criteria: {name_filter, types, date_field, days, path_len} + * Object with criteria: {name_filter, types, date_field, days} */ // Name filter const nameFilter = document.getElementById('cleanupNameFilter')?.value?.trim() || ''; @@ -172,15 +172,11 @@ function collectCleanupCriteria() { // Days of inactivity const days = parseInt(document.getElementById('cleanupDays')?.value) || 0; - // Path length - const pathLen = parseInt(document.getElementById('cleanupPathLen')?.value) || 0; - return { name_filter: nameFilter, types: types, date_field: dateField, - days: days, - path_len: pathLen + days: days }; } diff --git a/app/templates/contacts-manage.html b/app/templates/contacts-manage.html index 14cdbda..bd94443 100644 --- a/app/templates/contacts-manage.html +++ b/app/templates/contacts-manage.html @@ -135,13 +135,6 @@ Contacts inactive for more than this many days will be selected - - -
- - - Select contacts with path length greater than this value -