This commit is contained in:
aozhiwei 2024-05-10 15:18:40 +08:00
parent b85af87e19
commit 338f311cf4
3 changed files with 20 additions and 2 deletions

View File

@ -38,6 +38,7 @@ type Player interface {
GetAttachment([]Mail) error
DeleteMails([]Mail) error
IsReadable(Mail) bool
IsUnread(Mail) bool
}
type PlayerMgr interface {

View File

@ -95,6 +95,11 @@ func (this *mail) fillMailDto(hum common.Player, p *common.MailDto) bool {
p.Subject = this.subject
p.Content = this.content
//p.Flags
if hum.IsUnread(this) {
p.Flags = 1 << 0
} else {
p.Flags = 0
}
p.SendTime = this.sendTime
p.ExpireTime = this.expireTime
p.MailType = this.mailType

View File

@ -117,7 +117,7 @@ func (this *player) DeleteMails(mails []common.Mail) error {
}
func (this *player) checkLock() {
if !this.lock.TryLock() {
if this.lock.TryLock() {
panic("player checkLock error")
}
}
@ -153,7 +153,19 @@ func (this *player) getInbox(mailId int64) *inbox {
}
}
func (this* player) IsReadable(mail common.Mail) bool {
func (this* player) IsReadable(m common.Mail) bool {
mi := this.getInbox(m.GetMailId())
if mi != nil {
return mi.state != constant.INBOX_STATE_DELETED
}
return true
}
func (this* player) IsUnread(m common.Mail) bool {
mi := this.getInbox(m.GetMailId())
if mi != nil {
return mi.state != constant.INBOX_STATE_NONE
}
return true
}