Files
pic/api/routes/__init__.py
T
roof 44d7e96f29 feat: Phase 6 — require_active_service decorator + wizard install wiring
Email/calendar/files routes now return 404 when the service is not
installed, using a require_active_service decorator that checks
ServiceRegistry. Status endpoints are exempt so health checks always work.

SetupManager.complete_setup() now accepts a service_store_manager and
installs any wizard-selected services in a background daemon thread after
setup completes. Failures are logged but do not fail the wizard.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-29 16:58:57 -04:00

20 lines
678 B
Python

from functools import wraps
from flask import jsonify
def require_active_service(service_id: str):
"""Decorator: return 404 if the named service is not installed.
Apply to all email/calendar/files routes except /status endpoints,
so the UI can always check installation state without being blocked.
"""
def decorator(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
from app import service_registry
if service_registry.get(service_id) is None:
return jsonify({'error': f'Service {service_id!r} is not installed'}), 404
return fn(*args, **kwargs)
return wrapper
return decorator