✨ feat(聊天): 战区频道
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { CHANNEL_PREFIX, MSG_SOURCE, getChannelType } from './../../../consts/constModules/chatConst';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { genCode, resResult } from '../../../pubUtils/util';
|
||||
import { DEFAULT_MSG_PER_PAGE, STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo, recentPrivateChatInfos, recentWorldMsgs, recentSysMsgs, recentGuildMsgs, updatePrivateMsgIsTop, delPrivateMsg, recentServerGroupMsgs, recentLeagueMsgs } from '../../../services/chatService';
|
||||
import { getSimpleRoleInfo } from '../../../services/roleService';
|
||||
@@ -8,8 +8,9 @@ import { checkTask } from '../../../services/task/taskService';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { getFriendRelationType } from '../../../services/friendService';
|
||||
import { GVGLeagueModel } from '../../../db/GVGLeague';
|
||||
import { getGVGGroupIdOfServer } from '../../../services/serverService';
|
||||
import { getAllGroupOfServer } from '../../../services/serverService';
|
||||
import { getGuildCodeString } from '../../../services/gvg/gvgRecService';
|
||||
import { GroupMessageType } from '../../../db/GroupMessage';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
@@ -36,22 +37,26 @@ export class ChatHandler {
|
||||
const guildCode = session.get('guildCode');
|
||||
|
||||
const sid = session.get('sid');
|
||||
let channelId = '', otherInfo = '';
|
||||
if (channel === CHANNEL_PREFIX.WORLD) channelId = `${serverId}`;
|
||||
if (channel === CHANNEL_PREFIX.GUILD) channelId = guildCode;
|
||||
let channelIds: (string|number)[] = [], otherInfo = '';
|
||||
if (channel === CHANNEL_PREFIX.WORLD) channelIds.push(serverId);
|
||||
if (channel === CHANNEL_PREFIX.GUILD) channelIds.push(guildCode);
|
||||
if (channel === CHANNEL_PREFIX.GVG) {
|
||||
let groupId = await getGVGGroupIdOfServer(serverId);
|
||||
channelId = `${groupId}`;
|
||||
let groupIds = await getAllGroupOfServer(serverId);
|
||||
groupIds.forEach(groupId => channelIds.push(groupId));
|
||||
otherInfo = genCode(10);
|
||||
}
|
||||
if (channel == CHANNEL_PREFIX.LEAGUE) {
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
if(!myLeague) return resResult(STATUS.GVG_NOT_JOIN_LEAGUE);
|
||||
channelId = myLeague.leagueCode;
|
||||
channelIds.push(myLeague.leagueCode);
|
||||
otherInfo = getGuildCodeString(myLeague);
|
||||
}
|
||||
const msgData = await createGroupMsg(roleId, roleName, channel, channelId, type, MSG_SOURCE.ROLE_SEND_TEXT, content, targetRoleId, targetMsgCode, otherInfo);
|
||||
if (!msgData) return resResult(STATUS.WRONG_PARMS);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
let msgData: GroupMessageType;
|
||||
for(let channelId of channelIds) {
|
||||
msgData = await createGroupMsg(roleId, roleName, channel, `${channelId}`, type, MSG_SOURCE.ROLE_SEND_TEXT, content, targetRoleId, targetMsgCode, otherInfo);
|
||||
if (!msgData) return resResult(STATUS.WRONG_PARMS);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
}
|
||||
|
||||
// 任务
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.CHAT, { chatType: getChannelType(channel) });
|
||||
|
||||
Reference in New Issue
Block a user