From 88ab3c9b8d80d4544ae008ba894a4e0abedd53ff Mon Sep 17 00:00:00 2001 From: Stefan Hacker Date: Sun, 12 Apr 2026 10:56:51 +0200 Subject: [PATCH] fix: Save-Endpoints feuern SSE-Event - Web-Edits synchronisieren sich /files//save (Text/HTML/Spreadsheet) und der OnlyOffice- Callback aktualisierten Inhalt + Checksum, riefen aber notify_file_change nicht auf. Der Client bekam dadurch keinen SSE-Trigger und merkte die neue Server-Version erst beim naechsten 30s-Fallback-Sync - wenn ueberhaupt. Jetzt: beide Endpoints emittieren 'updated' an Owner + Share- Empfaenger, Desktop- und Web-Clients reagieren sofort. Co-Authored-By: Claude Opus 4.6 (1M context) --- backend/app/api/office.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/app/api/office.py b/backend/app/api/office.py index fc7a9de..656f9f0 100644 --- a/backend/app/api/office.py +++ b/backend/app/api/office.py @@ -8,9 +8,10 @@ from flask import request, jsonify, current_app, send_file from app.api import api_bp from app.api.auth import token_required -from app.api.files import _get_file_or_403 +from app.api.files import _get_file_or_403, _share_recipients from app.extensions import db from app.models.settings import AppSettings +from app.services.events import notify_file_change @api_bp.route('/files//preview', methods=['GET']) @@ -219,6 +220,8 @@ def save_file(file_id): f.updated_at = datetime.now(timezone.utc) db.session.commit() + notify_file_change(f.owner_id, f.id, 'updated', + shared_with=_share_recipients(f)) return jsonify({'message': 'Gespeichert', 'size': f.size}), 200 except Exception as e: return jsonify({'error': f'Speichern fehlgeschlagen: {str(e)}'}), 500 @@ -482,6 +485,8 @@ def onlyoffice_callback(): f.checksum = h.hexdigest() f.updated_at = datetime.now(timezone.utc) db.session.commit() + notify_file_change(f.owner_id, f.id, 'updated', + shared_with=_share_recipients(f)) print(f'[OnlyOffice Callback] File saved: {f.name} ({f.size} bytes)') # Status 2, 4, 6: cleanup