✨ feat(gvg): 添加推送
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
import { addRedisChannel, redisChannelServer } from './redisService';
|
||||
import { addGVGHistoryAreas, addGVGHistoryAreaTeam, addRedisChannel, getGVGHistoryAreas, getGVGHistoryAreaTeam, redisChannelServer } from './redisService';
|
||||
import { groupRoomId } from './chatService';
|
||||
import { pinus } from 'pinus';
|
||||
import { crc32 } from 'crc';
|
||||
@@ -61,6 +61,20 @@ export async function addRoleToGroupShopChannel(roleId: string, sid: string) {
|
||||
await addRoleToChannel(roomId, roleId, sid);
|
||||
}
|
||||
|
||||
export async function addRoleToAreaChannel(roleId: string, groupId: number, serverType: number, areaIds: number[], sid: string) {
|
||||
for(let areaId of areaIds) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GVG_AREAS, `${groupId}_${serverType}_${areaId}`);
|
||||
await addRoleToChannel(roomId, roleId, sid);
|
||||
}
|
||||
await addGVGHistoryAreas(roleId, groupId, serverType, areaIds);
|
||||
}
|
||||
|
||||
export async function addRoleToAreaTeamChannel(roleId: string, groupId: number, serverType: number, areaId: number, sid: string) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GVG_AREA_BY_TEAM, `${groupId}_${serverType}_${areaId}`);
|
||||
await addRoleToChannel(roomId, roleId, sid);
|
||||
await addGVGHistoryAreaTeam(roleId, groupId, serverType, areaId);
|
||||
}
|
||||
|
||||
async function leaveChannel(roomId: string, roleId: string, sid: string) {
|
||||
const channelSid = await channelServer(roomId);
|
||||
await pinus.app.rpc.chat.chatRemote.leaveChannel.toServer(channelSid, roomId, roleId, sid);
|
||||
@@ -102,6 +116,22 @@ export async function leaveGuildChannel(roleId: string, sid: string, guildCode:
|
||||
await leaveChannel(roomId, roleId, sid);
|
||||
}
|
||||
|
||||
export async function leaveGVGAreaChannel(roleId: string, sid: string) {
|
||||
let keys = await getGVGHistoryAreas(roleId)||[];
|
||||
for(let key of keys) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GVG_AREAS, key);
|
||||
await leaveChannel(roomId, roleId, sid);
|
||||
}
|
||||
}
|
||||
|
||||
export async function leaveGVGAreaTeamChannel(roleId: string, sid: string) {
|
||||
let channelName = await getGVGHistoryAreaTeam(roleId);
|
||||
if(channelName) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GVG_AREA_BY_TEAM, channelName);
|
||||
await leaveChannel(roomId, roleId, sid);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getWorldChannelSid(serverId: number) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
const channelSid = await channelServer(roomId);
|
||||
@@ -138,6 +168,18 @@ export async function getGroupShopSid() {
|
||||
return channelSid;
|
||||
}
|
||||
|
||||
export async function getGVGAreaChannelSid(groupId: number, serverType: number, areaId: number) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GVG_AREAS, `${groupId}_${serverType}_${areaId}`);
|
||||
const channelSid = await channelServer(roomId);
|
||||
return channelSid;
|
||||
}
|
||||
|
||||
export async function getGVGAreaTeamChannelSid(groupId: number, serverType: number, areaId: number) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GVG_AREA_BY_TEAM, `${groupId}_${serverType}_${areaId}`);
|
||||
const channelSid = await channelServer(roomId);
|
||||
return channelSid;
|
||||
}
|
||||
|
||||
async function delChannel(roomId: string) {
|
||||
const channelSid = await channelServer(roomId);
|
||||
await pinus.app.rpc.chat.chatRemote.deleteChannel.toServer(channelSid, roomId);
|
||||
|
||||
Reference in New Issue
Block a user