mirror of
https://github.com/zvx-echo6/recon.git
synced 2026-06-10 08:54:34 +02:00
cleanup: remove /api/contacts + /api/address_book handlers + pull entire /nav-i/* subtree (extraction #3 shadow) (#12)
* cleanup: remove /api/address_book handlers (extraction #3 shadow) Removes address_book_bp (lib/address_book_api.py: /api/address_book/lookup + /api/address_book/list) + its registration in lib/api.py. Edge-shadowed since extraction #3 — navi-contacts (:8423) serves /api/address_book/* on navi.echo6.co; no recon-side consumer (no template/JS reference). lib/address_book.py is KEPT — geocode.py (nickname short-circuit + annotation) and netsyms_api.py import it. NOT removed this PR: contacts_bp. The recon dashboard at /deleted-contacts (recon-product, stays) calls /api/contacts/<id>/{restore,restore-as,purge} via XHR, and recon.echo6.co proxies straight to recon:8420 (verified the Caddy block — no navi-contacts routing there). Removing contacts_bp would break those dashboard actions. Flagged for a decision; lib/contacts.py also stays (dashboard ContactsDB reads). See PR body. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * cleanup: deprecate /nav-i + /deleted-contacts; remove contacts_bp + lib/contacts.py Probe found recon's /deleted-contacts dashboard reads /opt/recon/data/contacts.db — frozen since extraction #3 moved write ownership to navi-contacts (/var/lib/navi-backend/contacts.db). The page has been silently rendering ~25-day stale data, and its restore/restore-as/purge XHRs hit recon's contacts_bp (the recon.echo6.co Caddy block proxies straight to recon:8420 — no navi-contacts routing there). Per Matt's decision, deprecate the pages entirely; they'll be re-surfaced later as a proper admin page consuming navi-contacts via API. Removed: - contacts_bp (lib/contacts_api.py, all 10 /api/contacts* routes) + its registration in lib/api.py — edge-shadowed by navi-contacts :8423 since #3, and now free of recon-product consumers once the dashboard goes. - /nav-i (navi_landing_page) + /deleted-contacts (deleted_contacts_page) route handlers; templates/navi/landing.html + templates/navi/deleted_contacts.html. - lib/contacts.py (ContactsDB) — the dashboard was its only non-contacts_bp consumer; both gone. - The two dead NAVI_SUBNAV entries (Overview→/nav-i, Deleted Contacts→ /deleted-contacts). Kept / adapted: - /nav-i/api-keys page (recon-product key management) stays. NAVI_SUBNAV reduced to just its API Keys entry; the base.html top-nav "Nav-I" link repointed /nav-i -> /nav-i/api-keys so the surviving section page stays reachable (minimal href change, not a nav restructure — flagged in PR). - lib/address_book.py — geocode.py + netsyms_api.py still consume it (untouched). Out-of-band follow-up after merge: delete the stale /opt/recon/data/contacts.db (frozen 2026-04-28; data, not code). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * cleanup: pull the entire /nav-i/* subtree (api-keys page is a weaker dup of /settings/keys) Completes the contacts cleanup by removing the rest of /nav-i/. The /nav-i/api-keys page was (a) a weaker duplicate of /settings/keys for Gemini (it lacked remove + reload-from-.env), and (b) a write-only-to-dead-files surface for TomTom + Google Places: it wrote /opt/recon/.env, but the live navi-traffic (:8421) and navi-places (:8425) services read their own /etc/navi-backend/<svc>.env and have ignored recon's copy since extractions #1 + #5. End state: no /nav-i/* URLs in recon. Removed: - /nav-i/api-keys route + template (templates/navi/api_keys.html) - all /api/nav-i/api-keys/* endpoints (list/update/test/restart-recon) - lib/api_keys_admin.py (its only importers were those 4 endpoints; _KEY_DEFS/ _read_env/_write_env were private to it) - the now-orphaned NAVI_SUBNAV - the "Nav-I" top-nav entry in base.html (reverses the /nav-i->/nav-i/api-keys repoint from the previous commit, now that the page itself is gone) Kept (Gemini's real home, recon-product): - /settings/keys + /api/keys/* + lib/key_manager.py (KeyManager) — they import key_manager directly, never api_keys_admin, so untouched. Note: TOMTOM_API_KEY now has zero recon .py references. GOOGLE_PLACES_API_KEY still has one (lib/google_places.py), kept in the prior /api/place cleanup as place_detail's dep; its only caller (_enrich_with_google) is unreachable since the /api/place handlers were removed — left in place pending /api/wiki-enrich retirement (out of scope here). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: zvx-echo6 <mj@k7zvx.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c968497b94
commit
d56b1d5f92
9 changed files with 0 additions and 1257 deletions
98
lib/api.py
98
lib/api.py
|
|
@ -59,14 +59,6 @@ class _LargeZimRequest(_FlaskRequest):
|
|||
return super()._get_file_stream(total_content_length, content_type, filename, content_length)
|
||||
|
||||
app.request_class = _LargeZimRequest
|
||||
# ── Address Book Blueprint ──
|
||||
from .address_book_api import address_book_bp
|
||||
app.register_blueprint(address_book_bp)
|
||||
|
||||
# ── Contacts Blueprint ──
|
||||
from .contacts_api import contacts_bp
|
||||
app.register_blueprint(contacts_bp)
|
||||
|
||||
# ── Netsyms + Geocode Blueprints ──
|
||||
from .netsyms_api import netsyms_bp, geocode_bp
|
||||
app.register_blueprint(netsyms_bp)
|
||||
|
|
@ -109,12 +101,6 @@ SETTINGS_SUBNAV = [
|
|||
{'href': '/settings/health', 'label': 'Service Health'},
|
||||
]
|
||||
|
||||
NAVI_SUBNAV = [
|
||||
{'href': '/nav-i', 'label': 'Overview'},
|
||||
{'href': '/deleted-contacts', 'label': 'Deleted Contacts'},
|
||||
{'href': '/nav-i/api-keys', 'label': 'API Keys'},
|
||||
]
|
||||
|
||||
|
||||
def _format_source_citation(payload):
|
||||
"""Format a human-readable citation from a search result payload."""
|
||||
|
|
@ -341,36 +327,6 @@ def failures_page():
|
|||
failures=failures)
|
||||
|
||||
|
||||
@app.route("/deleted-contacts")
|
||||
def deleted_contacts_page():
|
||||
from .auth import get_user_id
|
||||
from .contacts import ContactsDB
|
||||
user_id = get_user_id() or "anonymous"
|
||||
db = ContactsDB()
|
||||
contacts = db.list_deleted(user_id)
|
||||
return render_template("navi/deleted_contacts.html",
|
||||
domain="navi", subnav=NAVI_SUBNAV, active_page="/deleted-contacts",
|
||||
contacts=contacts)
|
||||
|
||||
|
||||
@app.route("/nav-i")
|
||||
def navi_landing_page():
|
||||
from .auth import get_user_id
|
||||
from .contacts import ContactsDB
|
||||
user_id = get_user_id() or "anonymous"
|
||||
db = ContactsDB()
|
||||
deleted_count = len(db.list_deleted(user_id))
|
||||
return render_template("navi/landing.html",
|
||||
domain="navi", subnav=NAVI_SUBNAV, active_page="/nav-i",
|
||||
deleted_count=deleted_count)
|
||||
|
||||
|
||||
@app.route("/nav-i/api-keys")
|
||||
def navi_api_keys_page():
|
||||
return render_template("navi/api_keys.html",
|
||||
domain="navi", subnav=NAVI_SUBNAV, active_page="/nav-i/api-keys")
|
||||
|
||||
|
||||
@app.route('/peertube')
|
||||
def peertube_dashboard():
|
||||
return render_template('peertube/dashboard.html',
|
||||
|
|
@ -1408,60 +1364,6 @@ def api_keys_reload():
|
|||
|
||||
|
||||
|
||||
# ── Nav-I API Key Admin ──
|
||||
|
||||
@app.route('/api/nav-i/api-keys/list', methods=['GET'])
|
||||
def navi_api_keys_list():
|
||||
from .api_keys_admin import list_keys
|
||||
return jsonify({'keys': list_keys()})
|
||||
|
||||
|
||||
@app.route('/api/nav-i/api-keys/update', methods=['POST'])
|
||||
def navi_api_keys_update():
|
||||
from .auth import require_auth
|
||||
from .api_keys_admin import update_key, update_gemini_key
|
||||
data = request.get_json(force=True)
|
||||
name = data.get('name', '')
|
||||
new_value = data.get('new_value', '')
|
||||
index = data.get('index') # optional, for Gemini key replacement
|
||||
if not name or not new_value:
|
||||
return jsonify({'error': 'name and new_value required'}), 400
|
||||
if name == 'GEMINI_KEY' and index is not None:
|
||||
result = update_gemini_key(int(index), new_value)
|
||||
else:
|
||||
result = update_key(name, new_value)
|
||||
if result.get('success'):
|
||||
return jsonify(result)
|
||||
return jsonify(result), 400
|
||||
|
||||
|
||||
@app.route('/api/nav-i/api-keys/test', methods=['POST'])
|
||||
def navi_api_keys_test():
|
||||
from .api_keys_admin import test_key
|
||||
data = request.get_json(force=True)
|
||||
name = data.get('name', '')
|
||||
index = data.get('index') # optional, for testing specific Gemini key
|
||||
if not name:
|
||||
return jsonify({'error': 'name required'}), 400
|
||||
result = test_key(name, index=int(index) if index is not None else None)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
@app.route('/api/nav-i/api-keys/restart-recon', methods=['POST'])
|
||||
def navi_api_keys_restart():
|
||||
import subprocess
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['sudo', 'systemctl', 'restart', 'recon'],
|
||||
capture_output=True, text=True, timeout=30
|
||||
)
|
||||
if result.returncode == 0:
|
||||
return jsonify({'success': True, 'note': 'RECON service restarted'})
|
||||
return jsonify({'success': False, 'error': result.stderr.strip()}), 500
|
||||
except subprocess.TimeoutExpired:
|
||||
return jsonify({'success': False, 'error': 'Restart timed out'}), 500
|
||||
except Exception as e:
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
|
||||
# ── YouTube Cookie Management ──
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue