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 {
|
||||
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'});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user