save
This commit is contained in:
parent
14223c4f96
commit
c834b49870
@ -82,6 +82,8 @@ func (mm *MailMgr) LoadFromDB() {
|
||||
attachmentsStr := q5.ToString(*rows.GetByName("attachments"))
|
||||
if len(attachmentsStr) > 0 {
|
||||
m.ParseAttachments(attachmentsStr)
|
||||
} else {
|
||||
m.ATT = make([]*Attachment, 0)
|
||||
}
|
||||
|
||||
mm.AddMail(m)
|
||||
|
@ -35,20 +35,18 @@ func (mm *MailMgr) AddMail(m *Mail) {
|
||||
}
|
||||
|
||||
func (mm *MailMgr) GetMails(player common.Player) []*Mail {
|
||||
gameMails := mm.gameMailHash[constant.GAMEID]
|
||||
playerMails := mm.playerMailHash[player.GetAccountId()]
|
||||
playerMailSize := len(playerMails)
|
||||
if len(gameMails)+playerMailSize == 0 {
|
||||
return nil
|
||||
}
|
||||
gameMailList := mm.gameMailHash[constant.GAMEID]
|
||||
playerMailList := mm.playerMailHash[player.GetAccountId()]
|
||||
|
||||
resMailsSize := len(gameMails)
|
||||
if playerMailSize > 0 {
|
||||
resMailsSize += playerMailSize
|
||||
}
|
||||
gameMailSize := len(gameMailList)
|
||||
playerMailSize := len(playerMailList)
|
||||
totalSize := gameMailSize + playerMailSize
|
||||
resMailList := make([]*Mail, 0, totalSize)
|
||||
|
||||
resMailList := make([]*Mail, 0, resMailsSize)
|
||||
for _, gMail := range gameMails {
|
||||
if totalSize == 0 {
|
||||
return resMailList
|
||||
}
|
||||
for _, gMail := range gameMailList {
|
||||
newMail := &Mail{
|
||||
GameId: gMail.GameId,
|
||||
MailId: gMail.MailId,
|
||||
@ -74,7 +72,7 @@ func (mm *MailMgr) GetMails(player common.Player) []*Mail {
|
||||
}
|
||||
|
||||
if playerMailSize > 0 {
|
||||
for _, pMail := range playerMails {
|
||||
for _, pMail := range playerMailList {
|
||||
if player.IsUnreadMail(pMail.MailId) {
|
||||
pMail.Flag = 0
|
||||
} else {
|
||||
|
@ -11,21 +11,19 @@ func Auth() gin.HandlerFunc {
|
||||
accountID := c.Query("account_id")
|
||||
sessionID := c.Query("session_id")
|
||||
if accountID == "" || sessionID == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"errcode": http.StatusBadRequest,
|
||||
"errmsg": "Bad Request: Missing account_id or session_id",
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
|
||||
"errcode": http.StatusUnauthorized,
|
||||
"errmsg": "Bad Request: authorization account_id or session_id is not provided",
|
||||
})
|
||||
f5.GetSysLog().Info("logUnauthorizedAccess, clientIP:%s, requestURL:%s", c.ClientIP(), c.Request.URL.String())
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
if !isValidSession(accountID, sessionID) {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
f5.GetSysLog().Info("logUnauthorizedAccess, clientIP:%s, requestURL:%s", c.ClientIP(), c.Request.URL.String())
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
|
||||
"errcode": http.StatusUnauthorized,
|
||||
"errmsg": "Unauthorized",
|
||||
"errmsg": "Bad Request: token is invalid",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package player
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@ -30,7 +29,7 @@ func (pm *PlayerMgr) GetPlayer(accountId string) *Player {
|
||||
func (pm *PlayerMgr) AsyncGetPlayer(accountId string) *Player {
|
||||
p := pm.GetPlayer(accountId)
|
||||
if p != nil && !p.IsCacheExpired() {
|
||||
f5.GetSysLog().Info("GetPlayer(%s) from cache", accountId)
|
||||
// f5.GetSysLog().Info("GetPlayer(%s) from cache", accountId)
|
||||
return p
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user