feat : add winner to endGame event
release-tag / release-image (push) Failing after 7s

Related to heronfief/front#71
This commit is contained in:
2024-12-21 11:17:00 +01:00
parent 0aaf03839b
commit 179b5feacc
+3 -1
View File
@@ -288,7 +288,7 @@ export class GameService {
});
await game.save({ session });
if (game.teams.length <= 1) {
await this.endGame(game, session);
await this.endGame(game, game.teams[0], session);
return false;
}
return true;
@@ -359,10 +359,12 @@ export class GameService {
@WithTransaction
async endGame(
game: Document<Game> & Game,
winner: Team,
session?: mongoose.mongo.ClientSession,
) {
this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
type: 'endGame',
winner: winner._id.toHexString(),
});
await game.deleteOne({ session });
}