部分推送不加密
This commit is contained in:
@@ -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 }[]) {
|
export async function sendMessageToUsers(route: string, data: any, uids: { uid: string, sid: string }[]) {
|
||||||
if(uids.length > 0) {
|
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()}`);
|
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) {
|
export async function sendMessageToTeam(teamCode: string, route: string, data: any) {
|
||||||
const channel = pinus.app.get('channelService').getChannel(teamCode);
|
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 }
|
return { k, v }
|
||||||
}
|
}
|
||||||
|
|
||||||
function encryptMsg(json: any) {
|
function encryptMsg(event: string, json: any) {
|
||||||
|
if(checkNotEncryptRoute(event)) return json
|
||||||
let kv = getKvFromMemory();
|
let kv = getKvFromMemory();
|
||||||
let msgEncrypt = new MsgEncrypt(kv);
|
let msgEncrypt = new MsgEncrypt(kv);
|
||||||
let { aesKey, aesIV } = msgEncrypt.getEncodeKv();
|
let { aesKey, aesIV } = msgEncrypt.getEncodeKv();
|
||||||
let data = msgEncrypt.encryptMsg(json);
|
let data = msgEncrypt.encryptMsg(json);
|
||||||
return { data, k: aesKey, v: aesIV }
|
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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user