diff --git a/backend/src/app.py b/backend/src/app.py index c11cf37..946f38f 100644 --- a/backend/src/app.py +++ b/backend/src/app.py @@ -11,6 +11,7 @@ from .room import Room from .song import Song, init_db, get_song_by_title_artist, add_song_in_db, get_song_by_uuid from .song_fetch import query_search, yt_get_audio_url, yt_search_song from .qrcode_gen import generate_qr +from .gps import is_within_range dotenv.load_dotenv() @@ -74,6 +75,7 @@ def on_leave(data): def join(): room_id = request.args.get("room") code = request.args.get("code") + user_location = request.args.get("location") if room_id is None: return error("Missing room id") @@ -84,6 +86,9 @@ def join(): if room.pin is not None and room.pin != code: return error("Invalid code") + if is_within_range(user_location, room.coord, room.range_size) is False: + return error("You are not within the room range") + return {"success": True, "ws": f"/ws/{room_id}"}