update many files

This commit is contained in:
ben
2026-08-03 16:21:10 +02:00
parent 9e69edc08b
commit cff9aa0dd1
5 changed files with 220 additions and 110 deletions
+29 -14
View File
@@ -81,39 +81,54 @@ def search_room(
return room["name"]
def accept_room(
user_id,
invite_code
):
def accept_room(user_id, invite_code):
query = """
SELECT id
FROM rooms
WHERE invite_code = ?
"""
room = fetch_one(
query,
(
invite_code,
)
(invite_code,)
)
if room is None:
return None
room_id = room["id"]
role = DEFAULT_ROLE
query2 = """
INSERT INTO "main"."room_members"
("room_id", "user_id", "role")
VALUES (?, ?, ?);
# check dubbele join
existing = fetch_one(
"""
SELECT id
FROM room_members
WHERE room_id = ?
AND user_id = ?
""",
(
room_id,
user_id
)
)
if existing:
return None
query = """
INSERT INTO room_members
(room_id, user_id, role)
VALUES (?, ?, ?)
"""
member_id = execute(
query2,
query,
(
room_id,
user_id,
role
"member"
)
)