From 4b091bfb349eaaa3955f114dd4e2e9faa05e699e Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Sat, 20 Jun 2026 18:56:03 -0400 Subject: [PATCH] Resolve activity device_type from the device record Instead of always inferring "web" for browser-emitted activity events, look the device up by device_id and use its client type, falling back to "web" (the browser default) when no device record exists. Mirrors the REST heartbeat endpoint, which derives device_type from device.client. Co-Authored-By: Claude Opus 4.8 (1M context) --- backend/endpoints/sockets/activity.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/backend/endpoints/sockets/activity.py b/backend/endpoints/sockets/activity.py index be1058b9d..fcbb80eb8 100644 --- a/backend/endpoints/sockets/activity.py +++ b/backend/endpoints/sockets/activity.py @@ -16,7 +16,7 @@ from typing import TypedDict from endpoints.responses.activity import ActivityClearSchema from handler.activity_handler import ActivityEntry, activity_handler -from handler.database import db_rom_handler, db_user_handler +from handler.database import db_device_handler, db_rom_handler, db_user_handler from handler.socket_handler import socket_handler from logger.logger import log @@ -66,12 +66,11 @@ async def _build_entry( if existing: started_at = existing["started_at"] - # Infer device_type: web is the default for browser-emitted events. - device_type = "web" - if device_id != "web": - # The browser may pass its device_id (a UUID) - we still treat it as "web" - # because Socket.IO events are only emitted from browser clients. - device_type = "web" + # Resolve the device type from the device record rather than assuming it. + # The device_id may reference a registered device (with its own client + # type); fall back to "web" — the browser default — when none is found. + device = db_device_handler.get_device(device_id=device_id, user_id=user_id) + device_type = (device.client if device else None) or "web" return ActivityEntry( user_id=user.id,