From 2f6eb5969e64ef044a558692eae450dd9c88592e Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 16 Aug 2022 21:21:29 +0800 Subject: [PATCH 1/5] getui --- internal/push/getui/push.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/push/getui/push.go b/internal/push/getui/push.go index 69b4584f9..93a55b084 100644 --- a/internal/push/getui/push.go +++ b/internal/push/getui/push.go @@ -152,10 +152,10 @@ func (g *Getui) Push(userIDList []string, alert, detailContent, operationID stri ChannelID string `json:"/message/android/notification/channel_id"` Sound string `json:"/message/android/notification/sound"` Importance string `json:"/message/android/notification/importance"` - }{ChannelID: "RingRing4", Sound: "/raw/ring001", Importance: "importance"}, + }{ChannelID: "RingRing4", Sound: "/raw/ring001", Importance: "NORMAL"}, XM: struct { ChannelID string `json:"/extra.channel_id"` - }{ChannelID: "Default"}, + }{ChannelID: "high_system"}, } pushResp := PushResp{} err = g.request(PushURL, pushReq, token, &pushResp, operationID) From 64e1361ef5a8f8549a98e04fdfe9099e56d52564 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Tue, 16 Aug 2022 23:08:16 +0800 Subject: [PATCH 2/5] fix signal bug --- internal/push/logic/push_to_client.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/push/logic/push_to_client.go b/internal/push/logic/push_to_client.go index fa4f8afb2..c22b26827 100644 --- a/internal/push/logic/push_to_client.go +++ b/internal/push/logic/push_to_client.go @@ -20,8 +20,9 @@ import ( "Open_IM/pkg/utils" "context" "encoding/json" - "github.com/golang/protobuf/proto" "strings" + + "github.com/golang/protobuf/proto" ) type OpenIMContent struct { @@ -94,8 +95,8 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) { var content string if pushMsg.MsgData.OfflinePushInfo != nil { content = pushMsg.MsgData.OfflinePushInfo.Title - - } else { + } + if content == "" { switch pushMsg.MsgData.ContentType { case constant.Text: content = constant.ContentType2PushContent[constant.Text] From 5b06791a6c36a8b68765b0f0e59182ca0d1979c3 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 16 Aug 2022 23:26:13 +0800 Subject: [PATCH 3/5] set max PlatformID = 9 --- pkg/base_info/auth_api_struct.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/base_info/auth_api_struct.go b/pkg/base_info/auth_api_struct.go index 4f26084f5..85aa2301e 100644 --- a/pkg/base_info/auth_api_struct.go +++ b/pkg/base_info/auth_api_struct.go @@ -28,7 +28,7 @@ type UserRegisterResp struct { type UserTokenReq struct { Secret string `json:"secret" binding:"required,max=32"` - Platform int32 `json:"platform" binding:"required,min=1,max=8"` + Platform int32 `json:"platform" binding:"required,min=1,max=9"` UserID string `json:"userID" binding:"required,min=1,max=64"` LoginIp string `json:"loginIp"` OperationID string `json:"operationID" binding:"required"` @@ -40,7 +40,7 @@ type UserTokenResp struct { } type ForceLogoutReq struct { - Platform int32 `json:"platform" binding:"required,min=1,max=8"` + Platform int32 `json:"platform" binding:"required,min=1,max=9"` FromUserID string `json:"fromUserID" binding:"required,min=1,max=64"` OperationID string `json:"operationID" binding:"required"` } From bda96a2175c5d39f0d37a1730e8285ec4506b4ae Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Tue, 16 Aug 2022 23:45:32 +0800 Subject: [PATCH 4/5] fix --- internal/rpc/auth/auth.go | 44 +++++++++------------------------------ 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index 91692aaf4..225d40881 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -15,7 +15,6 @@ import ( "net" "strconv" "strings" - "time" "Open_IM/pkg/common/config" @@ -30,13 +29,13 @@ func (rpc *rpcAuth) UserRegister(_ context.Context, req *pbAuth.UserRegisterReq) user.Birth = utils.UnixSecondToTime(int64(req.UserInfo.Birth)) } log.Debug(req.OperationID, "copy ", user, req.UserInfo) - Limited, LimitError := imdb.IsLimitRegisterIp(req.UserInfo.CreateIp) - if LimitError != nil { - return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: LimitError.Error()}}, nil - } - if Limited { - return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.RegisterLimit, ErrMsg: "Register Limit"}}, nil - } + // Limited, LimitError := imdb.IsLimitRegisterIp(req.UserInfo.CreateIp) + // if LimitError != nil { + // return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: LimitError.Error()}}, nil + // } + // if Limited { + // return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.RegisterLimit, ErrMsg: "Register Limit"}}, nil + // } err := imdb.UserRegister(user) if err != nil { errMsg := req.OperationID + " imdb.UserRegister failed " + err.Error() + user.UserID @@ -50,43 +49,20 @@ func (rpc *rpcAuth) UserRegister(_ context.Context, req *pbAuth.UserRegisterReq) func (rpc *rpcAuth) UserToken(_ context.Context, req *pbAuth.UserTokenReq) (*pbAuth.UserTokenResp, error) { log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String()) - user, err := imdb.GetUserByUserID(req.FromUserID) + _, err := imdb.GetUserByUserID(req.FromUserID) if err != nil { errMsg := req.OperationID + " imdb.GetUserByUserID failed " + err.Error() + req.FromUserID log.NewError(req.OperationID, errMsg) return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil } - var Limited bool - var LimitError error - if user.LoginLimit == 0 { - Limited, LimitError = imdb.IsLimitLoginIp(req.LoginIp) - } else if user.LoginLimit == 1 { - Limited, LimitError = imdb.IsLimitUserLoginIp(user.UserID, req.LoginIp) - } else if user.LoginLimit == 2 { - Limited, LimitError = imdb.UserIsBlock(user.UserID) - } - if LimitError != nil { - return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: LimitError.Error()}}, nil - } - if Limited { - return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.LoginLimit, ErrMsg: "用户被限制"}}, nil - } + tokens, expTime, err := token_verify.CreateToken(req.FromUserID, int(req.Platform)) if err != nil { errMsg := req.OperationID + " token_verify.CreateToken failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform) log.NewError(req.OperationID, errMsg) return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil } - //增加用户登录信息 - user.LoginTimes = user.LoginTimes + 1 - user.LastLoginIp = req.LoginIp - user.LastLoginTime = time.Now() - err = imdb.UpdateUserInfo(*user) - if err != nil { - errMsg := req.OperationID + " imdb.UpdateUserInfo failed " + err.Error() + req.FromUserID - log.NewError(req.OperationID, errMsg) - return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil - } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime}) return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime}, nil } From 723e304ed8cc7104af1a4cee3aea158b1c81e42d Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 16 Aug 2022 23:52:53 +0800 Subject: [PATCH 5/5] set mysql max conn --- config/config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 400f6e6aa..58cc41814 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -17,8 +17,8 @@ mysql: dbMysqlDatabaseName: openIM_v2 #默认即可 dbTableName: eMsg #默认即可 dbMsgTableNum: 1 - dbMaxOpenConns: 20 - dbMaxIdleConns: 10 + dbMaxOpenConns: 200 + dbMaxIdleConns: 100 dbMaxLifeTime: 120 mongo: