mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-26 19:46:57 +08:00
Merge remote-tracking branch 'origin/tuoyun' into tuoyun
This commit is contained in:
commit
95c125a5af
@ -73,6 +73,8 @@ api:
|
|||||||
openImApiPort: [ 10000 ]
|
openImApiPort: [ 10000 ]
|
||||||
sdk:
|
sdk:
|
||||||
openImSdkWsPort: [ 30000 ]
|
openImSdkWsPort: [ 30000 ]
|
||||||
|
cmsapi:
|
||||||
|
openImCmsApiPort: [ 8000 ]
|
||||||
|
|
||||||
credential:
|
credential:
|
||||||
tencent:
|
tencent:
|
||||||
@ -91,7 +93,9 @@ rpcport:
|
|||||||
openImGroupPort: [ 10500 ]
|
openImGroupPort: [ 10500 ]
|
||||||
openImAuthPort: [ 10600 ]
|
openImAuthPort: [ 10600 ]
|
||||||
openImPushPort: [ 10700 ]
|
openImPushPort: [ 10700 ]
|
||||||
|
openImStatisticsPort: [ 10800 ]
|
||||||
|
openImMessageCmsPort: [ 10900 ]
|
||||||
|
openImAdminCmsPort: [ 11000 ]
|
||||||
|
|
||||||
rpcregistername:
|
rpcregistername:
|
||||||
openImUserName: User
|
openImUserName: User
|
||||||
|
@ -60,9 +60,9 @@ func SendVerificationCode(c *gin.Context) {
|
|||||||
case constant.VerificationCodeForReset:
|
case constant.VerificationCodeForReset:
|
||||||
accountKey = account + "_" + constant.VerificationCodeForResetSuffix
|
accountKey = account + "_" + constant.VerificationCodeForResetSuffix
|
||||||
}
|
}
|
||||||
log.NewInfo(params.OperationID, params.UsedFor,"begin store redis", accountKey)
|
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
code := 100000 + rand.Intn(900000)
|
code := 100000 + rand.Intn(900000)
|
||||||
|
log.NewInfo(params.OperationID, params.UsedFor,"begin store redis", accountKey, code)
|
||||||
err := db.DB.SetAccountCode(accountKey, code, config.Config.Demo.CodeTTL)
|
err := db.DB.SetAccountCode(accountKey, code, config.Config.Demo.CodeTTL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(params.OperationID, "set redis error", accountKey, "err", err.Error())
|
log.NewError(params.OperationID, "set redis error", accountKey, "err", err.Error())
|
||||||
|
@ -49,9 +49,9 @@ func Verify(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
accountKey := account + "_" + constant.VerificationCodeForRegisterSuffix
|
accountKey := account + "_" + constant.VerificationCodeForRegisterSuffix
|
||||||
code, err := db.DB.GetAccountCode(accountKey)
|
code, err := db.DB.GetAccountCode(accountKey)
|
||||||
log.NewInfo(params.OperationID, "redis phone number and verificating Code", account, code)
|
log.NewInfo(params.OperationID, "redis phone number and verificating Code", accountKey, code, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(params.OperationID, "Verification code expired", account, "err", err.Error())
|
log.NewError(params.OperationID, "Verification code expired", accountKey, "err", err.Error())
|
||||||
data := make(map[string]interface{})
|
data := make(map[string]interface{})
|
||||||
data["account"] = account
|
data["account"] = account
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code expired!", "data": data})
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code expired!", "data": data})
|
||||||
|
@ -32,7 +32,7 @@ func (mc *HistoryConsumerHandler) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string) {
|
func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string) {
|
||||||
log.InfoByKv("msg come mongo!!!", "", "msg", string(msg))
|
log.NewInfo("msg come mongo!!!", "", "msg", string(msg))
|
||||||
time := utils.GetCurrentTimestampByNano()
|
time := utils.GetCurrentTimestampByNano()
|
||||||
msgFromMQ := pbMsg.MsgDataToMQ{}
|
msgFromMQ := pbMsg.MsgDataToMQ{}
|
||||||
err := proto.Unmarshal(msg, &msgFromMQ)
|
err := proto.Unmarshal(msg, &msgFromMQ)
|
||||||
|
@ -33,7 +33,7 @@ func (pc *PersistentConsumerHandler) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pc *PersistentConsumerHandler) handleChatWs2Mysql(msg []byte, msgKey string) {
|
func (pc *PersistentConsumerHandler) handleChatWs2Mysql(msg []byte, msgKey string) {
|
||||||
log.InfoByKv("msg come here mysql!!!", "", "msg", string(msg))
|
log.NewInfo("msg come here mysql!!!", "", "msg", string(msg))
|
||||||
msgFromMQ := pbMsg.MsgDataToMQ{}
|
msgFromMQ := pbMsg.MsgDataToMQ{}
|
||||||
err := proto.Unmarshal(msg, &msgFromMQ)
|
err := proto.Unmarshal(msg, &msgFromMQ)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -778,10 +778,26 @@ func (s *groupServer) DeleteGroup(_ context.Context, req *pbGroup.DeleteGroupReq
|
|||||||
func (s *groupServer) OperateUserRole(_ context.Context, req *pbGroup.OperateUserRoleReq) (*pbGroup.OperateUserRoleResp, error) {
|
func (s *groupServer) OperateUserRole(_ context.Context, req *pbGroup.OperateUserRoleReq) (*pbGroup.OperateUserRoleResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
||||||
resp := &pbGroup.OperateUserRoleResp{}
|
resp := &pbGroup.OperateUserRoleResp{}
|
||||||
if err := imdb.OperateGroupRole(req.UserId, req.GroupId, req.RoleLevel); err != nil {
|
oldOwnerUserID, err := imdb.GetGroupMaster(req.GroupId)
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "OperateGroupRole error", err.Error())
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error())
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
return resp, http.WrapError(constant.ErrDB)
|
||||||
}
|
}
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
|
var reqPb pbGroup.TransferGroupOwnerReq
|
||||||
|
reqPb.OperationID = req.OperationID
|
||||||
|
reqPb.NewOwnerUserID = req.UserId
|
||||||
|
reqPb.GroupID = req.GroupId
|
||||||
|
reqPb.OpUserID = "cms admin"
|
||||||
|
reqPb.OldOwnerUserID = oldOwnerUserID.UserID
|
||||||
|
reply, err := client.TransferGroupOwner(context.Background(), &reqPb)
|
||||||
|
if reply.CommonResp.ErrCode != 0 || err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "TransferGroupOwner rpc failed")
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -838,6 +854,8 @@ func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.Remo
|
|||||||
OpUserID: req.OpUserId,
|
OpUserID: req.OpUserId,
|
||||||
}
|
}
|
||||||
chat.MemberKickedNotification(reqKick, resp.Success)
|
chat.MemberKickedNotification(reqKick, resp.Success)
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "success: ", resp.Success)
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "failed: ", resp.Failed)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,9 @@ type config struct {
|
|||||||
Api struct {
|
Api struct {
|
||||||
GinPort []int `yaml:"openImApiPort"`
|
GinPort []int `yaml:"openImApiPort"`
|
||||||
}
|
}
|
||||||
|
CmsApi struct{
|
||||||
|
GinPort []int `yaml:"openImCmsApiPort"`
|
||||||
|
}
|
||||||
Sdk struct {
|
Sdk struct {
|
||||||
WsPort []int `yaml:"openImSdkWsPort"`
|
WsPort []int `yaml:"openImSdkWsPort"`
|
||||||
}
|
}
|
||||||
|
@ -116,10 +116,10 @@ func DeleteGroup(groupId string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func OperateGroupRole(userId, groupId string, roleLevel int32) error {
|
func OperateGroupRole(userId, groupId string, roleLevel int32) (string, string, error) {
|
||||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", "", err
|
||||||
}
|
}
|
||||||
dbConn.LogMode(true)
|
dbConn.LogMode(true)
|
||||||
groupMember := db.GroupMember{
|
groupMember := db.GroupMember{
|
||||||
@ -133,7 +133,7 @@ func OperateGroupRole(userId, groupId string, roleLevel int32) error {
|
|||||||
}
|
}
|
||||||
switch roleLevel {
|
switch roleLevel {
|
||||||
case constant.GroupOwner:
|
case constant.GroupOwner:
|
||||||
return dbConn.Transaction(func(tx *gorm.DB) error {
|
err = dbConn.Transaction(func(tx *gorm.DB) error {
|
||||||
result := dbConn.Table("group_members").Where("group_id = ? and role_level = ?", groupId, constant.GroupOwner).First(&groupMaster).Update(&db.GroupMember{
|
result := dbConn.Table("group_members").Where("group_id = ? and role_level = ?", groupId, constant.GroupOwner).First(&groupMaster).Update(&db.GroupMember{
|
||||||
RoleLevel: constant.GroupOrdinaryUsers,
|
RoleLevel: constant.GroupOrdinaryUsers,
|
||||||
})
|
})
|
||||||
@ -153,8 +153,9 @@ func OperateGroupRole(userId, groupId string, roleLevel int32) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
case constant.GroupOrdinaryUsers:
|
case constant.GroupOrdinaryUsers:
|
||||||
return dbConn.Transaction(func(tx *gorm.DB) error {
|
err = dbConn.Transaction(func(tx *gorm.DB) error {
|
||||||
result := dbConn.Table("group_members").Where("group_id = ? and role_level = ?", groupId, constant.GroupOwner).First(&groupMaster)
|
result := dbConn.Table("group_members").Where("group_id = ? and role_level = ?", groupId, constant.GroupOwner).First(&groupMaster)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
return result.Error
|
return result.Error
|
||||||
@ -176,7 +177,7 @@ func OperateGroupRole(userId, groupId string, roleLevel int32) error {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return nil
|
return "", "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGroupsCountNum(group db.Group) (int32, error) {
|
func GetGroupsCountNum(group db.Group) (int32, error) {
|
||||||
|
@ -41,7 +41,7 @@ func (d *DataBases) JudgeAccountEXISTS(account string) (bool, error) {
|
|||||||
}
|
}
|
||||||
func (d *DataBases) SetAccountCode(account string, code, ttl int) (err error) {
|
func (d *DataBases) SetAccountCode(account string, code, ttl int) (err error) {
|
||||||
key := AccountTempCode + account
|
key := AccountTempCode + account
|
||||||
_, err = d.Exec("SET", key, code)
|
_, err = d.Exec("SET", key, code, "ex", ttl)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
func (d *DataBases) GetAccountCode(account string) (string, error) {
|
func (d *DataBases) GetAccountCode(account string) (string, error) {
|
||||||
@ -49,7 +49,6 @@ func (d *DataBases) GetAccountCode(account string) (string, error) {
|
|||||||
return redis.String(d.Exec("GET", key))
|
return redis.String(d.Exec("GET", key))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Perform seq auto-increment operation of user messages
|
//Perform seq auto-increment operation of user messages
|
||||||
func (d *DataBases) IncrUserSeq(uid string) (uint64, error) {
|
func (d *DataBases) IncrUserSeq(uid string) (uint64, error) {
|
||||||
key := userIncrSeq + uid
|
key := userIncrSeq + uid
|
||||||
|
@ -6,13 +6,15 @@ source ./function.sh
|
|||||||
list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}')
|
list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}')
|
||||||
list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}')
|
list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}')
|
||||||
list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}')
|
list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}')
|
||||||
|
list4=$(cat $config_path | grep openImCmsApiPort | awk - F '[:]' '{print $NF}')
|
||||||
list_to_string $list1
|
list_to_string $list1
|
||||||
api_ports=($ports_array)
|
api_ports=($ports_array)
|
||||||
list_to_string $list2
|
list_to_string $list2
|
||||||
ws_ports=($ports_array)
|
ws_ports=($ports_array)
|
||||||
list_to_string $list3
|
list_to_string $list3
|
||||||
sdk_ws_ports=($ports_array)
|
sdk_ws_ports=($ports_array)
|
||||||
|
list_to_string $list4
|
||||||
|
cms_api_ports=($ports_array)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ service_port_name=(
|
|||||||
openImUserPort
|
openImUserPort
|
||||||
openImFriendPort
|
openImFriendPort
|
||||||
openImGroupPort
|
openImGroupPort
|
||||||
openImAuthPort
|
|
||||||
openImAdminCmsPort
|
openImAdminCmsPort
|
||||||
openImMessageCmsPort
|
openImMessageCmsPort
|
||||||
openImStatisticsPort
|
openImStatisticsPort
|
||||||
|
Loading…
x
Reference in New Issue
Block a user