✨ feat(gvg): 添加联军频道
This commit is contained in:
@@ -18,6 +18,7 @@ import { comBtlLvInvalid } from './comBattleService';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { RegionModel } from '../db/Region';
|
||||
import { getGroupIdOfServer, getServersByGroupId } from './gvg/gvgService';
|
||||
import { GVGLeagueModel } from '../db/GVGLeague';
|
||||
|
||||
export * from './chatChannelService';
|
||||
export * from './sysChatService';
|
||||
@@ -75,8 +76,8 @@ async function createPrivateMsgData(roleId: string, roleName: string, type: numb
|
||||
/**
|
||||
* @description 生成群聊消息数据
|
||||
*/
|
||||
async function createGroupMsgData(roleId: string, roleName: string, channel: string, channelId: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string) {
|
||||
const result: GroupMessageParam = {roleId, roleName, channel, channelId, type, source, content, targetRoleId, targetMsgCode};
|
||||
async function createGroupMsgData(roleId: string, roleName: string, channel: string, channelId: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string, otherInfo = '') {
|
||||
const result: GroupMessageParam = {roleId, roleName, channel, channelId, type, source, content, targetRoleId, targetMsgCode, otherInfo };
|
||||
result.roomId = groupRoomId(channel, channelId);
|
||||
await setupBaseMsgParm(result);
|
||||
return result;
|
||||
@@ -120,8 +121,8 @@ export async function createPrivateMsg(roleId: string, roleName: string, type: n
|
||||
* @param {string} targetMsgCode
|
||||
* @returns
|
||||
*/
|
||||
export async function createGroupMsg(roleId: string, roleName: string, channel: string, channelId: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string) {
|
||||
const msgData: GroupMessageParam = await createGroupMsgData(roleId, roleName, channel, channelId, type, source, content, targetRoleId, targetMsgCode);
|
||||
export async function createGroupMsg(roleId: string, roleName: string, channel: string, channelId: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string, otherInfo = '') {
|
||||
const msgData: GroupMessageParam = await createGroupMsgData(roleId, roleName, channel, channelId, type, source, content, targetRoleId, targetMsgCode, otherInfo);
|
||||
const result: GroupMessageType = await GroupMessageModel.createMsg(msgData);
|
||||
return result;
|
||||
}
|
||||
@@ -170,7 +171,12 @@ export async function pushGroupMsgToRoom(msg: GroupMessageType) {
|
||||
for(let serverId of serverIds) {
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo });
|
||||
}
|
||||
}
|
||||
} else if (msg.channel == CHANNEL_PREFIX.LEAGUE) {
|
||||
let guildCodes = msg.otherInfo? msg.otherInfo.split('|'): [];
|
||||
for(let guildCode of guildCodes) {
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function pushGroupMsgToAll(msg: GroupMessageType, filterCb?: ({ lv, topLineupCe }) => boolean) {
|
||||
@@ -231,7 +237,6 @@ async function recentGroupMsgs(roomId: string, count?: number) {
|
||||
*/
|
||||
export async function recentServerGroupMsgs(serverId: number, count?: number) {
|
||||
let groupId = await getGroupIdOfServer(serverId);
|
||||
console.log('####', groupId);
|
||||
const result = await recentGroupMsgs(groupRoomId(CHANNEL_PREFIX.GVG, groupId), count);
|
||||
return result;
|
||||
}
|
||||
@@ -273,6 +278,21 @@ export async function recentGuildMsgs(guildCode: string, count?: number) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取最近的联军聊天消息
|
||||
* @export
|
||||
* @param {string} guildCode 用区服编号做房间标识
|
||||
* @param {number} [count]
|
||||
* @returns
|
||||
*/
|
||||
export async function recentLeagueMsgs(guildCode: string, count?: number) {
|
||||
if(!guildCode) return [];
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
if(!myLeague) return [];
|
||||
const result = await recentGroupMsgs(groupRoomId(CHANNEL_PREFIX.LEAGUE, myLeague.leagueCode), count);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 创建新的私聊记录
|
||||
* @param {boolean} sender 给发送者还是接收者创建,发送者发消息的时候也阅读了消息
|
||||
|
||||
Reference in New Issue
Block a user