From e4720f2a9f32515b22d7858c9494596578b1cfbe Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 16 Jun 2022 20:21:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E6=8E=A8=E9=80=81=E4=B8=8D?= =?UTF-8?q?=E5=8A=A0=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/services/pushService.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/game-server/app/services/pushService.ts b/game-server/app/services/pushService.ts index abd174dee..222d399d7 100644 --- a/game-server/app/services/pushService.ts +++ b/game-server/app/services/pushService.ts @@ -85,14 +85,14 @@ export async function sendMessageToUsersWithSuc(route: string, data: any, uids: // 推送给个人的方法收束于这个函数 export async function sendMessageToUsers(route: string, data: any, uids: { uid: string, sid: string }[]) { if(uids.length > 0) { - pinus.app.get('channelService').pushMessageByUids(route, encryptMsg(data), uids); + pinus.app.get('channelService').pushMessageByUids(route, encryptMsg(route, data), uids); infologger.debug(`pushMessage route: ${route} data: ${JSON.stringify(data)} members: ${uids.map(obj => obj.uid).join()}`); } } export async function sendMessageToTeam(teamCode: string, route: string, data: any) { const channel = pinus.app.get('channelService').getChannel(teamCode); - sendMessageToChannel(channel, route, resResult(STATUS.SUCCESS, encryptMsg(data))); + sendMessageToChannel(channel, route, resResult(STATUS.SUCCESS, encryptMsg(route, data))); } /** @@ -171,10 +171,19 @@ function getKvFromMemory() { return { k, v } } -function encryptMsg(json: any) { +function encryptMsg(event: string, json: any) { + if(checkNotEncryptRoute(event)) return json let kv = getKvFromMemory(); let msgEncrypt = new MsgEncrypt(kv); let { aesKey, aesIV } = msgEncrypt.getEncodeKv(); let data = msgEncrypt.encryptMsg(json); return { data, k: aesKey, v: aesIV } } + +function checkNotEncryptRoute(event: string) { + return [ + PUSH_ROUTE.PUSH_CURRENT_TIME, + PUSH_ROUTE.RACE_START, + PUSH_ROUTE.GUILD_ACTIVITY_END, + ].indexOf(event) != -1 +} \ No newline at end of file