From 822447799d0363b8ef54761f9b1155bb5630f748 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 13 Apr 2024 21:35:51 +0800 Subject: [PATCH] 1 --- server/mailserver/mail/mailmgr.go | 20 ++++++++++++++++---- server/mailserver/player/player.go | 4 ++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/server/mailserver/mail/mailmgr.go b/server/mailserver/mail/mailmgr.go index 72109dd6..b3035c29 100644 --- a/server/mailserver/mail/mailmgr.go +++ b/server/mailserver/mail/mailmgr.go @@ -117,15 +117,27 @@ func (this *mailMgr) caDeleteMails(hum common.Player, c *gin.Context) { func (this *mailMgr) traversePlayerMail(hum common.Player, cb func(*mail) bool) { this.wholeMails.Range( func (k, v interface {}) bool { + m := v.(*mail) + if m.isValid(hum) { + cb(m) + } return true }) this.groupMails.Range( func (k, v interface {}) bool { + m := v.(*mail) + if m.isValid(hum) { + cb(m) + } return true }) - if hum, ok := this.personalMails.Load(hum.GetAccountId()); ok { - (hum.(*sync.Map)).Range( + if p, ok := this.personalMails.Load(hum.GetAccountId()); ok { + (p.(*sync.Map)).Range( func (k, v interface{}) bool { + m := v.(*mail) + if m.isValid(hum) { + cb(m) + } return true }) } @@ -138,8 +150,8 @@ func (this *mailMgr) addMail(m *mail) { } else if m.isType(constant.MAIL_TYPE_GROUP) { this.groupMails.Store(m.mailId, m) } else if m.isType(constant.MAIL_TYPE_PERSONAL) { - if hum, ok := this.personalMails.Load(m.reciver); ok { - (hum.(*sync.Map)).Store(m.mailId, m) + if p, ok := this.personalMails.Load(m.reciver); ok { + (p.(*sync.Map)).Store(m.mailId, m) } else { p := new(sync.Map) p.Store(m.mailId, m) diff --git a/server/mailserver/player/player.go b/server/mailserver/player/player.go index be75e2fc..5a945390 100644 --- a/server/mailserver/player/player.go +++ b/server/mailserver/player/player.go @@ -39,3 +39,7 @@ func (this *player) Lock() { func (this *player) UnLock() { this.lock.Unlock() } + +func (this *player) GetAccountId() string { + return this.accountId +}