diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index 964bf23..0fcb90c 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -21,6 +21,7 @@ import { setGameLink } from './setGameLink'; import { list_SocketListener } from './chatBackHelperFunctions/list_SocketListener'; import { isUser_BlockedBy_me } from './chatBackHelperFunctions/isUser_BlockedBy_me'; import type { inviteUserTOGame, ClientInfo, blockedUnBlocked } from './chat_types'; +import { PongGameId } from '@shared/database/mixin/pong'; declare const __SERVICE_NAME: string; @@ -216,10 +217,9 @@ async function onReady(fastify: FastifyInstance) { socket.on('inviteGame', async (data: string) => { const clientName: string = clientChat.get(socket.id)?.user || ''; const profilInvite: ClientProfil = JSON.parse(data) || ''; - const linkGame: Response | undefined = await setGameLink(fastify, data); + const linkGame: PongGameId | undefined = await setGameLink(fastify, data); if (!linkGame) return; - const tmp: inviteUserTOGame = await linkGame?.json() as inviteUserTOGame; - const link: string = `Click me`; + const link: string = `Click me`; const inviteHtml: string = 'invites you to a game ' + link; if (clientName !== null) { sendInvite(fastify, inviteHtml, profilInvite); diff --git a/src/chat/src/setGameLink.ts b/src/chat/src/setGameLink.ts index 210bdee..6cd9034 100644 --- a/src/chat/src/setGameLink.ts +++ b/src/chat/src/setGameLink.ts @@ -1,9 +1,9 @@ import { FastifyInstance } from 'fastify'; import type { ClientProfil } from './chat_types'; +import { PongGameId } from '@shared/database/mixin/pong'; -export async function setGameLink(fastify: FastifyInstance, data: string): Promise { - +export async function setGameLink(fastify: FastifyInstance, data: string): Promise { const profilInvite: ClientProfil = JSON.parse(data) || ''; const payload = { 'user1': `'${profilInvite.SenderID}'`, 'user2':`'${profilInvite.userID}'` }; @@ -14,12 +14,17 @@ export async function setGameLink(fastify: FastifyInstance, data: string): Promi body: JSON.stringify(payload), }); if (!resp.ok) { + fastify.log.info("HELLO ?"); throw (resp); } else { fastify.log.info('game-end info to chat success'); } - return resp; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const json = await resp.json() as any; + fastify.log.info(json); + return json.payload.gameId; } // disable eslint for err catching // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/src/pong/src/run.ts b/src/pong/src/run.ts index b1b3727..ce20b7d 100644 --- a/src/pong/src/run.ts +++ b/src/pong/src/run.ts @@ -4,21 +4,7 @@ import fastify, { FastifyInstance } from 'fastify'; import app from './app'; const start = async () => { - const envToLogger = { - development: { - transport: { - target: 'pino-pretty', - options: { - translateTime: 'HH:MM:ss Z', - ignore: 'pid,hostname', - }, - }, - }, - production: true, - test: false, - }; - - const f: FastifyInstance = fastify({ logger: envToLogger.development }); + const f: FastifyInstance = fastify({ logger: true }); try { process.on('SIGTERM', () => { f.log.info('Requested to shutdown'); diff --git a/src/pong/src/state.ts b/src/pong/src/state.ts index d03a7ec..2f31977 100644 --- a/src/pong/src/state.ts +++ b/src/pong/src/state.ts @@ -223,9 +223,13 @@ class StateI { } public newPausedGame(suid1: string, suid2: string): GameId | undefined { - if (!this.fastify.db.getUser(suid1) || !this.fastify.db.getUser(suid2)) { - return undefined; - } + + this.fastify.log.info('suid1:' + suid1); + this.fastify.log.info('suid2:' + suid2); + // if (!this.fastify.db.getUser(suid1) || !this.fastify.db.getUser(suid2)) { + // return undefined; + // } + this.fastify.log.info('new paused start'); const uid1: UserId = suid1 as UserId; const uid2: UserId = suid2 as UserId; const g = new Pong(uid1, uid2);