邮件 活跃度下发
This commit is contained in:
38
shared/pubUtils/gmData/gmDataUtil.ts
Normal file
38
shared/pubUtils/gmData/gmDataUtil.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
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 serverIds = [serverId, ALL_SERVER];
|
||||
for (let serverId of serverIds) {
|
||||
if (!gmData.mails.get(serverId))
|
||||
continue;
|
||||
gmData.mails.get(serverId).map(({updatedAt, sendTime, endTime, id, sendRoles, goods, content, gmMailType})=>{
|
||||
if (updatedAt >= updatedMailAt || sendTime > updatedMailAt || endTime < nowSeconds() )
|
||||
list.push({updatedAt, sendTime, endTime, id, sendRoles, goods, content, gmMailType});
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
export function getGmMailById(id: string, serverId: 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);
|
||||
}
|
||||
}
|
||||
return gmMail;
|
||||
}
|
||||
|
||||
export function setGmMails(mails: GMMail[]) {
|
||||
setMails(mails, gmData.mails);
|
||||
}
|
||||
Reference in New Issue
Block a user