1
This commit is contained in:
parent
aa8d1e27cf
commit
ff4f33b972
@ -49,6 +49,7 @@ type PlayerMgr interface {
|
||||
type Mail interface {
|
||||
GetMailId() int64
|
||||
IsValid(Player) bool
|
||||
HasAttachment() bool
|
||||
GetExpireTime() int32
|
||||
TraverseAttachment(cb func(int32, int32))
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ const (
|
||||
INBOX_STATE_NONE = 0
|
||||
INBOX_STATE_READ = 1
|
||||
INBOX_STATE_DELETED = 2
|
||||
INBOX_STATE_RECEIVED = 3
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -77,6 +77,10 @@ func (this *mail) IsValid(hum common.Player) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *mail) HasAttachment() bool {
|
||||
return len(this.attachments) > 0
|
||||
}
|
||||
|
||||
func (this *mail) GetMailId() int64 {
|
||||
return this.mailId
|
||||
}
|
||||
|
@ -153,24 +153,28 @@ func (this *player) DeleteMails(mails []common.Mail) error {
|
||||
if m.IsValid(this) {
|
||||
mi := this.getInbox(m.GetMailId())
|
||||
if mi == nil {
|
||||
err := model.Inbox.Delete(this.GetAccountId(), m.GetMailId(), nowTime, m.GetExpireTime())
|
||||
if err != nil {
|
||||
resultErr = err
|
||||
break
|
||||
if m.HasAttachment() {
|
||||
err := model.Inbox.Delete(this.GetAccountId(), m.GetMailId(), nowTime, m.GetExpireTime())
|
||||
if err != nil {
|
||||
resultErr = err
|
||||
break
|
||||
}
|
||||
mi = new(inbox)
|
||||
mi.mailId = m.GetMailId()
|
||||
mi.state = constant.INBOX_STATE_DELETED
|
||||
mi.expireTime = m.GetExpireTime()
|
||||
this.inboxHash[mi.mailId] = mi
|
||||
}
|
||||
mi = new(inbox)
|
||||
mi.mailId = m.GetMailId()
|
||||
mi.state = constant.INBOX_STATE_DELETED
|
||||
mi.expireTime = m.GetExpireTime()
|
||||
this.inboxHash[mi.mailId] = mi
|
||||
} else if mi.state != constant.INBOX_STATE_DELETED {
|
||||
err := model.Inbox.Delete(this.GetAccountId(), m.GetMailId(), nowTime, m.GetExpireTime())
|
||||
if err != nil {
|
||||
resultErr = err
|
||||
break
|
||||
if !m.HasAttachment() || mi.state != constant.INBOX_STATE_RECEIVED {
|
||||
err := model.Inbox.Delete(this.GetAccountId(), m.GetMailId(), nowTime, m.GetExpireTime())
|
||||
if err != nil {
|
||||
resultErr = err
|
||||
break
|
||||
}
|
||||
mi.state = constant.INBOX_STATE_DELETED
|
||||
mi.expireTime = m.GetExpireTime()
|
||||
}
|
||||
mi.state = constant.INBOX_STATE_DELETED
|
||||
mi.expireTime = m.GetExpireTime()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user