abc
This commit is contained in:
@@ -213,8 +213,9 @@ router.post("/games", asyncHandler(async (req, res) => {
|
||||
|
||||
try {
|
||||
await conn.beginTransaction();
|
||||
|
||||
const [gameResult] = await conn.query(
|
||||
"INSERT INTO current_games (is_open, is_local) VALUES (?, ?, ?)",
|
||||
"INSERT INTO current_games (is_open, is_local) VALUES (?, ?)",
|
||||
[true, is_local]
|
||||
);
|
||||
|
||||
@@ -279,6 +280,13 @@ router.post("/games/:id/players", asyncHandler(async (req, res) => {
|
||||
|
||||
try {
|
||||
await conn.beginTransaction();
|
||||
|
||||
const [alreadyJoined] = await conn.query(
|
||||
"SELECT 1 FROM game_players WHERE game = ? AND user = ?",
|
||||
[gameId, user]
|
||||
);
|
||||
if (alreadyJoined.length) throw new ApiError(400, "User already joined this game");
|
||||
|
||||
const [gameRows] = await conn.query(
|
||||
"SELECT * FROM current_games WHERE id = ? AND is_open = TRUE AND is_local = FALSE",
|
||||
[gameId]
|
||||
|
||||
Reference in New Issue
Block a user