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