fix: Save-Endpoints feuern SSE-Event - Web-Edits synchronisieren sich
/files/<id>/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) <noreply@anthropic.com>
This commit is contained in:
parent
e3cf7b1b64
commit
88ab3c9b8d
|
|
@ -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/<int:file_id>/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
|
||||
|
|
|
|||
Loading…
Reference in New Issue