multiprofile rooms events

This commit is contained in:
Mateusz Gruszczyński
2026-06-16 14:03:39 +02:00
parent fc7ca12a01
commit 0f1ffc1c3d
6 changed files with 13 additions and 12 deletions
+4 -3
View File
@@ -27,8 +27,9 @@ def _poller_profiles() -> list[dict]:
def emit_profile_event(socketio, event: str, payload: dict, profile_id: int) -> None:
target = _profile_room(profile_id) if auth.enabled() else None
socketio.emit(event, payload, to=target) if target else socketio.emit(event, payload)
# Note: Profile-scoped events always go to the selected profile room, even when authentication is disabled.
scoped_payload = {**(payload or {}), "profile_id": int(profile_id)}
socketio.emit(event, scoped_payload, to=_profile_room(profile_id))
def _emit_profile(socketio, event: str, payload: dict, profile_id: int) -> None:
@@ -51,7 +52,7 @@ def _run_slow_profile_tasks(socketio, profile: dict, profile_id: int) -> None:
profile_user_id = int(profile.get("user_id") or default_user_id())
try:
try:
torrent_stats.queue_refresh(socketio, profile, force=False, room=_profile_room(profile_id) if auth.enabled() else None)
torrent_stats.queue_refresh(socketio, profile, force=False, room=_profile_room(profile_id))
except Exception as exc:
_emit_profile(socketio, "torrent_stats_update", {"ok": False, "profile_id": profile_id, "error": str(exc)}, profile_id)
try: