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: 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) 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] 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 } 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"` }