fix: resolve null pointer and serialization errors in /watch endpoint
This commit is contained in:
@@ -60,8 +60,12 @@ class AuthRoutes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Response> _watch(Request request, String login) async {
|
Future<Response> _watch(Request request, String login) async {
|
||||||
final uniqueId = request.url.queryParameters['unique_id'];
|
final uniqueId = request.url.queryParameters['share_id'];
|
||||||
final geoId = database.getGeoIdByShareId(uniqueId!);
|
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) {
|
if (geoId == null) {
|
||||||
await database.createLog(login, 'Accessed invalid share link');
|
await database.createLog(login, 'Accessed invalid share link');
|
||||||
@@ -79,8 +83,8 @@ class AuthRoutes {
|
|||||||
return Response(200, body: jsonEncode({
|
return Response(200, body: jsonEncode({
|
||||||
'x': position.xValue,
|
'x': position.xValue,
|
||||||
'y': position.yValue,
|
'y': position.yValue,
|
||||||
'last_update': position.lastUpdate,
|
'last_update': position.lastUpdate.toIso8601String(),
|
||||||
'expires_at': position.expiresAt,
|
'expires_at': position.expiresAt.toIso8601String(),
|
||||||
}), headers: {'Content-Type': 'application/json'});
|
}), headers: {'Content-Type': 'application/json'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user