diff --git a/internal/api/chat/send_msg.go b/internal/api/chat/send_msg.go index 8522ae228..3909ac125 100644 --- a/internal/api/chat/send_msg.go +++ b/internal/api/chat/send_msg.go @@ -44,7 +44,7 @@ func newUserSendMsgReq(token string, params *paramsUserSendMsg) *pbChat.SendMsgR GroupID: params.Data.GroupID, ClientMsgID: params.Data.ClientMsgID, SenderPlatformID: params.SenderPlatformID, - SenderNickName: params.SenderNickName, + SenderNickname: params.SenderNickName, SenderFaceURL: params.SenderFaceURL, SessionType: params.Data.SessionType, MsgFrom: params.Data.MsgFrom, diff --git a/pkg/common/db/redisModel.go b/pkg/common/db/redisModel.go index a9d552699..7364d7e68 100644 --- a/pkg/common/db/redisModel.go +++ b/pkg/common/db/redisModel.go @@ -91,10 +91,15 @@ func (d *DataBases) SetTokenMapByUidPid(userID string, platformID int32, m map[s _, err := d.Exec("hmset", key, redis.Args{}.Add().AddFlat(m)...) return err } +func (d *DataBases) DeleteTokenByUidPid(userID string, platformID int32, fields []string) error { + key := uidPidToken + userID + ":" + constant.PlatformIDToName(platformID) + _, err := d.Exec("HDEL", key, redis.Args{}.Add().AddFlat(fields)...) + return err +} func (d *DataBases) SetSingleConversationMsgOpt(userID, conversationID string, opt int) error { key := conversationReceiveMessageOpt + userID - _, err1 := d.Exec("HSet", key, conversationID, opt) - return err1 + _, err := d.Exec("HSet", key, conversationID, opt) + return err } func (d *DataBases) GetSingleConversationMsgOpt(userID, conversationID string) (int, error) { key := conversationReceiveMessageOpt + userID diff --git a/pkg/common/token_verify/jwt_token.go b/pkg/common/token_verify/jwt_token.go index 1f3f444b2..4d33c3a58 100644 --- a/pkg/common/token_verify/jwt_token.go +++ b/pkg/common/token_verify/jwt_token.go @@ -6,6 +6,7 @@ import ( commonDB "Open_IM/pkg/common/db" "Open_IM/pkg/common/log" "Open_IM/pkg/utils" + "github.com/garyburd/redigo/redis" "github.com/golang-jwt/jwt/v4" "time" ) @@ -43,6 +44,21 @@ func CreateToken(userID string, platformID int32) (string, int64, error) { if err != nil { return "", 0, err } + //remove Invalid token + m, err := commonDB.DB.GetTokenMapByUidPid(userID, constant.PlatformIDToName(platformID)) + if err != nil && err != redis.ErrNil { + return "", 0, err + } + var deleteTokenKey []string + for k, v := range m { + if v != constant.NormalToken { + deleteTokenKey = append(deleteTokenKey, k) + } + } + err = commonDB.DB.DeleteTokenByUidPid(userID, platformID, deleteTokenKey) + if err != nil { + return "", 0, err + } err = commonDB.DB.AddTokenFlag(userID, platformID, tokenString, constant.NormalToken) if err != nil { return "", 0, err