1
This commit is contained in:
parent
ff4f33b972
commit
89e94a8557
@ -139,12 +139,44 @@ func (this *player) GetAttachment(mails []common.Mail, c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if errCode, err := q5.ToInt64Ex(rspObj.ErrCode); err == nil && errCode == 0 {
|
||||
this.DeleteMails(mails)
|
||||
this.ReceivedMails(mails)
|
||||
}
|
||||
c.String(200, rsp.GetRawData())
|
||||
})
|
||||
}
|
||||
|
||||
func (this *player) ReceivedMails(mails []common.Mail) error {
|
||||
this.checkLock()
|
||||
var resultErr error
|
||||
var nowTime int64
|
||||
for _, m := range(mails) {
|
||||
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
|
||||
}
|
||||
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
|
||||
}
|
||||
mi.state = constant.INBOX_STATE_DELETED
|
||||
mi.expireTime = m.GetExpireTime()
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultErr
|
||||
}
|
||||
|
||||
func (this *player) DeleteMails(mails []common.Mail) error {
|
||||
this.checkLock()
|
||||
var resultErr error
|
||||
@ -153,7 +185,7 @@ func (this *player) DeleteMails(mails []common.Mail) error {
|
||||
if m.IsValid(this) {
|
||||
mi := this.getInbox(m.GetMailId())
|
||||
if mi == nil {
|
||||
if m.HasAttachment() {
|
||||
if !m.HasAttachment() {
|
||||
err := model.Inbox.Delete(this.GetAccountId(), m.GetMailId(), nowTime, m.GetExpireTime())
|
||||
if err != nil {
|
||||
resultErr = err
|
||||
@ -166,7 +198,7 @@ func (this *player) DeleteMails(mails []common.Mail) error {
|
||||
this.inboxHash[mi.mailId] = mi
|
||||
}
|
||||
} else if mi.state != constant.INBOX_STATE_DELETED {
|
||||
if !m.HasAttachment() || mi.state != constant.INBOX_STATE_RECEIVED {
|
||||
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
|
||||
@ -190,10 +222,10 @@ func (this *player) checkLock() {
|
||||
func (this *player) load() {
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.MAIL_DB,
|
||||
"SELECT * FROM t_inbox WHERE account_id=? AND expiretime<?",
|
||||
"SELECT * FROM t_inbox WHERE account_id=? AND expiretime>?",
|
||||
[]string{
|
||||
this.GetAccountId(),
|
||||
q5.ToString(f5.GetApp().GetRealSeconds() + 3600 * 24 * 7),
|
||||
q5.ToString(f5.GetApp().GetRealSeconds() - 3600 * 24 * 7),
|
||||
},
|
||||
func (err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user