Merge remote-tracking branch 'origin/tuoyun' into tuoyun

pull/131/head
wenxu12345 3 years ago
commit 4223b2d0f0

@ -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,

@ -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

@ -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

Loading…
Cancel
Save