Game invitation from chat WIP (missing username)

+ fetchUser() and fetchAllUsers()
+ changes accept/declineInvitation()
This commit is contained in:
LuckyLaszlo
2023-01-15 00:00:35 +01:00
parent 888255c810
commit b72042a263
6 changed files with 96 additions and 28 deletions

View File

@@ -200,8 +200,10 @@ export class GameService {
async declineInvitation(user : User, token : string, @Res() res : Response)
{
if (user.status !== STATUS.CONNECTED)
return res.status(HttpStatus.FORBIDDEN).json({message : "You must not be in game to decline an invitation"});
/* Luke: le check de user.status n'est pas fonctionnel avec l'implémentation des invitations dans le front.
Ça me semble dispensable, je désactive donc pour le moment plutôt que de refaire l'implémentation front. */
// if (user.status !== STATUS.CONNECTED)
// return res.status(HttpStatus.FORBIDDEN).json({message : "You must not be in game to decline an invitation"});
console.log("On décline l'invitation")
const tokenGame = await this.tokenGameRepository.createQueryBuilder('tokengame')
.andWhere('tokengame.playerTwoUsername = :playerTwoUsername', {playerTwoUsername : user.username})
@@ -236,8 +238,10 @@ export class GameService {
async acceptInvitation(user : User, token : string, @Res() res : Response)
{
if (user.status !== STATUS.CONNECTED)
return res.status(HttpStatus.FORBIDDEN).send("")
/* Luke: le check de user.status n'est pas fonctionnel avec l'implémentation des invitations dans le front.
Ça me semble dispensable, je désactive donc pour le moment plutôt que de refaire l'implémentation front. */
// if (user.status !== STATUS.CONNECTED)
// return res.status(HttpStatus.FORBIDDEN).send("")
const tokenGame = await this.tokenGameRepository.createQueryBuilder('tokenGame')
.andWhere('tokenGame.playerTwoUsername = :playerTwoUsername', {playerTwoUsername : user.username})
.andWhere('tokenGame.token = :token', {token : token})