fix军团:分服推送无法推全,放入chat服
This commit is contained in:
@@ -245,77 +245,3 @@ export async function settleGuildWeekly() {
|
||||
await SystemConfigModel.updateSystemConfig({settleGuildWeeklyTime: nowSeconds()}); // 记录一下
|
||||
console.log('————— settleGuildWeekly结束 —————');
|
||||
}
|
||||
|
||||
export const message = {
|
||||
getChannel: function(name: string, create: boolean = false) {
|
||||
let channel = pinus.app.get('channelService').getChannel(name, create);
|
||||
return channel
|
||||
},
|
||||
enterChannel: function (guildCode: string, roleId: string, sid: string) {
|
||||
// 加入channel
|
||||
let channel = this.getChannel(`guild${guildCode}`, true);
|
||||
let users = channel.getMembers();
|
||||
if (users.indexOf(roleId) === -1) {
|
||||
channel.add(roleId, sid);
|
||||
}
|
||||
return channel
|
||||
},
|
||||
memberQuit: function (guildCode: string, roleId: string, guild: GuildType,sid?: string) {
|
||||
// 被踢出公会
|
||||
this.pushMessageByUids(`guild${guildCode}`, 'onMemberQuit', roleId, {
|
||||
code: guildCode,
|
||||
roleId
|
||||
}, sid);
|
||||
// 更新人数减少
|
||||
this.updateInfo(guildCode, { memberCnt: guild.memberCnt });
|
||||
},
|
||||
dismiss: function(guildCode: string) {
|
||||
let channel = this.getChannel(`guild${guildCode}`);
|
||||
if(!!channel) {
|
||||
channel.pushMessage('onDismiss', resResult(STATUS.SUCCESS, { code: guildCode }));
|
||||
channel.destroy();
|
||||
}
|
||||
},
|
||||
updateInfo: function(guildCode: string, info: any) {
|
||||
let channel = this.getChannel(`guild${guildCode}`);
|
||||
if(!!channel) {
|
||||
channel.pushMessage('onGuildInfoUpdate', resResult(STATUS.SUCCESS, {code: guildCode, ...info}));
|
||||
}
|
||||
},
|
||||
changeLeader: function(guildCode: string, managerCnt: number, newLeader: RoleType, oldLeaderId: string) {
|
||||
let { roleId, roleName, sHid, headHid, lv, quitTime } = newLeader;
|
||||
this.updateInfo(guildCode, {managerCnt, leader: { roleId, roleName, sHid, headHid, lv, quitTime }});
|
||||
this.demotion(guildCode, oldLeaderId);
|
||||
this.promotion(guildCode, roleId);
|
||||
},
|
||||
demotion: function(guildCode: string, roleId: string) {
|
||||
this.pushMessageByUids(`guild${guildCode}`, 'onDemotion', roleId, {
|
||||
code: guildCode
|
||||
});
|
||||
},
|
||||
promotion: function(guildCode: string, roleId: string) {
|
||||
this.pushMessageByUids(`guild${guildCode}`, 'onPromotion', roleId, {
|
||||
code: guildCode
|
||||
});
|
||||
},
|
||||
addRec: function(guildRecType: GuildRecType) {
|
||||
let { guildCode, type, params, createTime } = guildRecType;
|
||||
let channel = this.getChannel(`guild${guildCode}`);
|
||||
if(!!channel) {
|
||||
channel.pushMessage('onGuildRecAdd', resResult(STATUS.SUCCESS, {type, params, createTime}));
|
||||
}
|
||||
},
|
||||
pushMessageByUids: function (name: string, path: string, roleId: string, message: {code: string, roleId?: string}, sid?: string) {
|
||||
|
||||
let channel = this.getChannel(name);
|
||||
let uids = [];
|
||||
if(!sid) {
|
||||
sid = channel && channel.getMember(roleId)['sid'];
|
||||
}
|
||||
if(sid) {
|
||||
uids.push({roleId, sid});
|
||||
pinus.app.get('channelService').pushMessageByUids(path, resResult(STATUS.SUCCESS, message), uids);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user