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>
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import logging
|
||||
from flask import Blueprint, request, jsonify
|
||||
from routes import require_active_service
|
||||
|
||||
logger = logging.getLogger('picell')
|
||||
bp = Blueprint('files', __name__)
|
||||
|
||||
@bp.route('/api/files/users', methods=['GET'])
|
||||
@require_active_service('files')
|
||||
def get_file_users():
|
||||
"""Get file storage users."""
|
||||
try:
|
||||
@@ -15,6 +18,7 @@ def get_file_users():
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@bp.route('/api/files/users', methods=['POST'])
|
||||
@require_active_service('files')
|
||||
def create_file_user():
|
||||
"""Create file storage user."""
|
||||
try:
|
||||
@@ -33,6 +37,7 @@ def create_file_user():
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@bp.route('/api/files/users/<username>', methods=['DELETE'])
|
||||
@require_active_service('files')
|
||||
def delete_file_user(username):
|
||||
"""Delete file storage user."""
|
||||
try:
|
||||
@@ -44,6 +49,7 @@ def delete_file_user(username):
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@bp.route('/api/files/folders', methods=['POST'])
|
||||
@require_active_service('files')
|
||||
def create_folder():
|
||||
"""Create folder."""
|
||||
try:
|
||||
@@ -64,6 +70,7 @@ def create_folder():
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@bp.route('/api/files/folders/<username>/<path:folder_path>', methods=['DELETE'])
|
||||
@require_active_service('files')
|
||||
def delete_folder(username, folder_path):
|
||||
"""Delete folder."""
|
||||
try:
|
||||
@@ -77,6 +84,7 @@ def delete_folder(username, folder_path):
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@bp.route('/api/files/upload/<username>', methods=['POST'])
|
||||
@require_active_service('files')
|
||||
def upload_file(username):
|
||||
"""Upload file."""
|
||||
try:
|
||||
@@ -97,6 +105,7 @@ def upload_file(username):
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@bp.route('/api/files/download/<username>/<path:file_path>', methods=['GET'])
|
||||
@require_active_service('files')
|
||||
def download_file(username, file_path):
|
||||
"""Download file."""
|
||||
try:
|
||||
@@ -110,6 +119,7 @@ def download_file(username, file_path):
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@bp.route('/api/files/delete/<username>/<path:file_path>', methods=['DELETE'])
|
||||
@require_active_service('files')
|
||||
def delete_file(username, file_path):
|
||||
"""Delete file."""
|
||||
try:
|
||||
@@ -123,6 +133,7 @@ def delete_file(username, file_path):
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@bp.route('/api/files/list/<username>', methods=['GET'])
|
||||
@require_active_service('files')
|
||||
def list_files(username):
|
||||
"""List files."""
|
||||
try:
|
||||
@@ -148,6 +159,7 @@ def get_file_status():
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@bp.route('/api/files/connectivity', methods=['GET'])
|
||||
@require_active_service('files')
|
||||
def test_file_connectivity():
|
||||
"""Test file service connectivity."""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user