邮件
This commit is contained in:
@@ -13,6 +13,8 @@ import { GuildListInfo } from '../../../pubUtils/interface';
|
||||
import { UserGuildApplyModel } from '../../../db/UserGuildApply';
|
||||
import { hasStructureConsume, getStructureConsume, gameData } from '../../../pubUtils/data';
|
||||
import { GuildRecModel } from '../../../db/GuildRec';
|
||||
import { MailModel } from '../../../db/Mail';
|
||||
import { getRedis } from '../../../services/redisService';
|
||||
|
||||
export default function (app: Application) {
|
||||
return new GuildHandler(app);
|
||||
@@ -688,4 +690,32 @@ export class GuildHandler {
|
||||
|
||||
return resResult(STATUS.SUCCESS, { list });
|
||||
}
|
||||
|
||||
// 团长发送消息给军团内所有成员的邮箱
|
||||
async sendMail(msg: { code: string, info: string }, session: BackendSession) {
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
const { code, info } = msg;
|
||||
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.SEND_MAIL, roleId, code);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const guild = await GuildModel.findByCode(code, serverId);
|
||||
if(!guild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
|
||||
const { members } = guild;
|
||||
//下发邮件
|
||||
for(let roleId of members) {
|
||||
let mail = await MailModel.addMail({roleId, goods: [], sendName: roleName, mailId: 1, content: info});
|
||||
let key = 'login_roleId_' + roleId;
|
||||
let sid = await getRedis(key);
|
||||
if (!!sid) {
|
||||
pinus.app.rpc.connector.connectorRemote.pushMessage.toServer(sid, roleId, 'onMailsAdd', [mail]);
|
||||
}
|
||||
}
|
||||
|
||||
return resResult(STATUS.SUCCESS, { isSuccess: true });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user