From 6b4c599981b345c46727c2c8b5f92afc050eccc6 Mon Sep 17 00:00:00 2001 From: "dmit.b" Date: Sat, 9 May 2026 12:33:39 +0300 Subject: [PATCH] fix: resolve null pointer and serialization errors in /watch endpoint --- bin/routes/auth_routes.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/routes/auth_routes.dart b/bin/routes/auth_routes.dart index 59e910e..1c48a21 100644 --- a/bin/routes/auth_routes.dart +++ b/bin/routes/auth_routes.dart @@ -60,8 +60,12 @@ class AuthRoutes { } Future _watch(Request request, String login) async { - final uniqueId = request.url.queryParameters['unique_id']; - final geoId = database.getGeoIdByShareId(uniqueId!); + final uniqueId = request.url.queryParameters['share_id']; + if (uniqueId == null) { + return Response(404, body: jsonEncode({'error': 'Share link not found'}), headers: {'Content-Type': 'application/json'}); + } + + final geoId = database.getGeoIdByShareId(uniqueId); if (geoId == null) { await database.createLog(login, 'Accessed invalid share link'); @@ -79,8 +83,8 @@ class AuthRoutes { return Response(200, body: jsonEncode({ 'x': position.xValue, 'y': position.yValue, - 'last_update': position.lastUpdate, - 'expires_at': position.expiresAt, + 'last_update': position.lastUpdate.toIso8601String(), + 'expires_at': position.expiresAt.toIso8601String(), }), headers: {'Content-Type': 'application/json'}); } } \ No newline at end of file