mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-27 20:30:40 +08:00
Merge branch 'shichuang' of github.com:OpenIMSDK/Open-IM-Server into shichuang
This commit is contained in:
commit
63a830cc95
@ -17,8 +17,8 @@ mysql:
|
|||||||
dbMysqlDatabaseName: openIM_v2 #默认即可
|
dbMysqlDatabaseName: openIM_v2 #默认即可
|
||||||
dbTableName: eMsg #默认即可
|
dbTableName: eMsg #默认即可
|
||||||
dbMsgTableNum: 1
|
dbMsgTableNum: 1
|
||||||
dbMaxOpenConns: 20
|
dbMaxOpenConns: 200
|
||||||
dbMaxIdleConns: 10
|
dbMaxIdleConns: 100
|
||||||
dbMaxLifeTime: 120
|
dbMaxLifeTime: 120
|
||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
|
@ -152,10 +152,10 @@ func (g *Getui) Push(userIDList []string, alert, detailContent, operationID stri
|
|||||||
ChannelID string `json:"/message/android/notification/channel_id"`
|
ChannelID string `json:"/message/android/notification/channel_id"`
|
||||||
Sound string `json:"/message/android/notification/sound"`
|
Sound string `json:"/message/android/notification/sound"`
|
||||||
Importance string `json:"/message/android/notification/importance"`
|
Importance string `json:"/message/android/notification/importance"`
|
||||||
}{ChannelID: "RingRing4", Sound: "/raw/ring001", Importance: "importance"},
|
}{ChannelID: "RingRing4", Sound: "/raw/ring001", Importance: "NORMAL"},
|
||||||
XM: struct {
|
XM: struct {
|
||||||
ChannelID string `json:"/extra.channel_id"`
|
ChannelID string `json:"/extra.channel_id"`
|
||||||
}{ChannelID: "Default"},
|
}{ChannelID: "high_system"},
|
||||||
}
|
}
|
||||||
pushResp := PushResp{}
|
pushResp := PushResp{}
|
||||||
err = g.request(PushURL, pushReq, token, &pushResp, operationID)
|
err = g.request(PushURL, pushReq, token, &pushResp, operationID)
|
||||||
|
@ -20,8 +20,9 @@ import (
|
|||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OpenIMContent struct {
|
type OpenIMContent struct {
|
||||||
@ -94,8 +95,8 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
var content string
|
var content string
|
||||||
if pushMsg.MsgData.OfflinePushInfo != nil {
|
if pushMsg.MsgData.OfflinePushInfo != nil {
|
||||||
content = pushMsg.MsgData.OfflinePushInfo.Title
|
content = pushMsg.MsgData.OfflinePushInfo.Title
|
||||||
|
}
|
||||||
} else {
|
if content == "" {
|
||||||
switch pushMsg.MsgData.ContentType {
|
switch pushMsg.MsgData.ContentType {
|
||||||
case constant.Text:
|
case constant.Text:
|
||||||
content = constant.ContentType2PushContent[constant.Text]
|
content = constant.ContentType2PushContent[constant.Text]
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"Open_IM/pkg/common/config"
|
"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))
|
user.Birth = utils.UnixSecondToTime(int64(req.UserInfo.Birth))
|
||||||
}
|
}
|
||||||
log.Debug(req.OperationID, "copy ", user, req.UserInfo)
|
log.Debug(req.OperationID, "copy ", user, req.UserInfo)
|
||||||
Limited, LimitError := imdb.IsLimitRegisterIp(req.UserInfo.CreateIp)
|
// Limited, LimitError := imdb.IsLimitRegisterIp(req.UserInfo.CreateIp)
|
||||||
if LimitError != nil {
|
// if LimitError != nil {
|
||||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: LimitError.Error()}}, nil
|
// return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: LimitError.Error()}}, nil
|
||||||
}
|
// }
|
||||||
if Limited {
|
// if Limited {
|
||||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.RegisterLimit, ErrMsg: "Register Limit"}}, nil
|
// return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.RegisterLimit, ErrMsg: "Register Limit"}}, nil
|
||||||
}
|
// }
|
||||||
err := imdb.UserRegister(user)
|
err := imdb.UserRegister(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := req.OperationID + " imdb.UserRegister failed " + err.Error() + user.UserID
|
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) {
|
func (rpc *rpcAuth) UserToken(_ context.Context, req *pbAuth.UserTokenReq) (*pbAuth.UserTokenResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
||||||
user, err := imdb.GetUserByUserID(req.FromUserID)
|
_, err := imdb.GetUserByUserID(req.FromUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := req.OperationID + " imdb.GetUserByUserID failed " + err.Error() + req.FromUserID
|
errMsg := req.OperationID + " imdb.GetUserByUserID failed " + err.Error() + req.FromUserID
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
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))
|
tokens, expTime, err := token_verify.CreateToken(req.FromUserID, int(req.Platform))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := req.OperationID + " token_verify.CreateToken failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform)
|
errMsg := req.OperationID + " token_verify.CreateToken failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform)
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
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})
|
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
|
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime}, nil
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ type UserRegisterResp struct {
|
|||||||
|
|
||||||
type UserTokenReq struct {
|
type UserTokenReq struct {
|
||||||
Secret string `json:"secret" binding:"required,max=32"`
|
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"`
|
UserID string `json:"userID" binding:"required,min=1,max=64"`
|
||||||
LoginIp string `json:"loginIp"`
|
LoginIp string `json:"loginIp"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
@ -40,7 +40,7 @@ type UserTokenResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ForceLogoutReq 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"`
|
FromUserID string `json:"fromUserID" binding:"required,min=1,max=64"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user