Fix: link share_id to geo_id so /watch returns correct position
This commit is contained in:
@@ -61,13 +61,14 @@ class AuthRoutes {
|
||||
|
||||
Future<Response> _watch(Request request, String login) async {
|
||||
final uniqueId = request.url.queryParameters['unique_id'];
|
||||
final geoId = database.getGeoIdByShareId(uniqueId!);
|
||||
|
||||
if (!database.isValidShareId(uniqueId!)) {
|
||||
if (geoId == null) {
|
||||
await database.createLog(login, 'Accessed invalid share link');
|
||||
return Response(404, body: jsonEncode({'error': 'Share link not found'}), headers: {'Content-Type': 'application/json'});
|
||||
}
|
||||
|
||||
final position = await database.getLatestPosition();
|
||||
final position = await database.getPositionById(geoId);
|
||||
|
||||
if (position == null) {
|
||||
await database.createLog(login, 'Accessed share link - no position');
|
||||
|
||||
@@ -37,7 +37,7 @@ class GeoRoutes {
|
||||
final y = data['y'];
|
||||
|
||||
final position = await database.createPosition(x, y);
|
||||
final shareId = database.createShareId();
|
||||
final shareId = database.createShareId(position.id);
|
||||
|
||||
await database.createLog(login, 'Created share link geo_id=${position.id}');
|
||||
return Response(201, body: jsonEncode({
|
||||
|
||||
Reference in New Issue
Block a user