save
This commit is contained in:
parent
ef23d1aad3
commit
c029301901
@ -18,12 +18,12 @@ type Mail struct {
|
|||||||
Subject string `json:"subject"`
|
Subject string `json:"subject"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
Flag int `json:"flags"`
|
Flag int `json:"flags"`
|
||||||
SendTime int `json:"sendtime"`
|
SendTime int32 `json:"sendtime"`
|
||||||
Expiretime int `json:"expiretime"`
|
ExpireTime int32 `json:"expiretime"`
|
||||||
Mailtype int `json:"mailtype"`
|
Mailtype int `json:"mailtype"`
|
||||||
Mailsubtype int `json:"mailsubtype"`
|
Mailsubtype int `json:"mailsubtype"`
|
||||||
Usertype int `json:"-"`
|
Usertype int `json:"-"`
|
||||||
Createtime int `json:"-"`
|
CreateTime int32 `json:"-"`
|
||||||
Ext string `json:"ext"`
|
Ext string `json:"ext"`
|
||||||
ATT []*Attachments `json:"attachments"`
|
ATT []*Attachments `json:"attachments"`
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package mail
|
|||||||
import (
|
import (
|
||||||
"f5"
|
"f5"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"main/common"
|
||||||
"main/constant"
|
"main/constant"
|
||||||
"main/player"
|
|
||||||
"q5"
|
"q5"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ type MailMgr struct {
|
|||||||
playerMailHash map[string]map[int64]*Mail
|
playerMailHash map[string]map[int64]*Mail
|
||||||
currReqId int64
|
currReqId int64
|
||||||
lastFetchMailTick int64
|
lastFetchMailTick int64
|
||||||
accountHash map[string]*player.Player
|
accountHash map[string]*common.Player
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mm *MailMgr) Init() {
|
func (mm *MailMgr) Init() {
|
||||||
@ -27,6 +27,13 @@ func (mm *MailMgr) Init() {
|
|||||||
func (mm *MailMgr) UnInit() {
|
func (mm *MailMgr) UnInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mm *MailMgr) GetMail(mailId int64) *Mail {
|
||||||
|
if m, exists := mm.allMailHash[mailId]; exists {
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (mm *MailMgr) FetchMailFromDB() {
|
func (mm *MailMgr) FetchMailFromDB() {
|
||||||
timer := f5.GetTimer()
|
timer := f5.GetTimer()
|
||||||
timer.SetInterval(1000, func(e int32, args *q5.Args) {
|
timer.SetInterval(1000, func(e int32, args *q5.Args) {
|
||||||
@ -67,9 +74,9 @@ func (mm *MailMgr) LoadFromDB() {
|
|||||||
m.Mailtype = q5.ToInt(*rows.GetByName("mailtype"))
|
m.Mailtype = q5.ToInt(*rows.GetByName("mailtype"))
|
||||||
m.Mailsubtype = q5.ToInt(*rows.GetByName("mailsubtype"))
|
m.Mailsubtype = q5.ToInt(*rows.GetByName("mailsubtype"))
|
||||||
m.Usertype = q5.ToInt(*rows.GetByName("usertype"))
|
m.Usertype = q5.ToInt(*rows.GetByName("usertype"))
|
||||||
m.SendTime = q5.ToInt(*rows.GetByName("sendtime"))
|
m.SendTime = q5.ToInt32(*rows.GetByName("sendtime"))
|
||||||
m.Expiretime = q5.ToInt(*rows.GetByName("expiretime"))
|
m.ExpireTime = q5.ToInt32(*rows.GetByName("expiretime"))
|
||||||
m.Createtime = q5.ToInt(*rows.GetByName("createtime"))
|
m.CreateTime = q5.ToInt32(*rows.GetByName("createtime"))
|
||||||
// parse ATT
|
// parse ATT
|
||||||
m.ParseAttachments(q5.ToString(*rows.GetByName("attachments")))
|
m.ParseAttachments(q5.ToString(*rows.GetByName("attachments")))
|
||||||
|
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package player
|
package player
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"main/global"
|
||||||
|
"main/mail"
|
||||||
"main/ss"
|
"main/ss"
|
||||||
|
"q5"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -42,45 +46,110 @@ func (p *Player) IsDeletedMail(mailId int64) bool {
|
|||||||
return m != nil
|
return m != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) MarkMail(mailIds string) {}
|
func (p *Player) MarkMail(mailIds string) {
|
||||||
func (p *Player) DeleteMails(mailIds string) {}
|
nowUnixSec := time.Now().Unix()
|
||||||
|
mailMgrPtr := global.GetMailMgr().(*mail.MailMgr)
|
||||||
|
mailIdStrings := strings.Split(mailIds, ",")
|
||||||
|
for _, mailId := range mailIdStrings {
|
||||||
|
mailObj := mailMgrPtr.GetMail(q5.ToInt64(mailId))
|
||||||
|
if mailObj != nil {
|
||||||
|
m := &ReadMail{
|
||||||
|
mailId: mailObj.MailId,
|
||||||
|
readTime: int32(nowUnixSec),
|
||||||
|
expireTime: mailObj.ExpireTime,
|
||||||
|
}
|
||||||
|
p.ReadMailHash[mailObj.MailId] = m
|
||||||
|
p.MarkDirty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Player) DeleteMails(mailIds string) {
|
||||||
|
nowUnixSec := time.Now().Unix()
|
||||||
|
mailMgrPtr := global.GetMailMgr().(*mail.MailMgr)
|
||||||
|
|
||||||
|
mailIdStrings := strings.Split(mailIds, ",")
|
||||||
|
for _, mailId := range mailIdStrings {
|
||||||
|
mailObj := mailMgrPtr.GetMail(q5.ToInt64(mailId))
|
||||||
|
if mailObj != nil {
|
||||||
|
m := &DeletedMail{
|
||||||
|
mailId: mailObj.MailId,
|
||||||
|
deleteTime: int32(nowUnixSec),
|
||||||
|
expireTime: mailObj.ExpireTime,
|
||||||
|
}
|
||||||
|
p.DeletedMailHash[mailObj.MailId] = m
|
||||||
|
p.MarkDirty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
func (p *Player) AddToReadList(mailIds string) {}
|
func (p *Player) AddToReadList(mailIds string) {}
|
||||||
func (p *Player) GetAttachment(mailIds string) {}
|
func (p *Player) GetAttachment(mailIds string) {}
|
||||||
|
|
||||||
func (p *Player) Deserialize(accountPB *ss.MFAccountData) {
|
func (p *Player) Deserialize(accountPB *ss.MFAccountData) {
|
||||||
var nextDaySec int32 = 3600 * 24
|
var nextDaySec int32 = 3600 * 24
|
||||||
unixSec := int32(time.Now().Unix())
|
nowUnixSec := int32(time.Now().Unix())
|
||||||
|
|
||||||
for _, MFReadMail := range accountPB.GetReadMailList() {
|
for _, MFReadMail := range accountPB.GetReadMailList() {
|
||||||
expireTime := MFReadMail.GetExpireTime() + nextDaySec
|
expireTime := MFReadMail.GetExpireTime() + nextDaySec
|
||||||
if expireTime < unixSec {
|
if expireTime > nowUnixSec {
|
||||||
continue
|
readMail := &ReadMail{
|
||||||
|
mailId: MFReadMail.GetMailId(),
|
||||||
|
readTime: MFReadMail.GetReadTime(),
|
||||||
|
expireTime: MFReadMail.GetExpireTime(),
|
||||||
|
}
|
||||||
|
p.ReadMailHash[readMail.mailId] = readMail
|
||||||
|
|
||||||
|
if readMail.readTime <= 1590577793 {
|
||||||
|
delMail := &DeletedMail{
|
||||||
|
mailId: readMail.mailId,
|
||||||
|
deleteTime: readMail.readTime,
|
||||||
|
expireTime: readMail.expireTime,
|
||||||
|
}
|
||||||
|
p.DeletedMailHash[delMail.mailId] = delMail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
readMail := &ReadMail{
|
|
||||||
mailId: MFReadMail.GetMailId(),
|
|
||||||
readTime: MFReadMail.GetReadTime(),
|
|
||||||
expireTime: MFReadMail.GetExpireTime(),
|
|
||||||
}
|
|
||||||
p.ReadMailHash[readMail.mailId] = readMail
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, MFDeletedMail := range accountPB.GetDeletedMailList() {
|
for _, MFDeletedMail := range accountPB.GetDeletedMailList() {
|
||||||
expireTime := MFDeletedMail.GetExpireTime() + nextDaySec
|
expireTime := MFDeletedMail.GetExpireTime() + nextDaySec
|
||||||
if expireTime < unixSec {
|
if expireTime > nowUnixSec {
|
||||||
continue
|
deleteMail := &DeletedMail{
|
||||||
|
mailId: MFDeletedMail.GetMailId(),
|
||||||
|
deleteTime: MFDeletedMail.GetDeleteTime(),
|
||||||
|
expireTime: MFDeletedMail.GetExpireTime(),
|
||||||
|
}
|
||||||
|
p.DeletedMailHash[deleteMail.mailId] = deleteMail
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteMail := &DeletedMail{
|
|
||||||
mailId: MFDeletedMail.GetMailId(),
|
|
||||||
deleteTime: MFDeletedMail.GetDeleteTime(),
|
|
||||||
expireTime: MFDeletedMail.GetExpireTime(),
|
|
||||||
}
|
|
||||||
p.DeletedMailHash[deleteMail.mailId] = deleteMail
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) Serialize(accountPB ss.MFAccountData) {
|
func (p *Player) Serialize(accountPB *ss.MFAccountData) {
|
||||||
|
var nextDaySec int32 = 3600 * 24
|
||||||
|
nowUnixSec := time.Now().Unix()
|
||||||
|
|
||||||
|
for _, readMail := range p.ReadMailHash {
|
||||||
|
if int64(readMail.expireTime+nextDaySec) > nowUnixSec {
|
||||||
|
p2 := &ss.MFReadMail{
|
||||||
|
MailId: &readMail.mailId,
|
||||||
|
ReadTime: &readMail.readTime,
|
||||||
|
ExpireTime: &readMail.expireTime,
|
||||||
|
}
|
||||||
|
accountPB.ReadMailList = append(accountPB.ReadMailList, p2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, deletedMail := range p.DeletedMailHash {
|
||||||
|
if int64(deletedMail.expireTime+nextDaySec) > nowUnixSec {
|
||||||
|
p3 := &ss.MFDeletedMail{
|
||||||
|
MailId: &deletedMail.mailId,
|
||||||
|
DeleteTime: &deletedMail.deleteTime,
|
||||||
|
ExpireTime: &deletedMail.expireTime,
|
||||||
|
}
|
||||||
|
accountPB.DeletedMailList = append(accountPB.DeletedMailList, p3)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) SaveToDB() {}
|
func (p *Player) SaveToDB() {}
|
||||||
|
|
||||||
|
func (p *Player) MarkDirty() {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user