Fix : add transaction

This commit is contained in:
2024-06-27 19:40:15 +02:00
parent 224bd71a2c
commit d6ab8bd148
7 changed files with 121 additions and 34 deletions
+2 -14
View File
@@ -82,20 +82,8 @@ export class GamesController {
const currentTurn = game.teams.find(
(t) => t._id.toHexString() == game.currentTurn,
);
if (!currentTurn.players.some((p) => p._id == player._id)) {
throw new HttpException('It is not your turn', HttpStatus.BAD_REQUEST);
}
if (
!currentTurn.players.some(
(p) => p._id.toHexString() == player._id.toHexString(),
)
) {
throw new HttpException(
'It is not your turn to play',
HttpStatus.FORBIDDEN,
);
}
await this.gameService.endTurn(game);
await this.gameService.endTurn(game, player._id.toHexString());
}
@Sse('/subscribe')