优化:抽象推送方法
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
import { EPlace, HeroType } from '../db/Hero';
|
||||
import { GuildType } from '../db/Guild';
|
||||
import { CHANNEL_PREFIX, HERO_GROW_MAX, HERO_INITIAL_QUALITY, MSG_SOURCE, MSG_TYPE, ON_GROUP_MSG_ROUTE, STATUS, WAR_TYPE } from '../consts';
|
||||
import { CHANNEL_PREFIX, HERO_GROW_MAX, HERO_INITIAL_QUALITY, MSG_SOURCE, MSG_TYPE, ON_GROUP_MSG_ROUTE, PUSH_ROUTE, STATUS, WAR_TYPE } from '../consts';
|
||||
import { createGroupMsg, pushGroupMsgToRoom } from './chatService';
|
||||
import { pick } from 'lodash';
|
||||
import { isString } from 'underscore';
|
||||
import { pinus } from 'pinus';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
import { BossInstanceType } from '../db/BossInstance';
|
||||
import { getSimpleRoleInfo } from './roleService';
|
||||
import { GroupMessageType } from '../db/GroupMessage';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
|
||||
async function pushNormalHeroInfoBySource(roleId: string, roleName: string, serverId: number | string, source: number, heroInfo: Partial<HeroType>) {
|
||||
const hero = pick(heroInfo, ['hName', 'hid', 'seqId', 'quality', 'star', 'starStage', 'colorStar', 'colorStarStage']);
|
||||
@@ -70,10 +66,7 @@ export async function pushPresent(roleId: string, roleName: string, serverId: nu
|
||||
|
||||
export async function pushComBtlTeamMsg(teamCode: string, roleId: string, roleName: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string) {
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.TEAM, teamCode, type, source, content, targetRoleId, targetMsgCode);
|
||||
if (!msgData) return null;
|
||||
const channel = pinus.app.get('channelService').getChannel(teamCode);
|
||||
const roleInfo = await getSimpleRoleInfo(msgData.roleId);
|
||||
channel.pushMessage(ON_GROUP_MSG_ROUTE, resResult(STATUS.SUCCESS, { ...msgData, roleInfo }));
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user