推送:对单人推送函数抽象

This commit is contained in:
luying
2022-04-09 10:28:21 +08:00
parent f486a8d8a5
commit 26a649b213
32 changed files with 146 additions and 703 deletions
@@ -3,12 +3,13 @@ import {Application, RouteRecord, FrontendOrBackendSession, HandlerCallback, pin
import { refresh } from '../../../services/refreshService';
import { checkPrivateChat, checkGuildChat, checkOtherChat, checkRoleName, checkGuildName } from "../../../services/sdkService";
import { resResult, checkWhiteList, genCode } from "../../../pubUtils/util";
import { BLOCK_TYPE, CHANNEL_PREFIX, MSG_TYPE, STATUS } from "../../../consts";
import { BLOCK_TYPE, CHANNEL_PREFIX, MSG_TYPE, PUSH_ROUTE, STATUS } from "../../../consts";
import { SERVER_DEBUG_MODE } from "../../../pubUtils/dicParam";
import { nowSeconds } from "../../../pubUtils/timeUtil";
import { getServerMainten } from "../../../services/gmService";
import { errlogger } from "../../../util/logger";
import { gameData } from "../../../pubUtils/data";
import { sendMessageToUser, sendMessageToUserWithSuc } from "../../../services/pushService";
export function globalFilter(app: Application) {
return new Filter(app);
}
@@ -98,7 +99,7 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se
let isWhiteList = await checkWhiteList(this.app.get('env'), ip, uid, serverId);
if(isWhiteList) return next(null);
pinus.app.get('channelService').pushMessageByUids('onServerMaintenance', resResult(STATUS.SERVER_MAINTENANCE), [{ uid: roleId, sid }]);
sendMessageToUser(roleId, PUSH_ROUTE.SERVER_MAINTENANCE, resResult(STATUS.SERVER_MAINTENANCE), sid);
return next(new Error('globalFilter'), resResult(STATUS.SERVER_MAINTENANCE));
}
}