1
This commit is contained in:
parent
4b99b28a97
commit
0f80a2b352
@ -250,6 +250,26 @@ func (this *mailMgr) traversePlayerMail(hum common.Player, cb func(*mail) bool)
|
||||
}
|
||||
}
|
||||
|
||||
func (this *mailMgr) removeMail(m *mail) {
|
||||
this.idHash.Delete(m.mailId)
|
||||
if m.isType(constant.MAIL_TYPE_ALL) {
|
||||
this.wholeMails.Delete(m.mailId)
|
||||
} else if m.isType(constant.MAIL_TYPE_GROUP) {
|
||||
m.traverseUserGroup(
|
||||
func (int64, *userGroup) bool {
|
||||
this.groupMails.Delete(m.mailId)
|
||||
return false
|
||||
})
|
||||
m.traverseRecipients(
|
||||
func (accountId string) bool {
|
||||
if p, ok := this.personalMails.Load(accountId); ok {
|
||||
(p.(*sync.Map)).Delete(m.mailId)
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (this *mailMgr) addMail(m *mail) {
|
||||
this.idHash.Store(m.mailId, m)
|
||||
if m.isType(constant.MAIL_TYPE_ALL) {
|
||||
@ -275,6 +295,17 @@ func (this *mailMgr) addMail(m *mail) {
|
||||
}
|
||||
|
||||
func (this *mailMgr) updateMail(m *mail) {
|
||||
oldM := this.internalGetMail(m.mailId)
|
||||
if oldM == nil {
|
||||
this.addMail(m)
|
||||
return
|
||||
}
|
||||
if oldM.mailType != m.mailType {
|
||||
panic(fmt.Sprintf("updateMail mailType error"));
|
||||
return
|
||||
}
|
||||
this.removeMail(oldM)
|
||||
this.addMail(m)
|
||||
}
|
||||
|
||||
func (this *mailMgr) addGroup(g *userGroup) {
|
||||
@ -290,15 +321,15 @@ func (this *mailMgr) getGroup(groupId int64) *userGroup {
|
||||
}
|
||||
|
||||
func (this *mailMgr) getMail(mailId string) common.Mail {
|
||||
if m := this.internalGetMail(mailId); m != nil {
|
||||
if m := this.internalGetMail(q5.ToInt64(mailId)); m != nil {
|
||||
return m
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (this *mailMgr) internalGetMail(mailId string) *mail {
|
||||
if p, ok := this.idHash.Load(q5.ToInt64(mailId)); ok {
|
||||
func (this *mailMgr) internalGetMail(mailId int64) *mail {
|
||||
if p, ok := this.idHash.Load(mailId); ok {
|
||||
return p.(*mail)
|
||||
} else {
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user