From c9d7b63ef715f0240f16f4f83c502be80f9b3fd4 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 11 Aug 2022 12:19:03 +0800 Subject: [PATCH 1/5] Multiple gateways --- internal/msg_gateway/gate/ws_server.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/msg_gateway/gate/ws_server.go b/internal/msg_gateway/gate/ws_server.go index c92aa6a28..12844eab4 100644 --- a/internal/msg_gateway/gate/ws_server.go +++ b/internal/msg_gateway/gate/ws_server.go @@ -144,7 +144,6 @@ func (ws *WServer) MultiTerminalLoginCheckerWithLock(uid string, platformID int, rwLock.Lock() defer rwLock.Unlock() log.NewInfo(operationID, utils.GetSelfFuncName(), " rpc args: ", uid, platformID, token) - return switch config.Config.MultiLoginPolicy { case constant.AllLoginButSameTermKick: if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn] From 78c807a514201fa596b501631e10cd131f74fb30 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 11 Aug 2022 16:06:35 +0800 Subject: [PATCH 2/5] add Invitation Code --- internal/demo/register/send_code.go | 11 ++++++----- internal/demo/register/set_password.go | 1 + pkg/common/db/model_struct.go | 16 +++++++++++----- pkg/common/db/mysql.go | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/internal/demo/register/send_code.go b/internal/demo/register/send_code.go index cd67c0c04..c7fca46e6 100644 --- a/internal/demo/register/send_code.go +++ b/internal/demo/register/send_code.go @@ -34,11 +34,12 @@ func init() { } type paramsVerificationCode struct { - Email string `json:"email"` - PhoneNumber string `json:"phoneNumber"` - OperationID string `json:"operationID" binding:"required"` - UsedFor int `json:"usedFor"` - AreaCode string `json:"areaCode"` + Email string `json:"email"` + PhoneNumber string `json:"phoneNumber"` + OperationID string `json:"operationID" binding:"required"` + UsedFor int `json:"usedFor"` + AreaCode string `json:"areaCode"` + InvitationCode string `json:"invitationCode"` } func SendVerificationCode(c *gin.Context) { diff --git a/internal/demo/register/set_password.go b/internal/demo/register/set_password.go index f88b9b42c..a553a10cd 100644 --- a/internal/demo/register/set_password.go +++ b/internal/demo/register/set_password.go @@ -30,6 +30,7 @@ type ParamsSetPassword struct { FaceURL string `json:"faceURL"` OperationID string `json:"operationID" binding:"required"` AreaCode string `json:"areaCode"` + InvitationCode string `json:"invitationCode"` } func SetPassword(c *gin.Context) { diff --git a/pkg/common/db/model_struct.go b/pkg/common/db/model_struct.go index cd08ec8ae..ea2c0734d 100644 --- a/pkg/common/db/model_struct.go +++ b/pkg/common/db/model_struct.go @@ -3,11 +3,17 @@ package db import "time" type Register struct { - Account string `gorm:"column:account;primary_key;type:char(255)" json:"account"` - Password string `gorm:"column:password;type:varchar(255)" json:"password"` - Ex string `gorm:"column:ex;size:1024" json:"ex"` - UserID string `gorm:"column:user_id;type:varchar(255)" json:"userID"` - AreaCode string `gorm:"column:area_code;type:varchar(255)"` + Account string `gorm:"column:account;primary_key;type:char(255)" json:"account"` + Password string `gorm:"column:password;type:varchar(255)" json:"password"` + Ex string `gorm:"column:ex;size:1024" json:"ex"` + UserID string `gorm:"column:user_id;type:varchar(255)" json:"userID"` + AreaCode string `gorm:"column:area_code;type:varchar(255)"` + InvitationCode string `gorm:"column:invitation_code;type:varchar(255)"` +} + +type Invitation struct { + InvitationCode string `gorm:"column:invitation_code;primary_key;type:varchar(255)"` + CreateTime time.Time `gorm:"column:create_time"` } // diff --git a/pkg/common/db/mysql.go b/pkg/common/db/mysql.go index e794b4884..58f651d94 100644 --- a/pkg/common/db/mysql.go +++ b/pkg/common/db/mysql.go @@ -78,7 +78,7 @@ func initMysqlDB() { &GroupMember{}, &GroupRequest{}, &User{}, - &Black{}, &ChatLog{}, &Register{}, &Conversation{}, &AppVersion{}, &Department{}, &BlackList{}, &IpLimit{}, &UserIpLimit{}) + &Black{}, &ChatLog{}, &Register{}, &Conversation{}, &AppVersion{}, &Department{}, &BlackList{}, &IpLimit{}, &UserIpLimit{}, &Invitation{}) db.Set("gorm:table_options", "CHARSET=utf8") db.Set("gorm:table_options", "collation=utf8_unicode_ci") From a2ddf3567cef39c9f236610b92a2e435be14d0bd Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 11 Aug 2022 16:51:21 +0800 Subject: [PATCH 3/5] callback kickoff --- pkg/base_info/auth_api_struct.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/base_info/auth_api_struct.go b/pkg/base_info/auth_api_struct.go index fea71aa58..4f26084f5 100644 --- a/pkg/base_info/auth_api_struct.go +++ b/pkg/base_info/auth_api_struct.go @@ -30,7 +30,7 @@ type UserTokenReq struct { Secret string `json:"secret" binding:"required,max=32"` Platform int32 `json:"platform" binding:"required,min=1,max=8"` UserID string `json:"userID" binding:"required,min=1,max=64"` - LoginIp string `json:"loginIp" binding:"required,max=15"` + LoginIp string `json:"loginIp"` OperationID string `json:"operationID" binding:"required"` } From 54cdb24cec1e870527656eca5107d27924a3cfb1 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Thu, 11 Aug 2022 20:04:15 +0800 Subject: [PATCH 4/5] user add delete cache --- internal/rpc/user/user.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 711395506..f8d019838 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -467,6 +467,10 @@ func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbUser.Se log.NewError(req.OperationID, "SetGlobalRecvMessageOpt failed ", err.Error(), user) return &pbUser.SetGlobalRecvMessageOptResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil } + if err := rocksCache.DelUserInfoFromCache(user.UserID); err != nil { + log.NewError(req.OperationID, "DelUserInfoFromCache failed ", err.Error(), req.String()) + return &pbUser.SetGlobalRecvMessageOptResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil + } chat.UserInfoUpdatedNotification(req.OperationID, req.UserID, req.UserID) return &pbUser.SetGlobalRecvMessageOptResp{CommonResp: &pbUser.CommonResp{}}, nil } From f3e71fec91027a72e1dbf7b5a4712174b817d0a5 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 11 Aug 2022 20:25:33 +0800 Subject: [PATCH 5/5] callback kickoff --- pkg/common/db/RedisModel.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/common/db/RedisModel.go b/pkg/common/db/RedisModel.go index 535acd2e8..8ad30f878 100644 --- a/pkg/common/db/RedisModel.go +++ b/pkg/common/db/RedisModel.go @@ -253,8 +253,8 @@ func (d *DataBases) CleanUpOneUserAllMsgFromRedis(userID string, operationID str if err != nil { return utils.Wrap(err, "") } - if err = d.RDB.Del(ctx, vals...).Err(); err != nil { - return utils.Wrap(err, "") + for _, v := range vals { + err = d.RDB.Del(ctx, v).Err() } return nil }