后台:邮件审核人
This commit is contained in:
@@ -7,6 +7,8 @@ export interface DicMail {
|
||||
readonly id: number;
|
||||
// 内容 %d 替换
|
||||
readonly content: string;
|
||||
readonly title: string;
|
||||
readonly sendName: string;
|
||||
readonly time: number;
|
||||
}
|
||||
|
||||
@@ -16,6 +18,8 @@ export function loadMail() {
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_MAIL);
|
||||
arr.forEach(o => {
|
||||
if(o.title == '&') o.title = '';
|
||||
if(o.sendName == '&') o.sendName = '';
|
||||
o.time = o.time * 60 * 60;
|
||||
dicMail.set(o.id, o);
|
||||
});
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
import { mailInit, setMails, GMMail } from '../gmData/gmMail';
|
||||
import { nowSeconds } from '../timeUtil';
|
||||
const ALL_SERVER = 0;
|
||||
export let gmData:any = {};
|
||||
export async function init() {
|
||||
gmData.mails = await mailInit();
|
||||
}
|
||||
|
||||
export function getGmMails(updatedMailAt: number, serverId: number) {
|
||||
let list = [];
|
||||
let nowTime = nowSeconds();
|
||||
let serverIds = [serverId, ALL_SERVER];
|
||||
for (let serverId of serverIds) {
|
||||
let gmServerData = gmData.mails.get(serverId);
|
||||
if (!gmServerData)
|
||||
continue;
|
||||
gmServerData.forEach((gmMail)=>{
|
||||
if (gmMail.updatedAt >= updatedMailAt || gmMail.sendTime > updatedMailAt || gmMail.endTime > nowTime )
|
||||
list.push(gmMail);
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
export function getUseGmMails(serverId: number) {
|
||||
let list = new Map<string, GMMail>();
|
||||
let serverIds = [serverId, ALL_SERVER];
|
||||
let nowTime = nowSeconds();
|
||||
for (let serverId of serverIds) {
|
||||
let gmServerData = gmData.mails.get(serverId);
|
||||
if (!gmServerData)
|
||||
continue;
|
||||
gmServerData.forEach((gmMail)=>{
|
||||
if (gmMail.endTime > nowTime)
|
||||
list.set(gmMail.id, gmMail);
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
export function getGmMailById(id: string, serverId: number, nowTime: number) {
|
||||
let gmMail;
|
||||
if (!!gmData.mails.get(serverId)) {
|
||||
gmMail = gmData.mails.get(serverId).get(id);
|
||||
}
|
||||
if (!gmMail) {
|
||||
if (!!gmData.mails.get(ALL_SERVER)) {
|
||||
gmMail = gmData.mails.get(ALL_SERVER).get(id);
|
||||
}
|
||||
}
|
||||
if (!gmMail || gmMail.endTime < nowTime)
|
||||
return null;
|
||||
return gmMail;
|
||||
}
|
||||
|
||||
export function setGmMails(mails: GMMail[]) {
|
||||
setMails(mails, gmData.mails);
|
||||
}
|
||||
|
||||
|
||||
export function getGmUseMails(serverId: number) {
|
||||
let list = new Map<number, any>();
|
||||
if (!!gmData.mails.get(serverId)) {
|
||||
list = gmData.mails.get(serverId);
|
||||
}
|
||||
let serverMail = gmData.mails.get(ALL_SERVER);
|
||||
if (!!serverMail) {
|
||||
list = Object.assign(list, serverMail);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
import { RewardInter } from '../interface';
|
||||
import { GMMailModel } from '../../db/GMMail';
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface GMMail {
|
||||
readonly id: string;
|
||||
readonly sendRoles?: Array<{roleId: string, status: number}>;
|
||||
readonly goods: Array<RewardInter>;
|
||||
readonly sendTime: number;
|
||||
readonly endTime: number;
|
||||
readonly content: string;
|
||||
readonly gmMailType: number;
|
||||
readonly updatedAt: number;
|
||||
readonly serverId: number;
|
||||
readonly sendName: string;
|
||||
}
|
||||
|
||||
const GMMailKeys: KeysEnum<GMMail> = {
|
||||
id: true,
|
||||
sendRoles: true,
|
||||
goods: true,
|
||||
sendTime: true,
|
||||
endTime: true,
|
||||
content: true,
|
||||
gmMailType: true,
|
||||
updatedAt: true,
|
||||
serverId: true,
|
||||
sendName: true
|
||||
};
|
||||
|
||||
export async function mailInit() {
|
||||
let gmMail = new Map<number, any>();
|
||||
let mails = await GMMailModel.getMails();
|
||||
mails.map((o:any)=>{
|
||||
o.id = o._id.toString();
|
||||
o.updatedAt = Math.floor(o.updatedAt.getTime()/1000);
|
||||
let mail = gmMail.get(o.serverId);
|
||||
if (!mail)
|
||||
mail = new Map<string, GMMail>();
|
||||
o.sendName = o.sendName||'系统';
|
||||
mail.set(o.id, _.pick(o, Object.keys(GMMailKeys)));
|
||||
gmMail.set(o.serverId, mail);
|
||||
});
|
||||
return gmMail;
|
||||
}
|
||||
|
||||
|
||||
export function setMails(mails:GMMail[], gmMail) {
|
||||
mails.map((o:any)=>{
|
||||
o.id = o._id.toString();
|
||||
o.updatedAt = Math.floor(o.updatedAt.getTime()/1000);
|
||||
o.sendName = o.sendName||'系统';
|
||||
let mail = gmMail.get(o.serverId);
|
||||
if (!mail)
|
||||
mail = new Map<string, GMMail>();
|
||||
mail.set(o.id, _.pick(o, Object.keys(GMMailKeys)));
|
||||
gmMail.set(o.serverId, mail);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user