Merge branch 'shichuang' of github.com:OpenIMSDK/Open-IM-Server into shichuang

pull/351/head
wangchuxiao 2 years ago
commit 63a830cc95

@ -17,8 +17,8 @@ mysql:
dbMysqlDatabaseName: openIM_v2 #默认即可
dbTableName: eMsg #默认即可
dbMsgTableNum: 1
dbMaxOpenConns: 20
dbMaxIdleConns: 10
dbMaxOpenConns: 200
dbMaxIdleConns: 100
dbMaxLifeTime: 120
mongo:

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

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

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

@ -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"`
}

Loading…
Cancel
Save