From 1871b616ba89b8869f001452180069f644c732bb Mon Sep 17 00:00:00 2001 From: brennanli Date: Sun, 17 Oct 2021 13:25:10 +0800 Subject: [PATCH 01/31] Modify bug for getting lastest seq --- src/common/db/redisModel.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/db/redisModel.go b/src/common/db/redisModel.go index f86dbb638..2e3277914 100644 --- a/src/common/db/redisModel.go +++ b/src/common/db/redisModel.go @@ -66,7 +66,7 @@ func (d *DataBases) SetLastGetSeq(uid string) (err error) { //获取用户上一次主动拉取Seq的值 func (d *DataBases) GetLastGetSeq(uid string) (int64, error) { - key := userIncrSeq + uid + key := lastGetSeq + uid return redis.Int64(d.Exec("GET", key)) } From 7caf5a0df9a757e077adb275eb749a863c2a30ca Mon Sep 17 00:00:00 2001 From: Yaxian Date: Wed, 20 Oct 2021 23:03:55 +0800 Subject: [PATCH 02/31] ci: ignore files created by docker-compose (#19) --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..6913e8f09 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +components +logs \ No newline at end of file From c8155553b84268efbb9032544d264106f2ab5656 Mon Sep 17 00:00:00 2001 From: Yaxian Date: Thu, 21 Oct 2021 11:30:48 +0800 Subject: [PATCH 03/31] feat: optimise get server ip (#20) * feat: optimise get server ip * feat: test ServerIP --- src/common/config/config.go | 17 +++++++++++++---- src/utils/get_server_ip.go | 23 +++++++---------------- src/utils/get_server_ip_test.go | 12 ++++++++++++ 3 files changed, 32 insertions(+), 20 deletions(-) create mode 100644 src/utils/get_server_ip_test.go diff --git a/src/common/config/config.go b/src/common/config/config.go index faf75a5b8..6294a031c 100644 --- a/src/common/config/config.go +++ b/src/common/config/config.go @@ -1,8 +1,17 @@ package config import ( - "gopkg.in/yaml.v3" "io/ioutil" + "path/filepath" + "runtime" + + "gopkg.in/yaml.v3" +) + +var ( + _, b, _, _ = runtime.Caller(0) + // Root folder of this project + Root = filepath.Join(filepath.Dir(b), "../../..") ) var Config config @@ -147,14 +156,14 @@ type config struct { } func init() { - bytes, err := ioutil.ReadFile("../config/config.yaml") + // if we cd Open-IM-Server/src/utils and run go test + // it will panic cannot find config/config.yaml + bytes, err := ioutil.ReadFile(Root + "/config/config.yaml") if err != nil { panic(err) - return } if err = yaml.Unmarshal(bytes, &Config); err != nil { panic(err) - return } } diff --git a/src/utils/get_server_ip.go b/src/utils/get_server_ip.go index 21092ffa1..ec5824cb8 100644 --- a/src/utils/get_server_ip.go +++ b/src/utils/get_server_ip.go @@ -13,23 +13,14 @@ func init() { ServerIP = config.Config.ServerIP return } - //fixme Get the ip of the local network card - netInterfaces, err := net.Interfaces() + + // see https://gist.github.com/jniltinho/9787946#gistcomment-3019898 + conn, err := net.Dial("udp", "8.8.8.8:80") if err != nil { panic(err) } - for i := 0; i < len(netInterfaces); i++ { - //Exclude useless network cards by judging the net.flag Up flag - if (netInterfaces[i].Flags & net.FlagUp) != 0 { - address, _ := netInterfaces[i].Addrs() - for _, addr := range address { - if ipNet, ok := addr.(*net.IPNet); ok && !ipNet.IP.IsLoopback() { - if ipNet.IP.To4() != nil { - ServerIP = ipNet.IP.String() - return - } - } - } - } - } + + defer conn.Close() + localAddr := conn.LocalAddr().(*net.UDPAddr) + ServerIP = localAddr.IP.String() } diff --git a/src/utils/get_server_ip_test.go b/src/utils/get_server_ip_test.go new file mode 100644 index 000000000..54e2142ef --- /dev/null +++ b/src/utils/get_server_ip_test.go @@ -0,0 +1,12 @@ +package utils + +import ( + "net" + "testing" +) + +func TestServerIP(t *testing.T) { + if net.ParseIP(ServerIP) == nil { + t.Fail() + } +} From 72b23ca2358089f693394e86450bb94b3f0967ff Mon Sep 17 00:00:00 2001 From: Zzr Date: Thu, 21 Oct 2021 12:10:38 +0800 Subject: [PATCH 04/31] fix issue#15 (#18) Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --- .gitignore | 4 +- src/rpc/chat/chat/send_msg.go | 123 ++++++++++++++++------------------ 2 files changed, 61 insertions(+), 66 deletions(-) diff --git a/.gitignore b/.gitignore index 6913e8f09..6726c686a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ + components -logs \ No newline at end of file +logs + diff --git a/src/rpc/chat/chat/send_msg.go b/src/rpc/chat/chat/send_msg.go index 21a1a7be8..602ad03e3 100644 --- a/src/rpc/chat/chat/send_msg.go +++ b/src/rpc/chat/chat/send_msg.go @@ -88,84 +88,77 @@ func (rpc *rpcChat) UserSendMsg(_ context.Context, pb *pbChat.UserSendMsgReq) (* return returnMsg(&replay, pb, m.ResponseErrCode, m.ErrMsg, "", 0) } else { pbData.Content = m.ResponseResult.ModifiedMsg - err1 := rpc.sendMsgToKafka(&pbData, pbData.RecvID) - err2 := rpc.sendMsgToKafka(&pbData, pbData.SendID) - if err1 != nil || err2 != nil { - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } - return returnMsg(&replay, pb, 0, "", serverMsgID, pbData.SendTime) } } - } else { - switch pbData.SessionType { - case constant.SingleChatType: - err1 := rpc.sendMsgToKafka(&pbData, pbData.RecvID) - err2 := rpc.sendMsgToKafka(&pbData, pbData.SendID) - if err1 != nil || err2 != nil { - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } - return returnMsg(&replay, pb, 0, "", serverMsgID, pbData.SendTime) - case constant.GroupChatType: - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) - client := pbGroup.NewGroupClient(etcdConn) - req := &pbGroup.GetGroupAllMemberReq{ - GroupID: pbData.RecvID, - Token: pbData.Token, - OperationID: pbData.OperationID, - } - reply, err := client.GetGroupAllMember(context.Background(), req) + } + switch pbData.SessionType { + case constant.SingleChatType: + err1 := rpc.sendMsgToKafka(&pbData, pbData.RecvID) + err2 := rpc.sendMsgToKafka(&pbData, pbData.SendID) + if err1 != nil || err2 != nil { + return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) + } + return returnMsg(&replay, pb, 0, "", serverMsgID, pbData.SendTime) + case constant.GroupChatType: + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + client := pbGroup.NewGroupClient(etcdConn) + req := &pbGroup.GetGroupAllMemberReq{ + GroupID: pbData.RecvID, + Token: pbData.Token, + OperationID: pbData.OperationID, + } + reply, err := client.GetGroupAllMember(context.Background(), req) + if err != nil { + log.Error(pbData.Token, pbData.OperationID, "rpc send_msg getGroupInfo failed, err = %s", err.Error()) + return returnMsg(&replay, pb, 201, err.Error(), "", 0) + } + if reply.ErrorCode != 0 { + log.Error(pbData.Token, pbData.OperationID, "rpc send_msg getGroupInfo failed, err = %s", reply.ErrorMsg) + return returnMsg(&replay, pb, reply.ErrorCode, reply.ErrorMsg, "", 0) + } + var addUidList []string + switch pbData.ContentType { + case constant.KickGroupMemberTip: + var notification content_struct.NotificationContent + var kickContent group.KickGroupMemberReq + err := utils.JsonStringToStruct(pbData.Content, ¬ification) if err != nil { - log.Error(pbData.Token, pbData.OperationID, "rpc send_msg getGroupInfo failed, err = %s", err.Error()) - return returnMsg(&replay, pb, 201, err.Error(), "", 0) - } - if reply.ErrorCode != 0 { - log.Error(pbData.Token, pbData.OperationID, "rpc send_msg getGroupInfo failed, err = %s", reply.ErrorMsg) - return returnMsg(&replay, pb, reply.ErrorCode, reply.ErrorMsg, "", 0) - } - var addUidList []string - switch pbData.ContentType { - case constant.KickGroupMemberTip: - var notification content_struct.NotificationContent - var kickContent group.KickGroupMemberReq - err := utils.JsonStringToStruct(pbData.Content, ¬ification) + log.ErrorByKv("json unmarshall err", pbData.OperationID, "err", err.Error()) + return returnMsg(&replay, pb, 200, err.Error(), "", 0) + } else { + err := utils.JsonStringToStruct(notification.Detail, &kickContent) if err != nil { log.ErrorByKv("json unmarshall err", pbData.OperationID, "err", err.Error()) return returnMsg(&replay, pb, 200, err.Error(), "", 0) - } else { - err := utils.JsonStringToStruct(notification.Detail, &kickContent) - if err != nil { - log.ErrorByKv("json unmarshall err", pbData.OperationID, "err", err.Error()) - return returnMsg(&replay, pb, 200, err.Error(), "", 0) - } - for _, v := range kickContent.UidListInfo { - addUidList = append(addUidList, v.UserId) - } - } - case constant.QuitGroupTip: - addUidList = append(addUidList, pbData.SendID) - default: - } - groupID := pbData.RecvID - for i, v := range reply.MemberList { - pbData.RecvID = v.UserId + " " + groupID - err := rpc.sendMsgToKafka(&pbData, utils.IntToString(i)) - if err != nil { - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) } - } - for i, v := range addUidList { - pbData.RecvID = v + " " + groupID - err := rpc.sendMsgToKafka(&pbData, utils.IntToString(i+1)) - if err != nil { - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) + for _, v := range kickContent.UidListInfo { + addUidList = append(addUidList, v.UserId) } } - return returnMsg(&replay, pb, 0, "", serverMsgID, pbData.SendTime) + case constant.QuitGroupTip: + addUidList = append(addUidList, pbData.SendID) default: - } + groupID := pbData.RecvID + for i, v := range reply.MemberList { + pbData.RecvID = v.UserId + " " + groupID + err := rpc.sendMsgToKafka(&pbData, utils.IntToString(i)) + if err != nil { + return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) + } + } + for i, v := range addUidList { + pbData.RecvID = v + " " + groupID + err := rpc.sendMsgToKafka(&pbData, utils.IntToString(i+1)) + if err != nil { + return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) + } + } + return returnMsg(&replay, pb, 0, "", serverMsgID, pbData.SendTime) + default: } + return returnMsg(&replay, pb, 203, "unkonwn sessionType", "", 0) } From 0dfaa49c97edccb8e76b7313aa6705d91c354232 Mon Sep 17 00:00:00 2001 From: Away <42713450+memory-qianxiao@users.noreply.github.com> Date: Fri, 22 Oct 2021 10:14:32 +0800 Subject: [PATCH 05/31] Reduce the MongoDB version to adapt to a few machine (#22) --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index a9fa9a1c9..1d64dcd9f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -15,7 +15,7 @@ services: restart: always mongodb: - image: mongo + image: mongo:4.0 ports: - 27017:27017 container_name: mongo From 0e6432f95a55544dedb4b4e77f1854cfe70f3cc7 Mon Sep 17 00:00:00 2001 From: Yaxian Date: Fri, 22 Oct 2021 18:49:44 +0800 Subject: [PATCH 06/31] Feature/optimise jwt token (#24) --- go.mod | 1 + go.sum | 2 + src/utils/jwt_token.go | 155 ++++++++++++++---------------------- src/utils/jwt_token_test.go | 86 ++++++++++++++++++++ 4 files changed, 150 insertions(+), 94 deletions(-) create mode 100644 src/utils/jwt_token_test.go diff --git a/go.mod b/go.mod index ac0c9edf0..e70c37bda 100644 --- a/go.mod +++ b/go.mod @@ -32,6 +32,7 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 github.com/sirupsen/logrus v1.6.0 + github.com/stretchr/testify v1.7.0 github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 diff --git a/go.sum b/go.sum index fbbe5ea96..3cfde6ff6 100644 --- a/go.sum +++ b/go.sum @@ -233,6 +233,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca h1:G/aIr3WiUesWHL2YGYgEqjM5tCAJ43Ml+0C18wDkWWs= github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca/go.mod h1:b18KQa4IxHbxeseW1GcZox53d7J0z39VNONTxvvlkXw= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= diff --git a/src/utils/jwt_token.go b/src/utils/jwt_token.go index 264da2483..938cf6ede 100644 --- a/src/utils/jwt_token.go +++ b/src/utils/jwt_token.go @@ -4,8 +4,9 @@ import ( "Open_IM/src/common/config" "Open_IM/src/common/db" "errors" - "github.com/dgrijalva/jwt-go" "time" + + "github.com/dgrijalva/jwt-go" ) var ( @@ -25,21 +26,16 @@ type Claims struct { func BuildClaims(uid, accountAddr, platform string, ttl int64) Claims { now := time.Now().Unix() //if ttl=-1 Permanent token - if ttl == -1 { - return Claims{ - UID: uid, - Platform: platform, - StandardClaims: jwt.StandardClaims{ - ExpiresAt: -1, - IssuedAt: now, - NotBefore: now, - }} + expiresAt := int64(-1) + if ttl != -1 { + expiresAt = now + ttl } + return Claims{ UID: uid, Platform: platform, StandardClaims: jwt.StandardClaims{ - ExpiresAt: now + ttl, //Expiration time + ExpiresAt: expiresAt, //Expiration time IssuedAt: now, //Issuing time NotBefore: now, //Begin Effective time }} @@ -59,7 +55,7 @@ func secret() jwt.Keyfunc { } } -func ParseToken(tokensString string) (claims *Claims, err error) { +func getClaimFromToken(tokensString string) (*Claims, error) { token, err := jwt.ParseWithClaims(tokensString, &Claims{}, secret()) if err != nil { if ve, ok := err.(*jwt.ValidationError); ok { @@ -75,73 +71,63 @@ func ParseToken(tokensString string) (claims *Claims, err error) { } } if claims, ok := token.Claims.(*Claims); ok && token.Valid { - // 1.check userid and platform class 0 not exists and 1 exists - existsInterface, err := db.DB.ExistsUserIDAndPlatform(claims.UID, Platform2class[claims.Platform]) + return claims, nil + } + return nil, err +} + +func ParseToken(tokensString string) (claims *Claims, err error) { + claims, err = getClaimFromToken(tokensString) + + if err != nil { + return nil, err + } + + // 1.check userid and platform class 0 not exists and 1 exists + existsInterface, err := db.DB.ExistsUserIDAndPlatform(claims.UID, Platform2class[claims.Platform]) + if err != nil { + return nil, err + } + exists := existsInterface.(int64) + //get config multi login policy + if config.Config.MultiLoginPolicy.OnlyOneTerminalAccess { + //OnlyOneTerminalAccess policy need to check all terminal + //When only one end is allowed to log in, there is a situation that needs to be paid attention to. After PC login, + //mobile login should check two platform times. One of them is less than the redis storage time, which is the invalid token. + platform := "PC" + if Platform2class[claims.Platform] == "PC" { + platform = "Mobile" + } + + existsInterface, err = db.DB.ExistsUserIDAndPlatform(claims.UID, platform) if err != nil { return nil, err } - exists := existsInterface.(int64) - //get config multi login policy - if config.Config.MultiLoginPolicy.OnlyOneTerminalAccess { - //OnlyOneTerminalAccess policy need to check all terminal - //When only one end is allowed to log in, there is a situation that needs to be paid attention to. After PC login, - //mobile login should check two platform times. One of them is less than the redis storage time, which is the invalid token. - if Platform2class[claims.Platform] == "PC" { - existsInterface, err = db.DB.ExistsUserIDAndPlatform(claims.UID, "Mobile") - if err != nil { - return nil, err - } - exists = existsInterface.(int64) - if exists == 1 { - res, err := MakeTheTokenInvalid(*claims, "Mobile") - if err != nil { - return nil, err - } - if res { - return nil, TokenInvalid - } - } - } else { - existsInterface, err = db.DB.ExistsUserIDAndPlatform(claims.UID, "PC") - if err != nil { - return nil, err - } - exists = existsInterface.(int64) - if exists == 1 { - res, err := MakeTheTokenInvalid(*claims, "PC") - if err != nil { - return nil, err - } - if res { - return nil, TokenInvalid - } - } - } - if exists == 1 { - res, err := MakeTheTokenInvalid(*claims, Platform2class[claims.Platform]) - if err != nil { - return nil, err - } - if res { - return nil, TokenInvalid - } + exists = existsInterface.(int64) + if exists == 1 { + res, err := MakeTheTokenInvalid(*claims, platform) + if err != nil { + return nil, err } - - } else if config.Config.MultiLoginPolicy.MobileAndPCTerminalAccessButOtherTerminalKickEachOther { - if exists == 1 { - res, err := MakeTheTokenInvalid(*claims, Platform2class[claims.Platform]) - if err != nil { - return nil, err - } - if res { - return nil, TokenInvalid - } + if res { + return nil, TokenInvalid } } - return claims, nil } - return nil, TokenUnknown + // config.Config.MultiLoginPolicy.MobileAndPCTerminalAccessButOtherTerminalKickEachOther == true + // or PC/Mobile validate success + // final check + if exists == 1 { + res, err := MakeTheTokenInvalid(*claims, Platform2class[claims.Platform]) + if err != nil { + return nil, err + } + if res { + return nil, TokenInvalid + } + } + return claims, nil } func MakeTheTokenInvalid(currentClaims Claims, platformClass string) (bool, error) { @@ -159,35 +145,16 @@ func MakeTheTokenInvalid(currentClaims Claims, platformClass string) (bool, erro } return false, nil } + func ParseRedisInterfaceToken(redisToken interface{}) (*Claims, error) { - token, err := jwt.ParseWithClaims(string(redisToken.([]uint8)), &Claims{}, secret()) - if err != nil { - if ve, ok := err.(*jwt.ValidationError); ok { - if ve.Errors&jwt.ValidationErrorMalformed != 0 { - return nil, TokenMalformed - } else if ve.Errors&jwt.ValidationErrorExpired != 0 { - return nil, TokenExpired - } else if ve.Errors&jwt.ValidationErrorNotValidYet != 0 { - return nil, TokenNotValidYet - } else { - return nil, TokenInvalid - } - } - } - if claims, ok := token.Claims.(*Claims); ok && token.Valid { - return claims, nil - } - return nil, err + return getClaimFromToken(string(redisToken.([]uint8))) } //Validation token, false means failure, true means successful verification func VerifyToken(token, uid string) bool { claims, err := ParseToken(token) - if err != nil { - return false - } else if claims.UID != uid { + if err != nil || claims.UID != uid { return false - } else { - return true } + return true } diff --git a/src/utils/jwt_token_test.go b/src/utils/jwt_token_test.go new file mode 100644 index 000000000..0d5ac7463 --- /dev/null +++ b/src/utils/jwt_token_test.go @@ -0,0 +1,86 @@ +package utils + +import ( + "Open_IM/src/common/config" + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func Test_BuildClaims(t *testing.T) { + uid := "1" + accountAddr := "accountAddr" + platform := "PC" + ttl := int64(-1) + claim := BuildClaims(uid, accountAddr, platform, ttl) + now := time.Now().Unix() + + assert.Equal(t, claim.UID, uid, "uid should equal") + assert.Equal(t, claim.Platform, platform, "platform should equal") + assert.Equal(t, claim.StandardClaims.ExpiresAt, int64(-1), "StandardClaims.ExpiresAt should be equal") + // time difference within 1s + assert.Equal(t, claim.StandardClaims.IssuedAt, now, "StandardClaims.IssuedAt should be equal") + assert.Equal(t, claim.StandardClaims.NotBefore, now, "StandardClaims.NotBefore should be equal") + + ttl = int64(60) + now = time.Now().Unix() + claim = BuildClaims(uid, accountAddr, platform, ttl) + // time difference within 1s + assert.Equal(t, claim.StandardClaims.ExpiresAt, int64(60)+now, "StandardClaims.ExpiresAt should be equal") + assert.Equal(t, claim.StandardClaims.IssuedAt, now, "StandardClaims.IssuedAt should be equal") + assert.Equal(t, claim.StandardClaims.NotBefore, now, "StandardClaims.NotBefore should be equal") +} + +func Test_CreateToken(t *testing.T) { + uid := "1" + accountAddr := "accountAddr" + platform := int32(1) + now := time.Now().Unix() + + tokenString, expiresAt, err := CreateToken(uid, accountAddr, platform) + + assert.NotEmpty(t, tokenString) + assert.Equal(t, expiresAt, 604800+now) + assert.Nil(t, err) +} + +func Test_VerifyToken(t *testing.T) { + uid := "1" + accountAddr := "accountAddr" + platform := int32(1) + tokenString, _, _ := CreateToken(uid, accountAddr, platform) + result := VerifyToken(tokenString, uid) + assert.True(t, result) + result = VerifyToken(tokenString, "2") + assert.False(t, result) +} + +func Test_ParseRedisInterfaceToken(t *testing.T) { + uid := "1" + accountAddr := "accountAddr" + platform := int32(1) + tokenString, _, _ := CreateToken(uid, accountAddr, platform) + + claims, err := ParseRedisInterfaceToken([]uint8(tokenString)) + assert.Nil(t, err) + assert.Equal(t, claims.UID, uid) + + // timeout + config.Config.TokenPolicy.AccessExpire = -80 + tokenString, _, _ = CreateToken(uid, accountAddr, platform) + claims, err = ParseRedisInterfaceToken([]uint8(tokenString)) + assert.Equal(t, err, TokenExpired) + assert.Nil(t, claims) +} + +func Test_ParseToken(t *testing.T) { + uid := "1" + accountAddr := "accountAddr" + platform := int32(1) + tokenString, _, _ := CreateToken(uid, accountAddr, platform) + claims, err := ParseToken(tokenString) + if err == nil { + assert.Equal(t, claims.UID, uid) + } +} From d6ba0a803d4488cb9230983b8f3cdf1936391ed8 Mon Sep 17 00:00:00 2001 From: Away <42713450+memory-qianxiao@users.noreply.github.com> Date: Fri, 22 Oct 2021 21:20:31 +0800 Subject: [PATCH 07/31] Pr branch (#25) * fix update jwt-token version to avoid attackers to bypass intended access restrictions in situations with []string{} for m["aud"] * del accountAddr --- go.mod | 2 +- go.sum | 2 ++ src/rpc/auth/auth/user_token.go | 2 +- src/utils/jwt_token.go | 9 ++++----- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index e70c37bda..00fe22cb0 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect github.com/antonfisher/nested-logrus-formatter v1.3.0 github.com/coreos/go-semver v0.3.0 // indirect - github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dustin/go-humanize v1.0.0 // indirect github.com/eapache/go-resiliency v1.2.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect @@ -16,6 +15,7 @@ require ( github.com/garyburd/redigo v1.6.2 github.com/gin-gonic/gin v1.7.0 github.com/go-playground/validator/v10 v10.4.1 + github.com/golang-jwt/jwt/v4 v4.1.0 // indirect github.com/golang/protobuf v1.5.2 github.com/golang/snappy v0.0.3 // indirect github.com/gorilla/websocket v1.4.2 diff --git a/go.sum b/go.sum index 3cfde6ff6..664a73e93 100644 --- a/go.sum +++ b/go.sum @@ -74,6 +74,8 @@ github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang-jwt/jwt/v4 v4.1.0 h1:XUgk2Ex5veyVFVeLm0xhusUTQybEbexJXrvPNOKkSY0= +github.com/golang-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= diff --git a/src/rpc/auth/auth/user_token.go b/src/rpc/auth/auth/user_token.go index 59e91c33b..c89e4312d 100644 --- a/src/rpc/auth/auth/user_token.go +++ b/src/rpc/auth/auth/user_token.go @@ -18,7 +18,7 @@ func (rpc *rpcAuth) UserToken(_ context.Context, pb *pbAuth.UserTokenReq) (*pbAu } log.Info("", "", "rpc user_token call..., im_mysql_model.AppServerFindFromUserByUserID") - tokens, expTime, err := utils.CreateToken(pb.UID, "", pb.Platform) + tokens, expTime, err := utils.CreateToken(pb.UID, pb.Platform) if err != nil { log.Error("", "", "rpc user_token call..., utils.CreateToken fail [uid: %s] [err: %s]", pb.UID, err.Error()) return &pbAuth.UserTokenResp{ErrCode: 500, ErrMsg: err.Error()}, err diff --git a/src/utils/jwt_token.go b/src/utils/jwt_token.go index 938cf6ede..19fdb9a3b 100644 --- a/src/utils/jwt_token.go +++ b/src/utils/jwt_token.go @@ -4,9 +4,8 @@ import ( "Open_IM/src/common/config" "Open_IM/src/common/db" "errors" + "github.com/golang-jwt/jwt/v4" "time" - - "github.com/dgrijalva/jwt-go" ) var ( @@ -23,7 +22,7 @@ type Claims struct { jwt.StandardClaims } -func BuildClaims(uid, accountAddr, platform string, ttl int64) Claims { +func BuildClaims(uid, platform string, ttl int64) Claims { now := time.Now().Unix() //if ttl=-1 Permanent token expiresAt := int64(-1) @@ -41,8 +40,8 @@ func BuildClaims(uid, accountAddr, platform string, ttl int64) Claims { }} } -func CreateToken(userID, accountAddr string, platform int32) (string, int64, error) { - claims := BuildClaims(userID, accountAddr, PlatformIDToName(platform), config.Config.TokenPolicy.AccessExpire) +func CreateToken(userID string, platform int32) (string, int64, error) { + claims := BuildClaims(userID, PlatformIDToName(platform), config.Config.TokenPolicy.AccessExpire) token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) tokenString, err := token.SignedString([]byte(config.Config.TokenPolicy.AccessSecret)) From b2cc5977557cbaafe97d0f9f5505d88b02733f49 Mon Sep 17 00:00:00 2001 From: Away <42713450+memory-qianxiao@users.noreply.github.com> Date: Sat, 23 Oct 2021 09:21:05 +0800 Subject: [PATCH 08/31] Create codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000..f106438e3 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,71 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: '23 2 * * 2' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From 3d7fd2c19214ca7a4aaea8e3d96a2069a777e5b5 Mon Sep 17 00:00:00 2001 From: senyu <1819625428@qq.com> Date: Sat, 23 Oct 2021 10:51:57 +0800 Subject: [PATCH 09/31] del unuse filed --- src/utils/jwt_token_test.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/utils/jwt_token_test.go b/src/utils/jwt_token_test.go index 0d5ac7463..31e5a4d4a 100644 --- a/src/utils/jwt_token_test.go +++ b/src/utils/jwt_token_test.go @@ -10,10 +10,9 @@ import ( func Test_BuildClaims(t *testing.T) { uid := "1" - accountAddr := "accountAddr" platform := "PC" ttl := int64(-1) - claim := BuildClaims(uid, accountAddr, platform, ttl) + claim := BuildClaims(uid, platform, ttl) now := time.Now().Unix() assert.Equal(t, claim.UID, uid, "uid should equal") @@ -25,7 +24,7 @@ func Test_BuildClaims(t *testing.T) { ttl = int64(60) now = time.Now().Unix() - claim = BuildClaims(uid, accountAddr, platform, ttl) + claim = BuildClaims(uid, platform, ttl) // time difference within 1s assert.Equal(t, claim.StandardClaims.ExpiresAt, int64(60)+now, "StandardClaims.ExpiresAt should be equal") assert.Equal(t, claim.StandardClaims.IssuedAt, now, "StandardClaims.IssuedAt should be equal") @@ -34,11 +33,10 @@ func Test_BuildClaims(t *testing.T) { func Test_CreateToken(t *testing.T) { uid := "1" - accountAddr := "accountAddr" platform := int32(1) now := time.Now().Unix() - tokenString, expiresAt, err := CreateToken(uid, accountAddr, platform) + tokenString, expiresAt, err := CreateToken(uid, platform) assert.NotEmpty(t, tokenString) assert.Equal(t, expiresAt, 604800+now) @@ -47,9 +45,8 @@ func Test_CreateToken(t *testing.T) { func Test_VerifyToken(t *testing.T) { uid := "1" - accountAddr := "accountAddr" platform := int32(1) - tokenString, _, _ := CreateToken(uid, accountAddr, platform) + tokenString, _, _ := CreateToken(uid, platform) result := VerifyToken(tokenString, uid) assert.True(t, result) result = VerifyToken(tokenString, "2") @@ -58,9 +55,8 @@ func Test_VerifyToken(t *testing.T) { func Test_ParseRedisInterfaceToken(t *testing.T) { uid := "1" - accountAddr := "accountAddr" platform := int32(1) - tokenString, _, _ := CreateToken(uid, accountAddr, platform) + tokenString, _, _ := CreateToken(uid, platform) claims, err := ParseRedisInterfaceToken([]uint8(tokenString)) assert.Nil(t, err) @@ -68,7 +64,7 @@ func Test_ParseRedisInterfaceToken(t *testing.T) { // timeout config.Config.TokenPolicy.AccessExpire = -80 - tokenString, _, _ = CreateToken(uid, accountAddr, platform) + tokenString, _, _ = CreateToken(uid, platform) claims, err = ParseRedisInterfaceToken([]uint8(tokenString)) assert.Equal(t, err, TokenExpired) assert.Nil(t, claims) @@ -76,9 +72,8 @@ func Test_ParseRedisInterfaceToken(t *testing.T) { func Test_ParseToken(t *testing.T) { uid := "1" - accountAddr := "accountAddr" platform := int32(1) - tokenString, _, _ := CreateToken(uid, accountAddr, platform) + tokenString, _, _ := CreateToken(uid, platform) claims, err := ParseToken(tokenString) if err == nil { assert.Equal(t, claims.UID, uid) From 8913ca161f1726435b9d69bb24dc601833c8517c Mon Sep 17 00:00:00 2001 From: Zzr Date: Sat, 23 Oct 2021 14:18:55 +0800 Subject: [PATCH 10/31] Fix #21 (#23) * fix issue#15 * fix #21 Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --- .gitignore | 2 +- src/msg_gateway/gate/rpc_server.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 6726c686a..74a748ab0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ - +.devcontainer components logs diff --git a/src/msg_gateway/gate/rpc_server.go b/src/msg_gateway/gate/rpc_server.go index e9aa28033..54bb78076 100644 --- a/src/msg_gateway/gate/rpc_server.go +++ b/src/msg_gateway/gate/rpc_server.go @@ -10,10 +10,11 @@ import ( "context" "encoding/json" "fmt" - "github.com/gorilla/websocket" - "google.golang.org/grpc" "net" "strings" + + "github.com/gorilla/websocket" + "google.golang.org/grpc" ) type RPCServer struct { @@ -41,7 +42,7 @@ func (r *RPCServer) run() { srv := grpc.NewServer() defer srv.GracefulStop() pbRelay.RegisterOnlineMessageRelayServiceServer(srv, r) - err = getcdv3.RegisterEtcd4Unique(r.etcdSchema, strings.Join(r.etcdAddr, ","), ip, r.rpcPort, r.rpcRegisterName, 10) + err = getcdv3.RegisterEtcd(r.etcdSchema, strings.Join(r.etcdAddr, ","), ip, r.rpcPort, r.rpcRegisterName, 10) if err != nil { log.ErrorByKv("register push message rpc to etcd err", "", "err", err.Error()) } From 65157ede231b90f7b392de2e97b396aa16fd67d1 Mon Sep 17 00:00:00 2001 From: Away <42713450+memory-qianxiao@users.noreply.github.com> Date: Mon, 25 Oct 2021 11:08:10 +0800 Subject: [PATCH 11/31] Update jwt token version (#27) * add sdk svr to docker script * panic handle * fix build from dockerfile on docker-compose * Update deploy.Dockerfile * log and scripts optimization * ci: ignore files created by docker-compose (#19) * feat: optimise get server ip (#20) * feat: optimise get server ip * feat: test ServerIP * fix issue#15 (#18) Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * Modify bug for getting lastest seq * Reduce the MongoDB version to adapt to a few machine (#22) * Feature/optimise jwt token (#24) * Pr branch (#25) * fix update jwt-token version to avoid attackers to bypass intended access restrictions in situations with []string{} for m["aud"] * del accountAddr * Create codeql-analysis.yml * del unuse filed * fix update jwt-token version to avoid attackers to bypass intended access restrictions in situations with []string{} for m["aud"] Co-authored-by: Gordon <1432970085@qq.com> Co-authored-by: Yaxian Co-authored-by: Zzr Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com> Co-authored-by: brennanli --- config/config.yaml | 4 ++-- src/utils/jwt_token.go | 28 +++++++++++----------------- src/utils/jwt_token_test.go | 12 ++++++------ 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 9e8741b48..d7becbbb4 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -134,8 +134,8 @@ multiloginpolicy: tokenpolicy: accessSecret: "open_im_server" # Token effective time seconds as a unit - #Seven days 7*24*60*60 - accessExpire: 604800 + #Seven days + accessExpire: 7 messagecallback: callbackSwitch: false diff --git a/src/utils/jwt_token.go b/src/utils/jwt_token.go index 19fdb9a3b..14977f7ae 100644 --- a/src/utils/jwt_token.go +++ b/src/utils/jwt_token.go @@ -19,24 +19,18 @@ var ( type Claims struct { UID string Platform string //login platform - jwt.StandardClaims + jwt.RegisteredClaims } func BuildClaims(uid, platform string, ttl int64) Claims { - now := time.Now().Unix() - //if ttl=-1 Permanent token - expiresAt := int64(-1) - if ttl != -1 { - expiresAt = now + ttl - } - + now := time.Now() return Claims{ UID: uid, Platform: platform, - StandardClaims: jwt.StandardClaims{ - ExpiresAt: expiresAt, //Expiration time - IssuedAt: now, //Issuing time - NotBefore: now, //Begin Effective time + RegisteredClaims: jwt.RegisteredClaims{ + ExpiresAt: jwt.NewNumericDate(now.Add(time.Duration(ttl*24) * time.Hour)), //Expiration time + IssuedAt: jwt.NewNumericDate(now), //Issuing time + NotBefore: jwt.NewNumericDate(now), //Begin Effective time }} } @@ -45,7 +39,7 @@ func CreateToken(userID string, platform int32) (string, int64, error) { token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) tokenString, err := token.SignedString([]byte(config.Config.TokenPolicy.AccessSecret)) - return tokenString, claims.ExpiresAt, err + return tokenString, claims.ExpiresAt.Time.Unix(), err } func secret() jwt.Keyfunc { @@ -105,7 +99,7 @@ func ParseToken(tokensString string) (claims *Claims, err error) { exists = existsInterface.(int64) if exists == 1 { - res, err := MakeTheTokenInvalid(*claims, platform) + res, err := MakeTheTokenInvalid(claims, platform) if err != nil { return nil, err } @@ -118,7 +112,7 @@ func ParseToken(tokensString string) (claims *Claims, err error) { // or PC/Mobile validate success // final check if exists == 1 { - res, err := MakeTheTokenInvalid(*claims, Platform2class[claims.Platform]) + res, err := MakeTheTokenInvalid(claims, Platform2class[claims.Platform]) if err != nil { return nil, err } @@ -129,7 +123,7 @@ func ParseToken(tokensString string) (claims *Claims, err error) { return claims, nil } -func MakeTheTokenInvalid(currentClaims Claims, platformClass string) (bool, error) { +func MakeTheTokenInvalid(currentClaims *Claims, platformClass string) (bool, error) { storedRedisTokenInterface, err := db.DB.GetPlatformToken(currentClaims.UID, platformClass) if err != nil { return false, err @@ -139,7 +133,7 @@ func MakeTheTokenInvalid(currentClaims Claims, platformClass string) (bool, erro return false, err } //if issue time less than redis token then make this token invalid - if currentClaims.IssuedAt < storedRedisPlatformClaims.IssuedAt { + if currentClaims.IssuedAt.Time.Unix() < storedRedisPlatformClaims.IssuedAt.Time.Unix() { return true, TokenInvalid } return false, nil diff --git a/src/utils/jwt_token_test.go b/src/utils/jwt_token_test.go index 31e5a4d4a..83b9bb91c 100644 --- a/src/utils/jwt_token_test.go +++ b/src/utils/jwt_token_test.go @@ -17,18 +17,18 @@ func Test_BuildClaims(t *testing.T) { assert.Equal(t, claim.UID, uid, "uid should equal") assert.Equal(t, claim.Platform, platform, "platform should equal") - assert.Equal(t, claim.StandardClaims.ExpiresAt, int64(-1), "StandardClaims.ExpiresAt should be equal") + assert.Equal(t, claim.RegisteredClaims.ExpiresAt, int64(-1), "StandardClaims.ExpiresAt should be equal") // time difference within 1s - assert.Equal(t, claim.StandardClaims.IssuedAt, now, "StandardClaims.IssuedAt should be equal") - assert.Equal(t, claim.StandardClaims.NotBefore, now, "StandardClaims.NotBefore should be equal") + assert.Equal(t, claim.RegisteredClaims.IssuedAt, now, "StandardClaims.IssuedAt should be equal") + assert.Equal(t, claim.RegisteredClaims.NotBefore, now, "StandardClaims.NotBefore should be equal") ttl = int64(60) now = time.Now().Unix() claim = BuildClaims(uid, platform, ttl) // time difference within 1s - assert.Equal(t, claim.StandardClaims.ExpiresAt, int64(60)+now, "StandardClaims.ExpiresAt should be equal") - assert.Equal(t, claim.StandardClaims.IssuedAt, now, "StandardClaims.IssuedAt should be equal") - assert.Equal(t, claim.StandardClaims.NotBefore, now, "StandardClaims.NotBefore should be equal") + assert.Equal(t, claim.RegisteredClaims.ExpiresAt, int64(60)+now, "StandardClaims.ExpiresAt should be equal") + assert.Equal(t, claim.RegisteredClaims.IssuedAt, now, "StandardClaims.IssuedAt should be equal") + assert.Equal(t, claim.RegisteredClaims.NotBefore, now, "StandardClaims.NotBefore should be equal") } func Test_CreateToken(t *testing.T) { From 7c3aa7ee0b6321e7888d484ec87947dde671378e Mon Sep 17 00:00:00 2001 From: antcorp <527455294@qq.com> Date: Mon, 25 Oct 2021 16:42:56 +0800 Subject: [PATCH 12/31] fix: Startup error (#11) * fix: Startup error Fixed a path error that prompted that the configuration file could not be found at startup * Update config.go Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --- src/common/config/config.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/common/config/config.go b/src/common/config/config.go index 6294a031c..5d7084653 100644 --- a/src/common/config/config.go +++ b/src/common/config/config.go @@ -2,17 +2,15 @@ package config import ( "io/ioutil" + + "os" + "path/filepath" "runtime" "gopkg.in/yaml.v3" ) -var ( - _, b, _, _ = runtime.Caller(0) - // Root folder of this project - Root = filepath.Join(filepath.Dir(b), "../../..") -) var Config config @@ -156,9 +154,8 @@ type config struct { } func init() { - // if we cd Open-IM-Server/src/utils and run go test - // it will panic cannot find config/config.yaml - bytes, err := ioutil.ReadFile(Root + "/config/config.yaml") + path, _ := os.Getwd() + bytes, err := ioutil.ReadFile(path + "/config/config.yaml") if err != nil { panic(err) } From 37a8ddbae61f431a2e38001d9503ed027c986660 Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Fri, 29 Oct 2021 15:02:52 +0800 Subject: [PATCH 13/31] Update README.md (#30) * Update README.md * Add files via upload update config * Add files via upload update script --- README.md | 2 +- docs/config.yaml | 146 +++++++++++++++++++++++++++++++++ script/build_all_service.sh | 60 +++++++------- script/check_all.sh | 74 ++++++++++------- script/docker_check_service.sh | 66 +++++++-------- script/docker_start_all.sh | 46 +++++------ script/function.sh | 20 ++--- script/msg_gateway_start.sh | 96 +++++++++++----------- script/msg_transfer_start.sh | 74 ++++++++--------- script/mysql_database_init.sh | 76 ++++++++--------- script/path_info.cfg | 125 ++++++++++++++-------------- script/push_start.sh | 90 ++++++++++---------- script/sdk_svr_start.sh | 94 ++++++++++----------- script/start_all.sh | 36 ++++---- script/start_rpc_service.sh | 118 +++++++++++++------------- script/stop_all.sh | 38 ++++----- script/style_info.cfg | 18 ++-- 17 files changed, 668 insertions(+), 511 deletions(-) create mode 100644 docs/config.yaml diff --git a/README.md b/README.md index 8b32d0903..669b57926 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Open-IM-Server +# Open-IM-Server ![avatar](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/open-im-logo.png) diff --git a/docs/config.yaml b/docs/config.yaml new file mode 100644 index 000000000..765cbb21b --- /dev/null +++ b/docs/config.yaml @@ -0,0 +1,146 @@ +# The class cannot be named by Pascal or camel case. +# If it is not used, the corresponding structure will not be set, +# and it will not be read naturally. +serverversion: 1.0.0 +#---------------Infrastructure configuration---------------------# +etcd: + etcdSchema: openIM + etcdAddr: [ 127.0.0.1:2379 ] + +mysql: + dbMysqlAddress: [ 127.0.0.1:3306 ] + dbMysqlUserName: root + dbMysqlPassword: openIM + dbMysqlDatabaseName: openIM + dbTableName: eMsg + dbMsgTableNum: 1 + dbMaxOpenConns: 20 + dbMaxIdleConns: 10 + dbMaxLifeTime: 120 + +mongo: + dbAddress: [ 127.0.0.1:27017 ] + dbDirect: false + dbTimeout: 10 + dbDatabase: openIM + dbSource: admin + dbUserName: + dbPassword: + dbMaxPoolSize: 20 + dbRetainChatRecords: 7 + +redis: + dbAddress: 127.0.0.1:6379 + dbMaxIdle: 128 + dbMaxActive: 0 + dbIdleTimeout: 120 + dbPassWord: openIM + +kafka: + ws2mschat: + addr: [ 127.0.0.1:9092 ] + topic: "ws2ms_chat" + ms2pschat: + addr: [ 127.0.0.1:9092 ] + topic: "ms2ps_chat" + consumergroupid: + msgToMongo: mongo + msgToMySql: mysql + msgToPush: push + + + +#---------------Internal service configuration---------------------# + +# The service ip default is empty, +# automatically obtain the machine's valid network card ip as the service ip, +# otherwise the configuration ip is preferred +serverip: + +api: + openImApiPort: [ 10000 ] +sdk: + openImSdkWsPort: [ 30000 ] + +credential: + tencent: + appID: 1302656840 + region: ap-chengdu + bucket: echat-1302656840 + secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC + secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe + + +rpcport: + openImUserPort: [ 10100 ] + openImFriendPort: [ 10200 ] + openImOfflineMessagePort: [ 10300 ] + openImOnlineRelayPort: [ 10400 ] + openImGroupPort: [ 10500 ] + openImAuthPort: [ 10600 ] + openImPushPort: [ 10700 ] + + +rpcregistername: + openImUserName: User + openImFriendName: Friend + openImOfflineMessageName: OfflineMessage + openImPushName: Push + openImOnlineMessageRelayName: OnlineMessageRelay + openImGroupName: Group + openImAuthName: Auth + +log: + storageLocation: ../logs/ + rotationTime: 24 + remainRotationCount: 5 + remainLogLevel: 6 + elasticSearchSwitch: false + elasticSearchAddr: [ 127.0.0.1:9201 ] + elasticSearchUser: "" + elasticSearchPassword: "" + +modulename: + longConnSvrName: msg_gateway + msgTransferName: msg_transfer + pushName: push + +longconnsvr: + openImWsPort: [ 17778 ] + websocketMaxConnNum: 10000 + websocketMaxMsgLen: 4096 + websocketTimeOut: 10 + +push: + tpns: + ios: + accessID: 1600018281 + secretKey: 3cd68a77a95b89e5089a1aca523f318f + android: + accessID: 111 + secretKey: 111 + jpns: + appKey: 2783339cee4de379cc798fe1 + masterSecret: 66e5f309e032c68cc668c28a + pushUrl: "https://api.jpush.cn/v3/push" +manager: + appManagerUid: ["openIM123456","openIM654321"] + secrets: ["openIM1","openIM2"] + +secret: tuoyun + +multiloginpolicy: + onlyOneTerminalAccess: false + mobileAndPCTerminalAccessButOtherTerminalKickEachOther: true + allTerminalAccess: false + +#token config +tokenpolicy: + accessSecret: "open_im_server" + # Token effective time seconds as a unit + #Seven days 7*24*60*60 + accessExpire: 604800 + +messagecallback: + callbackSwitch: false + callbackUrl: "http://www.xxx.com/msg/judge" \ No newline at end of file diff --git a/script/build_all_service.sh b/script/build_all_service.sh index 07a34bb08..6f563b6f6 100644 --- a/script/build_all_service.sh +++ b/script/build_all_service.sh @@ -1,30 +1,30 @@ -#!/usr/bin/env bash - -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh - -bin_dir="../bin" -logs_dir="../logs" -sdk_db_dir="../db/sdk/" -#Automatically created when there is no bin, logs folder -if [ ! -d $bin_dir ]; then - mkdir -p $bin_dir -fi -if [ ! -d $logs_dir ]; then - mkdir -p $logs_dir -fi -if [ ! -d $sdk_db_dir ]; then - mkdir -p $sdk_db_dir -fi - -#begin path -begin_path=$PWD - -for ((i = 0; i < ${#service_source_root[*]}; i++)); do - cd $begin_path - service_path=${service_source_root[$i]} - cd $service_path && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX" - make install && echo -e "${SKY_BLUE_PREFIX}build ${service_names[$i]} success,moving binary file to the bin directory${COLOR_SUFFIX}" && - echo -e "${SKY_BLUE_PREFIX}Successful moved ${service_names[$i]} to the bin directory${COLOR_SUFFIX}\n" -done +#!/usr/bin/env bash + +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh + +bin_dir="../bin" +logs_dir="../logs" +sdk_db_dir="../db/sdk/" +#Automatically created when there is no bin, logs folder +if [ ! -d $bin_dir ]; then + mkdir -p $bin_dir +fi +if [ ! -d $logs_dir ]; then + mkdir -p $logs_dir +fi +if [ ! -d $sdk_db_dir ]; then + mkdir -p $sdk_db_dir +fi + +#begin path +begin_path=$PWD + +for ((i = 0; i < ${#service_source_root[*]}; i++)); do + cd $begin_path + service_path=${service_source_root[$i]} + cd $service_path && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX" + make install && echo -e "${SKY_BLUE_PREFIX}build ${service_names[$i]} success,moving binary file to the bin directory${COLOR_SUFFIX}" && + echo -e "${SKY_BLUE_PREFIX}Successful moved ${service_names[$i]} to the bin directory${COLOR_SUFFIX}\n" +done diff --git a/script/check_all.sh b/script/check_all.sh index dd8042fde..b984cc10a 100644 --- a/script/check_all.sh +++ b/script/check_all.sh @@ -1,31 +1,43 @@ -#!/usr/bin/env bash - -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh -service_port_name=( - openImApiPort - openImUserPort - openImFriendPort - openImOfflineMessagePort - openImOnlineRelayPort - openImGroupPort - openImAuthPort - openImPushPort - openImWsPort - openImSdkWsPort -) - for i in ${service_port_name[*]};do - list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}') - list_to_string $list - for j in ${ports_array};do - port=`netstat -netulp |grep ./open_im| awk '{print $4}'|grep -w ${j}|awk -F '[:]' '{print $NF}'` - if [[ ${port} -ne ${j} ]]; then - echo -e ${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${YELLOW_PREFIX}${j}${COLOR_SUFFIX} - exit 1 - else - echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX} - fi - done - done - echo -e ${YELLOW_PREFIX}"all services launch success"${COLOR_SUFFIX} +#!/usr/bin/env bash + +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh +service_port_name=( + openImApiPort + openImUserPort + openImFriendPort + openImOfflineMessagePort + openImOnlineRelayPort + openImGroupPort + openImAuthPort + openImPushPort + openImWsPort + openImSdkWsPort +) +for i in ${service_port_name[*]}; do + list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}') + list_to_string $list + for j in ${ports_array}; do + port=$(netstat -netulp | grep ./open_im | awk '{print $4}' | grep -w ${j} | awk -F '[:]' '{print $NF}') + if [[ ${port} -ne ${j} ]]; then + echo -e ${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${YELLOW_PREFIX}${j}${COLOR_SUFFIX} + echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} + exit -1 + else + echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX} + fi + done +done + +#Check launched service process +check=$(ps aux | grep -w ./${msg_transfer_name} | grep -v grep | wc -l) +if [ $check -eq ${msg_transfer_service_num} ]; then + echo -e ${GREEN_PREFIX}"service has been starting,belongs service is openImMsgTransfer"${COLOR_SUFFIX} +else + echo -e ${RED_PREFIX}"openImMsgTransfer service does not start normally, num err"${COLOR_SUFFIX} + echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} + exit -1 +fi + +echo -e ${YELLOW_PREFIX}"all services launch success"${COLOR_SUFFIX} diff --git a/script/docker_check_service.sh b/script/docker_check_service.sh index e380cb3fb..c9fd54ec8 100644 --- a/script/docker_check_service.sh +++ b/script/docker_check_service.sh @@ -1,33 +1,33 @@ -#!/usr/bin/env bash - -source ./style_info.cfg - -docker_compose_components=( - etcd - mongo - mysql - open-im-server - redis - kafka - zookeeper -) - -component_server_count=0 - -for ((i = 0; i < ${#docker_compose_components[*]}; i++)); do - component_server="docker-compose ps|grep -w ${docker_compose_components[$i]}|grep Up" - count="${component_server}|wc -l" - - if [ $(eval ${count}) -gt 0 ]; then - echo -e "${SKY_BLUE_PREFIX}docker-compose ${docker_compose_components[$i]} is Up!${COLOR_SUFFIX}" - let component_server_count+=1 - else - echo -e "${RED_PREFIX} ${docker_compose_components[$i]} start failed!${COLOR_SUFFIX}" - fi -done - -if [ ${component_server_count} -eq 7 ]; then - echo -e "${YELLOW_PREFIX}\ndocker-compose all services is Up!${COLOR_SUFFIX}" -else - echo -e "${RED_PREFIX}\nsome docker-compose services start failed,please check red logs on console ${COLOR_SUFFIX}" -fi +#!/usr/bin/env bash + +source ./style_info.cfg + +docker_compose_components=( + etcd + mongo + mysql + open-im-server + redis + kafka + zookeeper +) + +component_server_count=0 + +for ((i = 0; i < ${#docker_compose_components[*]}; i++)); do + component_server="docker-compose ps|grep -w ${docker_compose_components[$i]}|grep Up" + count="${component_server}|wc -l" + + if [ $(eval ${count}) -gt 0 ]; then + echo -e "${SKY_BLUE_PREFIX}docker-compose ${docker_compose_components[$i]} is Up!${COLOR_SUFFIX}" + let component_server_count+=1 + else + echo -e "${RED_PREFIX} ${docker_compose_components[$i]} start failed!${COLOR_SUFFIX}" + fi +done + +if [ ${component_server_count} -eq 7 ]; then + echo -e "${YELLOW_PREFIX}\ndocker-compose all services is Up!${COLOR_SUFFIX}" +else + echo -e "${RED_PREFIX}\nsome docker-compose services start failed,please check red logs on console ${COLOR_SUFFIX}" +fi diff --git a/script/docker_start_all.sh b/script/docker_start_all.sh index 740b88e85..fce59c41a 100644 --- a/script/docker_start_all.sh +++ b/script/docker_start_all.sh @@ -1,23 +1,23 @@ -#!/usr/bin/env bash -#fixme This script is the total startup script -#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array - -#fixme Put the shell script name here -need_to_start_server_shell=( - start_rpc_service.sh - msg_gateway_start.sh - push_start.sh - msg_transfer_start.sh - sdk_svr_start.sh -) - -#fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started -sleep 10 - -for i in ${need_to_start_server_shell[*]}; do - chmod +x $i - ./$i -done - -#fixme prevents the openIM service exit after execution in the docker container -tail -f /dev/null +#!/usr/bin/env bash +#fixme This script is the total startup script +#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array + +#fixme Put the shell script name here +need_to_start_server_shell=( + start_rpc_service.sh + msg_gateway_start.sh + push_start.sh + msg_transfer_start.sh + sdk_svr_start.sh +) + +#fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started +sleep 10 + +for i in ${need_to_start_server_shell[*]}; do + chmod +x $i + ./$i +done + +#fixme prevents the openIM service exit after execution in the docker container +tail -f /dev/null diff --git a/script/function.sh b/script/function.sh index 0deb52b38..b57373c72 100644 --- a/script/function.sh +++ b/script/function.sh @@ -1,11 +1,11 @@ -#!/usr/bin/env bash -#input:[10023,2323,3434] -#output:10023 2323 3434 -list_to_string(){ -ports_list=$* -sub_s1=`echo $ports_list | sed 's/ //g'` -sub_s2=${sub_s1//,/ } -sub_s3=${sub_s2#*[} -sub_s4=${sub_s3%]*} -ports_array=$sub_s4 +#!/usr/bin/env bash +#input:[10023,2323,3434] +#output:10023 2323 3434 +list_to_string(){ +ports_list=$* +sub_s1=`echo $ports_list | sed 's/ //g'` +sub_s2=${sub_s1//,/ } +sub_s3=${sub_s2#*[} +sub_s4=${sub_s3%]*} +ports_array=$sub_s4 } \ No newline at end of file diff --git a/script/msg_gateway_start.sh b/script/msg_gateway_start.sh index 197c28743..c21d335ca 100644 --- a/script/msg_gateway_start.sh +++ b/script/msg_gateway_start.sh @@ -1,48 +1,48 @@ -#!/usr/bin/env bash -#Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh -list1=$(cat $config_path | grep openImOnlineRelayPort | awk -F '[:]' '{print $NF}') -list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}') -list_to_string $list1 -rpc_ports=($ports_array) -list_to_string $list2 -ws_ports=($ports_array) -if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then - - echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX} - exit 0 - -fi -#Check if the service exists -#If it is exists,kill this process -check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l) -if [ $check -ge 1 ]; then - oldPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}') - kill -9 ${oldPid} -fi -#Waiting port recycling -sleep 1 -cd ${msg_gateway_binary_root} -for ((i = 0; i < ${#ws_ports[@]}; i++)); do - nohup ./${msg_gateway_name} -rpc_port ${rpc_ports[$i]} -ws_port ${ws_ports[$i]} >>../logs/openIM.log 2>&1 & -done - -#Check launched service process -sleep 3 -check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l) -allPorts="" -if [ $check -ge 1 ]; then - allNewPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}') - for i in $allNewPid; do - ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}') - allPorts=${allPorts}"$ports " - done - echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS"${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} -else - echo -e ${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR !!! PLEASE CHECK ERROR LOG"${COLOR_SUFFIX} -fi +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh +list1=$(cat $config_path | grep openImOnlineRelayPort | awk -F '[:]' '{print $NF}') +list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}') +list_to_string $list1 +rpc_ports=($ports_array) +list_to_string $list2 +ws_ports=($ports_array) +if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then + + echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX} + exit 0 + +fi +#Check if the service exists +#If it is exists,kill this process +check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + oldPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}') + kill -9 ${oldPid} +fi +#Waiting port recycling +sleep 1 +cd ${msg_gateway_binary_root} +for ((i = 0; i < ${#ws_ports[@]}; i++)); do + nohup ./${msg_gateway_name} -rpc_port ${rpc_ports[$i]} -ws_port ${ws_ports[$i]} >>../logs/openIM.log 2>&1 & +done + +#Check launched service process +sleep 3 +check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l) +allPorts="" +if [ $check -ge 1 ]; then + allNewPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}') + for i in $allNewPid; do + ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}') + allPorts=${allPorts}"$ports " + done + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS"${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/script/msg_transfer_start.sh b/script/msg_transfer_start.sh index 30caeb466..0b645596c 100644 --- a/script/msg_transfer_start.sh +++ b/script/msg_transfer_start.sh @@ -1,38 +1,36 @@ -#!/usr/bin/env bash -#Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg - - - -#Check if the service exists -#If it is exists,kill this process -check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l` -if [ $check -eq 1 ] -then -oldPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'` - kill -9 $oldPid -fi -#Waiting port recycling -sleep 1 -cd ${msg_transfer_binary_root} - nohup ./${msg_transfer_name} >>../logs/openIM.log 2>&1 & -#Check launched service process -check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l` -if [ $check -eq 1 ] -then -newPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'` -ports=`netstat -netulp | grep -w ${newPid}|awk '{print $4}'|awk -F '[:]' '{print $NF}'` -allPorts="" - -for i in $ports ; -do - allPorts=${allPorts}"$i " -done - echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} -else - echo -e ${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR !!! PLEASE CHECK ERROR LOG"${COLOR_SUFFIX} -fi +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg + + + +#Check if the service exists +#If it is exists,kill this process +check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l` +if [ $check -ge 1 ] +then +oldPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'` + kill -9 $oldPid +fi +#Waiting port recycling +sleep 1 + +cd ${msg_transfer_binary_root} +for ((i = 0; i < ${msg_transfer_service_num}; i++)); do + nohup ./${msg_transfer_name} >>../logs/openIM.log 2>&1 & +done + +#Check launched service process +check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l` +if [ $check -ge 1 ] +then +newPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'` +allPorts="" + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/script/mysql_database_init.sh b/script/mysql_database_init.sh index 2a5135e8e..f8e4caa59 100644 --- a/script/mysql_database_init.sh +++ b/script/mysql_database_init.sh @@ -1,38 +1,38 @@ -#!/usr/bin/env bash - -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh - -#define database attributes -address=$(cat $config_path | grep -w dbMysqlAddress) -list_to_string ${address} -hostAndPort=($ports_array) -DATABASE_HOST=$(echo $hostAndPort | awk -F '[:]' '{print $1}') -DATABASE_PORT=$(echo $hostAndPort | awk -F '[:]' '{print $NF}') -DATABASE_USERNAME=$(cat $config_path | grep -w dbMysqlUserName | awk -F '[:]' '{print $NF}') -DATABASE_PWD=`eval echo $(cat $config_path | grep -w dbMysqlPassword | awk -F '[:]' '{print $NF}')` -DATABASE_NAME=$(cat $config_path | grep -w dbMysqlDatabaseName | awk -F '[:]' '{print $NF}') -SQL_FILE="../config/mysql_sql_file/openIM.sql" - - -create_data_sql="create database IF NOT EXISTS $DATABASE_NAME" -set_character_code_sql="alter database $DATABASE_NAME character set utf8mb4 collate utf8mb4_general_ci" - -echo -e "${SKY_BLUE_PREFIX}start to create database.....$COLOR_SUFFIX" -mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$create_data_sql" - -if [ $? -eq 0 ]; then - echo -e "${SKY_BLUE_PREFIX}create database ${DATABASE_NAME} successfully$COLOR_SUFFIX" - mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$set_character_code_sql" -else - echo -e "${RED_PREFIX}create database failed or exists the database$COLOR_SUFFIX\n" -fi - -echo -e "${SKY_BLUE_PREFIX}start to source openIM.sql .....$COLOR_SUFFIX" -mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -D $DATABASE_NAME <$SQL_FILE -if [ $? -eq 0 ]; then - echo -e "${SKY_BLUE_PREFIX}source openIM.sql successfully$COLOR_SUFFIX" -else - echo -e "${RED_PREFIX}source openIM.sql failed$COLOR_SUFFIX\n" -fi +#!/usr/bin/env bash + +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh + +#define database attributes +address=$(cat $config_path | grep -w dbMysqlAddress) +list_to_string ${address} +hostAndPort=($ports_array) +DATABASE_HOST=$(echo $hostAndPort | awk -F '[:]' '{print $1}') +DATABASE_PORT=$(echo $hostAndPort | awk -F '[:]' '{print $NF}') +DATABASE_USERNAME=$(cat $config_path | grep -w dbMysqlUserName | awk -F '[:]' '{print $NF}') +DATABASE_PWD=`eval echo $(cat $config_path | grep -w dbMysqlPassword | awk -F '[:]' '{print $NF}')` +DATABASE_NAME=$(cat $config_path | grep -w dbMysqlDatabaseName | awk -F '[:]' '{print $NF}') +SQL_FILE="../config/mysql_sql_file/openIM.sql" + + +create_data_sql="create database IF NOT EXISTS $DATABASE_NAME" +set_character_code_sql="alter database $DATABASE_NAME character set utf8mb4 collate utf8mb4_general_ci" + +echo -e "${SKY_BLUE_PREFIX}start to create database.....$COLOR_SUFFIX" +mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$create_data_sql" + +if [ $? -eq 0 ]; then + echo -e "${SKY_BLUE_PREFIX}create database ${DATABASE_NAME} successfully$COLOR_SUFFIX" + mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$set_character_code_sql" +else + echo -e "${RED_PREFIX}create database failed or exists the database$COLOR_SUFFIX\n" +fi + +echo -e "${SKY_BLUE_PREFIX}start to source openIM.sql .....$COLOR_SUFFIX" +mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -D $DATABASE_NAME <$SQL_FILE +if [ $? -eq 0 ]; then + echo -e "${SKY_BLUE_PREFIX}source openIM.sql successfully$COLOR_SUFFIX" +else + echo -e "${RED_PREFIX}source openIM.sql failed$COLOR_SUFFIX\n" +fi diff --git a/script/path_info.cfg b/script/path_info.cfg index ed250d29d..4529c93d6 100644 --- a/script/path_info.cfg +++ b/script/path_info.cfg @@ -1,62 +1,63 @@ -#Don't put the space between "=" -msg_gateway_name="open_im_msg_gateway" -msg_gateway_binary_root="../bin/" -msg_gateway_source_root="../src/msg_gateway/" - -msg_name="open_im_msg" -msg_binary_root="../bin/" -msg_source_root="../src/rpc/chat/" - -push_name="open_im_push" -push_binary_root="../bin/" -push_source_root="../src/push/" - - - -msg_transfer_name="open_im_msg_transfer" -msg_transfer_binary_root="../bin/" -msg_transfer_source_root="../src/msg_transfer/" - - -sdk_server_name="open_im_sdk_server" -sdk_server_binary_root="../bin/" -sdk_server_source_root="../src/Open-IM-SDK-Core/" - - -#Global configuration file default dir -config_path="../config/config.yaml" - -#servicefile dir path -service_source_root=( - #api service file - ../src/api/ - #rpc service file - ../src/rpc/user/ - ../src/rpc/friend/ - ../src/rpc/group/ - ../src/rpc/auth/ - ${msg_gateway_source_root} - ${msg_transfer_source_root} - ${msg_source_root} - ${push_source_root} - ${sdk_server_source_root} -) -#service filename -service_names=( - #api service filename - open_im_api - #rpc service filename - open_im_user - open_im_friend - open_im_group - open_im_auth - ${msg_gateway_name} - ${msg_transfer_name} - ${msg_name} - ${push_name} - ${sdk_server_name} -) - - - - +#Don't put the space between "=" +msg_gateway_name="open_im_msg_gateway" +msg_gateway_binary_root="../bin/" +msg_gateway_source_root="../src/msg_gateway/" + +msg_name="open_im_msg" +msg_binary_root="../bin/" +msg_source_root="../src/rpc/chat/" + +push_name="open_im_push" +push_binary_root="../bin/" +push_source_root="../src/push/" + + + +msg_transfer_name="open_im_msg_transfer" +msg_transfer_binary_root="../bin/" +msg_transfer_source_root="../src/msg_transfer/" +msg_transfer_service_num=2 + + +sdk_server_name="open_im_sdk_server" +sdk_server_binary_root="../bin/" +sdk_server_source_root="../src/Open-IM-SDK-Core/" + + +#Global configuration file default dir +config_path="../config/config.yaml" + +#servicefile dir path +service_source_root=( + #api service file + ../src/api/ + #rpc service file + ../src/rpc/user/ + ../src/rpc/friend/ + ../src/rpc/group/ + ../src/rpc/auth/ + ${msg_gateway_source_root} + ${msg_transfer_source_root} + ${msg_source_root} + ${push_source_root} + ${sdk_server_source_root} +) +#service filename +service_names=( + #api service filename + open_im_api + #rpc service filename + open_im_user + open_im_friend + open_im_group + open_im_auth + ${msg_gateway_name} + ${msg_transfer_name} + ${msg_name} + ${push_name} + ${sdk_server_name} +) + + + + diff --git a/script/push_start.sh b/script/push_start.sh index 668c0068f..51ec1d6ba 100644 --- a/script/push_start.sh +++ b/script/push_start.sh @@ -1,45 +1,45 @@ -#!/usr/bin/env bash -#Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh - - - -list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}') -list_to_string $list1 -rpc_ports=($ports_array) - -#Check if the service exists -#If it is exists,kill this process -check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) -if [ $check -eq 1 ]; then - oldPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') - kill -9 $oldPid -fi -#Waiting port recycling -sleep 1 -cd ${push_binary_root} - -for ((i = 0; i < ${#rpc_ports[@]}; i++)); do - nohup ./${push_name} -port ${rpc_ports[$i]} >>../logs/openIM.log 2>&1 & -done - -sleep 3 -#Check launched service process -check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) -if [ $check -eq 1 ]; then - newPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') - ports=$(netstat -netulp | grep -w ${newPid} | awk '{print $4}' | awk -F '[:]' '{print $NF}') - allPorts="" - - for i in $ports; do - allPorts=${allPorts}"$i " - done - echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} -else - echo -e ${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR !!! PLEASE CHECK ERROR LOG"${COLOR_SUFFIX} -fi +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh + + + +list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}') +list_to_string $list1 +rpc_ports=($ports_array) + +#Check if the service exists +#If it is exists,kill this process +check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + oldPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') + kill -9 $oldPid +fi +#Waiting port recycling +sleep 1 +cd ${push_binary_root} + +for ((i = 0; i < ${#rpc_ports[@]}; i++)); do + nohup ./${push_name} -port ${rpc_ports[$i]} >>../logs/openIM.log 2>&1 & +done + +sleep 3 +#Check launched service process +check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + newPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') + ports=$(netstat -netulp | grep -w ${newPid} | awk '{print $4}' | awk -F '[:]' '{print $NF}') + allPorts="" + + for i in $ports; do + allPorts=${allPorts}"$i " + done + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/script/sdk_svr_start.sh b/script/sdk_svr_start.sh index 28d764b73..4d6af3999 100644 --- a/script/sdk_svr_start.sh +++ b/script/sdk_svr_start.sh @@ -1,47 +1,47 @@ -#!/usr/bin/env bash -#Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh -list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}') -list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}') -list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}') -list_to_string $list1 -api_ports=($ports_array) -list_to_string $list2 -ws_ports=($ports_array) -list_to_string $list3 -sdk_ws_ports=($ports_array) - - - - -#Check if the service exists -#If it is exists,kill this process -check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l) -if [ $check -ge 1 ]; then - oldPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}') - kill -9 ${oldPid} -fi -#Waiting port recycling -sleep 1 -cd ${sdk_server_binary_root} - nohup ./${sdk_server_name} -openIM_api_port ${api_ports[0]} -openIM_ws_port ${ws_ports[0]} -sdk_ws_port ${sdk_ws_ports[0]} >>../logs/openIM.log 2>&1 & - -#Check launched service process -sleep 3 -check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l) -allPorts="" -if [ $check -ge 1 ]; then - allNewPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}') - for i in $allNewPid; do - ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}') - allPorts=${allPorts}"$ports " - done - echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} -else - echo -e ${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR !!! PLEASE CHECK ERROR LOG"${COLOR_SUFFIX} -fi +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh +list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}') +list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}') +list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}') +list_to_string $list1 +api_ports=($ports_array) +list_to_string $list2 +ws_ports=($ports_array) +list_to_string $list3 +sdk_ws_ports=($ports_array) + + + + +#Check if the service exists +#If it is exists,kill this process +check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + oldPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}') + kill -9 ${oldPid} +fi +#Waiting port recycling +sleep 1 +cd ${sdk_server_binary_root} + nohup ./${sdk_server_name} -openIM_api_port ${api_ports[0]} -openIM_ws_port ${ws_ports[0]} -sdk_ws_port ${sdk_ws_ports[0]} >>../logs/openIM.log 2>&1 & + +#Check launched service process +sleep 3 +check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l) +allPorts="" +if [ $check -ge 1 ]; then + allNewPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}') + for i in $allNewPid; do + ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}') + allPorts=${allPorts}"$ports " + done + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/script/start_all.sh b/script/start_all.sh index 43a02b34d..9990cb6c8 100644 --- a/script/start_all.sh +++ b/script/start_all.sh @@ -1,18 +1,18 @@ -#!/usr/bin/env bash -#fixme This script is the total startup script -#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array - -#fixme Put the shell script name here -need_to_start_server_shell=( - start_rpc_service.sh - msg_gateway_start.sh - push_start.sh - msg_transfer_start.sh - sdk_svr_start.sh -) - -for i in ${need_to_start_server_shell[*]}; do - chmod +x $i - ./$i -done - +#!/usr/bin/env bash +#fixme This script is the total startup script +#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array + +#fixme Put the shell script name here +need_to_start_server_shell=( + start_rpc_service.sh + msg_gateway_start.sh + push_start.sh + msg_transfer_start.sh + sdk_svr_start.sh +) + +for i in ${need_to_start_server_shell[*]}; do + chmod +x $i + ./$i +done + diff --git a/script/start_rpc_service.sh b/script/start_rpc_service.sh index 74f00a3f4..6307ca1c0 100644 --- a/script/start_rpc_service.sh +++ b/script/start_rpc_service.sh @@ -1,59 +1,59 @@ -#!/usr/bin/env bash - -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh - -#service filename -service_filename=( - #api - open_im_api - #rpc - open_im_user - open_im_friend - open_im_group - open_im_auth - ${msg_name} -) - -#service config port name -service_port_name=( - #api port name - openImApiPort - #rpc port name - openImUserPort - openImFriendPort - openImGroupPort - openImAuthPort - openImOfflineMessagePort - -) - -for ((i = 0; i < ${#service_filename[*]}; i++)); do - #Check whether the service exists - service_name="ps -aux |grep -w ${service_filename[$i]} |grep -v grep" - count="${service_name}| wc -l" - - if [ $(eval ${count}) -gt 0 ]; then - pid="${service_name}| awk '{print \$2}'" - echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service has been started,pid:$(eval $pid)$COLOR_SUFFIX" - echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename[$i]} pid:$(eval $pid)${COLOR_SUFFIX}" - #kill the service that existed - kill -9 $(eval $pid) - sleep 0.5 - fi - cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service is starting${COLOR_SUFFIX}" - #Get the rpc port in the configuration file - portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}') - list_to_string ${portList} - #Start related rpc services based on the number of ports - for j in ${ports_array}; do - echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} Service is starting,port number:$j $COLOR_SUFFIX" - #Start the service in the background - # ./${service_filename[$i]} -port $j & - nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 & - sleep 1 - pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" - echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX" - done -done +#!/usr/bin/env bash + +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh + +#service filename +service_filename=( + #api + open_im_api + #rpc + open_im_user + open_im_friend + open_im_group + open_im_auth + ${msg_name} +) + +#service config port name +service_port_name=( + #api port name + openImApiPort + #rpc port name + openImUserPort + openImFriendPort + openImGroupPort + openImAuthPort + openImOfflineMessagePort + +) + +for ((i = 0; i < ${#service_filename[*]}; i++)); do + #Check whether the service exists + service_name="ps -aux |grep -w ${service_filename[$i]} |grep -v grep" + count="${service_name}| wc -l" + + if [ $(eval ${count}) -gt 0 ]; then + pid="${service_name}| awk '{print \$2}'" + echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service has been started,pid:$(eval $pid)$COLOR_SUFFIX" + echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename[$i]} pid:$(eval $pid)${COLOR_SUFFIX}" + #kill the service that existed + kill -9 $(eval $pid) + sleep 0.5 + fi + cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service is starting${COLOR_SUFFIX}" + #Get the rpc port in the configuration file + portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}') + list_to_string ${portList} + #Start related rpc services based on the number of ports + for j in ${ports_array}; do + echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} Service is starting,port number:$j $COLOR_SUFFIX" + #Start the service in the background + # ./${service_filename[$i]} -port $j & + nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 & + sleep 1 + pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" + echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX" + done +done diff --git a/script/stop_all.sh b/script/stop_all.sh index 2e1e119c1..ef7237ab5 100644 --- a/script/stop_all.sh +++ b/script/stop_all.sh @@ -1,19 +1,19 @@ -#!/usr/bin/env bash -#fixme This script is to stop the service - -source ./style_info.cfg -source ./path_info.cfg - - -for i in ${service_names[*]}; do - #Check whether the service exists - name="ps -aux |grep -w $i |grep -v grep" - count="${name}| wc -l" - if [ $(eval ${count}) -gt 0 ]; then - pid="${name}| awk '{print \$2}'" - echo -e "${SKY_BLUE_PREFIX}Killing service:$i pid:$(eval $pid)${COLOR_SUFFIX}" - #kill the service that existed - kill -9 $(eval $pid) - echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}" - fi -done +#!/usr/bin/env bash +#fixme This script is to stop the service + +source ./style_info.cfg +source ./path_info.cfg + + +for i in ${service_names[*]}; do + #Check whether the service exists + name="ps -aux |grep -w $i |grep -v grep" + count="${name}| wc -l" + if [ $(eval ${count}) -gt 0 ]; then + pid="${name}| awk '{print \$2}'" + echo -e "${SKY_BLUE_PREFIX}Killing service:$i pid:$(eval $pid)${COLOR_SUFFIX}" + #kill the service that existed + kill -9 $(eval $pid) + echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}" + fi +done diff --git a/script/style_info.cfg b/script/style_info.cfg index ff28dcb88..92cc5da49 100644 --- a/script/style_info.cfg +++ b/script/style_info.cfg @@ -1,9 +1,9 @@ -#Shell font formatting information -COLOR_SUFFIX="\033[0m" -BLACK_PREFIX="\033[30m" -RED_PREFIX="\033[31m" -GREEN_PREFIX="\033[32m" -YELLOW_PREFIX="\033[33m" -BLUE_PREFIX="\033[34m" -PURPLE_PREFIX="\033[35m" -SKY_BLUE_PREFIX="\033[36m" +#Shell font formatting information +COLOR_SUFFIX="\033[0m" +BLACK_PREFIX="\033[30m" +RED_PREFIX="\033[31m" +GREEN_PREFIX="\033[32m" +YELLOW_PREFIX="\033[33m" +BLUE_PREFIX="\033[34m" +PURPLE_PREFIX="\033[35m" +SKY_BLUE_PREFIX="\033[36m" From 76f2ea01bf3bf55ff239180029ca5aab1a55d1e6 Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Fri, 29 Oct 2021 15:08:43 +0800 Subject: [PATCH 14/31] update config (#31) * Update README.md * Add files via upload update config * Add files via upload update script * update config Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --- config/config.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index d7becbbb4..bdc5b4528 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -1,7 +1,8 @@ + # The class cannot be named by Pascal or camel case. # If it is not used, the corresponding structure will not be set, # and it will not be read naturally. - +serverversion: 1.0.0 #---------------Infrastructure configuration---------------------# etcd: etcdSchema: openIM @@ -119,6 +120,10 @@ push: android: accessID: 111 secretKey: 111 + jpns: + appKey: 2783339cee4de379cc798fe1 + masterSecret: 66e5f309e032c68cc668c28a + pushUrl: "https://api.jpush.cn/v3/push" manager: appManagerUid: ["openIM123456","openIM654321"] secrets: ["openIM1","openIM2"] @@ -134,8 +139,8 @@ multiloginpolicy: tokenpolicy: accessSecret: "open_im_server" # Token effective time seconds as a unit - #Seven days - accessExpire: 7 + #Seven days 7*24*60*60 + accessExpire: 604800 messagecallback: callbackSwitch: false From d6168cbad9abe52f1a75233170ab11906ed31b23 Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Fri, 29 Oct 2021 20:48:43 +0800 Subject: [PATCH 15/31] Add files via upload update script --- build_all_service.sh | 30 ++++++++++++++++++++ check_all.sh | 43 ++++++++++++++++++++++++++++ docker_check_service.sh | 33 +++++++++++++++++++++ docker_start_all.sh | 23 +++++++++++++++ function.sh | 11 +++++++ msg_gateway_start.sh | 48 +++++++++++++++++++++++++++++++ msg_transfer_start.sh | 36 +++++++++++++++++++++++ mysql_database_init.sh | 38 +++++++++++++++++++++++++ path_info.cfg | 63 +++++++++++++++++++++++++++++++++++++++++ push_start.sh | 45 +++++++++++++++++++++++++++++ sdk_svr_start.sh | 47 ++++++++++++++++++++++++++++++ start_all.sh | 18 ++++++++++++ start_rpc_service.sh | 59 ++++++++++++++++++++++++++++++++++++++ stop_all.sh | 19 +++++++++++++ style_info.cfg | 9 ++++++ 15 files changed, 522 insertions(+) create mode 100644 build_all_service.sh create mode 100644 check_all.sh create mode 100644 docker_check_service.sh create mode 100644 docker_start_all.sh create mode 100644 function.sh create mode 100644 msg_gateway_start.sh create mode 100644 msg_transfer_start.sh create mode 100644 mysql_database_init.sh create mode 100644 path_info.cfg create mode 100644 push_start.sh create mode 100644 sdk_svr_start.sh create mode 100644 start_all.sh create mode 100644 start_rpc_service.sh create mode 100644 stop_all.sh create mode 100644 style_info.cfg diff --git a/build_all_service.sh b/build_all_service.sh new file mode 100644 index 000000000..6f563b6f6 --- /dev/null +++ b/build_all_service.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh + +bin_dir="../bin" +logs_dir="../logs" +sdk_db_dir="../db/sdk/" +#Automatically created when there is no bin, logs folder +if [ ! -d $bin_dir ]; then + mkdir -p $bin_dir +fi +if [ ! -d $logs_dir ]; then + mkdir -p $logs_dir +fi +if [ ! -d $sdk_db_dir ]; then + mkdir -p $sdk_db_dir +fi + +#begin path +begin_path=$PWD + +for ((i = 0; i < ${#service_source_root[*]}; i++)); do + cd $begin_path + service_path=${service_source_root[$i]} + cd $service_path && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX" + make install && echo -e "${SKY_BLUE_PREFIX}build ${service_names[$i]} success,moving binary file to the bin directory${COLOR_SUFFIX}" && + echo -e "${SKY_BLUE_PREFIX}Successful moved ${service_names[$i]} to the bin directory${COLOR_SUFFIX}\n" +done diff --git a/check_all.sh b/check_all.sh new file mode 100644 index 000000000..b984cc10a --- /dev/null +++ b/check_all.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh +service_port_name=( + openImApiPort + openImUserPort + openImFriendPort + openImOfflineMessagePort + openImOnlineRelayPort + openImGroupPort + openImAuthPort + openImPushPort + openImWsPort + openImSdkWsPort +) +for i in ${service_port_name[*]}; do + list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}') + list_to_string $list + for j in ${ports_array}; do + port=$(netstat -netulp | grep ./open_im | awk '{print $4}' | grep -w ${j} | awk -F '[:]' '{print $NF}') + if [[ ${port} -ne ${j} ]]; then + echo -e ${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${YELLOW_PREFIX}${j}${COLOR_SUFFIX} + echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} + exit -1 + else + echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX} + fi + done +done + +#Check launched service process +check=$(ps aux | grep -w ./${msg_transfer_name} | grep -v grep | wc -l) +if [ $check -eq ${msg_transfer_service_num} ]; then + echo -e ${GREEN_PREFIX}"service has been starting,belongs service is openImMsgTransfer"${COLOR_SUFFIX} +else + echo -e ${RED_PREFIX}"openImMsgTransfer service does not start normally, num err"${COLOR_SUFFIX} + echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} + exit -1 +fi + +echo -e ${YELLOW_PREFIX}"all services launch success"${COLOR_SUFFIX} diff --git a/docker_check_service.sh b/docker_check_service.sh new file mode 100644 index 000000000..c9fd54ec8 --- /dev/null +++ b/docker_check_service.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +source ./style_info.cfg + +docker_compose_components=( + etcd + mongo + mysql + open-im-server + redis + kafka + zookeeper +) + +component_server_count=0 + +for ((i = 0; i < ${#docker_compose_components[*]}; i++)); do + component_server="docker-compose ps|grep -w ${docker_compose_components[$i]}|grep Up" + count="${component_server}|wc -l" + + if [ $(eval ${count}) -gt 0 ]; then + echo -e "${SKY_BLUE_PREFIX}docker-compose ${docker_compose_components[$i]} is Up!${COLOR_SUFFIX}" + let component_server_count+=1 + else + echo -e "${RED_PREFIX} ${docker_compose_components[$i]} start failed!${COLOR_SUFFIX}" + fi +done + +if [ ${component_server_count} -eq 7 ]; then + echo -e "${YELLOW_PREFIX}\ndocker-compose all services is Up!${COLOR_SUFFIX}" +else + echo -e "${RED_PREFIX}\nsome docker-compose services start failed,please check red logs on console ${COLOR_SUFFIX}" +fi diff --git a/docker_start_all.sh b/docker_start_all.sh new file mode 100644 index 000000000..fce59c41a --- /dev/null +++ b/docker_start_all.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +#fixme This script is the total startup script +#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array + +#fixme Put the shell script name here +need_to_start_server_shell=( + start_rpc_service.sh + msg_gateway_start.sh + push_start.sh + msg_transfer_start.sh + sdk_svr_start.sh +) + +#fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started +sleep 10 + +for i in ${need_to_start_server_shell[*]}; do + chmod +x $i + ./$i +done + +#fixme prevents the openIM service exit after execution in the docker container +tail -f /dev/null diff --git a/function.sh b/function.sh new file mode 100644 index 000000000..b57373c72 --- /dev/null +++ b/function.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +#input:[10023,2323,3434] +#output:10023 2323 3434 +list_to_string(){ +ports_list=$* +sub_s1=`echo $ports_list | sed 's/ //g'` +sub_s2=${sub_s1//,/ } +sub_s3=${sub_s2#*[} +sub_s4=${sub_s3%]*} +ports_array=$sub_s4 +} \ No newline at end of file diff --git a/msg_gateway_start.sh b/msg_gateway_start.sh new file mode 100644 index 000000000..c21d335ca --- /dev/null +++ b/msg_gateway_start.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh +list1=$(cat $config_path | grep openImOnlineRelayPort | awk -F '[:]' '{print $NF}') +list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}') +list_to_string $list1 +rpc_ports=($ports_array) +list_to_string $list2 +ws_ports=($ports_array) +if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then + + echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX} + exit 0 + +fi +#Check if the service exists +#If it is exists,kill this process +check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + oldPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}') + kill -9 ${oldPid} +fi +#Waiting port recycling +sleep 1 +cd ${msg_gateway_binary_root} +for ((i = 0; i < ${#ws_ports[@]}; i++)); do + nohup ./${msg_gateway_name} -rpc_port ${rpc_ports[$i]} -ws_port ${ws_ports[$i]} >>../logs/openIM.log 2>&1 & +done + +#Check launched service process +sleep 3 +check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l) +allPorts="" +if [ $check -ge 1 ]; then + allNewPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}') + for i in $allNewPid; do + ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}') + allPorts=${allPorts}"$ports " + done + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS"${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/msg_transfer_start.sh b/msg_transfer_start.sh new file mode 100644 index 000000000..0b645596c --- /dev/null +++ b/msg_transfer_start.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg + + + +#Check if the service exists +#If it is exists,kill this process +check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l` +if [ $check -ge 1 ] +then +oldPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'` + kill -9 $oldPid +fi +#Waiting port recycling +sleep 1 + +cd ${msg_transfer_binary_root} +for ((i = 0; i < ${msg_transfer_service_num}; i++)); do + nohup ./${msg_transfer_name} >>../logs/openIM.log 2>&1 & +done + +#Check launched service process +check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l` +if [ $check -ge 1 ] +then +newPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'` +allPorts="" + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/mysql_database_init.sh b/mysql_database_init.sh new file mode 100644 index 000000000..f8e4caa59 --- /dev/null +++ b/mysql_database_init.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh + +#define database attributes +address=$(cat $config_path | grep -w dbMysqlAddress) +list_to_string ${address} +hostAndPort=($ports_array) +DATABASE_HOST=$(echo $hostAndPort | awk -F '[:]' '{print $1}') +DATABASE_PORT=$(echo $hostAndPort | awk -F '[:]' '{print $NF}') +DATABASE_USERNAME=$(cat $config_path | grep -w dbMysqlUserName | awk -F '[:]' '{print $NF}') +DATABASE_PWD=`eval echo $(cat $config_path | grep -w dbMysqlPassword | awk -F '[:]' '{print $NF}')` +DATABASE_NAME=$(cat $config_path | grep -w dbMysqlDatabaseName | awk -F '[:]' '{print $NF}') +SQL_FILE="../config/mysql_sql_file/openIM.sql" + + +create_data_sql="create database IF NOT EXISTS $DATABASE_NAME" +set_character_code_sql="alter database $DATABASE_NAME character set utf8mb4 collate utf8mb4_general_ci" + +echo -e "${SKY_BLUE_PREFIX}start to create database.....$COLOR_SUFFIX" +mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$create_data_sql" + +if [ $? -eq 0 ]; then + echo -e "${SKY_BLUE_PREFIX}create database ${DATABASE_NAME} successfully$COLOR_SUFFIX" + mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$set_character_code_sql" +else + echo -e "${RED_PREFIX}create database failed or exists the database$COLOR_SUFFIX\n" +fi + +echo -e "${SKY_BLUE_PREFIX}start to source openIM.sql .....$COLOR_SUFFIX" +mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -D $DATABASE_NAME <$SQL_FILE +if [ $? -eq 0 ]; then + echo -e "${SKY_BLUE_PREFIX}source openIM.sql successfully$COLOR_SUFFIX" +else + echo -e "${RED_PREFIX}source openIM.sql failed$COLOR_SUFFIX\n" +fi diff --git a/path_info.cfg b/path_info.cfg new file mode 100644 index 000000000..4529c93d6 --- /dev/null +++ b/path_info.cfg @@ -0,0 +1,63 @@ +#Don't put the space between "=" +msg_gateway_name="open_im_msg_gateway" +msg_gateway_binary_root="../bin/" +msg_gateway_source_root="../src/msg_gateway/" + +msg_name="open_im_msg" +msg_binary_root="../bin/" +msg_source_root="../src/rpc/chat/" + +push_name="open_im_push" +push_binary_root="../bin/" +push_source_root="../src/push/" + + + +msg_transfer_name="open_im_msg_transfer" +msg_transfer_binary_root="../bin/" +msg_transfer_source_root="../src/msg_transfer/" +msg_transfer_service_num=2 + + +sdk_server_name="open_im_sdk_server" +sdk_server_binary_root="../bin/" +sdk_server_source_root="../src/Open-IM-SDK-Core/" + + +#Global configuration file default dir +config_path="../config/config.yaml" + +#servicefile dir path +service_source_root=( + #api service file + ../src/api/ + #rpc service file + ../src/rpc/user/ + ../src/rpc/friend/ + ../src/rpc/group/ + ../src/rpc/auth/ + ${msg_gateway_source_root} + ${msg_transfer_source_root} + ${msg_source_root} + ${push_source_root} + ${sdk_server_source_root} +) +#service filename +service_names=( + #api service filename + open_im_api + #rpc service filename + open_im_user + open_im_friend + open_im_group + open_im_auth + ${msg_gateway_name} + ${msg_transfer_name} + ${msg_name} + ${push_name} + ${sdk_server_name} +) + + + + diff --git a/push_start.sh b/push_start.sh new file mode 100644 index 000000000..51ec1d6ba --- /dev/null +++ b/push_start.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh + + + +list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}') +list_to_string $list1 +rpc_ports=($ports_array) + +#Check if the service exists +#If it is exists,kill this process +check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + oldPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') + kill -9 $oldPid +fi +#Waiting port recycling +sleep 1 +cd ${push_binary_root} + +for ((i = 0; i < ${#rpc_ports[@]}; i++)); do + nohup ./${push_name} -port ${rpc_ports[$i]} >>../logs/openIM.log 2>&1 & +done + +sleep 3 +#Check launched service process +check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + newPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') + ports=$(netstat -netulp | grep -w ${newPid} | awk '{print $4}' | awk -F '[:]' '{print $NF}') + allPorts="" + + for i in $ports; do + allPorts=${allPorts}"$i " + done + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/sdk_svr_start.sh b/sdk_svr_start.sh new file mode 100644 index 000000000..4d6af3999 --- /dev/null +++ b/sdk_svr_start.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh +list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}') +list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}') +list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}') +list_to_string $list1 +api_ports=($ports_array) +list_to_string $list2 +ws_ports=($ports_array) +list_to_string $list3 +sdk_ws_ports=($ports_array) + + + + +#Check if the service exists +#If it is exists,kill this process +check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + oldPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}') + kill -9 ${oldPid} +fi +#Waiting port recycling +sleep 1 +cd ${sdk_server_binary_root} + nohup ./${sdk_server_name} -openIM_api_port ${api_ports[0]} -openIM_ws_port ${ws_ports[0]} -sdk_ws_port ${sdk_ws_ports[0]} >>../logs/openIM.log 2>&1 & + +#Check launched service process +sleep 3 +check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l) +allPorts="" +if [ $check -ge 1 ]; then + allNewPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}') + for i in $allNewPid; do + ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}') + allPorts=${allPorts}"$ports " + done + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/start_all.sh b/start_all.sh new file mode 100644 index 000000000..9990cb6c8 --- /dev/null +++ b/start_all.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +#fixme This script is the total startup script +#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array + +#fixme Put the shell script name here +need_to_start_server_shell=( + start_rpc_service.sh + msg_gateway_start.sh + push_start.sh + msg_transfer_start.sh + sdk_svr_start.sh +) + +for i in ${need_to_start_server_shell[*]}; do + chmod +x $i + ./$i +done + diff --git a/start_rpc_service.sh b/start_rpc_service.sh new file mode 100644 index 000000000..6307ca1c0 --- /dev/null +++ b/start_rpc_service.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh + +#service filename +service_filename=( + #api + open_im_api + #rpc + open_im_user + open_im_friend + open_im_group + open_im_auth + ${msg_name} +) + +#service config port name +service_port_name=( + #api port name + openImApiPort + #rpc port name + openImUserPort + openImFriendPort + openImGroupPort + openImAuthPort + openImOfflineMessagePort + +) + +for ((i = 0; i < ${#service_filename[*]}; i++)); do + #Check whether the service exists + service_name="ps -aux |grep -w ${service_filename[$i]} |grep -v grep" + count="${service_name}| wc -l" + + if [ $(eval ${count}) -gt 0 ]; then + pid="${service_name}| awk '{print \$2}'" + echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service has been started,pid:$(eval $pid)$COLOR_SUFFIX" + echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename[$i]} pid:$(eval $pid)${COLOR_SUFFIX}" + #kill the service that existed + kill -9 $(eval $pid) + sleep 0.5 + fi + cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service is starting${COLOR_SUFFIX}" + #Get the rpc port in the configuration file + portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}') + list_to_string ${portList} + #Start related rpc services based on the number of ports + for j in ${ports_array}; do + echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} Service is starting,port number:$j $COLOR_SUFFIX" + #Start the service in the background + # ./${service_filename[$i]} -port $j & + nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 & + sleep 1 + pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" + echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX" + done +done diff --git a/stop_all.sh b/stop_all.sh new file mode 100644 index 000000000..ef7237ab5 --- /dev/null +++ b/stop_all.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +#fixme This script is to stop the service + +source ./style_info.cfg +source ./path_info.cfg + + +for i in ${service_names[*]}; do + #Check whether the service exists + name="ps -aux |grep -w $i |grep -v grep" + count="${name}| wc -l" + if [ $(eval ${count}) -gt 0 ]; then + pid="${name}| awk '{print \$2}'" + echo -e "${SKY_BLUE_PREFIX}Killing service:$i pid:$(eval $pid)${COLOR_SUFFIX}" + #kill the service that existed + kill -9 $(eval $pid) + echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}" + fi +done diff --git a/style_info.cfg b/style_info.cfg new file mode 100644 index 000000000..92cc5da49 --- /dev/null +++ b/style_info.cfg @@ -0,0 +1,9 @@ +#Shell font formatting information +COLOR_SUFFIX="\033[0m" +BLACK_PREFIX="\033[30m" +RED_PREFIX="\033[31m" +GREEN_PREFIX="\033[32m" +YELLOW_PREFIX="\033[33m" +BLUE_PREFIX="\033[34m" +PURPLE_PREFIX="\033[35m" +SKY_BLUE_PREFIX="\033[36m" From 51cef0bc53611b9aa3df10e047634dbc293d359e Mon Sep 17 00:00:00 2001 From: Yaxian Date: Fri, 29 Oct 2021 20:51:15 +0800 Subject: [PATCH 16/31] feat: test utils (#26) --- .gitignore | 2 +- src/utils/cors_middleware.go | 3 +- src/utils/cors_middleware_test.go | 67 ++++++++++++++++++++ src/utils/image.go | 15 +++-- src/utils/image_test.go | 27 ++++++++ src/utils/md5_test.go | 15 +++++ src/utils/platform_number_id_to_name_test.go | 45 +++++++++++++ 7 files changed, 167 insertions(+), 7 deletions(-) create mode 100644 src/utils/cors_middleware_test.go create mode 100644 src/utils/image_test.go create mode 100644 src/utils/md5_test.go create mode 100644 src/utils/platform_number_id_to_name_test.go diff --git a/.gitignore b/.gitignore index 74a748ab0..3f1a36dca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .devcontainer components logs - +out-test diff --git a/src/utils/cors_middleware.go b/src/utils/cors_middleware.go index 1d75c4ead..6809d786d 100644 --- a/src/utils/cors_middleware.go +++ b/src/utils/cors_middleware.go @@ -1,8 +1,9 @@ package utils import ( - "github.com/gin-gonic/gin" "net/http" + + "github.com/gin-gonic/gin" ) func CorsHandler() gin.HandlerFunc { diff --git a/src/utils/cors_middleware_test.go b/src/utils/cors_middleware_test.go new file mode 100644 index 000000000..0abfe3f3a --- /dev/null +++ b/src/utils/cors_middleware_test.go @@ -0,0 +1,67 @@ +package utils + +import ( + "net/http" + "net/http/httptest" + "testing" + + "github.com/gin-gonic/gin" + "github.com/stretchr/testify/assert" +) + +func init() { + gin.SetMode(gin.TestMode) +} + +func performRequest(r http.Handler, method, origin string) *httptest.ResponseRecorder { + return performRequestWithHeaders(r, method, origin, http.Header{}) +} + +func performRequestWithHeaders(r http.Handler, method, origin string, header http.Header) *httptest.ResponseRecorder { + req, _ := http.NewRequest(method, "/", nil) + // From go/net/http/request.go: + // For incoming requests, the Host header is promoted to the + // Request.Host field and removed from the Header map. + req.Host = header.Get("Host") + header.Del("Host") + if len(origin) > 0 { + header.Set("Origin", origin) + } + req.Header = header + w := httptest.NewRecorder() + r.ServeHTTP(w, req) + return w +} + +func newTestRouter() *gin.Engine { + router := gin.New() + router.Use(CorsHandler()) + router.GET("/", func(c *gin.Context) { + c.String(http.StatusOK, "get") + }) + router.POST("/", func(c *gin.Context) { + c.String(http.StatusOK, "post") + }) + router.PATCH("/", func(c *gin.Context) { + c.String(http.StatusOK, "patch") + }) + + return router +} + +func Test_CorsHandler(t *testing.T) { + router := newTestRouter() + // no CORS request, origin == "" + w := performRequest(router, "GET", "") + assert.Equal(t, "get", w.Body.String()) + assert.Equal(t, w.Header().Get("Access-Control-Allow-Origin"), "*") + assert.Equal(t, w.Header().Get("Access-Control-Allow-Methods"), "*") + assert.Equal(t, w.Header().Get("Access-Control-Allow-Headers"), "*") + assert.Equal(t, w.Header().Get("Access-Control-Expose-Headers"), "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar") + assert.Equal(t, w.Header().Get("Access-Control-Max-Age"), "172800") + assert.Equal(t, w.Header().Get("Access-Control-Allow-Credentials"), "false") + assert.Equal(t, w.Header().Get("content-type"), "application/json") + + w = performRequest(router, "OPTIONS", "") + assert.Equal(t, w.Body.String(), "\"Options Request!\"") +} diff --git a/src/utils/image.go b/src/utils/image.go index 393136e63..685c509b4 100644 --- a/src/utils/image.go +++ b/src/utils/image.go @@ -2,20 +2,27 @@ package utils import ( "errors" - "github.com/nfnt/resize" - "golang.org/x/image/bmp" "image" "image/gif" "image/jpeg" "image/png" "io" "os" + "path/filepath" + + "github.com/nfnt/resize" + "golang.org/x/image/bmp" ) func GenSmallImage(src, dst string) error { fIn, _ := os.Open(src) defer fIn.Close() + distDir := filepath.Dir(dst) + if _, err := os.Stat(distDir); os.IsNotExist(err) { + os.MkdirAll(distDir, os.ModePerm) + } + fOut, _ := os.Create(dst) defer fOut.Close() @@ -41,7 +48,7 @@ func scale(in io.Reader, out io.Writer, width, height, quality int) error { switch fm { case "jpeg": - return jpeg.Encode(out, canvas, &jpeg.Options{quality}) + return jpeg.Encode(out, canvas, &jpeg.Options{Quality: quality}) case "png": return png.Encode(out, canvas) case "gif": @@ -51,6 +58,4 @@ func scale(in io.Reader, out io.Writer, width, height, quality int) error { default: return errors.New("ERROR FORMAT") } - - return nil } diff --git a/src/utils/image_test.go b/src/utils/image_test.go new file mode 100644 index 000000000..f28cfc89d --- /dev/null +++ b/src/utils/image_test.go @@ -0,0 +1,27 @@ +package utils + +import ( + "path/filepath" + "runtime" + "testing" + + "github.com/stretchr/testify/assert" +) + +var ( + _, b, _, _ = runtime.Caller(0) + // Root folder of this project + Root = filepath.Join(filepath.Dir(b), "../..") +) + +func Test_GenSmallImage(t *testing.T) { + println(Root) + err := GenSmallImage(Root+"/docs/open-im-logo.png", Root+"/out-test/open-im-logo-test.png") + assert.Nil(t, err) + + err = GenSmallImage(Root+"/docs/open-im-logo.png", "out-test/open-im-logo-test.png") + assert.Nil(t, err) + + err = GenSmallImage(Root+"/docs/Architecture.jpg", "out-test/Architecture-test.jpg") + assert.Nil(t, err) +} diff --git a/src/utils/md5_test.go b/src/utils/md5_test.go new file mode 100644 index 000000000..63eec8077 --- /dev/null +++ b/src/utils/md5_test.go @@ -0,0 +1,15 @@ +package utils + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_Md5(t *testing.T) { + result := Md5("go") + assert.Equal(t, result, "34d1f91fb2e514b8576fab1a75a89a6b") + + result2 := Md5("go") + assert.Equal(t, result, result2) +} diff --git a/src/utils/platform_number_id_to_name_test.go b/src/utils/platform_number_id_to_name_test.go new file mode 100644 index 000000000..fefe39091 --- /dev/null +++ b/src/utils/platform_number_id_to_name_test.go @@ -0,0 +1,45 @@ +package utils + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_PlatformIDToName(t *testing.T) { + assert.Equal(t, PlatformIDToName(1), "IOS") + assert.Equal(t, PlatformIDToName(2), "Android") + assert.Equal(t, PlatformIDToName(3), "Windows") + assert.Equal(t, PlatformIDToName(4), "OSX") + assert.Equal(t, PlatformIDToName(5), "Web") + assert.Equal(t, PlatformIDToName(6), "MiniWeb") + assert.Equal(t, PlatformIDToName(7), "Linux") + + assert.Equal(t, PlatformIDToName(0), "") +} + +func Test_PlatformNameToID(t *testing.T) { + assert.Equal(t, PlatformNameToID("IOS"), int32(1)) + assert.Equal(t, PlatformNameToID("Android"), int32(2)) + assert.Equal(t, PlatformNameToID("Windows"), int32(3)) + assert.Equal(t, PlatformNameToID("OSX"), int32(4)) + assert.Equal(t, PlatformNameToID("Web"), int32(5)) + assert.Equal(t, PlatformNameToID("MiniWeb"), int32(6)) + assert.Equal(t, PlatformNameToID("Linux"), int32(7)) + + assert.Equal(t, PlatformNameToID("UnknownDevice"), int32(0)) + assert.Equal(t, PlatformNameToID(""), int32(0)) +} + +func Test_PlatformNameToClass(t *testing.T) { + assert.Equal(t, PlatformNameToClass("IOS"), "Mobile") + assert.Equal(t, PlatformNameToClass("Android"), "Mobile") + assert.Equal(t, PlatformNameToClass("OSX"), "PC") + assert.Equal(t, PlatformNameToClass("Windows"), "PC") + assert.Equal(t, PlatformNameToClass("Web"), "PC") + assert.Equal(t, PlatformNameToClass("MiniWeb"), "Mobile") + assert.Equal(t, PlatformNameToClass("Linux"), "PC") + + assert.Equal(t, PlatformNameToClass("UnknownDevice"), "") + assert.Equal(t, PlatformNameToClass(""), "") +} From 0cc641d1f82680d5deb78c62be266254067ae001 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Fri, 29 Oct 2021 21:00:59 +0800 Subject: [PATCH 17/31] script --- build_all_service.sh | 30 -------- check_all.sh | 43 ----------- docker_check_service.sh | 33 --------- docker_start_all.sh | 23 ------ function.sh | 11 --- msg_gateway_start.sh | 48 ------------- msg_transfer_start.sh | 36 ---------- mysql_database_init.sh | 38 ---------- path_info.cfg | 63 ----------------- push_start.sh | 45 ------------ script/build_all_service.sh | 60 ++++++++-------- script/check_all.sh | 86 +++++++++++----------- script/docker_check_service.sh | 66 ++++++++--------- script/docker_start_all.sh | 46 ++++++------ script/function.sh | 20 +++--- script/msg_gateway_start.sh | 96 ++++++++++++------------- script/msg_transfer_start.sh | 72 +++++++++---------- script/mysql_database_init.sh | 76 ++++++++++---------- script/path_info.cfg | 126 ++++++++++++++++----------------- script/push_start.sh | 90 +++++++++++------------ script/sdk_svr_start.sh | 94 ++++++++++++------------ script/start_all.sh | 36 +++++----- script/start_rpc_service.sh | 118 +++++++++++++++--------------- script/stop_all.sh | 38 +++++----- script/style_info.cfg | 18 ++--- sdk_svr_start.sh | 47 ------------ src/Open-IM-SDK-Core | 2 +- src/api/friend/add_friend.go | 2 + start_all.sh | 18 ----- start_rpc_service.sh | 59 --------------- stop_all.sh | 19 ----- style_info.cfg | 9 --- 32 files changed, 524 insertions(+), 1044 deletions(-) delete mode 100644 build_all_service.sh delete mode 100644 check_all.sh delete mode 100644 docker_check_service.sh delete mode 100644 docker_start_all.sh delete mode 100644 function.sh delete mode 100644 msg_gateway_start.sh delete mode 100644 msg_transfer_start.sh delete mode 100644 mysql_database_init.sh delete mode 100644 path_info.cfg delete mode 100644 push_start.sh delete mode 100644 sdk_svr_start.sh delete mode 100644 start_all.sh delete mode 100644 start_rpc_service.sh delete mode 100644 stop_all.sh delete mode 100644 style_info.cfg diff --git a/build_all_service.sh b/build_all_service.sh deleted file mode 100644 index 6f563b6f6..000000000 --- a/build_all_service.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh - -bin_dir="../bin" -logs_dir="../logs" -sdk_db_dir="../db/sdk/" -#Automatically created when there is no bin, logs folder -if [ ! -d $bin_dir ]; then - mkdir -p $bin_dir -fi -if [ ! -d $logs_dir ]; then - mkdir -p $logs_dir -fi -if [ ! -d $sdk_db_dir ]; then - mkdir -p $sdk_db_dir -fi - -#begin path -begin_path=$PWD - -for ((i = 0; i < ${#service_source_root[*]}; i++)); do - cd $begin_path - service_path=${service_source_root[$i]} - cd $service_path && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX" - make install && echo -e "${SKY_BLUE_PREFIX}build ${service_names[$i]} success,moving binary file to the bin directory${COLOR_SUFFIX}" && - echo -e "${SKY_BLUE_PREFIX}Successful moved ${service_names[$i]} to the bin directory${COLOR_SUFFIX}\n" -done diff --git a/check_all.sh b/check_all.sh deleted file mode 100644 index b984cc10a..000000000 --- a/check_all.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash - -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh -service_port_name=( - openImApiPort - openImUserPort - openImFriendPort - openImOfflineMessagePort - openImOnlineRelayPort - openImGroupPort - openImAuthPort - openImPushPort - openImWsPort - openImSdkWsPort -) -for i in ${service_port_name[*]}; do - list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}') - list_to_string $list - for j in ${ports_array}; do - port=$(netstat -netulp | grep ./open_im | awk '{print $4}' | grep -w ${j} | awk -F '[:]' '{print $NF}') - if [[ ${port} -ne ${j} ]]; then - echo -e ${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${YELLOW_PREFIX}${j}${COLOR_SUFFIX} - echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} - exit -1 - else - echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX} - fi - done -done - -#Check launched service process -check=$(ps aux | grep -w ./${msg_transfer_name} | grep -v grep | wc -l) -if [ $check -eq ${msg_transfer_service_num} ]; then - echo -e ${GREEN_PREFIX}"service has been starting,belongs service is openImMsgTransfer"${COLOR_SUFFIX} -else - echo -e ${RED_PREFIX}"openImMsgTransfer service does not start normally, num err"${COLOR_SUFFIX} - echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} - exit -1 -fi - -echo -e ${YELLOW_PREFIX}"all services launch success"${COLOR_SUFFIX} diff --git a/docker_check_service.sh b/docker_check_service.sh deleted file mode 100644 index c9fd54ec8..000000000 --- a/docker_check_service.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -source ./style_info.cfg - -docker_compose_components=( - etcd - mongo - mysql - open-im-server - redis - kafka - zookeeper -) - -component_server_count=0 - -for ((i = 0; i < ${#docker_compose_components[*]}; i++)); do - component_server="docker-compose ps|grep -w ${docker_compose_components[$i]}|grep Up" - count="${component_server}|wc -l" - - if [ $(eval ${count}) -gt 0 ]; then - echo -e "${SKY_BLUE_PREFIX}docker-compose ${docker_compose_components[$i]} is Up!${COLOR_SUFFIX}" - let component_server_count+=1 - else - echo -e "${RED_PREFIX} ${docker_compose_components[$i]} start failed!${COLOR_SUFFIX}" - fi -done - -if [ ${component_server_count} -eq 7 ]; then - echo -e "${YELLOW_PREFIX}\ndocker-compose all services is Up!${COLOR_SUFFIX}" -else - echo -e "${RED_PREFIX}\nsome docker-compose services start failed,please check red logs on console ${COLOR_SUFFIX}" -fi diff --git a/docker_start_all.sh b/docker_start_all.sh deleted file mode 100644 index fce59c41a..000000000 --- a/docker_start_all.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -#fixme This script is the total startup script -#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array - -#fixme Put the shell script name here -need_to_start_server_shell=( - start_rpc_service.sh - msg_gateway_start.sh - push_start.sh - msg_transfer_start.sh - sdk_svr_start.sh -) - -#fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started -sleep 10 - -for i in ${need_to_start_server_shell[*]}; do - chmod +x $i - ./$i -done - -#fixme prevents the openIM service exit after execution in the docker container -tail -f /dev/null diff --git a/function.sh b/function.sh deleted file mode 100644 index b57373c72..000000000 --- a/function.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -#input:[10023,2323,3434] -#output:10023 2323 3434 -list_to_string(){ -ports_list=$* -sub_s1=`echo $ports_list | sed 's/ //g'` -sub_s2=${sub_s1//,/ } -sub_s3=${sub_s2#*[} -sub_s4=${sub_s3%]*} -ports_array=$sub_s4 -} \ No newline at end of file diff --git a/msg_gateway_start.sh b/msg_gateway_start.sh deleted file mode 100644 index c21d335ca..000000000 --- a/msg_gateway_start.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash -#Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh -list1=$(cat $config_path | grep openImOnlineRelayPort | awk -F '[:]' '{print $NF}') -list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}') -list_to_string $list1 -rpc_ports=($ports_array) -list_to_string $list2 -ws_ports=($ports_array) -if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then - - echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX} - exit 0 - -fi -#Check if the service exists -#If it is exists,kill this process -check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l) -if [ $check -ge 1 ]; then - oldPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}') - kill -9 ${oldPid} -fi -#Waiting port recycling -sleep 1 -cd ${msg_gateway_binary_root} -for ((i = 0; i < ${#ws_ports[@]}; i++)); do - nohup ./${msg_gateway_name} -rpc_port ${rpc_ports[$i]} -ws_port ${ws_ports[$i]} >>../logs/openIM.log 2>&1 & -done - -#Check launched service process -sleep 3 -check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l) -allPorts="" -if [ $check -ge 1 ]; then - allNewPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}') - for i in $allNewPid; do - ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}') - allPorts=${allPorts}"$ports " - done - echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS"${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} -else - echo -e ${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} -fi diff --git a/msg_transfer_start.sh b/msg_transfer_start.sh deleted file mode 100644 index 0b645596c..000000000 --- a/msg_transfer_start.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -#Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg - - - -#Check if the service exists -#If it is exists,kill this process -check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l` -if [ $check -ge 1 ] -then -oldPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'` - kill -9 $oldPid -fi -#Waiting port recycling -sleep 1 - -cd ${msg_transfer_binary_root} -for ((i = 0; i < ${msg_transfer_service_num}; i++)); do - nohup ./${msg_transfer_name} >>../logs/openIM.log 2>&1 & -done - -#Check launched service process -check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l` -if [ $check -ge 1 ] -then -newPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'` -allPorts="" - echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} -else - echo -e ${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} -fi diff --git a/mysql_database_init.sh b/mysql_database_init.sh deleted file mode 100644 index f8e4caa59..000000000 --- a/mysql_database_init.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh - -#define database attributes -address=$(cat $config_path | grep -w dbMysqlAddress) -list_to_string ${address} -hostAndPort=($ports_array) -DATABASE_HOST=$(echo $hostAndPort | awk -F '[:]' '{print $1}') -DATABASE_PORT=$(echo $hostAndPort | awk -F '[:]' '{print $NF}') -DATABASE_USERNAME=$(cat $config_path | grep -w dbMysqlUserName | awk -F '[:]' '{print $NF}') -DATABASE_PWD=`eval echo $(cat $config_path | grep -w dbMysqlPassword | awk -F '[:]' '{print $NF}')` -DATABASE_NAME=$(cat $config_path | grep -w dbMysqlDatabaseName | awk -F '[:]' '{print $NF}') -SQL_FILE="../config/mysql_sql_file/openIM.sql" - - -create_data_sql="create database IF NOT EXISTS $DATABASE_NAME" -set_character_code_sql="alter database $DATABASE_NAME character set utf8mb4 collate utf8mb4_general_ci" - -echo -e "${SKY_BLUE_PREFIX}start to create database.....$COLOR_SUFFIX" -mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$create_data_sql" - -if [ $? -eq 0 ]; then - echo -e "${SKY_BLUE_PREFIX}create database ${DATABASE_NAME} successfully$COLOR_SUFFIX" - mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$set_character_code_sql" -else - echo -e "${RED_PREFIX}create database failed or exists the database$COLOR_SUFFIX\n" -fi - -echo -e "${SKY_BLUE_PREFIX}start to source openIM.sql .....$COLOR_SUFFIX" -mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -D $DATABASE_NAME <$SQL_FILE -if [ $? -eq 0 ]; then - echo -e "${SKY_BLUE_PREFIX}source openIM.sql successfully$COLOR_SUFFIX" -else - echo -e "${RED_PREFIX}source openIM.sql failed$COLOR_SUFFIX\n" -fi diff --git a/path_info.cfg b/path_info.cfg deleted file mode 100644 index 4529c93d6..000000000 --- a/path_info.cfg +++ /dev/null @@ -1,63 +0,0 @@ -#Don't put the space between "=" -msg_gateway_name="open_im_msg_gateway" -msg_gateway_binary_root="../bin/" -msg_gateway_source_root="../src/msg_gateway/" - -msg_name="open_im_msg" -msg_binary_root="../bin/" -msg_source_root="../src/rpc/chat/" - -push_name="open_im_push" -push_binary_root="../bin/" -push_source_root="../src/push/" - - - -msg_transfer_name="open_im_msg_transfer" -msg_transfer_binary_root="../bin/" -msg_transfer_source_root="../src/msg_transfer/" -msg_transfer_service_num=2 - - -sdk_server_name="open_im_sdk_server" -sdk_server_binary_root="../bin/" -sdk_server_source_root="../src/Open-IM-SDK-Core/" - - -#Global configuration file default dir -config_path="../config/config.yaml" - -#servicefile dir path -service_source_root=( - #api service file - ../src/api/ - #rpc service file - ../src/rpc/user/ - ../src/rpc/friend/ - ../src/rpc/group/ - ../src/rpc/auth/ - ${msg_gateway_source_root} - ${msg_transfer_source_root} - ${msg_source_root} - ${push_source_root} - ${sdk_server_source_root} -) -#service filename -service_names=( - #api service filename - open_im_api - #rpc service filename - open_im_user - open_im_friend - open_im_group - open_im_auth - ${msg_gateway_name} - ${msg_transfer_name} - ${msg_name} - ${push_name} - ${sdk_server_name} -) - - - - diff --git a/push_start.sh b/push_start.sh deleted file mode 100644 index 51ec1d6ba..000000000 --- a/push_start.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash -#Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh - - - -list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}') -list_to_string $list1 -rpc_ports=($ports_array) - -#Check if the service exists -#If it is exists,kill this process -check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) -if [ $check -ge 1 ]; then - oldPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') - kill -9 $oldPid -fi -#Waiting port recycling -sleep 1 -cd ${push_binary_root} - -for ((i = 0; i < ${#rpc_ports[@]}; i++)); do - nohup ./${push_name} -port ${rpc_ports[$i]} >>../logs/openIM.log 2>&1 & -done - -sleep 3 -#Check launched service process -check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) -if [ $check -ge 1 ]; then - newPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') - ports=$(netstat -netulp | grep -w ${newPid} | awk '{print $4}' | awk -F '[:]' '{print $NF}') - allPorts="" - - for i in $ports; do - allPorts=${allPorts}"$i " - done - echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} -else - echo -e ${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} -fi diff --git a/script/build_all_service.sh b/script/build_all_service.sh index 6f563b6f6..07a34bb08 100644 --- a/script/build_all_service.sh +++ b/script/build_all_service.sh @@ -1,30 +1,30 @@ -#!/usr/bin/env bash - -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh - -bin_dir="../bin" -logs_dir="../logs" -sdk_db_dir="../db/sdk/" -#Automatically created when there is no bin, logs folder -if [ ! -d $bin_dir ]; then - mkdir -p $bin_dir -fi -if [ ! -d $logs_dir ]; then - mkdir -p $logs_dir -fi -if [ ! -d $sdk_db_dir ]; then - mkdir -p $sdk_db_dir -fi - -#begin path -begin_path=$PWD - -for ((i = 0; i < ${#service_source_root[*]}; i++)); do - cd $begin_path - service_path=${service_source_root[$i]} - cd $service_path && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX" - make install && echo -e "${SKY_BLUE_PREFIX}build ${service_names[$i]} success,moving binary file to the bin directory${COLOR_SUFFIX}" && - echo -e "${SKY_BLUE_PREFIX}Successful moved ${service_names[$i]} to the bin directory${COLOR_SUFFIX}\n" -done +#!/usr/bin/env bash + +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh + +bin_dir="../bin" +logs_dir="../logs" +sdk_db_dir="../db/sdk/" +#Automatically created when there is no bin, logs folder +if [ ! -d $bin_dir ]; then + mkdir -p $bin_dir +fi +if [ ! -d $logs_dir ]; then + mkdir -p $logs_dir +fi +if [ ! -d $sdk_db_dir ]; then + mkdir -p $sdk_db_dir +fi + +#begin path +begin_path=$PWD + +for ((i = 0; i < ${#service_source_root[*]}; i++)); do + cd $begin_path + service_path=${service_source_root[$i]} + cd $service_path && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX" + make install && echo -e "${SKY_BLUE_PREFIX}build ${service_names[$i]} success,moving binary file to the bin directory${COLOR_SUFFIX}" && + echo -e "${SKY_BLUE_PREFIX}Successful moved ${service_names[$i]} to the bin directory${COLOR_SUFFIX}\n" +done diff --git a/script/check_all.sh b/script/check_all.sh index b984cc10a..3c57577c4 100644 --- a/script/check_all.sh +++ b/script/check_all.sh @@ -1,43 +1,43 @@ -#!/usr/bin/env bash - -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh -service_port_name=( - openImApiPort - openImUserPort - openImFriendPort - openImOfflineMessagePort - openImOnlineRelayPort - openImGroupPort - openImAuthPort - openImPushPort - openImWsPort - openImSdkWsPort -) -for i in ${service_port_name[*]}; do - list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}') - list_to_string $list - for j in ${ports_array}; do - port=$(netstat -netulp | grep ./open_im | awk '{print $4}' | grep -w ${j} | awk -F '[:]' '{print $NF}') - if [[ ${port} -ne ${j} ]]; then - echo -e ${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${YELLOW_PREFIX}${j}${COLOR_SUFFIX} - echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} - exit -1 - else - echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX} - fi - done -done - -#Check launched service process -check=$(ps aux | grep -w ./${msg_transfer_name} | grep -v grep | wc -l) -if [ $check -eq ${msg_transfer_service_num} ]; then - echo -e ${GREEN_PREFIX}"service has been starting,belongs service is openImMsgTransfer"${COLOR_SUFFIX} -else - echo -e ${RED_PREFIX}"openImMsgTransfer service does not start normally, num err"${COLOR_SUFFIX} - echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} - exit -1 -fi - -echo -e ${YELLOW_PREFIX}"all services launch success"${COLOR_SUFFIX} +#!/usr/bin/env bash + +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh +service_port_name=( + openImApiPort + openImUserPort + openImFriendPort + openImOfflineMessagePort + openImOnlineRelayPort + openImGroupPort + openImAuthPort + openImPushPort + openImWsPort + openImSdkWsPort +) +for i in ${service_port_name[*]}; do + list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}') + list_to_string $list + for j in ${ports_array}; do + port=$(netstat -netulp | grep ./open_im | awk '{print $4}' | grep -w ${j} | awk -F '[:]' '{print $NF}') + if [[ ${port} -ne ${j} ]]; then + echo -e ${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${YELLOW_PREFIX}${j}${COLOR_SUFFIX} + echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} + exit -1 + else + echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX} + fi + done +done + +#Check launched service process +check=$(ps aux | grep -w ./${msg_transfer_name} | grep -v grep | wc -l) +if [ $check -eq ${msg_transfer_service_num} ]; then + echo -e ${GREEN_PREFIX}"service has been starting,belongs service is openImMsgTransfer"${COLOR_SUFFIX} +else + echo -e ${RED_PREFIX}"openImMsgTransfer service does not start normally, num err"${COLOR_SUFFIX} + echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} + exit -1 +fi + +echo -e ${YELLOW_PREFIX}"all services launch success"${COLOR_SUFFIX} diff --git a/script/docker_check_service.sh b/script/docker_check_service.sh index c9fd54ec8..e380cb3fb 100644 --- a/script/docker_check_service.sh +++ b/script/docker_check_service.sh @@ -1,33 +1,33 @@ -#!/usr/bin/env bash - -source ./style_info.cfg - -docker_compose_components=( - etcd - mongo - mysql - open-im-server - redis - kafka - zookeeper -) - -component_server_count=0 - -for ((i = 0; i < ${#docker_compose_components[*]}; i++)); do - component_server="docker-compose ps|grep -w ${docker_compose_components[$i]}|grep Up" - count="${component_server}|wc -l" - - if [ $(eval ${count}) -gt 0 ]; then - echo -e "${SKY_BLUE_PREFIX}docker-compose ${docker_compose_components[$i]} is Up!${COLOR_SUFFIX}" - let component_server_count+=1 - else - echo -e "${RED_PREFIX} ${docker_compose_components[$i]} start failed!${COLOR_SUFFIX}" - fi -done - -if [ ${component_server_count} -eq 7 ]; then - echo -e "${YELLOW_PREFIX}\ndocker-compose all services is Up!${COLOR_SUFFIX}" -else - echo -e "${RED_PREFIX}\nsome docker-compose services start failed,please check red logs on console ${COLOR_SUFFIX}" -fi +#!/usr/bin/env bash + +source ./style_info.cfg + +docker_compose_components=( + etcd + mongo + mysql + open-im-server + redis + kafka + zookeeper +) + +component_server_count=0 + +for ((i = 0; i < ${#docker_compose_components[*]}; i++)); do + component_server="docker-compose ps|grep -w ${docker_compose_components[$i]}|grep Up" + count="${component_server}|wc -l" + + if [ $(eval ${count}) -gt 0 ]; then + echo -e "${SKY_BLUE_PREFIX}docker-compose ${docker_compose_components[$i]} is Up!${COLOR_SUFFIX}" + let component_server_count+=1 + else + echo -e "${RED_PREFIX} ${docker_compose_components[$i]} start failed!${COLOR_SUFFIX}" + fi +done + +if [ ${component_server_count} -eq 7 ]; then + echo -e "${YELLOW_PREFIX}\ndocker-compose all services is Up!${COLOR_SUFFIX}" +else + echo -e "${RED_PREFIX}\nsome docker-compose services start failed,please check red logs on console ${COLOR_SUFFIX}" +fi diff --git a/script/docker_start_all.sh b/script/docker_start_all.sh index fce59c41a..740b88e85 100644 --- a/script/docker_start_all.sh +++ b/script/docker_start_all.sh @@ -1,23 +1,23 @@ -#!/usr/bin/env bash -#fixme This script is the total startup script -#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array - -#fixme Put the shell script name here -need_to_start_server_shell=( - start_rpc_service.sh - msg_gateway_start.sh - push_start.sh - msg_transfer_start.sh - sdk_svr_start.sh -) - -#fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started -sleep 10 - -for i in ${need_to_start_server_shell[*]}; do - chmod +x $i - ./$i -done - -#fixme prevents the openIM service exit after execution in the docker container -tail -f /dev/null +#!/usr/bin/env bash +#fixme This script is the total startup script +#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array + +#fixme Put the shell script name here +need_to_start_server_shell=( + start_rpc_service.sh + msg_gateway_start.sh + push_start.sh + msg_transfer_start.sh + sdk_svr_start.sh +) + +#fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started +sleep 10 + +for i in ${need_to_start_server_shell[*]}; do + chmod +x $i + ./$i +done + +#fixme prevents the openIM service exit after execution in the docker container +tail -f /dev/null diff --git a/script/function.sh b/script/function.sh index b57373c72..0deb52b38 100644 --- a/script/function.sh +++ b/script/function.sh @@ -1,11 +1,11 @@ -#!/usr/bin/env bash -#input:[10023,2323,3434] -#output:10023 2323 3434 -list_to_string(){ -ports_list=$* -sub_s1=`echo $ports_list | sed 's/ //g'` -sub_s2=${sub_s1//,/ } -sub_s3=${sub_s2#*[} -sub_s4=${sub_s3%]*} -ports_array=$sub_s4 +#!/usr/bin/env bash +#input:[10023,2323,3434] +#output:10023 2323 3434 +list_to_string(){ +ports_list=$* +sub_s1=`echo $ports_list | sed 's/ //g'` +sub_s2=${sub_s1//,/ } +sub_s3=${sub_s2#*[} +sub_s4=${sub_s3%]*} +ports_array=$sub_s4 } \ No newline at end of file diff --git a/script/msg_gateway_start.sh b/script/msg_gateway_start.sh index c21d335ca..1df53cfdd 100644 --- a/script/msg_gateway_start.sh +++ b/script/msg_gateway_start.sh @@ -1,48 +1,48 @@ -#!/usr/bin/env bash -#Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh -list1=$(cat $config_path | grep openImOnlineRelayPort | awk -F '[:]' '{print $NF}') -list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}') -list_to_string $list1 -rpc_ports=($ports_array) -list_to_string $list2 -ws_ports=($ports_array) -if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then - - echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX} - exit 0 - -fi -#Check if the service exists -#If it is exists,kill this process -check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l) -if [ $check -ge 1 ]; then - oldPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}') - kill -9 ${oldPid} -fi -#Waiting port recycling -sleep 1 -cd ${msg_gateway_binary_root} -for ((i = 0; i < ${#ws_ports[@]}; i++)); do - nohup ./${msg_gateway_name} -rpc_port ${rpc_ports[$i]} -ws_port ${ws_ports[$i]} >>../logs/openIM.log 2>&1 & -done - -#Check launched service process -sleep 3 -check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l) -allPorts="" -if [ $check -ge 1 ]; then - allNewPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}') - for i in $allNewPid; do - ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}') - allPorts=${allPorts}"$ports " - done - echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS"${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} -else - echo -e ${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} -fi +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh +list1=$(cat $config_path | grep openImOnlineRelayPort | awk -F '[:]' '{print $NF}') +list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}') +list_to_string $list1 +rpc_ports=($ports_array) +list_to_string $list2 +ws_ports=($ports_array) +if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then + + echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX} + exit 0 + +fi +#Check if the service exists +#If it is exists,kill this process +check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + oldPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}') + kill -9 ${oldPid} +fi +#Waiting port recycling +sleep 1 +cd ${msg_gateway_binary_root} +for ((i = 0; i < ${#ws_ports[@]}; i++)); do + nohup ./${msg_gateway_name} -rpc_port ${rpc_ports[$i]} -ws_port ${ws_ports[$i]} >>../logs/openIM.log 2>&1 & +done + +#Check launched service process +sleep 3 +check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l) +allPorts="" +if [ $check -ge 1 ]; then + allNewPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}') + for i in $allNewPid; do + ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}') + allPorts=${allPorts}"$ports " + done + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS"${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/script/msg_transfer_start.sh b/script/msg_transfer_start.sh index 0b645596c..4d7fb96cd 100644 --- a/script/msg_transfer_start.sh +++ b/script/msg_transfer_start.sh @@ -1,36 +1,36 @@ -#!/usr/bin/env bash -#Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg - - - -#Check if the service exists -#If it is exists,kill this process -check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l` -if [ $check -ge 1 ] -then -oldPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'` - kill -9 $oldPid -fi -#Waiting port recycling -sleep 1 - -cd ${msg_transfer_binary_root} -for ((i = 0; i < ${msg_transfer_service_num}; i++)); do - nohup ./${msg_transfer_name} >>../logs/openIM.log 2>&1 & -done - -#Check launched service process -check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l` -if [ $check -ge 1 ] -then -newPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'` -allPorts="" - echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} -else - echo -e ${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} -fi +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg + + + +#Check if the service exists +#If it is exists,kill this process +check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l` +if [ $check -ge 1 ] +then +oldPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'` + kill -9 $oldPid +fi +#Waiting port recycling +sleep 1 + +cd ${msg_transfer_binary_root} +for ((i = 0; i < ${msg_transfer_service_num}; i++)); do + nohup ./${msg_transfer_name} >>../logs/openIM.log 2>&1 & +done + +#Check launched service process +check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l` +if [ $check -ge 1 ] +then +newPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'` +allPorts="" + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/script/mysql_database_init.sh b/script/mysql_database_init.sh index f8e4caa59..2a5135e8e 100644 --- a/script/mysql_database_init.sh +++ b/script/mysql_database_init.sh @@ -1,38 +1,38 @@ -#!/usr/bin/env bash - -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh - -#define database attributes -address=$(cat $config_path | grep -w dbMysqlAddress) -list_to_string ${address} -hostAndPort=($ports_array) -DATABASE_HOST=$(echo $hostAndPort | awk -F '[:]' '{print $1}') -DATABASE_PORT=$(echo $hostAndPort | awk -F '[:]' '{print $NF}') -DATABASE_USERNAME=$(cat $config_path | grep -w dbMysqlUserName | awk -F '[:]' '{print $NF}') -DATABASE_PWD=`eval echo $(cat $config_path | grep -w dbMysqlPassword | awk -F '[:]' '{print $NF}')` -DATABASE_NAME=$(cat $config_path | grep -w dbMysqlDatabaseName | awk -F '[:]' '{print $NF}') -SQL_FILE="../config/mysql_sql_file/openIM.sql" - - -create_data_sql="create database IF NOT EXISTS $DATABASE_NAME" -set_character_code_sql="alter database $DATABASE_NAME character set utf8mb4 collate utf8mb4_general_ci" - -echo -e "${SKY_BLUE_PREFIX}start to create database.....$COLOR_SUFFIX" -mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$create_data_sql" - -if [ $? -eq 0 ]; then - echo -e "${SKY_BLUE_PREFIX}create database ${DATABASE_NAME} successfully$COLOR_SUFFIX" - mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$set_character_code_sql" -else - echo -e "${RED_PREFIX}create database failed or exists the database$COLOR_SUFFIX\n" -fi - -echo -e "${SKY_BLUE_PREFIX}start to source openIM.sql .....$COLOR_SUFFIX" -mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -D $DATABASE_NAME <$SQL_FILE -if [ $? -eq 0 ]; then - echo -e "${SKY_BLUE_PREFIX}source openIM.sql successfully$COLOR_SUFFIX" -else - echo -e "${RED_PREFIX}source openIM.sql failed$COLOR_SUFFIX\n" -fi +#!/usr/bin/env bash + +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh + +#define database attributes +address=$(cat $config_path | grep -w dbMysqlAddress) +list_to_string ${address} +hostAndPort=($ports_array) +DATABASE_HOST=$(echo $hostAndPort | awk -F '[:]' '{print $1}') +DATABASE_PORT=$(echo $hostAndPort | awk -F '[:]' '{print $NF}') +DATABASE_USERNAME=$(cat $config_path | grep -w dbMysqlUserName | awk -F '[:]' '{print $NF}') +DATABASE_PWD=`eval echo $(cat $config_path | grep -w dbMysqlPassword | awk -F '[:]' '{print $NF}')` +DATABASE_NAME=$(cat $config_path | grep -w dbMysqlDatabaseName | awk -F '[:]' '{print $NF}') +SQL_FILE="../config/mysql_sql_file/openIM.sql" + + +create_data_sql="create database IF NOT EXISTS $DATABASE_NAME" +set_character_code_sql="alter database $DATABASE_NAME character set utf8mb4 collate utf8mb4_general_ci" + +echo -e "${SKY_BLUE_PREFIX}start to create database.....$COLOR_SUFFIX" +mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$create_data_sql" + +if [ $? -eq 0 ]; then + echo -e "${SKY_BLUE_PREFIX}create database ${DATABASE_NAME} successfully$COLOR_SUFFIX" + mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$set_character_code_sql" +else + echo -e "${RED_PREFIX}create database failed or exists the database$COLOR_SUFFIX\n" +fi + +echo -e "${SKY_BLUE_PREFIX}start to source openIM.sql .....$COLOR_SUFFIX" +mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -D $DATABASE_NAME <$SQL_FILE +if [ $? -eq 0 ]; then + echo -e "${SKY_BLUE_PREFIX}source openIM.sql successfully$COLOR_SUFFIX" +else + echo -e "${RED_PREFIX}source openIM.sql failed$COLOR_SUFFIX\n" +fi diff --git a/script/path_info.cfg b/script/path_info.cfg index 4529c93d6..f67e017c2 100644 --- a/script/path_info.cfg +++ b/script/path_info.cfg @@ -1,63 +1,63 @@ -#Don't put the space between "=" -msg_gateway_name="open_im_msg_gateway" -msg_gateway_binary_root="../bin/" -msg_gateway_source_root="../src/msg_gateway/" - -msg_name="open_im_msg" -msg_binary_root="../bin/" -msg_source_root="../src/rpc/chat/" - -push_name="open_im_push" -push_binary_root="../bin/" -push_source_root="../src/push/" - - - -msg_transfer_name="open_im_msg_transfer" -msg_transfer_binary_root="../bin/" -msg_transfer_source_root="../src/msg_transfer/" -msg_transfer_service_num=2 - - -sdk_server_name="open_im_sdk_server" -sdk_server_binary_root="../bin/" -sdk_server_source_root="../src/Open-IM-SDK-Core/" - - -#Global configuration file default dir -config_path="../config/config.yaml" - -#servicefile dir path -service_source_root=( - #api service file - ../src/api/ - #rpc service file - ../src/rpc/user/ - ../src/rpc/friend/ - ../src/rpc/group/ - ../src/rpc/auth/ - ${msg_gateway_source_root} - ${msg_transfer_source_root} - ${msg_source_root} - ${push_source_root} - ${sdk_server_source_root} -) -#service filename -service_names=( - #api service filename - open_im_api - #rpc service filename - open_im_user - open_im_friend - open_im_group - open_im_auth - ${msg_gateway_name} - ${msg_transfer_name} - ${msg_name} - ${push_name} - ${sdk_server_name} -) - - - - +#Don't put the space between "=" +msg_gateway_name="open_im_msg_gateway" +msg_gateway_binary_root="../bin/" +msg_gateway_source_root="../src/msg_gateway/" + +msg_name="open_im_msg" +msg_binary_root="../bin/" +msg_source_root="../src/rpc/chat/" + +push_name="open_im_push" +push_binary_root="../bin/" +push_source_root="../src/push/" + + + +msg_transfer_name="open_im_msg_transfer" +msg_transfer_binary_root="../bin/" +msg_transfer_source_root="../src/msg_transfer/" +msg_transfer_service_num=2 + + +sdk_server_name="open_im_sdk_server" +sdk_server_binary_root="../bin/" +sdk_server_source_root="../src/Open-IM-SDK-Core/" + + +#Global configuration file default dir +config_path="../config/config.yaml" + +#servicefile dir path +service_source_root=( + #api service file + ../src/api/ + #rpc service file + ../src/rpc/user/ + ../src/rpc/friend/ + ../src/rpc/group/ + ../src/rpc/auth/ + ${msg_gateway_source_root} + ${msg_transfer_source_root} + ${msg_source_root} + ${push_source_root} + ${sdk_server_source_root} +) +#service filename +service_names=( + #api service filename + open_im_api + #rpc service filename + open_im_user + open_im_friend + open_im_group + open_im_auth + ${msg_gateway_name} + ${msg_transfer_name} + ${msg_name} + ${push_name} + ${sdk_server_name} +) + + + + diff --git a/script/push_start.sh b/script/push_start.sh index 51ec1d6ba..8b2a47896 100644 --- a/script/push_start.sh +++ b/script/push_start.sh @@ -1,45 +1,45 @@ -#!/usr/bin/env bash -#Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh - - - -list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}') -list_to_string $list1 -rpc_ports=($ports_array) - -#Check if the service exists -#If it is exists,kill this process -check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) -if [ $check -ge 1 ]; then - oldPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') - kill -9 $oldPid -fi -#Waiting port recycling -sleep 1 -cd ${push_binary_root} - -for ((i = 0; i < ${#rpc_ports[@]}; i++)); do - nohup ./${push_name} -port ${rpc_ports[$i]} >>../logs/openIM.log 2>&1 & -done - -sleep 3 -#Check launched service process -check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) -if [ $check -ge 1 ]; then - newPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') - ports=$(netstat -netulp | grep -w ${newPid} | awk '{print $4}' | awk -F '[:]' '{print $NF}') - allPorts="" - - for i in $ports; do - allPorts=${allPorts}"$i " - done - echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} -else - echo -e ${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} -fi +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh + + + +list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}') +list_to_string $list1 +rpc_ports=($ports_array) + +#Check if the service exists +#If it is exists,kill this process +check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + oldPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') + kill -9 $oldPid +fi +#Waiting port recycling +sleep 1 +cd ${push_binary_root} + +for ((i = 0; i < ${#rpc_ports[@]}; i++)); do + nohup ./${push_name} -port ${rpc_ports[$i]} >>../logs/openIM.log 2>&1 & +done + +sleep 3 +#Check launched service process +check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + newPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}') + ports=$(netstat -netulp | grep -w ${newPid} | awk '{print $4}' | awk -F '[:]' '{print $NF}') + allPorts="" + + for i in $ports; do + allPorts=${allPorts}"$i " + done + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/script/sdk_svr_start.sh b/script/sdk_svr_start.sh index 4d6af3999..97c694233 100644 --- a/script/sdk_svr_start.sh +++ b/script/sdk_svr_start.sh @@ -1,47 +1,47 @@ -#!/usr/bin/env bash -#Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh -list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}') -list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}') -list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}') -list_to_string $list1 -api_ports=($ports_array) -list_to_string $list2 -ws_ports=($ports_array) -list_to_string $list3 -sdk_ws_ports=($ports_array) - - - - -#Check if the service exists -#If it is exists,kill this process -check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l) -if [ $check -ge 1 ]; then - oldPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}') - kill -9 ${oldPid} -fi -#Waiting port recycling -sleep 1 -cd ${sdk_server_binary_root} - nohup ./${sdk_server_name} -openIM_api_port ${api_ports[0]} -openIM_ws_port ${ws_ports[0]} -sdk_ws_port ${sdk_ws_ports[0]} >>../logs/openIM.log 2>&1 & - -#Check launched service process -sleep 3 -check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l) -allPorts="" -if [ $check -ge 1 ]; then - allNewPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}') - for i in $allNewPid; do - ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}') - allPorts=${allPorts}"$ports " - done - echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} -else - echo -e ${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR PLEASE CHECK openIM.log"${COLOR_SUFFIX} -fi +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh +list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}') +list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}') +list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}') +list_to_string $list1 +api_ports=($ports_array) +list_to_string $list2 +ws_ports=($ports_array) +list_to_string $list3 +sdk_ws_ports=($ports_array) + + + + +#Check if the service exists +#If it is exists,kill this process +check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + oldPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}') + kill -9 ${oldPid} +fi +#Waiting port recycling +sleep 1 +cd ${sdk_server_binary_root} + nohup ./${sdk_server_name} -openIM_api_port ${api_ports[0]} -openIM_ws_port ${ws_ports[0]} -sdk_ws_port ${sdk_ws_ports[0]} >>../logs/openIM.log 2>&1 & + +#Check launched service process +sleep 3 +check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l) +allPorts="" +if [ $check -ge 1 ]; then + allNewPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}') + for i in $allNewPid; do + ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}') + allPorts=${allPorts}"$ports " + done + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/script/start_all.sh b/script/start_all.sh index 9990cb6c8..43a02b34d 100644 --- a/script/start_all.sh +++ b/script/start_all.sh @@ -1,18 +1,18 @@ -#!/usr/bin/env bash -#fixme This script is the total startup script -#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array - -#fixme Put the shell script name here -need_to_start_server_shell=( - start_rpc_service.sh - msg_gateway_start.sh - push_start.sh - msg_transfer_start.sh - sdk_svr_start.sh -) - -for i in ${need_to_start_server_shell[*]}; do - chmod +x $i - ./$i -done - +#!/usr/bin/env bash +#fixme This script is the total startup script +#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array + +#fixme Put the shell script name here +need_to_start_server_shell=( + start_rpc_service.sh + msg_gateway_start.sh + push_start.sh + msg_transfer_start.sh + sdk_svr_start.sh +) + +for i in ${need_to_start_server_shell[*]}; do + chmod +x $i + ./$i +done + diff --git a/script/start_rpc_service.sh b/script/start_rpc_service.sh index 6307ca1c0..74f00a3f4 100644 --- a/script/start_rpc_service.sh +++ b/script/start_rpc_service.sh @@ -1,59 +1,59 @@ -#!/usr/bin/env bash - -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh - -#service filename -service_filename=( - #api - open_im_api - #rpc - open_im_user - open_im_friend - open_im_group - open_im_auth - ${msg_name} -) - -#service config port name -service_port_name=( - #api port name - openImApiPort - #rpc port name - openImUserPort - openImFriendPort - openImGroupPort - openImAuthPort - openImOfflineMessagePort - -) - -for ((i = 0; i < ${#service_filename[*]}; i++)); do - #Check whether the service exists - service_name="ps -aux |grep -w ${service_filename[$i]} |grep -v grep" - count="${service_name}| wc -l" - - if [ $(eval ${count}) -gt 0 ]; then - pid="${service_name}| awk '{print \$2}'" - echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service has been started,pid:$(eval $pid)$COLOR_SUFFIX" - echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename[$i]} pid:$(eval $pid)${COLOR_SUFFIX}" - #kill the service that existed - kill -9 $(eval $pid) - sleep 0.5 - fi - cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service is starting${COLOR_SUFFIX}" - #Get the rpc port in the configuration file - portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}') - list_to_string ${portList} - #Start related rpc services based on the number of ports - for j in ${ports_array}; do - echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} Service is starting,port number:$j $COLOR_SUFFIX" - #Start the service in the background - # ./${service_filename[$i]} -port $j & - nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 & - sleep 1 - pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" - echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX" - done -done +#!/usr/bin/env bash + +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh + +#service filename +service_filename=( + #api + open_im_api + #rpc + open_im_user + open_im_friend + open_im_group + open_im_auth + ${msg_name} +) + +#service config port name +service_port_name=( + #api port name + openImApiPort + #rpc port name + openImUserPort + openImFriendPort + openImGroupPort + openImAuthPort + openImOfflineMessagePort + +) + +for ((i = 0; i < ${#service_filename[*]}; i++)); do + #Check whether the service exists + service_name="ps -aux |grep -w ${service_filename[$i]} |grep -v grep" + count="${service_name}| wc -l" + + if [ $(eval ${count}) -gt 0 ]; then + pid="${service_name}| awk '{print \$2}'" + echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service has been started,pid:$(eval $pid)$COLOR_SUFFIX" + echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename[$i]} pid:$(eval $pid)${COLOR_SUFFIX}" + #kill the service that existed + kill -9 $(eval $pid) + sleep 0.5 + fi + cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service is starting${COLOR_SUFFIX}" + #Get the rpc port in the configuration file + portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}') + list_to_string ${portList} + #Start related rpc services based on the number of ports + for j in ${ports_array}; do + echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} Service is starting,port number:$j $COLOR_SUFFIX" + #Start the service in the background + # ./${service_filename[$i]} -port $j & + nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 & + sleep 1 + pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" + echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX" + done +done diff --git a/script/stop_all.sh b/script/stop_all.sh index ef7237ab5..2e1e119c1 100644 --- a/script/stop_all.sh +++ b/script/stop_all.sh @@ -1,19 +1,19 @@ -#!/usr/bin/env bash -#fixme This script is to stop the service - -source ./style_info.cfg -source ./path_info.cfg - - -for i in ${service_names[*]}; do - #Check whether the service exists - name="ps -aux |grep -w $i |grep -v grep" - count="${name}| wc -l" - if [ $(eval ${count}) -gt 0 ]; then - pid="${name}| awk '{print \$2}'" - echo -e "${SKY_BLUE_PREFIX}Killing service:$i pid:$(eval $pid)${COLOR_SUFFIX}" - #kill the service that existed - kill -9 $(eval $pid) - echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}" - fi -done +#!/usr/bin/env bash +#fixme This script is to stop the service + +source ./style_info.cfg +source ./path_info.cfg + + +for i in ${service_names[*]}; do + #Check whether the service exists + name="ps -aux |grep -w $i |grep -v grep" + count="${name}| wc -l" + if [ $(eval ${count}) -gt 0 ]; then + pid="${name}| awk '{print \$2}'" + echo -e "${SKY_BLUE_PREFIX}Killing service:$i pid:$(eval $pid)${COLOR_SUFFIX}" + #kill the service that existed + kill -9 $(eval $pid) + echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}" + fi +done diff --git a/script/style_info.cfg b/script/style_info.cfg index 92cc5da49..ff28dcb88 100644 --- a/script/style_info.cfg +++ b/script/style_info.cfg @@ -1,9 +1,9 @@ -#Shell font formatting information -COLOR_SUFFIX="\033[0m" -BLACK_PREFIX="\033[30m" -RED_PREFIX="\033[31m" -GREEN_PREFIX="\033[32m" -YELLOW_PREFIX="\033[33m" -BLUE_PREFIX="\033[34m" -PURPLE_PREFIX="\033[35m" -SKY_BLUE_PREFIX="\033[36m" +#Shell font formatting information +COLOR_SUFFIX="\033[0m" +BLACK_PREFIX="\033[30m" +RED_PREFIX="\033[31m" +GREEN_PREFIX="\033[32m" +YELLOW_PREFIX="\033[33m" +BLUE_PREFIX="\033[34m" +PURPLE_PREFIX="\033[35m" +SKY_BLUE_PREFIX="\033[36m" diff --git a/sdk_svr_start.sh b/sdk_svr_start.sh deleted file mode 100644 index 4d6af3999..000000000 --- a/sdk_svr_start.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -#Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh -list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}') -list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}') -list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}') -list_to_string $list1 -api_ports=($ports_array) -list_to_string $list2 -ws_ports=($ports_array) -list_to_string $list3 -sdk_ws_ports=($ports_array) - - - - -#Check if the service exists -#If it is exists,kill this process -check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l) -if [ $check -ge 1 ]; then - oldPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}') - kill -9 ${oldPid} -fi -#Waiting port recycling -sleep 1 -cd ${sdk_server_binary_root} - nohup ./${sdk_server_name} -openIM_api_port ${api_ports[0]} -openIM_ws_port ${ws_ports[0]} -sdk_ws_port ${sdk_ws_ports[0]} >>../logs/openIM.log 2>&1 & - -#Check launched service process -sleep 3 -check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l) -allPorts="" -if [ $check -ge 1 ]; then - allNewPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}') - for i in $allNewPid; do - ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}') - allPorts=${allPorts}"$ports " - done - echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX} - echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} -else - echo -e ${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR PLEASE CHECK openIM.log"${COLOR_SUFFIX} -fi diff --git a/src/Open-IM-SDK-Core b/src/Open-IM-SDK-Core index 3d956a1a4..17e4fc51c 160000 --- a/src/Open-IM-SDK-Core +++ b/src/Open-IM-SDK-Core @@ -1 +1 @@ -Subproject commit 3d956a1a40024f0a5f4959d6e46f6f503a1618ce +Subproject commit 17e4fc51ce877ab4d146865cc094bfbcc5abb021 diff --git a/src/api/friend/add_friend.go b/src/api/friend/add_friend.go index 40fee7dac..c671f949a 100644 --- a/src/api/friend/add_friend.go +++ b/src/api/friend/add_friend.go @@ -41,7 +41,9 @@ func ImportFriend(c *gin.Context) { OwnerUid: params.OwnerUid, Token: c.Request.Header.Get("token"), } + log.NewInfo(params.OperationID, "ImportFriend Test start", params.UIDList, params.OwnerUid) RpcResp, err := client.ImportFriend(context.Background(), req) + //log.ErrorByKv("ImportFriend Test end", params.OperationID, "resp", RpcResp, "err", err.Error()) if err != nil { log.Error(req.Token, req.OperationID, "err=%s,ImportFriend failed", err) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "cImportFriend failed" + err.Error()}) diff --git a/start_all.sh b/start_all.sh deleted file mode 100644 index 9990cb6c8..000000000 --- a/start_all.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -#fixme This script is the total startup script -#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array - -#fixme Put the shell script name here -need_to_start_server_shell=( - start_rpc_service.sh - msg_gateway_start.sh - push_start.sh - msg_transfer_start.sh - sdk_svr_start.sh -) - -for i in ${need_to_start_server_shell[*]}; do - chmod +x $i - ./$i -done - diff --git a/start_rpc_service.sh b/start_rpc_service.sh deleted file mode 100644 index 6307ca1c0..000000000 --- a/start_rpc_service.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env bash - -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh - -#service filename -service_filename=( - #api - open_im_api - #rpc - open_im_user - open_im_friend - open_im_group - open_im_auth - ${msg_name} -) - -#service config port name -service_port_name=( - #api port name - openImApiPort - #rpc port name - openImUserPort - openImFriendPort - openImGroupPort - openImAuthPort - openImOfflineMessagePort - -) - -for ((i = 0; i < ${#service_filename[*]}; i++)); do - #Check whether the service exists - service_name="ps -aux |grep -w ${service_filename[$i]} |grep -v grep" - count="${service_name}| wc -l" - - if [ $(eval ${count}) -gt 0 ]; then - pid="${service_name}| awk '{print \$2}'" - echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service has been started,pid:$(eval $pid)$COLOR_SUFFIX" - echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename[$i]} pid:$(eval $pid)${COLOR_SUFFIX}" - #kill the service that existed - kill -9 $(eval $pid) - sleep 0.5 - fi - cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service is starting${COLOR_SUFFIX}" - #Get the rpc port in the configuration file - portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}') - list_to_string ${portList} - #Start related rpc services based on the number of ports - for j in ${ports_array}; do - echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} Service is starting,port number:$j $COLOR_SUFFIX" - #Start the service in the background - # ./${service_filename[$i]} -port $j & - nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 & - sleep 1 - pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" - echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX" - done -done diff --git a/stop_all.sh b/stop_all.sh deleted file mode 100644 index ef7237ab5..000000000 --- a/stop_all.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -#fixme This script is to stop the service - -source ./style_info.cfg -source ./path_info.cfg - - -for i in ${service_names[*]}; do - #Check whether the service exists - name="ps -aux |grep -w $i |grep -v grep" - count="${name}| wc -l" - if [ $(eval ${count}) -gt 0 ]; then - pid="${name}| awk '{print \$2}'" - echo -e "${SKY_BLUE_PREFIX}Killing service:$i pid:$(eval $pid)${COLOR_SUFFIX}" - #kill the service that existed - kill -9 $(eval $pid) - echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}" - fi -done diff --git a/style_info.cfg b/style_info.cfg deleted file mode 100644 index 92cc5da49..000000000 --- a/style_info.cfg +++ /dev/null @@ -1,9 +0,0 @@ -#Shell font formatting information -COLOR_SUFFIX="\033[0m" -BLACK_PREFIX="\033[30m" -RED_PREFIX="\033[31m" -GREEN_PREFIX="\033[32m" -YELLOW_PREFIX="\033[33m" -BLUE_PREFIX="\033[34m" -PURPLE_PREFIX="\033[35m" -SKY_BLUE_PREFIX="\033[36m" From 7f2270844e538907f325f2639d13e8e68baa25ec Mon Sep 17 00:00:00 2001 From: Xan <270084782@qq.com> Date: Fri, 5 Nov 2021 16:37:17 +0800 Subject: [PATCH 18/31] feat:uid generator & rm incompatible gopkg (#34) --- .gitignore | 6 + go.mod | 19 +- go.sum | 371 ------------------ .../im_mysql_model/model_struct.go | 2 +- src/rpc/auth/auth/user_register.go | 4 + src/utils/id.go | 28 ++ src/utils/id_test.go | 15 + 7 files changed, 60 insertions(+), 385 deletions(-) delete mode 100644 go.sum create mode 100644 src/utils/id.go create mode 100644 src/utils/id_test.go diff --git a/.gitignore b/.gitignore index 3f1a36dca..927ba42cc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,9 @@ components logs out-test + +# for unit test +src/utils/config + +# gosum +go.sum diff --git a/go.mod b/go.mod index 00fe22cb0..d4212c16a 100644 --- a/go.mod +++ b/go.mod @@ -3,21 +3,16 @@ module Open_IM go 1.15 require ( - github.com/Shopify/sarama v1.19.0 - github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect + github.com/Shopify/sarama v1.30.0 github.com/antonfisher/nested-logrus-formatter v1.3.0 + github.com/bwmarrin/snowflake v0.3.0 github.com/coreos/go-semver v0.3.0 // indirect github.com/dustin/go-humanize v1.0.0 // indirect - github.com/eapache/go-resiliency v1.2.0 // indirect - github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect - github.com/eapache/queue v1.1.0 // indirect - github.com/frankban/quicktest v1.11.3 // indirect github.com/garyburd/redigo v1.6.2 github.com/gin-gonic/gin v1.7.0 github.com/go-playground/validator/v10 v10.4.1 - github.com/golang-jwt/jwt/v4 v4.1.0 // indirect + github.com/golang-jwt/jwt/v4 v4.1.0 github.com/golang/protobuf v1.5.2 - github.com/golang/snappy v0.0.3 // indirect github.com/gorilla/websocket v1.4.2 github.com/jinzhu/gorm v1.9.16 github.com/jonboulle/clockwork v0.2.2 // indirect @@ -28,20 +23,18 @@ require ( github.com/mitchellh/mapstructure v1.4.1 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/olivere/elastic/v7 v7.0.23 - github.com/pierrec/lz4 v2.6.0+incompatible // indirect - github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 - github.com/sirupsen/logrus v1.6.0 + github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.7.0 github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb - golang.org/x/net v0.0.0-20201110031124-69a78807bb2b + golang.org/x/net v0.0.0-20210917221730-978cfadd31cf golang.org/x/tools v0.0.0-20210106214847-113979e3529a // indirect google.golang.org/grpc v1.33.2 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b sigs.k8s.io/yaml v1.2.0 // indirect ) diff --git a/go.sum b/go.sum deleted file mode 100644 index 664a73e93..000000000 --- a/go.sum +++ /dev/null @@ -1,371 +0,0 @@ -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= -github.com/Shopify/sarama v1.19.0 h1:9oksLxC6uxVPHPVYUmq6xhr1BOF/hHobWH2UzO67z1s= -github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= -github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= -github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= -github.com/antonfisher/nested-logrus-formatter v1.3.0 h1:8zixYquU1Odk+vzAaAQPAdRh1ZjmUXNQ1T+dUBvlhVo= -github.com/antonfisher/nested-logrus-formatter v1.3.0/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= -github.com/aws/aws-sdk-go v1.38.3/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y= -github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd/v22 v22.0.0 h1:XJIw/+VlJ+87J+doOxznsAWIdmWuViOVhkQamW5YV28= -github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= -github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM= -github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/eapache/go-resiliency v1.2.0 h1:v7g92e/KSN71Rq7vSThKaWIq68fL4YHvWyiUKorFR1Q= -github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= -github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw= -github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= -github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= -github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y= -github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= -github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= -github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY= -github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= -github.com/garyburd/redigo v1.6.2 h1:yE/pwKCrbLpLpQICzYTeZ7JsTA/C53wFTJHaEtRqniM= -github.com/garyburd/redigo v1.6.2/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.7.0 h1:jGB9xAJQ12AIGNB4HguylppmDK1Am9ppF7XnGXXJuoU= -github.com/gin-gonic/gin v1.7.0/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= -github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= -github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= -github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/golang-jwt/jwt/v4 v4.1.0 h1:XUgk2Ex5veyVFVeLm0xhusUTQybEbexJXrvPNOKkSY0= -github.com/golang-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= -github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= -github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA= -github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4 h1:z53tR0945TRRQO/fLEVPI6SMv7ZflF0TEaTAoU7tOzg= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.9.5 h1:UImYN5qQ8tuGpGE16ZmjvcTtTw24zw1QAp/SlnNrZhI= -github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o= -github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs= -github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= -github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M= -github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= -github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8= -github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is= -github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4= -github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA= -github.com/lestrrat-go/strftime v1.0.4 h1:T1Rb9EPkAhgxKqbcMIPguPq8glqXTA1koF8n9BHElA8= -github.com/lestrrat-go/strftime v1.0.4/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR76fd03sz+Qz4g= -github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= -github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= -github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg= -github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= -github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= -github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olivere/elastic/v7 v7.0.23 h1:b7tjMogDMhf2CisGI+L02LXLVa0ZyE82Z15XfW1e8t8= -github.com/olivere/elastic/v7 v7.0.23/go.mod h1:OuWmD2DiuYhddWegBKPWQuelVKBLrW0fa/VUYgxuGTY= -github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= -github.com/pierrec/lz4 v2.6.0+incompatible h1:Ix9yFKn1nSPBLFl/yZknTp8TU5G4Ps0JDmguYK6iH1A= -github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= -github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo= -github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM= -github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/smartystreets/assertions v1.1.1/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= -github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM= -github.com/smartystreets/gunit v1.4.2/go.mod h1:ZjM1ozSIMJlAz/ay4SG8PeKF00ckUp+zMHZXV9/bvak= -github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E= -github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/pflag v1.0.1 h1:aCvUg6QPl3ibpQUxyLkrEkCHtPqYJL4x9AuhqVqFis4= -github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca h1:G/aIr3WiUesWHL2YGYgEqjM5tCAJ43Ml+0C18wDkWWs= -github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca/go.mod h1:b18KQa4IxHbxeseW1GcZox53d7J0z39VNONTxvvlkXw= -github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ= -github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= -github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg= -go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= -go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 h1:jWtjCJX1qxhHISBMLRztWwR+EXkI7MJAF2HjHAE/x/I= -go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698/go.mod h1:YoUyTScD3Vcv2RBm3eGVOq7i1ULiz3OuXoQFWOirmAM= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk= -go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= -go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= -go.uber.org/zap v1.14.1 h1:nYDKopTbvAPq/NrUVZwT15y2lpROBiLLyoRTbXOYWOo= -go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb h1:fqpd0EBDzlHRCjiphRR5Zo/RSWWQlWv34418dnEixWk= -golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw= -gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= -gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= diff --git a/src/common/db/mysql_model/im_mysql_model/model_struct.go b/src/common/db/mysql_model/im_mysql_model/model_struct.go index 87993df65..d8576ac19 100644 --- a/src/common/db/mysql_model/im_mysql_model/model_struct.go +++ b/src/common/db/mysql_model/im_mysql_model/model_struct.go @@ -3,7 +3,7 @@ package im_mysql_model import "time" type User struct { - UID string `gorm:"column:uid"` + UID string `gorm:"column:uid;primaryKey;"` Name string `gorm:"column:name"` Icon string `gorm:"column:icon"` Gender int32 `gorm:"column:gender"` diff --git a/src/rpc/auth/auth/user_register.go b/src/rpc/auth/auth/user_register.go index aa2bc40f3..d19acf881 100644 --- a/src/rpc/auth/auth/user_register.go +++ b/src/rpc/auth/auth/user_register.go @@ -4,12 +4,16 @@ import ( "Open_IM/src/common/db/mysql_model/im_mysql_model" "Open_IM/src/common/log" pbAuth "Open_IM/src/proto/auth" + "Open_IM/src/utils" "context" ) func (rpc *rpcAuth) UserRegister(_ context.Context, pb *pbAuth.UserRegisterReq) (*pbAuth.UserRegisterResp, error) { log.Info("", "", "rpc user_register start, [data: %s]", pb.String()) + if len(pb.UID) == 0 { + pb.UID = utils.GenID() + } if err := im_mysql_model.UserRegister(pb); err != nil { log.Error("", "", "rpc user_register error, [data: %s] [err: %s]", pb.String(), err.Error()) return &pbAuth.UserRegisterResp{Success: false}, err diff --git a/src/utils/id.go b/src/utils/id.go new file mode 100644 index 000000000..509578df7 --- /dev/null +++ b/src/utils/id.go @@ -0,0 +1,28 @@ +package utils + +import ( + "github.com/bwmarrin/snowflake" +) + +func init() { + var err error + idGenerator, err = snowflake.NewNode(getNodeNum()) + if err != nil { + panic(err) + } +} + +func getNodeNum() int64 { + return 1 +} + +var idGenerator *snowflake.Node + +func GenID() string { + return idGenerator.Generate().String() +} + +func GenIDs(count int) []string { + //impl + return []string{} +} diff --git a/src/utils/id_test.go b/src/utils/id_test.go new file mode 100644 index 000000000..3c0d5938e --- /dev/null +++ b/src/utils/id_test.go @@ -0,0 +1,15 @@ +package utils + +import "testing" + +func TestGenID(t *testing.T) { + m := map[string]struct{}{} + for i := 0; i < 2000; i++ { + got := GenID() + if _, ok := m[got]; !ok { + m[got] = struct{}{} + } else { + t.Error("id generate error", got) + } + } +} From 3e45d489b801dc12bb42b52a06d958dcb5f91a93 Mon Sep 17 00:00:00 2001 From: tzw Date: Wed, 10 Nov 2021 14:40:16 +0800 Subject: [PATCH 19/31] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=AD=E7=9A=84token=E8=BF=87=E6=9C=9F=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=20(#52)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: tanzhongwu --- config/config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 37f7c4af1..40baef4a7 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -133,9 +133,9 @@ multiloginpolicy: #token config tokenpolicy: accessSecret: "open_im_server" - # Token effective time seconds as a unit - #Seven days 7*24*60*60 - accessExpire: 604800 + # Token effective time days as a unit + #Seven days 7 + accessExpire: 7 messagecallback: callbackSwitch: false From 90a466ef0112863b83b8fd727d6dd76d89cbe3f8 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 10 Nov 2021 15:31:18 +0800 Subject: [PATCH 20/31] merge all branch and change project structure --- go.sum | 53 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/go.sum b/go.sum index fbbe5ea96..e50dd1004 100644 --- a/go.sum +++ b/go.sum @@ -15,6 +15,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0= +github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y= @@ -25,6 +27,7 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd/v22 v22.0.0 h1:XJIw/+VlJ+87J+doOxznsAWIdmWuViOVhkQamW5YV28= github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -48,8 +51,8 @@ github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= -github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY= -github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= +github.com/frankban/quicktest v1.14.0 h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzPPUss= +github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og= github.com/garyburd/redigo v1.6.2 h1:yE/pwKCrbLpLpQICzYTeZ7JsTA/C53wFTJHaEtRqniM= github.com/garyburd/redigo v1.6.2/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -74,6 +77,8 @@ github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang-jwt/jwt/v4 v4.1.0 h1:XUgk2Ex5veyVFVeLm0xhusUTQybEbexJXrvPNOKkSY0= +github.com/golang-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -94,8 +99,8 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -103,9 +108,10 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA= @@ -141,15 +147,16 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8= @@ -188,8 +195,8 @@ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:v github.com/olivere/elastic/v7 v7.0.23 h1:b7tjMogDMhf2CisGI+L02LXLVa0ZyE82Z15XfW1e8t8= github.com/olivere/elastic/v7 v7.0.23/go.mod h1:OuWmD2DiuYhddWegBKPWQuelVKBLrW0fa/VUYgxuGTY= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= -github.com/pierrec/lz4 v2.6.0+incompatible h1:Ix9yFKn1nSPBLFl/yZknTp8TU5G4Ps0JDmguYK6iH1A= -github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= +github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -214,10 +221,12 @@ github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnH github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/smartystreets/assertions v1.1.1/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM= github.com/smartystreets/gunit v1.4.2/go.mod h1:ZjM1ozSIMJlAz/ay4SG8PeKF00ckUp+zMHZXV9/bvak= @@ -231,8 +240,9 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca h1:G/aIr3WiUesWHL2YGYgEqjM5tCAJ43Ml+0C18wDkWWs= github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca/go.mod h1:b18KQa4IxHbxeseW1GcZox53d7J0z39VNONTxvvlkXw= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -289,8 +299,9 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210917221730-978cfadd31cf h1:R150MpwJIv1MpS0N/pc+NhTM8ajzvlmxlY5OYsrevXQ= +golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -302,15 +313,20 @@ golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -357,8 +373,9 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= From a08aeee0c24d8f3edabcb6fc1867829a9e3f9c30 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 10 Nov 2021 16:03:07 +0800 Subject: [PATCH 21/31] main modify --- cmd/open_im_msg_gateway/main.go | 4 ++-- cmd/open_im_push/main.go | 2 +- cmd/rpc/open_im_msg/main.go | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/open_im_msg_gateway/main.go b/cmd/open_im_msg_gateway/main.go index 8a022b0d8..196e6c005 100644 --- a/cmd/open_im_msg_gateway/main.go +++ b/cmd/open_im_msg_gateway/main.go @@ -7,8 +7,8 @@ import ( ) func main() { - rpcPort := flag.Int("rpc_port", 10500, "rpc listening port") - wsPort := flag.Int("ws_port", 10800, "ws listening port") + rpcPort := flag.Int("rpc_port", 10400, "rpc listening port") + wsPort := flag.Int("ws_port", 17778, "ws listening port") flag.Parse() var wg sync.WaitGroup wg.Add(1) diff --git a/cmd/open_im_push/main.go b/cmd/open_im_push/main.go index a57a56ba0..590793fbe 100644 --- a/cmd/open_im_push/main.go +++ b/cmd/open_im_push/main.go @@ -7,7 +7,7 @@ import ( ) func main() { - rpcPort := flag.Int("port", -1, "rpc listening port") + rpcPort := flag.Int("port", 10700, "rpc listening port") flag.Parse() var wg sync.WaitGroup wg.Add(1) diff --git a/cmd/rpc/open_im_msg/main.go b/cmd/rpc/open_im_msg/main.go index 68f5c8931..0dffe8aaa 100644 --- a/cmd/rpc/open_im_msg/main.go +++ b/cmd/rpc/open_im_msg/main.go @@ -2,13 +2,12 @@ package main import ( rpcChat "Open_IM/internal/rpc/chat" - "Open_IM/pkg/utils" "flag" ) func main() { - rpcPort := flag.String("port", "", "rpc listening port") + rpcPort := flag.Int("port", 10300, "rpc listening port") flag.Parse() - rpcServer := rpcChat.NewRpcChatServer(utils.StringToInt(*rpcPort)) + rpcServer := rpcChat.NewRpcChatServer(*rpcPort) rpcServer.Run() } From b729cac998d9b7b8cddcd57f14921bd64359aa6b Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 10 Nov 2021 18:13:04 +0800 Subject: [PATCH 22/31] add timer update redis minSeq --- cmd/open_im_timed_task/main.go | 78 ++++++++++++++++++++++------------ pkg/common/db/mongoModel.go | 34 ++++++++++++++- pkg/common/db/redisModel.go | 4 +- 3 files changed, 85 insertions(+), 31 deletions(-) diff --git a/cmd/open_im_timed_task/main.go b/cmd/open_im_timed_task/main.go index 1119ce577..a51c771e8 100644 --- a/cmd/open_im_timed_task/main.go +++ b/cmd/open_im_timed_task/main.go @@ -1,42 +1,64 @@ package main import ( - "Open_IM/pkg/common/config" - "Open_IM/pkg/common/db" - "fmt" + commonDB "Open_IM/pkg/common/db" + "Open_IM/pkg/common/db/mysql_model/im_mysql_model" + "Open_IM/pkg/common/log" "time" ) func main() { + //for { + // fmt.Println("start delete mongodb expired record") + // timeUnixBegin := time.Now().Unix() + // count, _ := db.DB.MgoUserCount() + // fmt.Println("mongodb record count: ", count) + // for i := 0; i < count; i++ { + // time.Sleep(1 * time.Millisecond) + // uid, _ := db.DB.MgoSkipUID(i) + // fmt.Println("operate uid: ", uid) + // err := db.DB.DelUserChat(uid) + // if err != nil { + // fmt.Println("operate uid failed: ", uid, err.Error()) + // } + // } + // + // timeUnixEnd := time.Now().Unix() + // costTime := timeUnixEnd - timeUnixBegin + // if costTime > int64(config.Config.Mongo.DBRetainChatRecords*24*3600) { + // continue + // } else { + // sleepTime := 0 + // if int64(config.Config.Mongo.DBRetainChatRecords*24*3600)-costTime > 24*3600 { + // sleepTime = 24 * 3600 + // } else { + // sleepTime = config.Config.Mongo.DBRetainChatRecords*24*3600 - int(costTime) + // } + // fmt.Println("sleep: ", sleepTime) + // time.Sleep(time.Duration(sleepTime) * time.Second) + // } + //} for { - fmt.Println("start delete mongodb expired record") - timeUnixBegin := time.Now().Unix() - count, _ := db.DB.MgoUserCount() - fmt.Println("mongodb record count: ", count) - for i := 0; i < count; i++ { - time.Sleep(1 * time.Millisecond) - uid, _ := db.DB.MgoSkipUID(i) - fmt.Println("operate uid: ", uid) - err := db.DB.DelUserChat(uid) - if err != nil { - fmt.Println("operate uid failed: ", uid, err.Error()) - } - } - - timeUnixEnd := time.Now().Unix() - costTime := timeUnixEnd - timeUnixBegin - if costTime > int64(config.Config.Mongo.DBRetainChatRecords*24*3600) { - continue + uidList, err := im_mysql_model.SelectAllUID() + if err != nil { + log.NewError("999999", err.Error()) } else { - sleepTime := 0 - if int64(config.Config.Mongo.DBRetainChatRecords*24*3600)-costTime > 24*3600 { - sleepTime = 24 * 3600 - } else { - sleepTime = config.Config.Mongo.DBRetainChatRecords*24*3600 - int(costTime) + for _, v := range uidList { + minSeq, err := commonDB.DB.GetMinSeqFromMongo(v) + if err != nil { + log.NewError("999999", "get user minSeq err", err.Error(), v) + continue + } else { + err := commonDB.DB.SetUserMinSeq(v, minSeq) + if err != nil { + log.NewError("999999", "set user minSeq err", err.Error(), v) + } + } + time.Sleep(time.Duration(100) * time.Millisecond) } - fmt.Println("sleep: ", sleepTime) - time.Sleep(time.Duration(sleepTime) * time.Second) + } + } } diff --git a/pkg/common/db/mongoModel.go b/pkg/common/db/mongoModel.go index d9c6f5d2f..93f64ff5f 100644 --- a/pkg/common/db/mongoModel.go +++ b/pkg/common/db/mongoModel.go @@ -6,6 +6,7 @@ import ( "Open_IM/pkg/common/log" pbMsg "Open_IM/pkg/proto/chat" "errors" + "github.com/garyburd/redigo/redis" "github.com/golang/protobuf/proto" "gopkg.in/mgo.v2/bson" "strconv" @@ -87,6 +88,34 @@ func (d *DataBases) GetMsgBySeqRange(uid string, seqBegin, seqEnd int64) (Single return SingleMsg, GroupMsg, MaxSeq, MinSeq, nil } +func (d *DataBases) GetMinSeqFromMongo(uid string) (MinSeq int64, err error) { + var i int64 + var seqUid string + session := d.mgoSession.Clone() + if session == nil { + return MinSeq, errors.New("session == nil") + } + defer session.Close() + c := session.DB(config.Config.Mongo.DBDatabase).C(cChat) + MaxSeq, err := d.GetUserMaxSeq(uid) + if err != nil && err != redis.ErrNil { + return MinSeq, err + } + NB := MaxSeq / singleGocMsgNum + for i = 0; i <= NB; i++ { + seqUid = indexGen(uid, i) + n, err := c.Find(bson.M{"uid": seqUid}).Count() + if err == nil && n != 0 { + if i == 0 { + MinSeq = 1 + } else { + MinSeq = i * singleGocMsgNum + } + break + } + } + return MinSeq, nil +} func (d *DataBases) GetMsgBySeqList(uid string, seqList []int64) (SingleMsg []*pbMsg.MsgFormat, GroupMsg []*pbMsg.MsgFormat, MaxSeq int64, MinSeq int64, err error) { allCount := 0 singleCount := 0 @@ -316,7 +345,7 @@ func getCurrentTimestampByMill() int64 { } func getSeqUid(uid string, seq int64) string { seqSuffix := seq / singleGocMsgNum - return uid + ":" + strconv.FormatInt(seqSuffix, 10) + return indexGen(uid, seqSuffix) } func isContainInt64(target int64, List []int64) bool { @@ -329,3 +358,6 @@ func isContainInt64(target int64, List []int64) bool { return false } +func indexGen(uid string, seqSuffix int64) string { + return uid + ":" + strconv.FormatInt(seqSuffix, 10) +} diff --git a/pkg/common/db/redisModel.go b/pkg/common/db/redisModel.go index 781cc86fe..b31fde8c1 100644 --- a/pkg/common/db/redisModel.go +++ b/pkg/common/db/redisModel.go @@ -45,9 +45,9 @@ func (d *DataBases) GetUserMaxSeq(uid string) (int64, error) { } //Set the user's minimum seq -func (d *DataBases) SetUserMinSeq(uid string) (err error) { +func (d *DataBases) SetUserMinSeq(uid string, minSeq int64) (err error) { key := userMinSeq + uid - _, err = d.Exec("SET", key) + _, err = d.Exec("SET", key, minSeq) return err } From 34e8961601331afd70bf25244189117f21edfd01 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 10 Nov 2021 19:11:49 +0800 Subject: [PATCH 23/31] shell update --- .../Makefile | 2 +- .../main.go | 1 + script/check_all.sh | 10 ++++++ script/docker_start_all.sh | 1 + script/path_info.cfg | 6 ++++ script/start_all.sh | 1 + script/start_rpc_service.sh | 1 - script/timer_start.sh | 35 +++++++++++++++++++ 8 files changed, 55 insertions(+), 2 deletions(-) rename cmd/{open_im_timed_task => open_im_timer_task}/Makefile (91%) rename cmd/{open_im_timed_task => open_im_timer_task}/main.go (98%) create mode 100644 script/timer_start.sh diff --git a/cmd/open_im_timed_task/Makefile b/cmd/open_im_timer_task/Makefile similarity index 91% rename from cmd/open_im_timed_task/Makefile rename to cmd/open_im_timer_task/Makefile index 29db3f53a..6c6d713d8 100644 --- a/cmd/open_im_timed_task/Makefile +++ b/cmd/open_im_timer_task/Makefile @@ -1,6 +1,6 @@ .PHONY: all build run gotool install clean help -BINARY_NAME=open_im_timed_task +BINARY_NAME=open_im_timer_task BIN_DIR=../../bin/ all: gotool build diff --git a/cmd/open_im_timed_task/main.go b/cmd/open_im_timer_task/main.go similarity index 98% rename from cmd/open_im_timed_task/main.go rename to cmd/open_im_timer_task/main.go index a51c771e8..d5cf8150c 100644 --- a/cmd/open_im_timed_task/main.go +++ b/cmd/open_im_timer_task/main.go @@ -8,6 +8,7 @@ import ( ) func main() { + log.NewPrivateLog("timer") //for { // fmt.Println("start delete mongodb expired record") // timeUnixBegin := time.Now().Unix() diff --git a/script/check_all.sh b/script/check_all.sh index a55dc39eb..301dbe461 100644 --- a/script/check_all.sh +++ b/script/check_all.sh @@ -40,4 +40,14 @@ else exit -1 fi + +check=$(ps aux | grep -w ./${timer_task_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + echo -e ${GREEN_PREFIX}"none port has been starting,belongs service is openImMsgTimer"${COLOR_SUFFIX} +else + echo -e ${RED_PREFIX}"openImMsgTimer service does not start normally"${COLOR_SUFFIX} + echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} + exit -1 +fi + echo -e ${YELLOW_PREFIX}"all services launch success"${COLOR_SUFFIX} diff --git a/script/docker_start_all.sh b/script/docker_start_all.sh index 740b88e85..839a46688 100644 --- a/script/docker_start_all.sh +++ b/script/docker_start_all.sh @@ -9,6 +9,7 @@ need_to_start_server_shell=( push_start.sh msg_transfer_start.sh sdk_svr_start.sh + timer_start.sh ) #fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started diff --git a/script/path_info.cfg b/script/path_info.cfg index 28b6239de..b97588e61 100644 --- a/script/path_info.cfg +++ b/script/path_info.cfg @@ -19,6 +19,10 @@ msg_transfer_source_root="../cmd/open_im_msg_transfer/" msg_transfer_service_num=2 +timer_task_name="open_im_timer_task" +timer_task_binary_root="../bin/" +timer_task_source_root="../cmd/open_im_timer_task/" + sdk_server_name="open_im_sdk_server" sdk_server_binary_root="../bin/" sdk_server_source_root="../cmd/Open-IM-SDK-Core/" @@ -41,6 +45,7 @@ service_source_root=( ${msg_source_root} ${push_source_root} ${sdk_server_source_root} + ${timer_task_source_root} ) #service filename service_names=( @@ -56,6 +61,7 @@ service_names=( ${msg_name} ${push_name} ${sdk_server_name} + ${timer_task_name} ) diff --git a/script/start_all.sh b/script/start_all.sh index 43a02b34d..956bc0d51 100644 --- a/script/start_all.sh +++ b/script/start_all.sh @@ -9,6 +9,7 @@ need_to_start_server_shell=( push_start.sh msg_transfer_start.sh sdk_svr_start.sh + timer_start.sh ) for i in ${need_to_start_server_shell[*]}; do diff --git a/script/start_rpc_service.sh b/script/start_rpc_service.sh index 74f00a3f4..9491a4fe8 100644 --- a/script/start_rpc_service.sh +++ b/script/start_rpc_service.sh @@ -26,7 +26,6 @@ service_port_name=( openImGroupPort openImAuthPort openImOfflineMessagePort - ) for ((i = 0; i < ${#service_filename[*]}; i++)); do diff --git a/script/timer_start.sh b/script/timer_start.sh new file mode 100644 index 000000000..7e2791f11 --- /dev/null +++ b/script/timer_start.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg + + + +#Check if the service exists +#If it is exists,kill this process +check=`ps aux | grep -w ./${timer_task_name} | grep -v grep| wc -l` +if [ $check -ge 1 ] +then +oldPid=`ps aux | grep -w ./${timer_task_name} | grep -v grep|awk '{print $2}'` + kill -9 $oldPid +fi +#Waiting port recycling +sleep 1 + +cd ${timer_task_binary_root} +nohup ./${timer_task_name} >>../logs/openIM.log 2>&1 & + + +#Check launched service process +check=`ps aux | grep -w ./${timer_task_name} | grep -v grep| wc -l` +if [ $check -ge 1 ] +then +newPid=`ps aux | grep -w ./${timer_task_name} | grep -v grep|awk '{print $2}'` +allPorts="" + echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${timer_task_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} +else + echo -e ${YELLOW_PREFIX}${timer_task_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi From d81b95d5a63a3261870a0b1395bf444e09b2ac0c Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 10 Nov 2021 20:05:40 +0800 Subject: [PATCH 24/31] make file --- cmd/open_im_api/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/open_im_api/Makefile b/cmd/open_im_api/Makefile index 1f96bca5a..8829dacba 100644 --- a/cmd/open_im_api/Makefile +++ b/cmd/open_im_api/Makefile @@ -2,12 +2,13 @@ BINARY_NAME=open_im_api BIN_DIR=../../bin/ - +LAN_FILE=.go +GO_FILE:=main${LAN_FILE} all: gotool build build: - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ${BINARY_NAME} ${GO_FILE} run: @go run ./ From aeaab0a8d9b1f1cf340322f5cebd65808e3ada60 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 10 Nov 2021 20:20:15 +0800 Subject: [PATCH 25/31] make file --- cmd/open_im_api/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/open_im_api/Makefile b/cmd/open_im_api/Makefile index 8829dacba..1f96bca5a 100644 --- a/cmd/open_im_api/Makefile +++ b/cmd/open_im_api/Makefile @@ -2,13 +2,12 @@ BINARY_NAME=open_im_api BIN_DIR=../../bin/ -LAN_FILE=.go -GO_FILE:=main${LAN_FILE} + all: gotool build build: - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ${BINARY_NAME} ${GO_FILE} + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" run: @go run ./ From f337b8d7ccfec3113a180a4967ce624d6479455b Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Thu, 11 Nov 2021 09:48:26 +0800 Subject: [PATCH 26/31] sub moudule --- cmd/Open-IM-SDK-Core | 1 + 1 file changed, 1 insertion(+) create mode 160000 cmd/Open-IM-SDK-Core diff --git a/cmd/Open-IM-SDK-Core b/cmd/Open-IM-SDK-Core new file mode 160000 index 000000000..3cf008476 --- /dev/null +++ b/cmd/Open-IM-SDK-Core @@ -0,0 +1 @@ +Subproject commit 3cf0084769c0950aed7700eede3a0c22fa398a7e From 7accffd7cd024c20b4660856d8691159e45eefd7 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Thu, 11 Nov 2021 10:15:28 +0800 Subject: [PATCH 27/31] shell update --- cmd/Open-IM-SDK-Core | 2 +- script/check_all.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/Open-IM-SDK-Core b/cmd/Open-IM-SDK-Core index 3cf008476..a85c10dbf 160000 --- a/cmd/Open-IM-SDK-Core +++ b/cmd/Open-IM-SDK-Core @@ -1 +1 @@ -Subproject commit 3cf0084769c0950aed7700eede3a0c22fa398a7e +Subproject commit a85c10dbffbb797b5b2091e209ff67a5534b9bfc diff --git a/script/check_all.sh b/script/check_all.sh index 301dbe461..9e6d45db4 100644 --- a/script/check_all.sh +++ b/script/check_all.sh @@ -33,7 +33,7 @@ done #Check launched service process check=$(ps aux | grep -w ./${msg_transfer_name} | grep -v grep | wc -l) if [ $check -eq ${msg_transfer_service_num} ]; then - echo -e ${GREEN_PREFIX}"none port has been starting,belongs service is openImMsgTransfer"${COLOR_SUFFIX} + echo -e ${GREEN_PREFIX}"none port has been listening,belongs service is openImMsgTransfer"${COLOR_SUFFIX} else echo -e ${RED_PREFIX}"openImMsgTransfer service does not start normally, num err"${COLOR_SUFFIX} echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} @@ -43,7 +43,7 @@ fi check=$(ps aux | grep -w ./${timer_task_name} | grep -v grep | wc -l) if [ $check -ge 1 ]; then - echo -e ${GREEN_PREFIX}"none port has been starting,belongs service is openImMsgTimer"${COLOR_SUFFIX} + echo -e ${GREEN_PREFIX}"none port has been listening,belongs service is openImMsgTimer"${COLOR_SUFFIX} else echo -e ${RED_PREFIX}"openImMsgTimer service does not start normally"${COLOR_SUFFIX} echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} From 1a5f2c630b5a4f1a5f4117867e3d65dd8dfd070d Mon Sep 17 00:00:00 2001 From: Yaxian Date: Thu, 11 Nov 2021 19:11:22 +0800 Subject: [PATCH 28/31] feat: improve develop experience (#60) --- .gitignore | 2 +- README.md | 45 ++- app.yaml | 41 +++ cmd/rpc/open_im_auth/main.go | 2 +- config/config.dev.yaml | 147 +++++++++ dev.Dockerfile | 11 + docker-compose.dev.yaml | 381 ++++++++++++++++++++++++ docker-compose.local.yaml | 85 ++++++ internal/api/auth/user_register_test.go | 25 ++ pkg/common/config/config.go | 10 +- 10 files changed, 738 insertions(+), 11 deletions(-) create mode 100644 app.yaml create mode 100644 config/config.dev.yaml create mode 100644 dev.Dockerfile create mode 100644 docker-compose.dev.yaml create mode 100644 docker-compose.local.yaml create mode 100644 internal/api/auth/user_register_test.go diff --git a/.gitignore b/.gitignore index 532c7da35..f75d03c97 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ logs out-test .github - +tmp diff --git a/README.md b/README.md index ad3aa2129..b6bf34c92 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Open-IM-Server +# Open-IM-Server ![avatar](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/open-im-logo.png) @@ -51,7 +51,7 @@ By deployment of the Open-IM-Server on the customer's server, developers can int ``` #cd Open-IM-server/script - + chmod +x *.sh ``` @@ -98,11 +98,48 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server 5. Check service ``` - ./docker_check_service.sh + ./docker_check_service.sh ``` ![OpenIMServersondockerpng](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/Open-IM-Servers-on-docker.png) +#### How to develop + +1. Install [Go environment](https://golang.org/doc/install). Make sure Go version is at least 1.15. + +2. Install `Nodejs` and `pm2` + +``` + curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - + npm install pm2 -g +``` + +2. Clone the Open-IM project to your server. + + ``` + git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive + ``` + +3. Start Service. + + ``` + # run etcd/mongodb/mysql/redis/kafka + docker-compose -f docker-compose.local.yaml up -d + + # run open-im services + pm2 start app.yaml --watch + pm2 ls + pm2 logs + ``` + +or try with `docker-compose` + +``` + docker-compose -f docker-compose.dev.yaml up -d + docker-compose -f docker-compose.dev.yaml ps + docker-compose -f docker-compose.dev.yaml logs -f +``` + ### CONFIGURATION INSTRUCTIONS > Open-IM configuration is divided into basic component configuration and business internal service configuration. Developers need to fill in the address of each component as the address of their server component when using the product, and ensure that the internal service port of the business is not occupied @@ -144,7 +181,7 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server - start_all.sh&&stop_all.sh - Total script, start all services and close all services -## Authentication Clow Chart +## Authentication Clow Chart ![avatar](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/open-im-server.png) diff --git a/app.yaml b/app.yaml new file mode 100644 index 000000000..52b14d2d7 --- /dev/null +++ b/app.yaml @@ -0,0 +1,41 @@ + +apps: +- name: open_im_api + script: "go run main.go" + cwd: "cmd/open_im_api" + +- name: open_im_auth + script: "go run main.go" + cwd: "cmd/rpc/open_im_auth" + +- name: open_im_offline_msg + script: "go run main.go" + cwd: "cmd/rpc/open_im_msg" + +- name: open_im_friend + script: "go run main.go" + cwd: "cmd/rpc/open_im_friend" + +- name: open_im_group + script: "go run main.go" + cwd: "cmd/rpc/open_im_group" + +- name: open_im_user + script: "go run main.go" + cwd: "cmd/rpc/open_im_user" + +- name: open_im_push + script: "go run main.go" + cwd: "cmd/open_im_push" + +- name: open_im_timed_task + script: "go run main.go" + cwd: "cmd/open_im_timer_task" + +- name: open_im_msg_transfer + script: "go run main.go" + cwd: "cmd/open_im_msg_transfer" + +- name: open_im_msg_gateway + script: "go run main.go" + cwd: "cmd/open_im_msg_gateway" \ No newline at end of file diff --git a/cmd/rpc/open_im_auth/main.go b/cmd/rpc/open_im_auth/main.go index ed4656d35..6c6f3da1c 100644 --- a/cmd/rpc/open_im_auth/main.go +++ b/cmd/rpc/open_im_auth/main.go @@ -6,7 +6,7 @@ import ( ) func main() { - rpcPort := flag.Int("port", 10600, "RpcToken default listen port 10800") + rpcPort := flag.Int("port", 10600, "RpcToken default listen port 10600") flag.Parse() rpcServer := rpcAuth.NewRpcAuthServer(*rpcPort) rpcServer.Run() diff --git a/config/config.dev.yaml b/config/config.dev.yaml new file mode 100644 index 000000000..2b9537bef --- /dev/null +++ b/config/config.dev.yaml @@ -0,0 +1,147 @@ + +# The class cannot be named by Pascal or camel case. +# If it is not used, the corresponding structure will not be set, +# and it will not be read naturally. +serverversion: 1.0.0 +#---------------Infrastructure configuration---------------------# +etcd: + etcdSchema: openIM + etcdAddr: [ etcd:2379 ] + +mysql: + dbMysqlAddress: [ mysql:3306 ] + dbMysqlUserName: root + dbMysqlPassword: openIM + dbMysqlDatabaseName: openIM + dbTableName: eMsg + dbMsgTableNum: 1 + dbMaxOpenConns: 20 + dbMaxIdleConns: 10 + dbMaxLifeTime: 120 + +mongo: + dbAddress: [ mongodb:27017 ] + dbDirect: false + dbTimeout: 10 + dbDatabase: openIM + dbSource: admin + dbUserName: + dbPassword: + dbMaxPoolSize: 20 + dbRetainChatRecords: 7 + +redis: + dbAddress: redis:6379 + dbMaxIdle: 128 + dbMaxActive: 0 + dbIdleTimeout: 120 + dbPassWord: openIM + +kafka: + ws2mschat: + addr: [ kafka:9092 ] + topic: "ws2ms_chat" + ms2pschat: + addr: [ kafka:9092 ] + topic: "ms2ps_chat" + consumergroupid: + msgToMongo: mongo + msgToMySql: mysql + msgToPush: push + + + +#---------------Internal service configuration---------------------# + +# The service ip default is empty, +# automatically obtain the machine's valid network card ip as the service ip, +# otherwise the configuration ip is preferred +serverip: + +api: + openImApiPort: [ 10000 ] +sdk: + openImSdkWsPort: [ 30000 ] + +credential: + tencent: + appID: 1302656840 + region: ap-chengdu + bucket: echat-1302656840 + secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC + secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe + + +rpcport: + openImUserPort: [ 10100 ] + openImFriendPort: [ 10200 ] + openImOfflineMessagePort: [ 10300 ] + openImOnlineRelayPort: [ 10400 ] + openImGroupPort: [ 10500 ] + openImAuthPort: [ 10600 ] + openImPushPort: [ 10700 ] + + +rpcregistername: + openImUserName: User + openImFriendName: Friend + openImOfflineMessageName: OfflineMessage + openImPushName: Push + openImOnlineMessageRelayName: OnlineMessageRelay + openImGroupName: Group + openImAuthName: Auth + +log: + storageLocation: ../logs/ + rotationTime: 24 + remainRotationCount: 5 + remainLogLevel: 6 + elasticSearchSwitch: false + elasticSearchAddr: [ 127.0.0.1:9201 ] + elasticSearchUser: "" + elasticSearchPassword: "" + +modulename: + longConnSvrName: msg_gateway + msgTransferName: msg_transfer + pushName: push + +longconnsvr: + openImWsPort: [ 17778 ] + websocketMaxConnNum: 10000 + websocketMaxMsgLen: 4096 + websocketTimeOut: 10 + +push: + tpns: + ios: + accessID: 1600018281 + secretKey: 3cd68a77a95b89e5089a1aca523f318f + android: + accessID: 111 + secretKey: 111 + jpns: + appKey: 2783339cee4de379cc798fe1 + masterSecret: 66e5f309e032c68cc668c28a + pushUrl: "https://api.jpush.cn/v3/push" +manager: + appManagerUid: ["openIM123456","openIM654321"] + secrets: ["openIM1","openIM2"] + +secret: tuoyun + +multiloginpolicy: + onlyOneTerminalAccess: false + mobileAndPCTerminalAccessButOtherTerminalKickEachOther: true + allTerminalAccess: false + +#token config +tokenpolicy: + accessSecret: "open_im_server" + # Token effective time seconds as a unit + #Seven days 7*24*60*60 + accessExpire: 604800 + +messagecallback: + callbackSwitch: false + callbackUrl: "http://www.xxx.com/msg/judge" \ No newline at end of file diff --git a/dev.Dockerfile b/dev.Dockerfile new file mode 100644 index 000000000..4b20d744f --- /dev/null +++ b/dev.Dockerfile @@ -0,0 +1,11 @@ +FROM golang:1.16 as base + +FROM base as dev + +ENV GO111MODULE=on +ENV GOPROXY=https://goproxy.cn,direct + + +RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin + +CMD ["air"] \ No newline at end of file diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml new file mode 100644 index 000000000..202450a33 --- /dev/null +++ b/docker-compose.dev.yaml @@ -0,0 +1,381 @@ +version: "3" +services: + mysql: + image: mysql:5.7 + ports: + - 3306:3306 + container_name: mysql + volumes: + - ./components/mysql/data:/var/lib/mysql + - /etc/localtime:/etc/localtime + environment: + MYSQL_ROOT_PASSWORD: openIM + restart: always + + mongodb: + image: mongo:4.0 + ports: + - 27017:27017 + container_name: mongo + volumes: + - ./components/mongodb/data:/data/db + environment: + TZ: Asia/Shanghai + restart: always + + redis: + image: redis + ports: + - 6379:6379 + container_name: redis + volumes: + - ./components/redis/data:/data + #redis config file + #- ./components/redis/config/redis.conf:/usr/local/redis/config/redis.conf + environment: + TZ: Asia/Shanghai + restart: always + sysctls: + net.core.somaxconn: 1024 + command: redis-server --requirepass openIM --appendonly yes + + + zookeeper: + image: wurstmeister/zookeeper + ports: + - 2181:2181 + container_name: zookeeper + volumes: + - /etc/localtime:/etc/localtime + environment: + TZ: Asia/Shanghai + restart: always + + + kafka: + image: wurstmeister/kafka + container_name: kafka + restart: always + environment: + TZ: Asia/Shanghai + KAFKA_BROKER_ID: 0 + KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092 + KAFKA_LISTENERS: PLAINTEXT://kafka:9092 + depends_on: + - zookeeper + links: + - zookeeper + ports: + - 9092:9092 + + etcd: + image: quay.io/coreos/etcd + ports: + - 2379:2379 + - 2380:2380 + container_name: etcd + volumes: + - /etc/timezone:/etc/timezone + - /etc/localtime:/etc/localtime + environment: + ETCDCTL_API: 3 + restart: always + command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new + + open_im_api: + build: + dockerfile: dev.Dockerfile + context: . + target: dev + network: host + depends_on: + - kafka + - mysql + - mongodb + - redis + - etcd + container_name: open_im_api + volumes: + - ./cmd:/Open-IM-Server/cmd + - ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml + - ./internal:/Open-IM-Server/internal + - ./pkg:/Open-IM-Server/pkg + - ./go.mod:/Open-IM-Server/go.mod + - ./go.sum:/Open-IM-Server/go.sum + working_dir: /Open-IM-Server/cmd/open_im_api + ports: + - 10000:10000 + links: + - kafka + - mysql + - mongodb + - redis + - etcd + + open_im_auth: + build: + dockerfile: dev.Dockerfile + context: . + target: dev + network: host + depends_on: + - kafka + - mysql + - mongodb + - redis + - etcd + links: + - kafka + - mysql + - mongodb + - redis + - etcd + container_name: open_im_auth + volumes: + - ./cmd:/Open-IM-Server/cmd + - ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml + - ./internal:/Open-IM-Server/internal + - ./pkg:/Open-IM-Server/pkg + - ./go.mod:/Open-IM-Server/go.mod + - ./go.sum:/Open-IM-Server/go.sum + working_dir: /Open-IM-Server/cmd/rpc/open_im_auth + ports: + - 10600:10600 + + open_im_user: + build: + dockerfile: dev.Dockerfile + context: . + target: dev + network: host + depends_on: + - kafka + - mysql + - mongodb + - redis + - etcd + links: + - kafka + - mysql + - mongodb + - redis + - etcd + container_name: open_im_user + volumes: + - ./cmd:/Open-IM-Server/cmd + - ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml + - ./internal:/Open-IM-Server/internal + - ./pkg:/Open-IM-Server/pkg + - ./go.mod:/Open-IM-Server/go.mod + - ./go.sum:/Open-IM-Server/go.sum + working_dir: /Open-IM-Server/cmd/rpc/open_im_user + ports: + - 10100:10100 + + open_im_friend: + build: + dockerfile: dev.Dockerfile + context: . + target: dev + network: host + depends_on: + - kafka + - mysql + - mongodb + - redis + - etcd + links: + - kafka + - mysql + - mongodb + - redis + - etcd + container_name: open_im_friend + volumes: + - ./cmd:/Open-IM-Server/cmd + - ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml + - ./internal:/Open-IM-Server/internal + - ./pkg:/Open-IM-Server/pkg + - ./go.mod:/Open-IM-Server/go.mod + - ./go.sum:/Open-IM-Server/go.sum + working_dir: /Open-IM-Server/cmd/rpc/open_im_friend + ports: + - 10200:10200 + + open_im_group: + build: + dockerfile: dev.Dockerfile + context: . + target: dev + network: host + depends_on: + - kafka + - mysql + - mongodb + - redis + - etcd + links: + - kafka + - mysql + - mongodb + - redis + - etcd + container_name: open_im_group + volumes: + - ./cmd:/Open-IM-Server/cmd + - ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml + - ./internal:/Open-IM-Server/internal + - ./pkg:/Open-IM-Server/pkg + - ./go.mod:/Open-IM-Server/go.mod + - ./go.sum:/Open-IM-Server/go.sum + working_dir: /Open-IM-Server/cmd/rpc/open_im_group + ports: + - 10500:10500 + + open_im_push: + build: + dockerfile: dev.Dockerfile + context: . + target: dev + network: host + depends_on: + - kafka + - mysql + - mongodb + - redis + - etcd + links: + - kafka + - mysql + - mongodb + - redis + - etcd + container_name: open_im_push + volumes: + - ./cmd:/Open-IM-Server/cmd + - ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml + - ./internal:/Open-IM-Server/internal + - ./pkg:/Open-IM-Server/pkg + - ./go.mod:/Open-IM-Server/go.mod + - ./go.sum:/Open-IM-Server/go.sum + working_dir: /Open-IM-Server/cmd/open_im_push + ports: + - 10700:10700 + + open_im_timed_task: + build: + dockerfile: dev.Dockerfile + context: . + target: dev + network: host + depends_on: + - kafka + - mysql + - mongodb + - redis + - etcd + links: + - kafka + - mysql + - mongodb + - redis + - etcd + container_name: open_im_timed_task + volumes: + - ./cmd:/Open-IM-Server/cmd + - ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml + - ./internal:/Open-IM-Server/internal + - ./pkg:/Open-IM-Server/pkg + - ./go.mod:/Open-IM-Server/go.mod + - ./go.sum:/Open-IM-Server/go.sum + working_dir: /Open-IM-Server/cmd/open_im_timer_task + + open_im_offline_msg: + build: + dockerfile: dev.Dockerfile + context: . + target: dev + network: host + depends_on: + - kafka + - mysql + - mongodb + - redis + - etcd + links: + - kafka + - mysql + - mongodb + - redis + - etcd + container_name: open_im_offline_msg + volumes: + - ./cmd:/Open-IM-Server/cmd + - ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml + - ./internal:/Open-IM-Server/internal + - ./pkg:/Open-IM-Server/pkg + - ./go.mod:/Open-IM-Server/go.mod + - ./go.sum:/Open-IM-Server/go.sum + working_dir: /Open-IM-Server/cmd/rpc/open_im_msg + ports: + - 10300:10300 + + open_im_msg_transfer: + build: + dockerfile: dev.Dockerfile + context: . + target: dev + network: host + depends_on: + - kafka + - mysql + - mongodb + - redis + - etcd + links: + - kafka + - mysql + - mongodb + - redis + - etcd + container_name: open_im_msg_transfer + volumes: + - ./cmd:/Open-IM-Server/cmd + - ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml + - ./internal:/Open-IM-Server/internal + - ./pkg:/Open-IM-Server/pkg + - ./go.mod:/Open-IM-Server/go.mod + - ./go.sum:/Open-IM-Server/go.sum + working_dir: /Open-IM-Server/cmd/open_im_msg_transfer + + open_im_msg_gateway: + build: + dockerfile: dev.Dockerfile + context: . + target: dev + network: host + depends_on: + - kafka + - mysql + - mongodb + - redis + - etcd + links: + - kafka + - mysql + - mongodb + - redis + - etcd + container_name: open_im_msg_gateway + volumes: + - ./cmd:/Open-IM-Server/cmd + - ./config/config.dev.yaml:/Open-IM-Server/config/config.yaml + - ./internal:/Open-IM-Server/internal + - ./pkg:/Open-IM-Server/pkg + - ./go.mod:/Open-IM-Server/go.mod + - ./go.sum:/Open-IM-Server/go.sum + working_dir: /Open-IM-Server/cmd/open_im_msg_gateway + ports: + - 10400:10400 + - 17778:17778 \ No newline at end of file diff --git a/docker-compose.local.yaml b/docker-compose.local.yaml new file mode 100644 index 000000000..4755f4118 --- /dev/null +++ b/docker-compose.local.yaml @@ -0,0 +1,85 @@ +version: "3" +services: + mysql: + image: mysql:5.7 + ports: + - 3306:3306 + container_name: mysql + volumes: + - ./components/mysql/data:/var/lib/mysql + - /etc/localtime:/etc/localtime + environment: + MYSQL_ROOT_PASSWORD: openIM + restart: always + + mongodb: + image: mongo:4.0 + ports: + - 27017:27017 + container_name: mongo + volumes: + - ./components/mongodb/data:/data/db + environment: + TZ: Asia/Shanghai + restart: always + + redis: + image: redis + ports: + - 6379:6379 + container_name: redis + volumes: + - ./components/redis/data:/data + #redis config file + #- ./components/redis/config/redis.conf:/usr/local/redis/config/redis.conf + environment: + TZ: Asia/Shanghai + restart: always + sysctls: + net.core.somaxconn: 1024 + command: redis-server --requirepass openIM --appendonly yes + + + zookeeper: + image: wurstmeister/zookeeper + ports: + - 2181:2181 + container_name: zookeeper + volumes: + - /etc/localtime:/etc/localtime + environment: + TZ: Asia/Shanghai + restart: always + + + kafka: + image: wurstmeister/kafka + container_name: kafka + restart: always + environment: + TZ: Asia/Shanghai + KAFKA_BROKER_ID: 0 + KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092 + KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092 + # network_mode: "host" + depends_on: + - zookeeper + links: + - zookeeper + ports: + - 9092:9092 + + etcd: + image: quay.io/coreos/etcd + ports: + - 2379:2379 + - 2380:2380 + container_name: etcd + volumes: + - /etc/timezone:/etc/timezone + - /etc/localtime:/etc/localtime + environment: + ETCDCTL_API: 3 + restart: always + command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new diff --git a/internal/api/auth/user_register_test.go b/internal/api/auth/user_register_test.go new file mode 100644 index 000000000..edebbbf79 --- /dev/null +++ b/internal/api/auth/user_register_test.go @@ -0,0 +1,25 @@ +package apiAuth + +import ( + "bytes" + "net/http" + "net/http/httptest" + "testing" + + "github.com/gin-gonic/gin" + "github.com/stretchr/testify/assert" +) + +func init() { + gin.SetMode(gin.TestMode) +} + +func Test_UserRegister(t *testing.T) { + res := httptest.NewRecorder() + c, _ := gin.CreateTestContext(res) + c.Request, _ = http.NewRequest("POST", "/", bytes.NewBufferString(`{"secret": "tuoyun", "platform": 1, "uid": "3", "name": "1"}`)) + + UserRegister(c) + + assert.Equal(t, res.Code, 200) +} diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 6f5723591..f10abdc0d 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -1,20 +1,22 @@ package config import ( - "gopkg.in/yaml.v3" "io/ioutil" + + "gopkg.in/yaml.v3" + "path/filepath" "runtime" ) +var Config config + var ( _, b, _, _ = runtime.Caller(0) // Root folder of this project Root = filepath.Join(filepath.Dir(b), "../../..") ) -var Config config - type config struct { ServerIP string `yaml:"serverip"` ServerVersion string `yaml:"serverversion"` @@ -160,8 +162,6 @@ type config struct { } func init() { - //path, _ := os.Getwd() - //bytes, err := ioutil.ReadFile(path + "/config/config.yaml") // if we cd Open-IM-Server/src/utils and run go test // it will panic cannot find config/config.yaml bytes, err := ioutil.ReadFile(Root + "/config/config.yaml") From 79138e995eb8f5c851a1164b08f6d0206c8c6345 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Thu, 11 Nov 2021 20:13:03 +0800 Subject: [PATCH 29/31] new server version --- config/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yaml b/config/config.yaml index 9f7969466..e65f23926 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -1,7 +1,7 @@ # The class cannot be named by Pascal or camel case. # If it is not used, the corresponding structure will not be set, # and it will not be read naturally. -serverversion: 1.0.2 +serverversion: 1.0.3 #---------------Infrastructure configuration---------------------# etcd: etcdSchema: openIM From c934368c1a0317a3705ea3949e9ca899fce1c1f8 Mon Sep 17 00:00:00 2001 From: tzw Date: Mon, 22 Nov 2021 19:30:36 +0800 Subject: [PATCH 30/31] fix IsFriend interface (#73) Co-authored-by: tanzhongwu --- internal/api/friend/is_friend.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/api/friend/is_friend.go b/internal/api/friend/is_friend.go index e10c969f3..2e856b558 100644 --- a/internal/api/friend/is_friend.go +++ b/internal/api/friend/is_friend.go @@ -30,7 +30,7 @@ func IsFriend(c *gin.Context) { } req := &pbFriend.IsFriendReq{ OperationID: params.OperationID, - ReceiveUid: params.OperationID, + ReceiveUid: params.ReceiveUid, Token: c.Request.Header.Get("token"), } log.Info(req.Token, req.OperationID, "api is friend is server") From d4db6c0f5c6a2014e50c819fcddbae5aede4ceb7 Mon Sep 17 00:00:00 2001 From: Yaxian Date: Mon, 22 Nov 2021 19:35:30 +0800 Subject: [PATCH 31/31] docs: integrate swagger to show api doc (#61) * docs: integrate swagger to show api doc * feat: optmise to get etcd connection --- README.md | 10 + app.yaml | 3 + cmd/open_im_api/main.go | 16 +- docs/docs.go | 3480 +++++++++++++++++ docs/swagger.json | 3407 ++++++++++++++++ docs/swagger.yaml | 2208 +++++++++++ go.mod | 12 +- go.sum | 80 + internal/api/auth/user_register.go | 25 +- internal/api/auth/user_token.go | 18 +- internal/api/chat/get_max_min_seq.go | 33 +- internal/api/chat/pull_msg.go | 38 +- internal/api/chat/send_msg.go | 26 +- internal/api/friend/add_blacklist.go | 27 +- internal/api/friend/add_friend.go | 43 +- internal/api/friend/add_friend_response.go | 22 +- internal/api/friend/delete_friend.go | 22 +- internal/api/friend/get_blcaklist.go | 23 +- internal/api/friend/get_friend_apply_list.go | 38 +- internal/api/friend/get_friend_list.go | 23 +- internal/api/friend/get_friends_info.go | 34 +- internal/api/friend/is_friend.go | 22 +- internal/api/friend/remove_blacklist.go | 22 +- internal/api/friend/set_friend_comment.go | 22 +- internal/api/group/create_group.go | 34 +- .../api/group/get_group_applicationList.go | 27 +- internal/api/group/get_groups_info.go | 21 +- internal/api/group/group.go | 121 +- .../api/group/group_application_response.go | 20 +- internal/api/group/join_group.go | 22 +- internal/api/group/quit_group.go | 22 +- internal/api/group/set_group_info.go | 22 +- internal/api/group/transfer_group_owner.go | 20 +- internal/api/manage/management_chat.go | 28 +- internal/api/manage/management_user.go | 52 +- .../third/tencent_cloud_storage_credential.go | 27 +- internal/api/user/get_user_info.go | 39 +- internal/api/user/get_user_info_test.go | 31 + internal/api/user/update_user_info.go | 44 +- internal/msg_gateway/gate/logic.go | 13 +- .../msg_transfer/logic/history_msg_handler.go | 5 +- internal/push/logic/push_to_client.go | 5 +- internal/rpc/chat/send_msg.go | 3 +- .../get_user_info_to_client.go | 6 +- internal/rpc/user/update_user_info.go | 3 +- pkg/grpc-etcdv3/getcdv3/resolver.go | 38 +- pkg/proto/group/group.pb.go | 2 + 47 files changed, 10066 insertions(+), 193 deletions(-) create mode 100644 docs/docs.go create mode 100644 docs/swagger.json create mode 100644 docs/swagger.yaml create mode 100644 internal/api/user/get_user_info_test.go diff --git a/README.md b/README.md index b6bf34c92..6d3bbf89f 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,16 @@ or try with `docker-compose` docker-compose -f docker-compose.dev.yaml logs -f ``` +### Api Swagger +run service by `pm2` firstly, then run visit `[ip]:10000/swagger/index.html` + +run following command to generate swagger docs +``` +go get -u github.com/swaggo/swag/cmd/swag +export PATH=$(go env GOPATH)/bin:$PATH +swag init --generalInfo cmd/open_im_api/main.go +``` + ### CONFIGURATION INSTRUCTIONS > Open-IM configuration is divided into basic component configuration and business internal service configuration. Developers need to fill in the address of each component as the address of their server component when using the product, and ensure that the internal service port of the business is not occupied diff --git a/app.yaml b/app.yaml index 52b14d2d7..5f2458f74 100644 --- a/app.yaml +++ b/app.yaml @@ -3,6 +3,9 @@ apps: - name: open_im_api script: "go run main.go" cwd: "cmd/open_im_api" + env: + OPEN_IM_SWAGGER_API: true + watch: ["docs", "cmd", "internal", "pkg"] - name: open_im_auth script: "go run main.go" diff --git a/cmd/open_im_api/main.go b/cmd/open_im_api/main.go index 14c8e1e38..7bd6efba0 100644 --- a/cmd/open_im_api/main.go +++ b/cmd/open_im_api/main.go @@ -1,6 +1,7 @@ package main import ( + docs "Open_IM/docs" apiAuth "Open_IM/internal/api/auth" apiChat "Open_IM/internal/api/chat" "Open_IM/internal/api/friend" @@ -11,9 +12,15 @@ import ( "Open_IM/pkg/common/log" "Open_IM/pkg/utils" "flag" - "github.com/gin-gonic/gin" + "os" "strconv" + + "github.com/gin-gonic/gin" + //"syscall" + + swaggerfiles "github.com/swaggo/files" + ginSwagger "github.com/swaggo/gin-swagger" ) func main() { @@ -28,6 +35,12 @@ func main() { //log.Info("", "", "api server running...") r := gin.Default() r.Use(utils.CorsHandler()) + + if os.Getenv("OPEN_IM_SWAGGER_API") == "true" { + docs.SwaggerInfo.BasePath = "/" + r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler)) + } + // user routing group, which handles user registration and login services userRouterGroup := r.Group("/user") { @@ -98,5 +111,6 @@ func main() { log.NewPrivateLog("api") ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port") flag.Parse() + r.Run(utils.ServerIP + ":" + strconv.Itoa(*ginPort)) } diff --git a/docs/docs.go b/docs/docs.go new file mode 100644 index 000000000..9de23d1c1 --- /dev/null +++ b/docs/docs.go @@ -0,0 +1,3480 @@ +// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// This file was generated by swaggo/swag +package docs + +import ( + "bytes" + "encoding/json" + "strings" + "text/template" + + "github.com/swaggo/swag" +) + +var doc = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": {}, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/auth/user_register": { + "post": { + "description": "register a new user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "parameters": [ + { + "description": "new user params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiAuth.paramsUserRegister" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/apiAuth.resultUserRegister" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/auth/user_token": { + "post": { + "description": "get token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "parameters": [ + { + "description": "get token params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiAuth.paramsUserToken" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/apiAuth.resultUserRegister" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/chat/newest_seq": { + "post": { + "description": "get latest message seq", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "chat" + ], + "parameters": [ + { + "description": "user get latest seq params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiChat.paramsUserNewestSeq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/apiChat.resultUserNewestSeq" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/chat/pull_msg": { + "post": { + "description": "user pull messages", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "chat" + ], + "parameters": [ + { + "description": "user pull messages", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiChat.paramsUserPullMsg" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "reqIdentifier": { + "type": "integer" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/chat/pull_msg_by_seq": { + "post": { + "description": "user pull msg by seq", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "chat" + ], + "parameters": [ + { + "description": "pull msg by seq", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiChat.paramsUserPullMsgBySeqList" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "reqIdentifier": { + "type": "integer" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/chat/send_msg": { + "post": { + "description": "user send messages", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "chat" + ], + "parameters": [ + { + "description": "user send messages", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiChat.paramsUserSendMsg" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/apiChat.resultSendMsg" + }, + "reqIdentifier": { + "type": "integer" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/add_blacklist": { + "post": { + "description": "add a user into black list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "add black list params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSearchFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/add_friend": { + "post": { + "description": "add a new friend by uid", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "add friend params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsAddFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/add_friend_response": { + "post": { + "description": "the response of adding friend", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "response of adding friend", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsAddFriendResponse" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/delete_friend": { + "post": { + "description": "delete friend", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "delete friend params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSearchFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/get_blacklist": { + "post": { + "description": "get black list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "get black list", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSearchFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/friend.blackListUserInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/get_friend_apply_list": { + "post": { + "description": "get friend apply list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "get friend apply list", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsGetApplyList" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/friend.UserInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/get_friend_list": { + "post": { + "description": "get friend apply list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "get friend apply list", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsGetFriendLIst" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/friend.friendInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/get_friends_info": { + "post": { + "description": "get friend info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "search friend params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSearchFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/get_self_apply_list": { + "post": { + "description": "get friend apply list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "get friend apply list", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsGetApplyList" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/friend.UserInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/import_friend": { + "post": { + "description": "import friend", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "import friend params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsImportFriendReq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/friend.resultImportFriend" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/is_friend": { + "post": { + "description": "check is friend", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "is friend params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSearchFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/remove_blacklist": { + "post": { + "description": "remove black list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "remove black list params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSearchFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/set_friend_comment": { + "post": { + "description": "set friend comment", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "set friend comment", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSetFriendComment" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/create_group": { + "post": { + "description": "create group", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "create group params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsCreateGroup" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/get_group_all_member_list": { + "post": { + "description": "get group all members", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "get group all members params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.getGroupAllMemberReq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/group.GetGroupMemberListResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/get_group_applicationList": { + "post": { + "description": "get group application list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "get group application list params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsGroupApplicationList" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/group.resultGroupApplication" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/get_group_member_list": { + "post": { + "description": "get group member list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "get group member list params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.GetGroupMemberListReq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/group.GetGroupMemberListResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/get_group_members_info": { + "post": { + "description": "get group members info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "get group members info params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.GetGroupMembersInfoReq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/group.GetGroupMembersInfoResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/get_groups_info": { + "post": { + "description": "get groups info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "get groups info params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsGetGroupInfo" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/group.GroupInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/get_joined_group_list": { + "post": { + "description": "get joined group list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "get joined group list params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.GetJoinedGroupListReq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/group.GetJoinedGroupListResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/group_application_response": { + "post": { + "description": "response of application group", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "application group param", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsGroupApplicationResponse" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/invite_user_to_group": { + "post": { + "description": "invite user to group", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "invite user to group params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.InviteUserToGroupReq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/group.InviteUserToGroupResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/kick_group": { + "post": { + "description": "kick member from group", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "kick member from group params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsKickGroupMember" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/group.KickGroupMemberResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/set_group_info": { + "post": { + "description": "set group info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "set group info params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsSetGroupInfo" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/transfer_group": { + "post": { + "description": "transfer group owner", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "transfer group owner param", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsTransferGroupOwner" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/manager/delete_user": { + "post": { + "description": "delete user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "manage" + ], + "parameters": [ + { + "description": "user to be deleted", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/manage.paramsDeleteUsers" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/manage.deleteUserResult" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/manager/get_all_users_uid": { + "post": { + "description": "get all user ids", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "manage" + ], + "parameters": [ + { + "description": "all user ids", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/manage.paramsGetAllUsersUid" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/manage.uidListResult" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/manage.uidListResult" + } + } + } + } + }, + "/manager/send_msg": { + "post": { + "description": "manage send message", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "manage" + ], + "parameters": [ + { + "description": "manage send message", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/manage.paramsManagementSendMsg" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/manage.sendMsgResult" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/third/user_register": { + "post": { + "description": "get Tencent cloud storage credential", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "third" + ], + "parameters": [ + { + "description": "get Tencent cloud storage credential params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiThird.paramsTencentCloudStorageCredential" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/apiThird.resultTencentCredential" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/user/get_user_info": { + "post": { + "description": "get user info by uid list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "parameters": [ + { + "description": "get userInfo by uidList", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.queryUserInfoParam" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/user.userInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/user/update_user_info": { + "post": { + "description": "update user info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "parameters": [ + { + "description": "new user info", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.updateUserInfoParam" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + } + }, + "definitions": { + "apiAuth.paramsUserRegister": { + "type": "object", + "required": [ + "name", + "platform", + "secret", + "uid" + ], + "properties": { + "birth": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "platform": { + "type": "integer" + }, + "secret": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "apiAuth.paramsUserToken": { + "type": "object", + "required": [ + "platform", + "secret", + "uid" + ], + "properties": { + "platform": { + "type": "integer" + }, + "secret": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "apiAuth.resultUserRegister": { + "type": "object", + "properties": { + "expiredTime": { + "type": "integer" + }, + "token": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "apiChat.paramsUserNewestSeq": { + "type": "object", + "required": [ + "msgIncr", + "operationID", + "reqIdentifier", + "sendID" + ], + "properties": { + "msgIncr": { + "type": "integer" + }, + "operationID": { + "type": "string" + }, + "reqIdentifier": { + "type": "integer" + }, + "sendID": { + "type": "string" + } + } + }, + "apiChat.paramsUserPullMsg": { + "type": "object", + "required": [ + "operationID", + "reqIdentifier", + "sendID" + ], + "properties": { + "data": { + "type": "object", + "required": [ + "seqBegin", + "seqEnd" + ], + "properties": { + "seqBegin": { + "type": "integer" + }, + "seqEnd": { + "type": "integer" + } + } + }, + "operationID": { + "type": "string" + }, + "reqIdentifier": { + "type": "integer" + }, + "sendID": { + "type": "string" + } + } + }, + "apiChat.paramsUserPullMsgBySeqList": { + "type": "object", + "required": [ + "operationID", + "reqIdentifier", + "sendID" + ], + "properties": { + "operationID": { + "type": "string" + }, + "reqIdentifier": { + "type": "integer" + }, + "sendID": { + "type": "string" + }, + "seqList": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "apiChat.paramsUserSendMsg": { + "type": "object", + "required": [ + "operationID", + "platformID", + "reqIdentifier", + "sendID" + ], + "properties": { + "data": { + "type": "object", + "required": [ + "clientMsgID", + "content", + "contentType", + "msgFrom", + "recvID", + "sessionType" + ], + "properties": { + "clientMsgID": { + "type": "string" + }, + "content": { + "type": "string" + }, + "contentType": { + "type": "integer" + }, + "ext": { + "type": "object", + "additionalProperties": true + }, + "forceList": { + "type": "array", + "items": { + "type": "string" + } + }, + "msgFrom": { + "type": "integer" + }, + "offlineInfo": { + "type": "object", + "additionalProperties": true + }, + "options": { + "type": "object", + "additionalProperties": true + }, + "recvID": { + "type": "string" + }, + "sessionType": { + "type": "integer" + } + } + }, + "operationID": { + "type": "string" + }, + "platformID": { + "type": "integer" + }, + "reqIdentifier": { + "type": "integer" + }, + "sendID": { + "type": "string" + }, + "senderFaceUrl": { + "type": "string" + }, + "senderNickName": { + "type": "string" + } + } + }, + "apiChat.resultSendMsg": { + "type": "object", + "properties": { + "clientMsgID": { + "type": "string" + }, + "sendTime": { + "type": "integer" + }, + "serverMsgID": { + "type": "string" + } + } + }, + "apiChat.resultUserNewestSeq": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "maxSeq": { + "type": "integer" + }, + "minSeq": { + "type": "integer" + } + } + }, + "errCode": { + "type": "integer" + }, + "errMsg": { + "type": "string" + }, + "msgIncr": { + "type": "integer" + }, + "reqIdentifier": { + "type": "integer" + } + } + }, + "apiThird.paramsTencentCloudStorageCredential": { + "type": "object", + "properties": { + "operationID": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, + "apiThird.resultTencentCredential": { + "type": "object", + "properties": { + "bucket": { + "type": "string" + }, + "data": {}, + "errCode": { + "type": "integer" + }, + "errMsg": { + "type": "string" + }, + "region": { + "type": "string" + } + } + }, + "friend.UserInfo": { + "type": "object", + "properties": { + "applyTime": { + "type": "string" + }, + "birth": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "flag": { + "type": "integer" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "reqMessage": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.blackListUserInfo": { + "type": "object", + "properties": { + "birth": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.friendInfo": { + "type": "object", + "properties": { + "birth": { + "type": "string" + }, + "comment": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "isInBlackList": { + "type": "integer" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.paramsAddFriend": { + "type": "object", + "required": [ + "operationID", + "uid" + ], + "properties": { + "operationID": { + "type": "string" + }, + "reqMessage": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.paramsAddFriendResponse": { + "type": "object", + "required": [ + "flag", + "operationID", + "uid" + ], + "properties": { + "flag": { + "type": "integer" + }, + "operationID": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.paramsGetApplyList": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "operationID": { + "type": "string" + } + } + }, + "friend.paramsGetFriendLIst": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "operationID": { + "type": "string" + } + } + }, + "friend.paramsImportFriendReq": { + "type": "object", + "required": [ + "operationID", + "ownerUid", + "uidList" + ], + "properties": { + "operationID": { + "type": "string" + }, + "ownerUid": { + "type": "string" + }, + "uidList": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "friend.paramsSearchFriend": { + "type": "object", + "required": [ + "operationID", + "uid" + ], + "properties": { + "operationID": { + "type": "string" + }, + "ownerUid": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.paramsSetFriendComment": { + "type": "object", + "required": [ + "operationID", + "uid" + ], + "properties": { + "comment": { + "type": "string" + }, + "operationID": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.resultFriendInfo": { + "type": "object", + "properties": { + "birth": { + "type": "string" + }, + "comment": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.resultImportFriend": { + "type": "object", + "properties": { + "errCode": { + "type": "integer", + "example": 0 + }, + "errMsg": { + "type": "string", + "example": "error" + }, + "failedUidList": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "group.GetGroupMemberListReq": { + "type": "object", + "properties": { + "filter": { + "type": "integer" + }, + "groupID": { + "type": "string" + }, + "nextSeq": { + "type": "integer" + }, + "operationID": { + "type": "string" + } + } + }, + "group.GetGroupMemberListResp": { + "type": "object", + "properties": { + "errorCode": { + "type": "integer" + }, + "errorMsg": { + "type": "string" + }, + "memberList": { + "type": "array", + "items": { + "$ref": "#/definitions/group.GroupMemberFullInfo" + } + }, + "nextSeq": { + "type": "integer" + } + } + }, + "group.GetGroupMembersInfoReq": { + "type": "object", + "properties": { + "groupID": { + "type": "string" + }, + "memberList": { + "type": "array", + "items": { + "type": "string" + } + }, + "operationID": { + "type": "string" + } + } + }, + "group.GetGroupMembersInfoResp": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/group.MemberResult" + } + }, + "errCode": { + "type": "integer" + }, + "errMsg": { + "type": "string" + } + } + }, + "group.GetJoinedGroupListReq": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "operationID": { + "type": "string" + } + } + }, + "group.GetJoinedGroupListResp": { + "type": "object", + "properties": { + "errorCode": { + "type": "integer" + }, + "errorMsg": { + "type": "string" + }, + "groupList": { + "type": "array", + "items": { + "$ref": "#/definitions/group.GroupInfo" + } + } + } + }, + "group.GroupInfo": { + "type": "object", + "properties": { + "createTime": { + "type": "integer" + }, + "faceUrl": { + "type": "string" + }, + "groupId": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "introduction": { + "type": "string" + }, + "memberCount": { + "type": "integer" + }, + "notification": { + "type": "string" + }, + "ownerId": { + "type": "string" + } + } + }, + "group.GroupMemberFullInfo": { + "type": "object", + "properties": { + "faceUrl": { + "type": "string" + }, + "joinTime": { + "type": "integer" + }, + "nickName": { + "type": "string" + }, + "role": { + "type": "integer" + }, + "userId": { + "type": "string" + } + } + }, + "group.Id2Result": { + "type": "object", + "properties": { + "result": { + "type": "integer" + }, + "uId": { + "type": "string" + } + } + }, + "group.InviteUserToGroupReq": { + "type": "object", + "required": [ + "groupID", + "operationID", + "uidList" + ], + "properties": { + "groupID": { + "type": "string" + }, + "operationID": { + "type": "string" + }, + "reason": { + "type": "string" + }, + "uidList": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "group.InviteUserToGroupResp": { + "type": "object", + "properties": { + "errorCode": { + "type": "integer" + }, + "errorMsg": { + "type": "string" + }, + "id2result": { + "type": "array", + "items": { + "$ref": "#/definitions/group.Id2Result" + } + } + } + }, + "group.KickGroupMemberResp": { + "type": "object", + "properties": { + "errorCode": { + "type": "integer" + }, + "errorMsg": { + "type": "string" + }, + "id2result": { + "type": "array", + "items": { + "$ref": "#/definitions/group.Id2Result" + } + } + } + }, + "group.MemberResult": { + "type": "object", + "properties": { + "faceUrl": { + "type": "string" + }, + "groupID": { + "type": "string" + }, + "joinTime": { + "type": "integer" + }, + "nickName": { + "type": "string" + }, + "role": { + "type": "integer" + }, + "userId": { + "type": "string" + } + } + }, + "group.getGroupAllMemberReq": { + "type": "object", + "properties": { + "groupID": { + "type": "string" + }, + "operationID": { + "type": "string" + } + } + }, + "group.paramsCreateGroup": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "ex": { + "type": "string" + }, + "faceUrl": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "introduction": { + "type": "string" + }, + "memberList": { + "type": "object", + "properties": { + "setRole": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "notification": { + "type": "string" + }, + "operationID": { + "type": "string" + } + } + }, + "group.paramsGetGroupInfo": { + "type": "object", + "required": [ + "groupIDList", + "operationID" + ], + "properties": { + "groupIDList": { + "type": "array", + "items": { + "type": "string" + } + }, + "operationID": { + "type": "string" + } + } + }, + "group.paramsGroupApplicationList": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "operationID": { + "type": "string" + } + } + }, + "group.paramsGroupApplicationListRet": { + "type": "object", + "properties": { + "createTime": { + "type": "integer" + }, + "flag": { + "type": "integer" + }, + "fromUserFaceURL": { + "type": "string" + }, + "fromUserID": { + "type": "string" + }, + "fromUserNickName": { + "type": "string" + }, + "groupID": { + "type": "string" + }, + "handleResult": { + "type": "integer" + }, + "handleStatus": { + "type": "integer" + }, + "handledMsg": { + "type": "string" + }, + "handledUser": { + "type": "string" + }, + "id": { + "type": "string" + }, + "reqMsg": { + "type": "string" + }, + "toUserFaceURL": { + "type": "string" + }, + "toUserID": { + "type": "string" + }, + "toUserNickName": { + "type": "string" + }, + "type": { + "type": "integer" + } + } + }, + "group.paramsGroupApplicationResponse": { + "type": "object", + "required": [ + "fromUserID", + "groupID", + "operationID", + "toUserID" + ], + "properties": { + "addTime": { + "type": "integer" + }, + "fromUserFaceUrl": { + "type": "string" + }, + "fromUserID": { + "type": "string" + }, + "fromUserNickName": { + "type": "string" + }, + "groupID": { + "type": "string" + }, + "handleResult": { + "type": "integer" + }, + "handleStatus": { + "type": "integer" + }, + "handledMsg": { + "type": "string" + }, + "operationID": { + "type": "string" + }, + "requestMsg": { + "type": "string" + }, + "toUserFaceUrl": { + "type": "string" + }, + "toUserID": { + "type": "string" + }, + "toUserNickName": { + "type": "string" + }, + "type": { + "type": "integer" + } + } + }, + "group.paramsJoinGroup": { + "type": "object", + "required": [ + "groupID", + "operationID" + ], + "properties": { + "groupID": { + "type": "string" + }, + "message": { + "type": "string" + }, + "operationID": { + "type": "string" + } + } + }, + "group.paramsKickGroupMember": { + "type": "object", + "required": [ + "operationID", + "uidListInfo" + ], + "properties": { + "groupID": { + "type": "string" + }, + "operationID": { + "type": "string" + }, + "reason": { + "type": "string" + }, + "uidListInfo": { + "type": "array", + "items": { + "type": "object", + "properties": { + "faceUrl": { + "type": "string" + }, + "joinTime": { + "type": "integer" + }, + "nickName": { + "type": "string" + }, + "role": { + "type": "integer" + }, + "userId": { + "type": "string" + } + } + } + } + } + }, + "group.paramsQuitGroup": { + "type": "object", + "required": [ + "groupID", + "operationID" + ], + "properties": { + "groupID": { + "type": "string" + }, + "operationID": { + "type": "string" + } + } + }, + "group.paramsSetGroupInfo": { + "type": "object", + "required": [ + "groupId", + "operationID" + ], + "properties": { + "faceUrl": { + "type": "string" + }, + "groupId": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "introduction": { + "type": "string" + }, + "notification": { + "type": "string" + }, + "operationID": { + "type": "string" + } + } + }, + "group.paramsTransferGroupOwner": { + "type": "object", + "required": [ + "groupID", + "operationID", + "uid" + ], + "properties": { + "groupID": { + "type": "string" + }, + "operationID": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "group.resultGroupApplication": { + "type": "object", + "properties": { + "count": { + "type": "integer" + }, + "user": { + "type": "array", + "items": { + "$ref": "#/definitions/group.paramsGroupApplicationListRet" + } + } + } + }, + "manage.deleteUserResult": { + "type": "object", + "properties": { + "errCode": { + "type": "integer", + "example": 0 + }, + "errMsg": { + "type": "string", + "example": "error" + }, + "failedUidList": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "manage.paramsDeleteUsers": { + "type": "object", + "required": [ + "deleteUidList", + "operationID" + ], + "properties": { + "deleteUidList": { + "type": "array", + "items": { + "type": "string" + } + }, + "operationID": { + "type": "string" + } + } + }, + "manage.paramsGetAllUsersUid": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "operationID": { + "type": "string" + } + } + }, + "manage.paramsManagementSendMsg": { + "type": "object", + "required": [ + "content", + "contentType", + "operationID", + "recvID", + "sendID", + "sessionType" + ], + "properties": { + "content": { + "type": "object", + "additionalProperties": true + }, + "contentType": { + "type": "integer" + }, + "forceList": { + "type": "array", + "items": { + "type": "string" + } + }, + "operationID": { + "type": "string" + }, + "recvID": { + "type": "string" + }, + "sendID": { + "type": "string" + }, + "senderFaceURL": { + "type": "string" + }, + "senderNickName": { + "type": "string" + }, + "sessionType": { + "type": "integer" + } + } + }, + "manage.sendMsgResult": { + "type": "object", + "properties": { + "errCode": { + "type": "integer", + "example": 0 + }, + "errMsg": { + "type": "string", + "example": "error" + }, + "msgID": { + "type": "string" + }, + "sendTime": { + "type": "integer" + } + } + }, + "manage.uidListResult": { + "type": "object", + "properties": { + "errCode": { + "type": "integer", + "example": 0 + }, + "errMsg": { + "type": "string", + "example": "error" + }, + "uidList": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "user.queryUserInfoParam": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "operationID": { + "type": "string" + }, + "uidList": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "user.result": { + "type": "object", + "properties": { + "data": {}, + "errCode": { + "type": "integer", + "example": 0 + }, + "errMsg": { + "type": "string", + "example": "error" + } + } + }, + "user.updateUserInfoParam": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "birth": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "operationID": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "user.userInfo": { + "type": "object", + "properties": { + "birth": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + } + } +}` + +type swaggerInfo struct { + Version string + Host string + BasePath string + Schemes []string + Title string + Description string +} + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = swaggerInfo{ + Version: "", + Host: "", + BasePath: "", + Schemes: []string{}, + Title: "", + Description: "", +} + +type s struct{} + +func (s *s) ReadDoc() string { + sInfo := SwaggerInfo + sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1) + + t, err := template.New("swagger_info").Funcs(template.FuncMap{ + "marshal": func(v interface{}) string { + a, _ := json.Marshal(v) + return string(a) + }, + "escape": func(v interface{}) string { + // escape tabs + str := strings.Replace(v.(string), "\t", "\\t", -1) + // replace " with \", and if that results in \\", replace that with \\\" + str = strings.Replace(str, "\"", "\\\"", -1) + return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1) + }, + }).Parse(doc) + if err != nil { + return doc + } + + var tpl bytes.Buffer + if err := t.Execute(&tpl, sInfo); err != nil { + return doc + } + + return tpl.String() +} + +func init() { + swag.Register("swagger", &s{}) +} diff --git a/docs/swagger.json b/docs/swagger.json new file mode 100644 index 000000000..2c1131d0f --- /dev/null +++ b/docs/swagger.json @@ -0,0 +1,3407 @@ +{ + "swagger": "2.0", + "info": { + "contact": {} + }, + "paths": { + "/auth/user_register": { + "post": { + "description": "register a new user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "parameters": [ + { + "description": "new user params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiAuth.paramsUserRegister" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/apiAuth.resultUserRegister" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/auth/user_token": { + "post": { + "description": "get token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "parameters": [ + { + "description": "get token params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiAuth.paramsUserToken" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/apiAuth.resultUserRegister" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/chat/newest_seq": { + "post": { + "description": "get latest message seq", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "chat" + ], + "parameters": [ + { + "description": "user get latest seq params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiChat.paramsUserNewestSeq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/apiChat.resultUserNewestSeq" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/chat/pull_msg": { + "post": { + "description": "user pull messages", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "chat" + ], + "parameters": [ + { + "description": "user pull messages", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiChat.paramsUserPullMsg" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "reqIdentifier": { + "type": "integer" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/chat/pull_msg_by_seq": { + "post": { + "description": "user pull msg by seq", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "chat" + ], + "parameters": [ + { + "description": "pull msg by seq", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiChat.paramsUserPullMsgBySeqList" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "reqIdentifier": { + "type": "integer" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/chat/send_msg": { + "post": { + "description": "user send messages", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "chat" + ], + "parameters": [ + { + "description": "user send messages", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiChat.paramsUserSendMsg" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/apiChat.resultSendMsg" + }, + "reqIdentifier": { + "type": "integer" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/add_blacklist": { + "post": { + "description": "add a user into black list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "add black list params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSearchFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/add_friend": { + "post": { + "description": "add a new friend by uid", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "add friend params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsAddFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/add_friend_response": { + "post": { + "description": "the response of adding friend", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "response of adding friend", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsAddFriendResponse" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/delete_friend": { + "post": { + "description": "delete friend", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "delete friend params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSearchFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/get_blacklist": { + "post": { + "description": "get black list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "get black list", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSearchFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/friend.blackListUserInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/get_friend_apply_list": { + "post": { + "description": "get friend apply list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "get friend apply list", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsGetApplyList" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/friend.UserInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/get_friend_list": { + "post": { + "description": "get friend apply list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "get friend apply list", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsGetFriendLIst" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/friend.friendInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/get_friends_info": { + "post": { + "description": "get friend info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "search friend params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSearchFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/get_self_apply_list": { + "post": { + "description": "get friend apply list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "get friend apply list", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsGetApplyList" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/friend.UserInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/import_friend": { + "post": { + "description": "import friend", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "import friend params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsImportFriendReq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/friend.resultImportFriend" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/is_friend": { + "post": { + "description": "check is friend", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "is friend params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSearchFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/remove_blacklist": { + "post": { + "description": "remove black list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "remove black list params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSearchFriend" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/friend/set_friend_comment": { + "post": { + "description": "set friend comment", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "friend" + ], + "parameters": [ + { + "description": "set friend comment", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend.paramsSetFriendComment" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/create_group": { + "post": { + "description": "create group", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "create group params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsCreateGroup" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/get_group_all_member_list": { + "post": { + "description": "get group all members", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "get group all members params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.getGroupAllMemberReq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/group.GetGroupMemberListResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/get_group_applicationList": { + "post": { + "description": "get group application list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "get group application list params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsGroupApplicationList" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/group.resultGroupApplication" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/get_group_member_list": { + "post": { + "description": "get group member list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "get group member list params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.GetGroupMemberListReq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/group.GetGroupMemberListResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/get_group_members_info": { + "post": { + "description": "get group members info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "get group members info params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.GetGroupMembersInfoReq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/group.GetGroupMembersInfoResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/get_groups_info": { + "post": { + "description": "get groups info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "get groups info params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsGetGroupInfo" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/group.GroupInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/get_joined_group_list": { + "post": { + "description": "get joined group list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "get joined group list params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.GetJoinedGroupListReq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/group.GetJoinedGroupListResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/group_application_response": { + "post": { + "description": "response of application group", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "application group param", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsGroupApplicationResponse" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/invite_user_to_group": { + "post": { + "description": "invite user to group", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "invite user to group params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.InviteUserToGroupReq" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/group.InviteUserToGroupResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/kick_group": { + "post": { + "description": "kick member from group", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "kick member from group params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsKickGroupMember" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/group.KickGroupMemberResp" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/set_group_info": { + "post": { + "description": "set group info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "set group info params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsSetGroupInfo" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/group/transfer_group": { + "post": { + "description": "transfer group owner", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "group" + ], + "parameters": [ + { + "description": "transfer group owner param", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group.paramsTransferGroupOwner" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/manager/delete_user": { + "post": { + "description": "delete user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "manage" + ], + "parameters": [ + { + "description": "user to be deleted", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/manage.paramsDeleteUsers" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/manage.deleteUserResult" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/manager/get_all_users_uid": { + "post": { + "description": "get all user ids", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "manage" + ], + "parameters": [ + { + "description": "all user ids", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/manage.paramsGetAllUsersUid" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/manage.uidListResult" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/manage.uidListResult" + } + } + } + } + }, + "/manager/send_msg": { + "post": { + "description": "manage send message", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "manage" + ], + "parameters": [ + { + "description": "manage send message", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/manage.paramsManagementSendMsg" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/manage.sendMsgResult" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/third/user_register": { + "post": { + "description": "get Tencent cloud storage credential", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "third" + ], + "parameters": [ + { + "description": "get Tencent cloud storage credential params", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/apiThird.paramsTencentCloudStorageCredential" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/apiThird.resultTencentCredential" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/user/get_user_info": { + "post": { + "description": "get user info by uid list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "parameters": [ + { + "description": "get userInfo by uidList", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.queryUserInfoParam" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/user.result" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/user.userInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + }, + "/user/update_user_info": { + "post": { + "description": "update user info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "parameters": [ + { + "description": "new user info", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.updateUserInfoParam" + } + }, + { + "type": "string", + "description": "token", + "name": "token", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.result" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/user.result" + } + } + } + } + } + }, + "definitions": { + "apiAuth.paramsUserRegister": { + "type": "object", + "required": [ + "name", + "platform", + "secret", + "uid" + ], + "properties": { + "birth": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "platform": { + "type": "integer" + }, + "secret": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "apiAuth.paramsUserToken": { + "type": "object", + "required": [ + "platform", + "secret", + "uid" + ], + "properties": { + "platform": { + "type": "integer" + }, + "secret": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "apiAuth.resultUserRegister": { + "type": "object", + "properties": { + "expiredTime": { + "type": "integer" + }, + "token": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "apiChat.paramsUserNewestSeq": { + "type": "object", + "required": [ + "msgIncr", + "operationID", + "reqIdentifier", + "sendID" + ], + "properties": { + "msgIncr": { + "type": "integer" + }, + "operationID": { + "type": "string" + }, + "reqIdentifier": { + "type": "integer" + }, + "sendID": { + "type": "string" + } + } + }, + "apiChat.paramsUserPullMsg": { + "type": "object", + "required": [ + "operationID", + "reqIdentifier", + "sendID" + ], + "properties": { + "data": { + "type": "object", + "required": [ + "seqBegin", + "seqEnd" + ], + "properties": { + "seqBegin": { + "type": "integer" + }, + "seqEnd": { + "type": "integer" + } + } + }, + "operationID": { + "type": "string" + }, + "reqIdentifier": { + "type": "integer" + }, + "sendID": { + "type": "string" + } + } + }, + "apiChat.paramsUserPullMsgBySeqList": { + "type": "object", + "required": [ + "operationID", + "reqIdentifier", + "sendID" + ], + "properties": { + "operationID": { + "type": "string" + }, + "reqIdentifier": { + "type": "integer" + }, + "sendID": { + "type": "string" + }, + "seqList": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "apiChat.paramsUserSendMsg": { + "type": "object", + "required": [ + "operationID", + "platformID", + "reqIdentifier", + "sendID" + ], + "properties": { + "data": { + "type": "object", + "required": [ + "clientMsgID", + "content", + "contentType", + "msgFrom", + "recvID", + "sessionType" + ], + "properties": { + "clientMsgID": { + "type": "string" + }, + "content": { + "type": "string" + }, + "contentType": { + "type": "integer" + }, + "ext": { + "type": "object", + "additionalProperties": true + }, + "forceList": { + "type": "array", + "items": { + "type": "string" + } + }, + "msgFrom": { + "type": "integer" + }, + "offlineInfo": { + "type": "object", + "additionalProperties": true + }, + "options": { + "type": "object", + "additionalProperties": true + }, + "recvID": { + "type": "string" + }, + "sessionType": { + "type": "integer" + } + } + }, + "operationID": { + "type": "string" + }, + "platformID": { + "type": "integer" + }, + "reqIdentifier": { + "type": "integer" + }, + "sendID": { + "type": "string" + }, + "senderFaceUrl": { + "type": "string" + }, + "senderNickName": { + "type": "string" + } + } + }, + "apiChat.resultSendMsg": { + "type": "object", + "properties": { + "clientMsgID": { + "type": "string" + }, + "sendTime": { + "type": "integer" + }, + "serverMsgID": { + "type": "string" + } + } + }, + "apiChat.resultUserNewestSeq": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "maxSeq": { + "type": "integer" + }, + "minSeq": { + "type": "integer" + } + } + }, + "errCode": { + "type": "integer" + }, + "errMsg": { + "type": "string" + }, + "msgIncr": { + "type": "integer" + }, + "reqIdentifier": { + "type": "integer" + } + } + }, + "apiThird.paramsTencentCloudStorageCredential": { + "type": "object", + "properties": { + "operationID": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, + "apiThird.resultTencentCredential": { + "type": "object", + "properties": { + "bucket": { + "type": "string" + }, + "data": {}, + "errCode": { + "type": "integer" + }, + "errMsg": { + "type": "string" + }, + "region": { + "type": "string" + } + } + }, + "friend.UserInfo": { + "type": "object", + "properties": { + "applyTime": { + "type": "string" + }, + "birth": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "flag": { + "type": "integer" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "reqMessage": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.blackListUserInfo": { + "type": "object", + "properties": { + "birth": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.friendInfo": { + "type": "object", + "properties": { + "birth": { + "type": "string" + }, + "comment": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "isInBlackList": { + "type": "integer" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.paramsAddFriend": { + "type": "object", + "required": [ + "operationID", + "uid" + ], + "properties": { + "operationID": { + "type": "string" + }, + "reqMessage": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.paramsAddFriendResponse": { + "type": "object", + "required": [ + "flag", + "operationID", + "uid" + ], + "properties": { + "flag": { + "type": "integer" + }, + "operationID": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.paramsGetApplyList": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "operationID": { + "type": "string" + } + } + }, + "friend.paramsGetFriendLIst": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "operationID": { + "type": "string" + } + } + }, + "friend.paramsImportFriendReq": { + "type": "object", + "required": [ + "operationID", + "ownerUid", + "uidList" + ], + "properties": { + "operationID": { + "type": "string" + }, + "ownerUid": { + "type": "string" + }, + "uidList": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "friend.paramsSearchFriend": { + "type": "object", + "required": [ + "operationID", + "uid" + ], + "properties": { + "operationID": { + "type": "string" + }, + "ownerUid": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.paramsSetFriendComment": { + "type": "object", + "required": [ + "operationID", + "uid" + ], + "properties": { + "comment": { + "type": "string" + }, + "operationID": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.resultFriendInfo": { + "type": "object", + "properties": { + "birth": { + "type": "string" + }, + "comment": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "friend.resultImportFriend": { + "type": "object", + "properties": { + "errCode": { + "type": "integer", + "example": 0 + }, + "errMsg": { + "type": "string", + "example": "error" + }, + "failedUidList": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "group.GetGroupMemberListReq": { + "type": "object", + "properties": { + "filter": { + "type": "integer" + }, + "groupID": { + "type": "string" + }, + "nextSeq": { + "type": "integer" + }, + "operationID": { + "type": "string" + } + } + }, + "group.GetGroupMemberListResp": { + "type": "object", + "properties": { + "errorCode": { + "type": "integer" + }, + "errorMsg": { + "type": "string" + }, + "memberList": { + "type": "array", + "items": { + "$ref": "#/definitions/group.GroupMemberFullInfo" + } + }, + "nextSeq": { + "type": "integer" + } + } + }, + "group.GetGroupMembersInfoReq": { + "type": "object", + "properties": { + "groupID": { + "type": "string" + }, + "memberList": { + "type": "array", + "items": { + "type": "string" + } + }, + "operationID": { + "type": "string" + } + } + }, + "group.GetGroupMembersInfoResp": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/group.MemberResult" + } + }, + "errCode": { + "type": "integer" + }, + "errMsg": { + "type": "string" + } + } + }, + "group.GetJoinedGroupListReq": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "operationID": { + "type": "string" + } + } + }, + "group.GetJoinedGroupListResp": { + "type": "object", + "properties": { + "errorCode": { + "type": "integer" + }, + "errorMsg": { + "type": "string" + }, + "groupList": { + "type": "array", + "items": { + "$ref": "#/definitions/group.GroupInfo" + } + } + } + }, + "group.GroupInfo": { + "type": "object", + "properties": { + "createTime": { + "type": "integer" + }, + "faceUrl": { + "type": "string" + }, + "groupId": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "introduction": { + "type": "string" + }, + "memberCount": { + "type": "integer" + }, + "notification": { + "type": "string" + }, + "ownerId": { + "type": "string" + } + } + }, + "group.GroupMemberFullInfo": { + "type": "object", + "properties": { + "faceUrl": { + "type": "string" + }, + "joinTime": { + "type": "integer" + }, + "nickName": { + "type": "string" + }, + "role": { + "type": "integer" + }, + "userId": { + "type": "string" + } + } + }, + "group.Id2Result": { + "type": "object", + "properties": { + "result": { + "type": "integer" + }, + "uId": { + "type": "string" + } + } + }, + "group.InviteUserToGroupReq": { + "type": "object", + "required": [ + "groupID", + "operationID", + "uidList" + ], + "properties": { + "groupID": { + "type": "string" + }, + "operationID": { + "type": "string" + }, + "reason": { + "type": "string" + }, + "uidList": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "group.InviteUserToGroupResp": { + "type": "object", + "properties": { + "errorCode": { + "type": "integer" + }, + "errorMsg": { + "type": "string" + }, + "id2result": { + "type": "array", + "items": { + "$ref": "#/definitions/group.Id2Result" + } + } + } + }, + "group.KickGroupMemberResp": { + "type": "object", + "properties": { + "errorCode": { + "type": "integer" + }, + "errorMsg": { + "type": "string" + }, + "id2result": { + "type": "array", + "items": { + "$ref": "#/definitions/group.Id2Result" + } + } + } + }, + "group.MemberResult": { + "type": "object", + "properties": { + "faceUrl": { + "type": "string" + }, + "groupID": { + "type": "string" + }, + "joinTime": { + "type": "integer" + }, + "nickName": { + "type": "string" + }, + "role": { + "type": "integer" + }, + "userId": { + "type": "string" + } + } + }, + "group.getGroupAllMemberReq": { + "type": "object", + "properties": { + "groupID": { + "type": "string" + }, + "operationID": { + "type": "string" + } + } + }, + "group.paramsCreateGroup": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "ex": { + "type": "string" + }, + "faceUrl": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "introduction": { + "type": "string" + }, + "memberList": { + "type": "object", + "properties": { + "setRole": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "notification": { + "type": "string" + }, + "operationID": { + "type": "string" + } + } + }, + "group.paramsGetGroupInfo": { + "type": "object", + "required": [ + "groupIDList", + "operationID" + ], + "properties": { + "groupIDList": { + "type": "array", + "items": { + "type": "string" + } + }, + "operationID": { + "type": "string" + } + } + }, + "group.paramsGroupApplicationList": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "operationID": { + "type": "string" + } + } + }, + "group.paramsGroupApplicationListRet": { + "type": "object", + "properties": { + "createTime": { + "type": "integer" + }, + "flag": { + "type": "integer" + }, + "fromUserFaceURL": { + "type": "string" + }, + "fromUserID": { + "type": "string" + }, + "fromUserNickName": { + "type": "string" + }, + "groupID": { + "type": "string" + }, + "handleResult": { + "type": "integer" + }, + "handleStatus": { + "type": "integer" + }, + "handledMsg": { + "type": "string" + }, + "handledUser": { + "type": "string" + }, + "id": { + "type": "string" + }, + "reqMsg": { + "type": "string" + }, + "toUserFaceURL": { + "type": "string" + }, + "toUserID": { + "type": "string" + }, + "toUserNickName": { + "type": "string" + }, + "type": { + "type": "integer" + } + } + }, + "group.paramsGroupApplicationResponse": { + "type": "object", + "required": [ + "fromUserID", + "groupID", + "operationID", + "toUserID" + ], + "properties": { + "addTime": { + "type": "integer" + }, + "fromUserFaceUrl": { + "type": "string" + }, + "fromUserID": { + "type": "string" + }, + "fromUserNickName": { + "type": "string" + }, + "groupID": { + "type": "string" + }, + "handleResult": { + "type": "integer" + }, + "handleStatus": { + "type": "integer" + }, + "handledMsg": { + "type": "string" + }, + "operationID": { + "type": "string" + }, + "requestMsg": { + "type": "string" + }, + "toUserFaceUrl": { + "type": "string" + }, + "toUserID": { + "type": "string" + }, + "toUserNickName": { + "type": "string" + }, + "type": { + "type": "integer" + } + } + }, + "group.paramsJoinGroup": { + "type": "object", + "required": [ + "groupID", + "operationID" + ], + "properties": { + "groupID": { + "type": "string" + }, + "message": { + "type": "string" + }, + "operationID": { + "type": "string" + } + } + }, + "group.paramsKickGroupMember": { + "type": "object", + "required": [ + "operationID", + "uidListInfo" + ], + "properties": { + "groupID": { + "type": "string" + }, + "operationID": { + "type": "string" + }, + "reason": { + "type": "string" + }, + "uidListInfo": { + "type": "array", + "items": { + "type": "object", + "properties": { + "faceUrl": { + "type": "string" + }, + "joinTime": { + "type": "integer" + }, + "nickName": { + "type": "string" + }, + "role": { + "type": "integer" + }, + "userId": { + "type": "string" + } + } + } + } + } + }, + "group.paramsQuitGroup": { + "type": "object", + "required": [ + "groupID", + "operationID" + ], + "properties": { + "groupID": { + "type": "string" + }, + "operationID": { + "type": "string" + } + } + }, + "group.paramsSetGroupInfo": { + "type": "object", + "required": [ + "groupId", + "operationID" + ], + "properties": { + "faceUrl": { + "type": "string" + }, + "groupId": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "introduction": { + "type": "string" + }, + "notification": { + "type": "string" + }, + "operationID": { + "type": "string" + } + } + }, + "group.paramsTransferGroupOwner": { + "type": "object", + "required": [ + "groupID", + "operationID", + "uid" + ], + "properties": { + "groupID": { + "type": "string" + }, + "operationID": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "group.resultGroupApplication": { + "type": "object", + "properties": { + "count": { + "type": "integer" + }, + "user": { + "type": "array", + "items": { + "$ref": "#/definitions/group.paramsGroupApplicationListRet" + } + } + } + }, + "manage.deleteUserResult": { + "type": "object", + "properties": { + "errCode": { + "type": "integer", + "example": 0 + }, + "errMsg": { + "type": "string", + "example": "error" + }, + "failedUidList": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "manage.paramsDeleteUsers": { + "type": "object", + "required": [ + "deleteUidList", + "operationID" + ], + "properties": { + "deleteUidList": { + "type": "array", + "items": { + "type": "string" + } + }, + "operationID": { + "type": "string" + } + } + }, + "manage.paramsGetAllUsersUid": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "operationID": { + "type": "string" + } + } + }, + "manage.paramsManagementSendMsg": { + "type": "object", + "required": [ + "content", + "contentType", + "operationID", + "recvID", + "sendID", + "sessionType" + ], + "properties": { + "content": { + "type": "object", + "additionalProperties": true + }, + "contentType": { + "type": "integer" + }, + "forceList": { + "type": "array", + "items": { + "type": "string" + } + }, + "operationID": { + "type": "string" + }, + "recvID": { + "type": "string" + }, + "sendID": { + "type": "string" + }, + "senderFaceURL": { + "type": "string" + }, + "senderNickName": { + "type": "string" + }, + "sessionType": { + "type": "integer" + } + } + }, + "manage.sendMsgResult": { + "type": "object", + "properties": { + "errCode": { + "type": "integer", + "example": 0 + }, + "errMsg": { + "type": "string", + "example": "error" + }, + "msgID": { + "type": "string" + }, + "sendTime": { + "type": "integer" + } + } + }, + "manage.uidListResult": { + "type": "object", + "properties": { + "errCode": { + "type": "integer", + "example": 0 + }, + "errMsg": { + "type": "string", + "example": "error" + }, + "uidList": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "user.queryUserInfoParam": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "operationID": { + "type": "string" + }, + "uidList": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "user.result": { + "type": "object", + "properties": { + "data": {}, + "errCode": { + "type": "integer", + "example": 0 + }, + "errMsg": { + "type": "string", + "example": "error" + } + } + }, + "user.updateUserInfoParam": { + "type": "object", + "required": [ + "operationID" + ], + "properties": { + "birth": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "operationID": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "user.userInfo": { + "type": "object", + "properties": { + "birth": { + "type": "string" + }, + "email": { + "type": "string" + }, + "ex": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "mobile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml new file mode 100644 index 000000000..517f009d5 --- /dev/null +++ b/docs/swagger.yaml @@ -0,0 +1,2208 @@ +definitions: + apiAuth.paramsUserRegister: + properties: + birth: + type: string + email: + type: string + ex: + type: string + gender: + type: integer + icon: + type: string + mobile: + type: string + name: + type: string + platform: + type: integer + secret: + type: string + uid: + type: string + required: + - name + - platform + - secret + - uid + type: object + apiAuth.paramsUserToken: + properties: + platform: + type: integer + secret: + type: string + uid: + type: string + required: + - platform + - secret + - uid + type: object + apiAuth.resultUserRegister: + properties: + expiredTime: + type: integer + token: + type: string + uid: + type: string + type: object + apiChat.paramsUserNewestSeq: + properties: + msgIncr: + type: integer + operationID: + type: string + reqIdentifier: + type: integer + sendID: + type: string + required: + - msgIncr + - operationID + - reqIdentifier + - sendID + type: object + apiChat.paramsUserPullMsg: + properties: + data: + properties: + seqBegin: + type: integer + seqEnd: + type: integer + required: + - seqBegin + - seqEnd + type: object + operationID: + type: string + reqIdentifier: + type: integer + sendID: + type: string + required: + - operationID + - reqIdentifier + - sendID + type: object + apiChat.paramsUserPullMsgBySeqList: + properties: + operationID: + type: string + reqIdentifier: + type: integer + sendID: + type: string + seqList: + items: + type: integer + type: array + required: + - operationID + - reqIdentifier + - sendID + type: object + apiChat.paramsUserSendMsg: + properties: + data: + properties: + clientMsgID: + type: string + content: + type: string + contentType: + type: integer + ext: + additionalProperties: true + type: object + forceList: + items: + type: string + type: array + msgFrom: + type: integer + offlineInfo: + additionalProperties: true + type: object + options: + additionalProperties: true + type: object + recvID: + type: string + sessionType: + type: integer + required: + - clientMsgID + - content + - contentType + - msgFrom + - recvID + - sessionType + type: object + operationID: + type: string + platformID: + type: integer + reqIdentifier: + type: integer + sendID: + type: string + senderFaceUrl: + type: string + senderNickName: + type: string + required: + - operationID + - platformID + - reqIdentifier + - sendID + type: object + apiChat.resultSendMsg: + properties: + clientMsgID: + type: string + sendTime: + type: integer + serverMsgID: + type: string + type: object + apiChat.resultUserNewestSeq: + properties: + data: + properties: + maxSeq: + type: integer + minSeq: + type: integer + type: object + errCode: + type: integer + errMsg: + type: string + msgIncr: + type: integer + reqIdentifier: + type: integer + type: object + apiThird.paramsTencentCloudStorageCredential: + properties: + operationID: + type: string + token: + type: string + type: object + apiThird.resultTencentCredential: + properties: + bucket: + type: string + data: {} + errCode: + type: integer + errMsg: + type: string + region: + type: string + type: object + friend.UserInfo: + properties: + applyTime: + type: string + birth: + type: string + email: + type: string + ex: + type: string + flag: + type: integer + gender: + type: integer + icon: + type: string + mobile: + type: string + name: + type: string + reqMessage: + type: string + uid: + type: string + type: object + friend.blackListUserInfo: + properties: + birth: + type: string + email: + type: string + ex: + type: string + gender: + type: integer + icon: + type: string + mobile: + type: string + name: + type: string + uid: + type: string + type: object + friend.friendInfo: + properties: + birth: + type: string + comment: + type: string + email: + type: string + ex: + type: string + gender: + type: integer + icon: + type: string + isInBlackList: + type: integer + mobile: + type: string + name: + type: string + uid: + type: string + type: object + friend.paramsAddFriend: + properties: + operationID: + type: string + reqMessage: + type: string + uid: + type: string + required: + - operationID + - uid + type: object + friend.paramsAddFriendResponse: + properties: + flag: + type: integer + operationID: + type: string + uid: + type: string + required: + - flag + - operationID + - uid + type: object + friend.paramsGetApplyList: + properties: + operationID: + type: string + required: + - operationID + type: object + friend.paramsGetFriendLIst: + properties: + operationID: + type: string + required: + - operationID + type: object + friend.paramsImportFriendReq: + properties: + operationID: + type: string + ownerUid: + type: string + uidList: + items: + type: string + type: array + required: + - operationID + - ownerUid + - uidList + type: object + friend.paramsSearchFriend: + properties: + operationID: + type: string + ownerUid: + type: string + uid: + type: string + required: + - operationID + - uid + type: object + friend.paramsSetFriendComment: + properties: + comment: + type: string + operationID: + type: string + uid: + type: string + required: + - operationID + - uid + type: object + friend.resultFriendInfo: + properties: + birth: + type: string + comment: + type: string + email: + type: string + ex: + type: string + gender: + type: integer + icon: + type: string + mobile: + type: string + name: + type: string + uid: + type: string + type: object + friend.resultImportFriend: + properties: + errCode: + example: 0 + type: integer + errMsg: + example: error + type: string + failedUidList: + items: + type: string + type: array + type: object + group.GetGroupMemberListReq: + properties: + filter: + type: integer + groupID: + type: string + nextSeq: + type: integer + operationID: + type: string + type: object + group.GetGroupMemberListResp: + properties: + errorCode: + type: integer + errorMsg: + type: string + memberList: + items: + $ref: '#/definitions/group.GroupMemberFullInfo' + type: array + nextSeq: + type: integer + type: object + group.GetGroupMembersInfoReq: + properties: + groupID: + type: string + memberList: + items: + type: string + type: array + operationID: + type: string + type: object + group.GetGroupMembersInfoResp: + properties: + data: + items: + $ref: '#/definitions/group.MemberResult' + type: array + errCode: + type: integer + errMsg: + type: string + type: object + group.GetJoinedGroupListReq: + properties: + operationID: + type: string + required: + - operationID + type: object + group.GetJoinedGroupListResp: + properties: + errorCode: + type: integer + errorMsg: + type: string + groupList: + items: + $ref: '#/definitions/group.GroupInfo' + type: array + type: object + group.GroupInfo: + properties: + createTime: + type: integer + faceUrl: + type: string + groupId: + type: string + groupName: + type: string + introduction: + type: string + memberCount: + type: integer + notification: + type: string + ownerId: + type: string + type: object + group.GroupMemberFullInfo: + properties: + faceUrl: + type: string + joinTime: + type: integer + nickName: + type: string + role: + type: integer + userId: + type: string + type: object + group.Id2Result: + properties: + result: + type: integer + uId: + type: string + type: object + group.InviteUserToGroupReq: + properties: + groupID: + type: string + operationID: + type: string + reason: + type: string + uidList: + items: + type: string + type: array + required: + - groupID + - operationID + - uidList + type: object + group.InviteUserToGroupResp: + properties: + errorCode: + type: integer + errorMsg: + type: string + id2result: + items: + $ref: '#/definitions/group.Id2Result' + type: array + type: object + group.KickGroupMemberResp: + properties: + errorCode: + type: integer + errorMsg: + type: string + id2result: + items: + $ref: '#/definitions/group.Id2Result' + type: array + type: object + group.MemberResult: + properties: + faceUrl: + type: string + groupID: + type: string + joinTime: + type: integer + nickName: + type: string + role: + type: integer + userId: + type: string + type: object + group.getGroupAllMemberReq: + properties: + groupID: + type: string + operationID: + type: string + type: object + group.paramsCreateGroup: + properties: + ex: + type: string + faceUrl: + type: string + groupName: + type: string + introduction: + type: string + memberList: + properties: + setRole: + type: string + uid: + type: string + type: object + notification: + type: string + operationID: + type: string + required: + - operationID + type: object + group.paramsGetGroupInfo: + properties: + groupIDList: + items: + type: string + type: array + operationID: + type: string + required: + - groupIDList + - operationID + type: object + group.paramsGroupApplicationList: + properties: + operationID: + type: string + required: + - operationID + type: object + group.paramsGroupApplicationListRet: + properties: + createTime: + type: integer + flag: + type: integer + fromUserFaceURL: + type: string + fromUserID: + type: string + fromUserNickName: + type: string + groupID: + type: string + handleResult: + type: integer + handleStatus: + type: integer + handledMsg: + type: string + handledUser: + type: string + id: + type: string + reqMsg: + type: string + toUserFaceURL: + type: string + toUserID: + type: string + toUserNickName: + type: string + type: + type: integer + type: object + group.paramsGroupApplicationResponse: + properties: + addTime: + type: integer + fromUserFaceUrl: + type: string + fromUserID: + type: string + fromUserNickName: + type: string + groupID: + type: string + handleResult: + type: integer + handleStatus: + type: integer + handledMsg: + type: string + operationID: + type: string + requestMsg: + type: string + toUserFaceUrl: + type: string + toUserID: + type: string + toUserNickName: + type: string + type: + type: integer + required: + - fromUserID + - groupID + - operationID + - toUserID + type: object + group.paramsJoinGroup: + properties: + groupID: + type: string + message: + type: string + operationID: + type: string + required: + - groupID + - operationID + type: object + group.paramsKickGroupMember: + properties: + groupID: + type: string + operationID: + type: string + reason: + type: string + uidListInfo: + items: + properties: + faceUrl: + type: string + joinTime: + type: integer + nickName: + type: string + role: + type: integer + userId: + type: string + type: object + type: array + required: + - operationID + - uidListInfo + type: object + group.paramsQuitGroup: + properties: + groupID: + type: string + operationID: + type: string + required: + - groupID + - operationID + type: object + group.paramsSetGroupInfo: + properties: + faceUrl: + type: string + groupId: + type: string + groupName: + type: string + introduction: + type: string + notification: + type: string + operationID: + type: string + required: + - groupId + - operationID + type: object + group.paramsTransferGroupOwner: + properties: + groupID: + type: string + operationID: + type: string + uid: + type: string + required: + - groupID + - operationID + - uid + type: object + group.resultGroupApplication: + properties: + count: + type: integer + user: + items: + $ref: '#/definitions/group.paramsGroupApplicationListRet' + type: array + type: object + manage.deleteUserResult: + properties: + errCode: + example: 0 + type: integer + errMsg: + example: error + type: string + failedUidList: + items: + type: string + type: array + type: object + manage.paramsDeleteUsers: + properties: + deleteUidList: + items: + type: string + type: array + operationID: + type: string + required: + - deleteUidList + - operationID + type: object + manage.paramsGetAllUsersUid: + properties: + operationID: + type: string + required: + - operationID + type: object + manage.paramsManagementSendMsg: + properties: + content: + additionalProperties: true + type: object + contentType: + type: integer + forceList: + items: + type: string + type: array + operationID: + type: string + recvID: + type: string + sendID: + type: string + senderFaceURL: + type: string + senderNickName: + type: string + sessionType: + type: integer + required: + - content + - contentType + - operationID + - recvID + - sendID + - sessionType + type: object + manage.sendMsgResult: + properties: + errCode: + example: 0 + type: integer + errMsg: + example: error + type: string + msgID: + type: string + sendTime: + type: integer + type: object + manage.uidListResult: + properties: + errCode: + example: 0 + type: integer + errMsg: + example: error + type: string + uidList: + items: + type: string + type: array + type: object + user.queryUserInfoParam: + properties: + operationID: + type: string + uidList: + items: + type: string + type: array + required: + - operationID + type: object + user.result: + properties: + data: {} + errCode: + example: 0 + type: integer + errMsg: + example: error + type: string + type: object + user.updateUserInfoParam: + properties: + birth: + type: string + email: + type: string + ex: + type: string + gender: + type: integer + icon: + type: string + mobile: + type: string + name: + type: string + operationID: + type: string + uid: + type: string + required: + - operationID + type: object + user.userInfo: + properties: + birth: + type: string + email: + type: string + ex: + type: string + gender: + type: integer + icon: + type: string + mobile: + type: string + name: + type: string + uid: + type: string + type: object +info: + contact: {} +paths: + /auth/user_register: + post: + consumes: + - application/json + description: register a new user + parameters: + - description: new user params + in: body + name: body + required: true + schema: + $ref: '#/definitions/apiAuth.paramsUserRegister' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/user.result' + - properties: + data: + $ref: '#/definitions/apiAuth.resultUserRegister' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - auth + /auth/user_token: + post: + consumes: + - application/json + description: get token + parameters: + - description: get token params + in: body + name: body + required: true + schema: + $ref: '#/definitions/apiAuth.paramsUserToken' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/user.result' + - properties: + data: + $ref: '#/definitions/apiAuth.resultUserRegister' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - auth + /chat/newest_seq: + post: + consumes: + - application/json + description: get latest message seq + parameters: + - description: user get latest seq params + in: body + name: body + required: true + schema: + $ref: '#/definitions/apiChat.paramsUserNewestSeq' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/apiChat.resultUserNewestSeq' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - chat + /chat/pull_msg: + post: + consumes: + - application/json + description: user pull messages + parameters: + - description: user pull messages + in: body + name: body + required: true + schema: + $ref: '#/definitions/apiChat.paramsUserPullMsg' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/user.result' + - properties: + reqIdentifier: + type: integer + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - chat + /chat/pull_msg_by_seq: + post: + consumes: + - application/json + description: user pull msg by seq + parameters: + - description: pull msg by seq + in: body + name: body + required: true + schema: + $ref: '#/definitions/apiChat.paramsUserPullMsgBySeqList' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/user.result' + - properties: + reqIdentifier: + type: integer + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - chat + /chat/send_msg: + post: + consumes: + - application/json + description: user send messages + parameters: + - description: user send messages + in: body + name: body + required: true + schema: + $ref: '#/definitions/apiChat.paramsUserSendMsg' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/user.result' + - properties: + data: + $ref: '#/definitions/apiChat.resultSendMsg' + reqIdentifier: + type: integer + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + tags: + - chat + /friend/add_blacklist: + post: + consumes: + - application/json + description: add a user into black list + parameters: + - description: add black list params + in: body + name: body + required: true + schema: + $ref: '#/definitions/friend.paramsSearchFriend' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.result' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - friend + /friend/add_friend: + post: + consumes: + - application/json + description: add a new friend by uid + parameters: + - description: add friend params + in: body + name: body + required: true + schema: + $ref: '#/definitions/friend.paramsAddFriend' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.result' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - friend + /friend/add_friend_response: + post: + consumes: + - application/json + description: the response of adding friend + parameters: + - description: response of adding friend + in: body + name: body + required: true + schema: + $ref: '#/definitions/friend.paramsAddFriendResponse' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.result' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - friend + /friend/delete_friend: + post: + consumes: + - application/json + description: delete friend + parameters: + - description: delete friend params + in: body + name: body + required: true + schema: + $ref: '#/definitions/friend.paramsSearchFriend' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.result' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - friend + /friend/get_blacklist: + post: + consumes: + - application/json + description: get black list + parameters: + - description: get black list + in: body + name: body + required: true + schema: + $ref: '#/definitions/friend.paramsSearchFriend' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/user.result' + - properties: + data: + items: + $ref: '#/definitions/friend.blackListUserInfo' + type: array + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - friend + /friend/get_friend_apply_list: + post: + consumes: + - application/json + description: get friend apply list + parameters: + - description: get friend apply list + in: body + name: body + required: true + schema: + $ref: '#/definitions/friend.paramsGetApplyList' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/user.result' + - properties: + data: + items: + $ref: '#/definitions/friend.UserInfo' + type: array + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - friend + /friend/get_friend_list: + post: + consumes: + - application/json + description: get friend apply list + parameters: + - description: get friend apply list + in: body + name: body + required: true + schema: + $ref: '#/definitions/friend.paramsGetFriendLIst' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/user.result' + - properties: + data: + items: + $ref: '#/definitions/friend.friendInfo' + type: array + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - friend + /friend/get_friends_info: + post: + consumes: + - application/json + description: get friend info + parameters: + - description: search friend params + in: body + name: body + required: true + schema: + $ref: '#/definitions/friend.paramsSearchFriend' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.result' + tags: + - friend + /friend/get_self_apply_list: + post: + consumes: + - application/json + description: get friend apply list + parameters: + - description: get friend apply list + in: body + name: body + required: true + schema: + $ref: '#/definitions/friend.paramsGetApplyList' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/user.result' + - properties: + data: + items: + $ref: '#/definitions/friend.UserInfo' + type: array + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - friend + /friend/import_friend: + post: + consumes: + - application/json + description: import friend + parameters: + - description: import friend params + in: body + name: body + required: true + schema: + $ref: '#/definitions/friend.paramsImportFriendReq' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/friend.resultImportFriend' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - friend + /friend/is_friend: + post: + consumes: + - application/json + description: check is friend + parameters: + - description: is friend params + in: body + name: body + required: true + schema: + $ref: '#/definitions/friend.paramsSearchFriend' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.result' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - friend + /friend/remove_blacklist: + post: + consumes: + - application/json + description: remove black list + parameters: + - description: remove black list params + in: body + name: body + required: true + schema: + $ref: '#/definitions/friend.paramsSearchFriend' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.result' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - friend + /friend/set_friend_comment: + post: + consumes: + - application/json + description: set friend comment + parameters: + - description: set friend comment + in: body + name: body + required: true + schema: + $ref: '#/definitions/friend.paramsSetFriendComment' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.result' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - friend + /group/create_group: + post: + consumes: + - application/json + description: create group + parameters: + - description: create group params + in: body + name: body + required: true + schema: + $ref: '#/definitions/group.paramsCreateGroup' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.result' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - group + /group/get_group_all_member_list: + post: + consumes: + - application/json + description: get group all members + parameters: + - description: get group all members params + in: body + name: body + required: true + schema: + $ref: '#/definitions/group.getGroupAllMemberReq' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/group.GetGroupMemberListResp' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - group + /group/get_group_applicationList: + post: + consumes: + - application/json + description: get group application list + parameters: + - description: get group application list params + in: body + name: body + required: true + schema: + $ref: '#/definitions/group.paramsGroupApplicationList' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/user.result' + - properties: + data: + $ref: '#/definitions/group.resultGroupApplication' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - group + /group/get_group_member_list: + post: + consumes: + - application/json + description: get group member list + parameters: + - description: get group member list params + in: body + name: body + required: true + schema: + $ref: '#/definitions/group.GetGroupMemberListReq' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/group.GetGroupMemberListResp' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - group + /group/get_group_members_info: + post: + consumes: + - application/json + description: get group members info + parameters: + - description: get group members info params + in: body + name: body + required: true + schema: + $ref: '#/definitions/group.GetGroupMembersInfoReq' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/group.GetGroupMembersInfoResp' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - group + /group/get_groups_info: + post: + consumes: + - application/json + description: get groups info + parameters: + - description: get groups info params + in: body + name: body + required: true + schema: + $ref: '#/definitions/group.paramsGetGroupInfo' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/user.result' + - properties: + data: + items: + $ref: '#/definitions/group.GroupInfo' + type: array + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - group + /group/get_joined_group_list: + post: + consumes: + - application/json + description: get joined group list + parameters: + - description: get joined group list params + in: body + name: body + required: true + schema: + $ref: '#/definitions/group.GetJoinedGroupListReq' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/group.GetJoinedGroupListResp' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - group + /group/group_application_response: + post: + consumes: + - application/json + description: response of application group + parameters: + - description: application group param + in: body + name: body + required: true + schema: + $ref: '#/definitions/group.paramsGroupApplicationResponse' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.result' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - group + /group/invite_user_to_group: + post: + consumes: + - application/json + description: invite user to group + parameters: + - description: invite user to group params + in: body + name: body + required: true + schema: + $ref: '#/definitions/group.InviteUserToGroupReq' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/group.InviteUserToGroupResp' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - group + /group/kick_group: + post: + consumes: + - application/json + description: kick member from group + parameters: + - description: kick member from group params + in: body + name: body + required: true + schema: + $ref: '#/definitions/group.paramsKickGroupMember' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/group.KickGroupMemberResp' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - group + /group/set_group_info: + post: + consumes: + - application/json + description: set group info + parameters: + - description: set group info params + in: body + name: body + required: true + schema: + $ref: '#/definitions/group.paramsSetGroupInfo' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.result' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - group + /group/transfer_group: + post: + consumes: + - application/json + description: transfer group owner + parameters: + - description: transfer group owner param + in: body + name: body + required: true + schema: + $ref: '#/definitions/group.paramsTransferGroupOwner' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.result' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - group + /manager/delete_user: + post: + consumes: + - application/json + description: delete user + parameters: + - description: user to be deleted + in: body + name: body + required: true + schema: + $ref: '#/definitions/manage.paramsDeleteUsers' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/manage.deleteUserResult' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - manage + /manager/get_all_users_uid: + post: + consumes: + - application/json + description: get all user ids + parameters: + - description: all user ids + in: body + name: body + required: true + schema: + $ref: '#/definitions/manage.paramsGetAllUsersUid' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/manage.uidListResult' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/manage.uidListResult' + tags: + - manage + /manager/send_msg: + post: + consumes: + - application/json + description: manage send message + parameters: + - description: manage send message + in: body + name: body + required: true + schema: + $ref: '#/definitions/manage.paramsManagementSendMsg' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/manage.sendMsgResult' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - manage + /third/user_register: + post: + consumes: + - application/json + description: get Tencent cloud storage credential + parameters: + - description: get Tencent cloud storage credential params + in: body + name: body + required: true + schema: + $ref: '#/definitions/apiThird.paramsTencentCloudStorageCredential' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/apiThird.resultTencentCredential' + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - third + /user/get_user_info: + post: + consumes: + - application/json + description: get user info by uid list + parameters: + - description: get userInfo by uidList + in: body + name: body + required: true + schema: + $ref: '#/definitions/user.queryUserInfoParam' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/user.result' + - properties: + data: + items: + $ref: '#/definitions/user.userInfo' + type: array + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/user.result' + tags: + - user + /user/update_user_info: + post: + consumes: + - application/json + description: update user info + parameters: + - description: new user info + in: body + name: body + required: true + schema: + $ref: '#/definitions/user.updateUserInfoParam' + - description: token + in: header + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.result' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/user.result' + tags: + - user +swagger: "2.0" diff --git a/go.mod b/go.mod index 8efd048e6..dff96a634 100644 --- a/go.mod +++ b/go.mod @@ -8,13 +8,15 @@ require ( github.com/antonfisher/nested-logrus-formatter v1.3.0 github.com/bwmarrin/snowflake v0.3.0 github.com/coreos/go-semver v0.3.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/eapache/go-resiliency v1.2.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect github.com/eapache/queue v1.1.0 // indirect github.com/frankban/quicktest v1.14.0 // indirect github.com/garyburd/redigo v1.6.2 - github.com/gin-gonic/gin v1.7.0 + github.com/gin-gonic/gin v1.7.4 + github.com/go-openapi/spec v0.20.4 // indirect github.com/go-playground/validator/v10 v10.4.1 github.com/golang-jwt/jwt/v4 v4.1.0 github.com/golang/protobuf v1.5.2 @@ -34,12 +36,16 @@ require ( github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.7.0 + github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2 // indirect + github.com/swaggo/gin-swagger v1.3.3 // indirect + github.com/swaggo/swag v1.7.4 // indirect github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb - golang.org/x/net v0.0.0-20210917221730-978cfadd31cf - golang.org/x/tools v0.0.0-20210106214847-113979e3529a // indirect + golang.org/x/net v0.0.0-20211111160137-58aab5ef257a + golang.org/x/sys v0.0.0-20211112143042-c6105e7cf70d // indirect + golang.org/x/tools v0.1.7 // indirect google.golang.org/grpc v1.33.2 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b diff --git a/go.sum b/go.sum index e50dd1004..56ac84b4c 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,12 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= +github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/sarama v1.19.0 h1:9oksLxC6uxVPHPVYUmq6xhr1BOF/hHobWH2UzO67z1s= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= @@ -26,6 +32,10 @@ github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmf github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.0.0 h1:XJIw/+VlJ+87J+doOxznsAWIdmWuViOVhkQamW5YV28= github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU= +github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -55,25 +65,48 @@ github.com/frankban/quicktest v1.14.0 h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzP github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og= github.com/garyburd/redigo v1.6.2 h1:yE/pwKCrbLpLpQICzYTeZ7JsTA/C53wFTJHaEtRqniM= github.com/garyburd/redigo v1.6.2/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/gzip v0.0.3/go.mod h1:YxxswVZIqOvcHEQpsSn+QF5guQtO1dCfy0shBPy4jFc= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.7.0 h1:jGB9xAJQ12AIGNB4HguylppmDK1Am9ppF7XnGXXJuoU= github.com/gin-gonic/gin v1.7.0/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= +github.com/gin-gonic/gin v1.7.4 h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM= +github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonreference v0.19.5 h1:1WJP/wi4OjB4iV8KVbH73rQaoialJrqv8gitZLxGLtM= +github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= +github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= +github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= +github.com/go-openapi/spec v0.20.3 h1:uH9RQ6vdyPSs2pSy9fL8QPspDF2AMIMPtmK5coSSjtQ= +github.com/go-openapi/spec v0.20.3/go.mod h1:gG4F8wdEDN+YPBMVnzE85Rbhf+Th2DTvA9nFPQ5AYEg= +github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= +github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.14 h1:gm3vOOXfiuw5i9p5N9xJvfjvuofpyvLA9Wr6QfK5Fng= +github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= +github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= @@ -168,6 +201,9 @@ github.com/lestrrat-go/strftime v1.0.4/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR7 github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= @@ -191,6 +227,7 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olivere/elastic/v7 v7.0.23 h1:b7tjMogDMhf2CisGI+L02LXLVa0ZyE82Z15XfW1e8t8= github.com/olivere/elastic/v7 v7.0.23/go.mod h1:OuWmD2DiuYhddWegBKPWQuelVKBLrW0fa/VUYgxuGTY= @@ -223,6 +260,13 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= @@ -243,6 +287,13 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14/go.mod h1:gxQT6pBGRuIGunNf/+tSOB5OHvguWi8Tbt82WOkf35E= +github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2 h1:+iNTcqQJy0OZ5jk6a5NLib47eqXK8uYcPX+O4+cBpEM= +github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w= +github.com/swaggo/gin-swagger v1.3.3 h1:XHyYmeNVFG5PbyWHG4jXtxOm2P4kiZapDCWsyDDiQ/I= +github.com/swaggo/gin-swagger v1.3.3/go.mod h1:ymsZuGpbbu+S7ZoQ49QPpZoDBj6uqhb8WizgQPVgWl0= +github.com/swaggo/swag v1.7.4 h1:up+ixy8yOqJKiFcuhMgkuYuF4xnevuhnFAXXF8OSfNg= +github.com/swaggo/swag v1.7.4/go.mod h1:zD8h6h4SPv7t3l+4BKdRquqW1ASWjKZgT6Qv9z3kNqI= github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca h1:G/aIr3WiUesWHL2YGYgEqjM5tCAJ43Ml+0C18wDkWWs= github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca/go.mod h1:b18KQa4IxHbxeseW1GcZox53d7J0z39VNONTxvvlkXw= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -252,10 +303,14 @@ github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= +github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg= go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 h1:jWtjCJX1qxhHISBMLRztWwR+EXkI7MJAF2HjHAE/x/I= @@ -287,6 +342,7 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -296,17 +352,24 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf h1:R150MpwJIv1MpS0N/pc+NhTM8ajzvlmxlY5OYsrevXQ= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211111160137-58aab5ef257a h1:c83jeVQW0KGKNaKBRfelNYNHaev+qawl9yaA825s8XE= +golang.org/x/net v0.0.0-20211111160137-58aab5ef257a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -319,14 +382,22 @@ golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211112143042-c6105e7cf70d h1:jp6PtFmjL+vGsuzd86xYqaJGv6eXdLvmVGzVVLI6EPI= +golang.org/x/sys v0.0.0-20211112143042-c6105e7cf70d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -339,6 +410,10 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.7 h1:6j8CgantCy3yc8JGBqkDLMKWqZ0RDU2g1HVgacojGWQ= +golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -363,6 +438,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw= @@ -371,9 +447,13 @@ gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/internal/api/auth/user_register.go b/internal/api/auth/user_register.go index e0d69eeda..40e039e12 100644 --- a/internal/api/auth/user_register.go +++ b/internal/api/auth/user_register.go @@ -6,11 +6,12 @@ import ( "Open_IM/pkg/grpc-etcdv3/getcdv3" pbAuth "Open_IM/pkg/proto/auth" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsUserRegister struct type paramsUserRegister struct { Secret string `json:"secret" binding:"required,max=32"` Platform int32 `json:"platform" binding:"required,min=1,max=7"` @@ -24,6 +25,13 @@ type paramsUserRegister struct { Ex string `json:"ex" binding:"omitempty,max=1024"` } +// resultUserRegister struct +type resultUserRegister struct { + UID string `json:"uid"` + Token string `json:"token"` + ExpiredTime int64 `json:"expiredTime"` +} + func newUserRegisterReq(params *paramsUserRegister) *pbAuth.UserRegisterReq { pbData := pbAuth.UserRegisterReq{ UID: params.UID, @@ -38,9 +46,20 @@ func newUserRegisterReq(params *paramsUserRegister) *pbAuth.UserRegisterReq { return &pbData } +// @Summary +// @Schemes +// @Description register a new user +// @Tags auth +// @Accept json +// @Produce json +// @Param body body apiAuth.paramsUserRegister true "new user params" +// @Success 200 {object} user.result{data=apiAuth.resultUserRegister} +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /auth/user_register [post] func UserRegister(c *gin.Context) { log.Info("", "", "api user_register init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName) + etcdConn := getcdv3.GetAuthConn() client := pbAuth.NewAuthClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/auth/user_token.go b/internal/api/auth/user_token.go index 31839b6b0..3f37b9ea9 100644 --- a/internal/api/auth/user_token.go +++ b/internal/api/auth/user_token.go @@ -6,11 +6,12 @@ import ( "Open_IM/pkg/grpc-etcdv3/getcdv3" pbAuth "Open_IM/pkg/proto/auth" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsUserToken struct type paramsUserToken struct { Secret string `json:"secret" binding:"required,max=32"` Platform int32 `json:"platform" binding:"required,min=1,max=8"` @@ -25,9 +26,20 @@ func newUserTokenReq(params *paramsUserToken) *pbAuth.UserTokenReq { return &pbData } +// @Summary +// @Schemes +// @Description get token +// @Tags auth +// @Accept json +// @Produce json +// @Param body body apiAuth.paramsUserToken true "get token params" +// @Success 200 {object} user.result{data=apiAuth.resultUserRegister} +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /auth/user_token [post] func UserToken(c *gin.Context) { log.Info("", "", "api user_token init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName) + etcdConn := getcdv3.GetAuthConn() client := pbAuth.NewAuthClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/chat/get_max_min_seq.go b/internal/api/chat/get_max_min_seq.go index 06db8fd9d..916d919e9 100644 --- a/internal/api/chat/get_max_min_seq.go +++ b/internal/api/chat/get_max_min_seq.go @@ -1,17 +1,17 @@ package apiChat import ( - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" pbMsg "Open_IM/pkg/proto/chat" "Open_IM/pkg/utils" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsUserNewestSeq struct type paramsUserNewestSeq struct { ReqIdentifier int `json:"reqIdentifier" binding:"required"` SendID string `json:"sendID" binding:"required"` @@ -19,6 +19,30 @@ type paramsUserNewestSeq struct { MsgIncr int `json:"msgIncr" binding:"required"` } +// resultUserNewestSeq struct +type resultUserNewestSeq struct { + ErrCode int32 `json:"errCode` + ErrMsg string `json:"errMsg"` + MsgIncr int `json:"msgIncr"` + ReqIdentifier int `json:"reqIdentifier"` + Data struct { + MaxSeq int64 `json:"maxSeq,omitempty"` + MinSeq int64 `json:"minSeq,omitempty"` + } `json:"data"` +} + +// @Summary +// @Schemes +// @Description get latest message seq +// @Tags chat +// @Accept json +// @Produce json +// @Param body body apiChat.paramsUserNewestSeq true "user get latest seq params" +// @Param token header string true "token" +// @Success 200 {object} apiChat.resultUserNewestSeq +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /chat/newest_seq [post] func UserGetSeq(c *gin.Context) { params := paramsUserNewestSeq{} if err := c.BindJSON(¶ms); err != nil { @@ -34,7 +58,7 @@ func UserGetSeq(c *gin.Context) { pbData := pbMsg.GetMaxAndMinSeqReq{} pbData.UserID = params.SendID pbData.OperationID = params.OperationID - grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName) + grpcConn := getcdv3.GetOfflineMessageConn() if grpcConn == nil { log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", params) @@ -43,6 +67,7 @@ func UserGetSeq(c *gin.Context) { reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData) if err != nil { log.ErrorByKv("rpc call failed to getNewSeq", pbData.OperationID, "err", err, "pbData", pbData.String()) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) return } diff --git a/internal/api/chat/pull_msg.go b/internal/api/chat/pull_msg.go index 4fb90b61f..14103b6e4 100644 --- a/internal/api/chat/pull_msg.go +++ b/internal/api/chat/pull_msg.go @@ -1,17 +1,17 @@ package apiChat import ( - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" - "Open_IM/pkg/proto/chat" + pbChat "Open_IM/pkg/proto/chat" "Open_IM/pkg/utils" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsUserPullMsg struct type paramsUserPullMsg struct { ReqIdentifier *int `json:"reqIdentifier" binding:"required"` SendID string `json:"sendID" binding:"required"` @@ -22,6 +22,18 @@ type paramsUserPullMsg struct { } } +// @Summary +// @Schemes +// @Description user pull messages +// @Tags chat +// @Accept json +// @Produce json +// @Param body body apiChat.paramsUserPullMsg true "user pull messages" +// @Param token header string true "token" +// @Success 200 {object} user.result{reqIdentifier=int} +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /chat/pull_msg [post] func UserPullMsg(c *gin.Context) { params := paramsUserPullMsg{} if err := c.BindJSON(¶ms); err != nil { @@ -39,7 +51,7 @@ func UserPullMsg(c *gin.Context) { pbData.OperationID = params.OperationID pbData.SeqBegin = *params.Data.SeqBegin pbData.SeqEnd = *params.Data.SeqEnd - grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName) + grpcConn := getcdv3.GetOfflineMessageConn() msgClient := pbChat.NewChatClient(grpcConn) reply, err := msgClient.PullMessage(context.Background(), &pbData) if err != nil { @@ -71,6 +83,7 @@ func UserPullMsg(c *gin.Context) { } +// paramsUserPullMsgBySeqList struct type paramsUserPullMsgBySeqList struct { ReqIdentifier int `json:"reqIdentifier" binding:"required"` SendID string `json:"sendID" binding:"required"` @@ -78,6 +91,18 @@ type paramsUserPullMsgBySeqList struct { SeqList []int64 `json:"seqList"` } +// @Summary +// @Schemes +// @Description user pull msg by seq +// @Tags chat +// @Accept json +// @Produce json +// @Param body body apiChat.paramsUserPullMsgBySeqList true "pull msg by seq" +// @Param token header string true "token" +// @Success 200 {object} user.result{reqIdentifier=int} +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /chat/pull_msg_by_seq [post] func UserPullMsgBySeqList(c *gin.Context) { params := paramsUserPullMsgBySeqList{} if err := c.BindJSON(¶ms); err != nil { @@ -95,11 +120,12 @@ func UserPullMsgBySeqList(c *gin.Context) { pbData.OperationID = params.OperationID pbData.SeqList = params.SeqList - grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName) + grpcConn := getcdv3.GetOfflineMessageConn() msgClient := pbChat.NewChatClient(grpcConn) reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData) if err != nil { log.ErrorByKv("PullMessageBySeqList error", pbData.OperationID, "err", err.Error()) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) return } log.InfoByKv("rpc call success to PullMessageBySeqList", pbData.OperationID, "ReplyArgs", reply.String(), "maxSeq", reply.GetMaxSeq(), diff --git a/internal/api/chat/send_msg.go b/internal/api/chat/send_msg.go index 6d7294109..402d5224f 100644 --- a/internal/api/chat/send_msg.go +++ b/internal/api/chat/send_msg.go @@ -1,18 +1,18 @@ package apiChat import ( - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" pbChat "Open_IM/pkg/proto/chat" "Open_IM/pkg/utils" "context" "Open_IM/pkg/grpc-etcdv3/getcdv3" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsUserSendMsg struct type paramsUserSendMsg struct { ReqIdentifier int32 `json:"reqIdentifier" binding:"required"` PlatformID int32 `json:"platformID" binding:"required"` @@ -57,6 +57,24 @@ func newUserSendMsgReq(token string, params *paramsUserSendMsg) *pbChat.UserSend return &pbData } +// resultSendMsg struct +type resultSendMsg struct { + ClientMsgID string `json:"clientMsgID"` + ServerMsgID string `json:"serverMsgID"` + SendTime int64 `json:"sendTime"` +} + +// @Summary +// @Schemes +// @Description user send messages +// @Tags chat +// @Accept json +// @Produce json +// @Param body body apiChat.paramsUserSendMsg true "user send messages" +// @Param token header string true "token" +// @Success 200 {object} user.result{reqIdentifier=int,data=resultSendMsg} +// @Failure 400 {object} user.result +// @Router /chat/send_msg [post] func UserSendMsg(c *gin.Context) { params := paramsUserSendMsg{} if err := c.BindJSON(¶ms); err != nil { @@ -72,7 +90,7 @@ func UserSendMsg(c *gin.Context) { pbData := newUserSendMsgReq(token, ¶ms) log.Info("", "", "api UserSendMsg call start..., [data: %s]", pbData.String()) - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName) + etcdConn := getcdv3.GetOfflineMessageConn() client := pbChat.NewChatClient(etcdConn) log.Info("", "", "api UserSendMsg call, api call rpc...") diff --git a/internal/api/friend/add_blacklist.go b/internal/api/friend/add_blacklist.go index e0969faf3..350981b9b 100644 --- a/internal/api/friend/add_blacklist.go +++ b/internal/api/friend/add_blacklist.go @@ -1,26 +1,31 @@ package friend import ( - pbFriend "Open_IM/pkg/proto/friend" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbFriend "Open_IM/pkg/proto/friend" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" -) -/* -type paramsAddBlackList struct { - OperationID string `json:"operationID" binding:"required"` - UID string `json:"uid" binding:"required"` -}*/ + "github.com/gin-gonic/gin" +) +// @Summary +// @Schemes +// @Description add a user into black list +// @Tags friend +// @Accept json +// @Produce json +// @Param body body friend.paramsSearchFriend true "add black list params" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /friend/add_blacklist [post] func AddBlacklist(c *gin.Context) { log.Info("", "", "api add blacklist init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/friend/add_friend.go b/internal/api/friend/add_friend.go index d949df083..1e7017982 100644 --- a/internal/api/friend/add_friend.go +++ b/internal/api/friend/add_friend.go @@ -1,33 +1,52 @@ package friend import ( - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" pbFriend "Open_IM/pkg/proto/friend" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsImportFriendReq struct type paramsImportFriendReq struct { OperationID string `json:"operationID" binding:"required"` UIDList []string `json:"uidList" binding:"required"` OwnerUid string `json:"ownerUid" binding:"required"` } +// resultImportFriend struct +type resultImportFriend struct { + ErrCode int `json:"errCode" example:"0"` + ErrMsg string `json:"errMsg" example:"error"` + FailedUidList []string `json:"failedUidList" example: []` +} + +// paramsAddFriend struct type paramsAddFriend struct { OperationID string `json:"operationID" binding:"required"` UID string `json:"uid" binding:"required"` ReqMessage string `json:"reqMessage"` } -// +// @Summary +// @Schemes +// @Description import friend +// @Tags friend +// @Accept json +// @Produce json +// @Param body body friend.paramsImportFriendReq true "import friend params" +// @Param token header string true "token" +// @Success 200 {object} friend.resultImportFriend +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /friend/import_friend [post] func ImportFriend(c *gin.Context) { log.Info("", "", "ImportFriend init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) params := paramsImportFriendReq{} @@ -53,10 +72,22 @@ func ImportFriend(c *gin.Context) { log.InfoByArgs("ImportFriend success return,get args=%s,return args=%s", req.String(), RpcResp.String()) } +// @Summary +// @Schemes +// @Description add a new friend by uid +// @Tags friend +// @Accept json +// @Produce json +// @Param body body friend.paramsAddFriend true "add friend params" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /friend/add_friend [post] func AddFriend(c *gin.Context) { log.Info("", "", "api add friend init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) params := paramsAddFriend{} diff --git a/internal/api/friend/add_friend_response.go b/internal/api/friend/add_friend_response.go index 37e801b3e..e6e3a5b62 100644 --- a/internal/api/friend/add_friend_response.go +++ b/internal/api/friend/add_friend_response.go @@ -1,27 +1,39 @@ package friend import ( - pbFriend "Open_IM/pkg/proto/friend" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbFriend "Open_IM/pkg/proto/friend" "context" "fmt" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsAddFriendResponse struct type paramsAddFriendResponse struct { OperationID string `json:"operationID" binding:"required"` UID string `json:"uid" binding:"required"` Flag int32 `json:"flag" binding:"required"` } +// @Summary +// @Schemes +// @Description the response of adding friend +// @Tags friend +// @Accept json +// @Produce json +// @Param body body friend.paramsAddFriendResponse true "response of adding friend" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /friend/add_friend_response [post] func AddFriendResponse(c *gin.Context) { log.Info("", "", fmt.Sprintf("api add friend response init ....")) - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/friend/delete_friend.go b/internal/api/friend/delete_friend.go index 4bdbedeee..c7c16de4e 100644 --- a/internal/api/friend/delete_friend.go +++ b/internal/api/friend/delete_friend.go @@ -1,26 +1,38 @@ package friend import ( - pbFriend "Open_IM/pkg/proto/friend" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbFriend "Open_IM/pkg/proto/friend" "context" "fmt" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsDeleteFriend struct type paramsDeleteFriend struct { OperationID string `json:"operationID" binding:"required"` UID string `json:"uid" binding:"required"` } +// @Summary +// @Schemes +// @Description delete friend +// @Tags friend +// @Accept json +// @Produce json +// @Param body body friend.paramsSearchFriend true "delete friend params" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /friend/delete_friend [post] func DeleteFriend(c *gin.Context) { log.Info("", "", fmt.Sprintf("api delete_friend init ....")) - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/friend/get_blcaklist.go b/internal/api/friend/get_blcaklist.go index 5e875a5e8..2684e56ab 100644 --- a/internal/api/friend/get_blcaklist.go +++ b/internal/api/friend/get_blcaklist.go @@ -1,21 +1,22 @@ package friend import ( - pbFriend "Open_IM/pkg/proto/friend" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbFriend "Open_IM/pkg/proto/friend" "context" "fmt" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsGetBlackList struct type paramsGetBlackList struct { OperationID string `json:"operationID" binding:"required"` } +// blackListUserInfo struct type blackListUserInfo struct { UID string `json:"uid"` Name string `json:"name"` @@ -27,10 +28,22 @@ type blackListUserInfo struct { Ex string `json:"ex"` } +// @Summary +// @Schemes +// @Description get black list +// @Tags friend +// @Accept json +// @Produce json +// @Param body body friend.paramsSearchFriend true "get black list" +// @Param token header string true "token" +// @Success 200 {object} user.result{data=[]friend.blackListUserInfo} +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /friend/get_blacklist [post] func GetBlacklist(c *gin.Context) { log.Info("", "", "api get blacklist init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/friend/get_friend_apply_list.go b/internal/api/friend/get_friend_apply_list.go index d7ca192e4..822eb12c5 100644 --- a/internal/api/friend/get_friend_apply_list.go +++ b/internal/api/friend/get_friend_apply_list.go @@ -1,19 +1,21 @@ package friend import ( - pbFriend "Open_IM/pkg/proto/friend" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbFriend "Open_IM/pkg/proto/friend" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsGetApplyList struct type paramsGetApplyList struct { OperationID string `json:"operationID" binding:"required"` } + +// UserInfo struct type UserInfo struct { UID string `json:"uid"` Name string `json:"name"` @@ -28,10 +30,22 @@ type UserInfo struct { Flag int32 `json:"flag"` } +// @Summary +// @Schemes +// @Description get friend apply list +// @Tags friend +// @Accept json +// @Produce json +// @Param body body friend.paramsGetApplyList true "get friend apply list" +// @Param token header string true "token" +// @Success 200 {object} user.result{data=[]friend.UserInfo} +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /friend/get_friend_apply_list [post] func GetFriendApplyList(c *gin.Context) { log.Info("", "", "api get_friend_apply_list init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) //defer etcdConn.Close() @@ -78,10 +92,22 @@ func GetFriendApplyList(c *gin.Context) { log.InfoByArgs("api get friend apply list success return,get args=%s,return args=%s", req.String(), RpcResp.String()) } +// @Summary +// @Schemes +// @Description get self friend apply list +// @Tags friend +// @Accept json +// @Produce json +// @Param body body friend.paramsGetApplyList true "get self friend apply list" +// @Param token header string true "token" +// @Success 200 {object} user.result{data=[]friend.UserInfo} +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /friend/get_self_apply_list [post] func GetSelfApplyList(c *gin.Context) { log.Info("", "", "api get self friend apply list init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/friend/get_friend_list.go b/internal/api/friend/get_friend_list.go index db1361572..de8b23215 100644 --- a/internal/api/friend/get_friend_list.go +++ b/internal/api/friend/get_friend_list.go @@ -1,21 +1,22 @@ package friend import ( - pbFriend "Open_IM/pkg/proto/friend" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbFriend "Open_IM/pkg/proto/friend" "context" "fmt" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsGetFriendLIst struct type paramsGetFriendLIst struct { OperationID string `json:"operationID" binding:"required"` } +// friendInfo struct type friendInfo struct { UID string `json:"uid"` Name string `json:"name"` @@ -29,10 +30,22 @@ type friendInfo struct { IsInBlackList int32 `json:"isInBlackList"` } +// @Summary +// @Schemes +// @Description get friend apply list +// @Tags friend +// @Accept json +// @Produce json +// @Param body body friend.paramsGetFriendLIst true "get friend apply list" +// @Param token header string true "token" +// @Success 200 {object} user.result{data=[]friend.friendInfo} +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /friend/get_friend_list [post] func GetFriendList(c *gin.Context) { log.Info("", "", fmt.Sprintf("api get_friendlist init ....")) - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/friend/get_friends_info.go b/internal/api/friend/get_friends_info.go index 47ee88a10..d16d4ed1f 100644 --- a/internal/api/friend/get_friends_info.go +++ b/internal/api/friend/get_friends_info.go @@ -1,26 +1,50 @@ package friend import ( - pbFriend "Open_IM/pkg/proto/friend" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbFriend "Open_IM/pkg/proto/friend" "context" "fmt" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsSearchFriend struct type paramsSearchFriend struct { OperationID string `json:"operationID" binding:"required"` UID string `json:"uid" binding:"required"` OwnerUid string `json:"ownerUid"` } +// resultFriendInfo struct +type resultFriendInfo struct { + UID string `json:"uid"` + Name string `json:"name"` + Icon string `json:"icon"` + Gender int32 `json:"gender"` + Mobile string `json:"mobile"` + Birth string `json:"birth"` + Email string `json:"email"` + Ex string `json:"ex"` + Comment string `json:"comment"` +} + +// @Summary +// @Schemes +// @Description get friend info +// @Tags friend +// @Accept json +// @Produce json +// @Param body body friend.paramsSearchFriend true "search friend params" +// @Param token header string true "token" +// @Success 200 {object} user.result{data=friend.resultFriendInfo} +// @Failure 200 {object} user.result +// @Router /friend/get_friends_info [post] func GetFriendsInfo(c *gin.Context) { log.Info("", "", fmt.Sprintf("api search friend init ....")) - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/friend/is_friend.go b/internal/api/friend/is_friend.go index 2e856b558..1cae7c451 100644 --- a/internal/api/friend/is_friend.go +++ b/internal/api/friend/is_friend.go @@ -1,25 +1,37 @@ package friend import ( - pbFriend "Open_IM/pkg/proto/friend" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbFriend "Open_IM/pkg/proto/friend" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsIsFriend struct type paramsIsFriend struct { OperationID string `json:"operationID" binding:"required"` ReceiveUid string `json:"receive_uid"` } +// @Summary +// @Schemes +// @Description check is friend +// @Tags friend +// @Accept json +// @Produce json +// @Param body body friend.paramsSearchFriend true "is friend params" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /friend/is_friend [post] func IsFriend(c *gin.Context) { log.Info("", "", "api is friend init....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/friend/remove_blacklist.go b/internal/api/friend/remove_blacklist.go index 57a018513..4aad89c14 100644 --- a/internal/api/friend/remove_blacklist.go +++ b/internal/api/friend/remove_blacklist.go @@ -1,25 +1,37 @@ package friend import ( - pbFriend "Open_IM/pkg/proto/friend" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbFriend "Open_IM/pkg/proto/friend" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsRemoveBlackList struct type paramsRemoveBlackList struct { OperationID string `json:"operationID" binding:"required"` UID string `json:"uid" binding:"required"` } +// @Summary +// @Schemes +// @Description remove black list +// @Tags friend +// @Accept json +// @Produce json +// @Param body body friend.paramsSearchFriend true "remove black list params" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /friend/remove_blacklist [post] func RemoveBlacklist(c *gin.Context) { log.Info("", "", "api remove_blacklist init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/friend/set_friend_comment.go b/internal/api/friend/set_friend_comment.go index e16f7e598..1300a0693 100644 --- a/internal/api/friend/set_friend_comment.go +++ b/internal/api/friend/set_friend_comment.go @@ -1,26 +1,38 @@ package friend import ( - pbFriend "Open_IM/pkg/proto/friend" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbFriend "Open_IM/pkg/proto/friend" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsSetFriendComment struct type paramsSetFriendComment struct { OperationID string `json:"operationID" binding:"required"` UID string `json:"uid" binding:"required"` Comment string `json:"comment"` } +// @Summary +// @Schemes +// @Description set friend comment +// @Tags friend +// @Accept json +// @Produce json +// @Param body body friend.paramsSetFriendComment true "set friend comment" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /friend/set_friend_comment [post] func SetFriendComment(c *gin.Context) { log.Info("", "", "api set friend comment init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/group/create_group.go b/internal/api/group/create_group.go index fd9cc14f7..95969b7e4 100644 --- a/internal/api/group/create_group.go +++ b/internal/api/group/create_group.go @@ -1,16 +1,28 @@ package group import ( - pb "Open_IM/pkg/proto/group" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pb "Open_IM/pkg/proto/group" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsCreateGroup struct +type paramsCreateGroup struct { + MemberList struct { + Uid string `json:"uid"` + SetRole string `json:"setRole,omitempty"` + } `json:"memberList"` + GroupName string `json:"groupName"` + Introduction string `json:"introduction"` + Notification string `json:"notification"` + FaceUrl string `json:"faceUrl"` + OperationID string `json:"operationID" binding:"required"` + Ex string `json:"ex"` +} type paramsCreateGroupStruct struct { MemberList []*pb.GroupAddMemberInfo `json:"memberList"` GroupName string `json:"groupName"` @@ -21,10 +33,22 @@ type paramsCreateGroupStruct struct { Ex string `json:"ex"` } +// @Summary +// @Schemes +// @Description create group +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.paramsCreateGroup true "create group params" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/create_group [post] func CreateGroup(c *gin.Context) { log.Info("", "", "api create group init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := pb.NewGroupClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/group/get_group_applicationList.go b/internal/api/group/get_group_applicationList.go index faceb921e..1abf57082 100644 --- a/internal/api/group/get_group_applicationList.go +++ b/internal/api/group/get_group_applicationList.go @@ -1,17 +1,17 @@ package group import ( - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" "Open_IM/pkg/proto/group" "Open_IM/pkg/utils" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsGroupApplicationList struct type paramsGroupApplicationList struct { OperationID string `json:"operationID" binding:"required"` } @@ -23,6 +23,7 @@ func newUserRegisterReq(params *paramsGroupApplicationList) *group.GetGroupAppli return &pbData } +// paramsGroupApplicationListRet struct type paramsGroupApplicationListRet struct { ID string `json:"id"` GroupID string `json:"groupID"` @@ -42,9 +43,27 @@ type paramsGroupApplicationListRet struct { HandleResult int32 `json:"handleResult"` } +// resultGroupApplication struct +type resultGroupApplication struct { + Count int `json:"count"` + User []paramsGroupApplicationListRet `json:"user"` +} + +// @Summary +// @Schemes +// @Description get group application list +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.paramsGroupApplicationList true "get group application list params" +// @Param token header string true "token" +// @Success 200 {object} user.result{data=group.resultGroupApplication} +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/get_group_applicationList [post] func GetGroupApplicationList(c *gin.Context) { log.Info("", "", "api GetGroupApplicationList init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := group.NewGroupClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/group/get_groups_info.go b/internal/api/group/get_groups_info.go index b2825485a..9babb56f8 100644 --- a/internal/api/group/get_groups_info.go +++ b/internal/api/group/get_groups_info.go @@ -1,14 +1,13 @@ package group import ( - pb "Open_IM/pkg/proto/group" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pb "Open_IM/pkg/proto/group" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) type paramsGetGroupInfo struct { @@ -16,10 +15,22 @@ type paramsGetGroupInfo struct { OperationID string `json:"operationID" binding:"required"` } +// @Summary +// @Schemes +// @Description get groups info +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.paramsGetGroupInfo true "get groups info params" +// @Param token header string true "token" +// @Success 200 {object} user.result{data=[]group.GroupInfo} +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/get_groups_info [post] func GetGroupsInfo(c *gin.Context) { log.Info("", "", "api get groups info init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := pb.NewGroupClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/group/group.go b/internal/api/group/group.go index e26d235b2..dbe300453 100644 --- a/internal/api/group/group.go +++ b/internal/api/group/group.go @@ -1,17 +1,19 @@ package group import ( - pb "Open_IM/pkg/proto/group" "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pb "Open_IM/pkg/proto/group" "context" "fmt" - "github.com/gin-gonic/gin" "net/http" "strings" + + "github.com/gin-gonic/gin" ) +// InviteUserToGroupReq struct type InviteUserToGroupReq struct { GroupID string `json:"groupID" binding:"required"` UidList []string `json:"uidList" binding:"required"` @@ -19,10 +21,25 @@ type InviteUserToGroupReq struct { OperationID string `json:"operationID" binding:"required"` } +// GetJoinedGroupListReq struct type GetJoinedGroupListReq struct { OperationID string `json:"operationID" binding:"required"` } +// paramsKickGroupMember struct +type paramsKickGroupMember struct { + GroupID string `json:"groupID"` + UidListInfo []struct { + UserId string `json:"userId,omitempty"` + Role int32 `json:"role,omitempty"` + JoinTime uint64 `json:"joinTime,omitempty"` + NickName string `json:"nickName,omitempty"` + FaceUrl string `json:"faceUrl,omitempty"` + } `json:"uidListInfo" binding:"required"` + Reason string `json:"reason"` + OperationID string `json:"operationID" binding:"required"` +} + type KickGroupMemberReq struct { GroupID string `json:"groupID"` UidListInfo []*pb.GroupMemberFullInfo `json:"uidListInfo" binding:"required"` @@ -30,10 +47,22 @@ type KickGroupMemberReq struct { OperationID string `json:"operationID" binding:"required"` } +// @Summary +// @Schemes +// @Description kick member from group +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.paramsKickGroupMember true "kick member from group params" +// @Param token header string true "token" +// @Success 200 {object} group.KickGroupMemberResp +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/kick_group [post] func KickGroupMember(c *gin.Context) { log.Info("", "", "KickGroupMember start....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := pb.NewGroupClient(etcdConn) params := KickGroupMemberReq{} @@ -58,6 +87,7 @@ func KickGroupMember(c *gin.Context) { return } + // KickGroupMemberResp struct type KickGroupMemberResp struct { ErrorCode int32 `json:"errCode"` ErrorMsg string `json:"errMsg"` @@ -75,21 +105,36 @@ func KickGroupMember(c *gin.Context) { c.JSON(http.StatusOK, memberListResp) } +// GetGroupMembersInfoReq struct type GetGroupMembersInfoReq struct { GroupID string `json:"groupID"` MemberList []string `json:"memberList"` OperationID string `json:"operationID"` } + +// GetGroupMembersInfoResp struct type GetGroupMembersInfoResp struct { ErrorCode int32 `json:"errCode"` ErrorMsg string `json:"errMsg"` Data []MemberResult `json:"data"` } +// @Summary +// @Schemes +// @Description get group members info +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.GetGroupMembersInfoReq true "get group members info params" +// @Param token header string true "token" +// @Success 200 {object} group.GetGroupMembersInfoResp +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/get_group_members_info [post] func GetGroupMembersInfo(c *gin.Context) { log.Info("", "", "GetGroupMembersInfo start....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := pb.NewGroupClient(etcdConn) params := GetGroupMembersInfoReq{} @@ -128,17 +173,21 @@ func GetGroupMembersInfo(c *gin.Context) { c.JSON(http.StatusOK, memberListResp) } +// GetGroupMemberListReq struct type GetGroupMemberListReq struct { GroupID string `json:"groupID"` Filter int32 `json:"filter"` - NextSeq int32 `json:"nextSeq"` + NextSeq int32 `json:"nextSeq,omitempty"` OperationID string `json:"operationID"` } + +// getGroupAllMemberReq struct type getGroupAllMemberReq struct { GroupID string `json:"groupID"` OperationID string `json:"operationID"` } +// MemberResult struct type MemberResult struct { GroupId string `json:"groupID"` UserId string `json:"userId"` @@ -148,10 +197,22 @@ type MemberResult struct { FaceUrl string `json:"faceUrl"` } +// @Summary +// @Schemes +// @Description get group member list +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.GetGroupMemberListReq true "get group member list params" +// @Param token header string true "token" +// @Success 200 {object} group.GetGroupMemberListResp +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/get_group_member_list [post] func GetGroupMemberList(c *gin.Context) { log.Info("", "", "GetGroupMemberList start....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := pb.NewGroupClient(etcdConn) params := GetGroupMemberListReq{} @@ -174,6 +235,7 @@ func GetGroupMemberList(c *gin.Context) { return } + // GetGroupMemberListResp struct type GetGroupMemberListResp struct { ErrorCode int32 `json:"errCode"` ErrorMsg string `json:"errMsg"` @@ -198,10 +260,22 @@ func GetGroupMemberList(c *gin.Context) { } +// @Summary +// @Schemes +// @Description get group all members +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.getGroupAllMemberReq true "get group all members params" +// @Param token header string true "token" +// @Success 200 {object} group.GetGroupMemberListResp +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/get_group_all_member_list [post] func GetGroupAllMember(c *gin.Context) { log.Info("", "", "GetGroupAllMember start....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := pb.NewGroupClient(etcdConn) params := getGroupAllMemberReq{} @@ -222,6 +296,7 @@ func GetGroupAllMember(c *gin.Context) { return } + // GetGroupMemberListResp struct type GetGroupMemberListResp struct { ErrorCode int32 `json:"errCode"` ErrorMsg string `json:"errMsg"` @@ -243,6 +318,7 @@ func GetGroupAllMember(c *gin.Context) { c.JSON(http.StatusOK, memberListResp) } +// groupResult struct type groupResult struct { GroupId string `json:"groupId"` GroupName string `json:"groupName"` @@ -254,10 +330,22 @@ type groupResult struct { MemberCount uint32 `json:"memberCount"` } +// @Summary +// @Schemes +// @Description get joined group list +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.GetJoinedGroupListReq true "get joined group list params" +// @Param token header string true "token" +// @Success 200 {object} group.GetJoinedGroupListResp +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/get_joined_group_list [post] func GetJoinedGroupList(c *gin.Context) { log.Info("", "", "GetJoinedGroupList start....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() fmt.Println("config: ", etcdConn, config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) client := pb.NewGroupClient(etcdConn) @@ -280,6 +368,7 @@ func GetJoinedGroupList(c *gin.Context) { } log.Info(req.Token, req.OperationID, "GetJoinedGroupList: ", RpcResp) + // GetJoinedGroupListResp struct type GetJoinedGroupListResp struct { ErrorCode int32 `json:"errCode"` ErrorMsg string `json:"errMsg"` @@ -302,14 +391,27 @@ func GetJoinedGroupList(c *gin.Context) { c.JSON(http.StatusOK, GroupListResp) } +// Id2Result struct type Id2Result struct { UId string `json:"uid"` Result int32 `json:"result"` } +// @Summary +// @Schemes +// @Description invite user to group +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.InviteUserToGroupReq true "invite user to group params" +// @Param token header string true "token" +// @Success 200 {object} group.InviteUserToGroupResp +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/invite_user_to_group [post] func InviteUserToGroup(c *gin.Context) { log.Info("", "", "InviteUserToGroup start....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := pb.NewGroupClient(etcdConn) params := InviteUserToGroupReq{} @@ -333,6 +435,7 @@ func InviteUserToGroup(c *gin.Context) { return } + // InviteUserToGroupResp struct type InviteUserToGroupResp struct { ErrorCode int32 `json:"errCode"` ErrorMsg string `json:"errMsg"` diff --git a/internal/api/group/group_application_response.go b/internal/api/group/group_application_response.go index 70dd966eb..b387096a9 100644 --- a/internal/api/group/group_application_response.go +++ b/internal/api/group/group_application_response.go @@ -1,17 +1,17 @@ package group import ( - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" "Open_IM/pkg/proto/group" "Open_IM/pkg/utils" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsGroupApplicationResponse struct type paramsGroupApplicationResponse struct { OperationID string `json:"operationID" binding:"required"` GroupID string `json:"groupID" binding:"required"` @@ -49,9 +49,21 @@ func newGroupApplicationResponse(params *paramsGroupApplicationResponse) *group. return &pbData } +// @Summary +// @Schemes +// @Description response of application group +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.paramsGroupApplicationResponse true "application group param" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/group_application_response [post] func ApplicationGroupResponse(c *gin.Context) { log.Info("", "", "api GroupApplicationResponse init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := group.NewGroupClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/group/join_group.go b/internal/api/group/join_group.go index 5e85e288e..a3e00e3aa 100644 --- a/internal/api/group/join_group.go +++ b/internal/api/group/join_group.go @@ -1,26 +1,38 @@ package group import ( - pb "Open_IM/pkg/proto/group" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pb "Open_IM/pkg/proto/group" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsJoinGroup struct type paramsJoinGroup struct { GroupID string `json:"groupID" binding:"required"` Message string `json:"message"` OperationID string `json:"operationID" binding:"required"` } +// @Summary +// @Schemes +// @Description join group +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.paramsJoinGroup true "join group params" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/set_group_info [post] func JoinGroup(c *gin.Context) { log.Info("", "", "api join group init....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := pb.NewGroupClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/group/quit_group.go b/internal/api/group/quit_group.go index 1caea9d0a..3e138691c 100644 --- a/internal/api/group/quit_group.go +++ b/internal/api/group/quit_group.go @@ -1,25 +1,37 @@ package group import ( - pb "Open_IM/pkg/proto/group" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pb "Open_IM/pkg/proto/group" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsQuitGroup struct type paramsQuitGroup struct { GroupID string `json:"groupID" binding:"required"` OperationID string `json:"operationID" binding:"required"` } +// @Summary +// @Schemes +// @Description quit group +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.paramsQuitGroup true "quit group" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/set_group_info [post] func QuitGroup(c *gin.Context) { log.Info("", "", "api quit group init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := pb.NewGroupClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/group/set_group_info.go b/internal/api/group/set_group_info.go index 03a3f8c43..80b3ac61d 100644 --- a/internal/api/group/set_group_info.go +++ b/internal/api/group/set_group_info.go @@ -1,16 +1,16 @@ package group import ( - pb "Open_IM/pkg/proto/group" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pb "Open_IM/pkg/proto/group" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsSetGroupInfo struct type paramsSetGroupInfo struct { GroupID string `json:"groupId" binding:"required"` GroupName string `json:"groupName"` @@ -20,10 +20,22 @@ type paramsSetGroupInfo struct { OperationID string `json:"operationID" binding:"required"` } +// @Summary +// @Schemes +// @Description set group info +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.paramsSetGroupInfo true "set group info params" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/set_group_info [post] func SetGroupInfo(c *gin.Context) { log.Info("", "", "api set group info init...") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := pb.NewGroupClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/group/transfer_group_owner.go b/internal/api/group/transfer_group_owner.go index f7baaba3f..f3fdf2152 100644 --- a/internal/api/group/transfer_group_owner.go +++ b/internal/api/group/transfer_group_owner.go @@ -1,17 +1,17 @@ package group import ( - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" "Open_IM/pkg/proto/group" "Open_IM/pkg/utils" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsTransferGroupOwner struct type paramsTransferGroupOwner struct { OperationID string `json:"operationID" binding:"required"` GroupID string `json:"groupID" binding:"required"` @@ -27,9 +27,21 @@ func newTransferGroupOwnerReq(params *paramsTransferGroupOwner) *group.TransferG return &pbData } +// @Summary +// @Schemes +// @Description transfer group owner +// @Tags group +// @Accept json +// @Produce json +// @Param body body group.paramsTransferGroupOwner true "transfer group owner param" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /group/transfer_group [post] func TransferGroupOwner(c *gin.Context) { log.Info("", "", "api TransferGroupOwner init ....") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := group.NewGroupClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/manage/management_chat.go b/internal/api/manage/management_chat.go index a398dce10..3523f4108 100644 --- a/internal/api/manage/management_chat.go +++ b/internal/api/manage/management_chat.go @@ -14,15 +14,16 @@ import ( pbChat "Open_IM/pkg/proto/chat" "Open_IM/pkg/utils" "context" + "net/http" + "github.com/gin-gonic/gin" "github.com/go-playground/validator/v10" "github.com/mitchellh/mapstructure" - "net/http" - "strings" ) var validate *validator.Validate +// paramsManagementSendMsg struct type paramsManagementSendMsg struct { OperationID string `json:"operationID" binding:"required"` SendID string `json:"sendID" binding:"required"` @@ -35,6 +36,14 @@ type paramsManagementSendMsg struct { SessionType int32 `json:"sessionType" binding:"required"` } +// sendMsgResult struct +type sendMsgResult struct { + ErrCode int `json:"errCode" example:"0"` + ErrMsg string `json:"errMsg" example:"error"` + SendTime int `json:"sendTime" example:0` + MsgID string `json:"msgID" example:""` +} + func newUserSendMsgReq(params *paramsManagementSendMsg) *pbChat.UserSendMsgReq { var newContent string switch params.ContentType { @@ -71,6 +80,19 @@ func newUserSendMsgReq(params *paramsManagementSendMsg) *pbChat.UserSendMsgReq { func init() { validate = validator.New() } + +// @Summary +// @Schemes +// @Description manage send message +// @Tags manage +// @Accept json +// @Produce json +// @Param body body manage.paramsManagementSendMsg true "manage send message" +// @Param token header string true "token" +// @Success 200 {object} manage.sendMsgResult +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /manager/send_msg [post] func ManagementSendMsg(c *gin.Context) { var data interface{} params := paramsManagementSendMsg{} @@ -117,7 +139,7 @@ func ManagementSendMsg(c *gin.Context) { pbData := newUserSendMsgReq(¶ms) log.Info("", "", "api ManagementSendMsg call start..., [data: %s]", pbData.String()) - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName) + etcdConn := getcdv3.GetOfflineMessageConn() client := pbChat.NewChatClient(etcdConn) log.Info("", "", "api ManagementSendMsg call, api call rpc...") diff --git a/internal/api/manage/management_user.go b/internal/api/manage/management_user.go index cd43fd59b..aa7d76398 100644 --- a/internal/api/manage/management_user.go +++ b/internal/api/manage/management_user.go @@ -7,24 +7,52 @@ package manage import ( - pbUser "Open_IM/pkg/proto/user" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbUser "Open_IM/pkg/proto/user" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// paramsDeleteUsers struct type paramsDeleteUsers struct { OperationID string `json:"operationID" binding:"required"` DeleteUidList []string `json:"deleteUidList" binding:"required"` } + +// paramsGetAllUsersUid struct type paramsGetAllUsersUid struct { OperationID string `json:"operationID" binding:"required"` } +// deleteUserResult struct +type deleteUserResult struct { + ErrCode int `json:"errCode" example:"0"` + ErrMsg string `json:"errMsg" example:"error"` + FailedUidList []string `json:"failedUidList" example:[]` +} + +// uidListResult struct +type uidListResult struct { + ErrCode int `json:"errCode" example:"0"` + ErrMsg string `json:"errMsg" example:"error"` + UidList []string `json:"uidList" example:[]` +} + +// @Summary +// @Schemes +// @Description delete user +// @Tags manage +// @Accept json +// @Produce json +// @Param body body manage.paramsDeleteUsers true "user to be deleted" +// @Param token header string true "token" +// @Success 200 {object} manage.deleteUserResult +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /manager/delete_user [post] func DeleteUser(c *gin.Context) { params := paramsDeleteUsers{} if err := c.BindJSON(¶ms); err != nil { @@ -32,7 +60,7 @@ func DeleteUser(c *gin.Context) { return } log.InfoByKv("DeleteUser req come here", params.OperationID, "DeleteUidList", params.DeleteUidList) - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) + etcdConn := getcdv3.GetUserConn() client := pbUser.NewUserClient(etcdConn) //defer etcdConn.Close() @@ -51,6 +79,18 @@ func DeleteUser(c *gin.Context) { resp := gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "failedUidList": RpcResp.FailedUidList} c.JSON(http.StatusOK, resp) } + +// @Summary +// @Schemes +// @Description get all user ids +// @Tags manage +// @Accept json +// @Produce json +// @Param body body manage.paramsGetAllUsersUid true "all user ids" +// @Param token header string true "token" +// @Success 200 {object} manage.uidListResult +// @Failure 500 {object} manage.uidListResult +// @Router /manager/get_all_users_uid [post] func GetAllUsersUid(c *gin.Context) { params := paramsGetAllUsersUid{} if err := c.BindJSON(¶ms); err != nil { @@ -58,7 +98,7 @@ func GetAllUsersUid(c *gin.Context) { return } log.InfoByKv("GetAllUsersUid req come here", params.OperationID) - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) + etcdConn := getcdv3.GetUserConn() client := pbUser.NewUserClient(etcdConn) //defer etcdConn.Close() diff --git a/internal/api/third/tencent_cloud_storage_credential.go b/internal/api/third/tencent_cloud_storage_credential.go index af68d8fd8..20c458c4d 100644 --- a/internal/api/third/tencent_cloud_storage_credential.go +++ b/internal/api/third/tencent_cloud_storage_credential.go @@ -3,20 +3,43 @@ package apiThird import ( "Open_IM/pkg/common/config" log2 "Open_IM/pkg/common/log" - "github.com/gin-gonic/gin" - sts "github.com/tencentyun/qcloud-cos-sts-sdk/go" "net/http" "time" + + "github.com/gin-gonic/gin" + sts "github.com/tencentyun/qcloud-cos-sts-sdk/go" ) +// paramsTencentCloudStorageCredential struct type paramsTencentCloudStorageCredential struct { Token string `json:"token"` OperationID string `json:"operationID"` } +// resultTencentCredential struct +type resultTencentCredential struct { + ErrCode int `json:"errCode` + ErrMsg string `json:"errMsg"` + Region string `json:"region"` + Bucket string `json:"bucket"` + Data interface{} `json:"data"` +} + var lastTime int64 var lastRes *sts.CredentialResult +// @Summary +// @Schemes +// @Description get Tencent cloud storage credential +// @Tags third +// @Accept json +// @Produce json +// @Param body body apiThird.paramsTencentCloudStorageCredential true "get Tencent cloud storage credential params" +// @Param token header string true "token" +// @Success 200 {object} apiThird.resultTencentCredential +// @Failure 400 {object} user.result +// @Failure 500 {object} user.result +// @Router /third/user_register [post] func TencentCloudStorageCredential(c *gin.Context) { params := paramsTencentCloudStorageCredential{} if err := c.BindJSON(¶ms); err != nil { diff --git a/internal/api/user/get_user_info.go b/internal/api/user/get_user_info.go index 4e93787b5..209f9f0f3 100644 --- a/internal/api/user/get_user_info.go +++ b/internal/api/user/get_user_info.go @@ -1,16 +1,23 @@ package user import ( - pbUser "Open_IM/pkg/proto/user" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbUser "Open_IM/pkg/proto/user" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) +// result struct +type result struct { + ErrCode int `json:"errCode" example:"0"` + ErrMsg string `json:"errMsg" example:"error"` + Data interface{} `json:"data,omitempty"` +} + +// userInfo struct type userInfo struct { UID string `json:"uid"` Name string `json:"name"` @@ -22,14 +29,30 @@ type userInfo struct { Ex string `json:"ex"` } +// queryUserInfoParam struct +type queryUserInfoParam struct { + OperationID string `json:"operationID" binding:"required"` + UIDList []string `json:"uidList"` +} + +// @Summary +// @Description get user info by uid list +// @Tags user +// @Accept json +// @Produce json +// @Param body body user.queryUserInfoParam true "get userInfo by uidList" +// @Param token header string true "token" +// @Success 200 {object} user.result{data=[]user.userInfo} +// @Failure 400 {object} user.result +// @Router /user/get_user_info [post] func GetUserInfo(c *gin.Context) { log.InfoByKv("api get userinfo init...", "") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) + etcdConn := getcdv3.GetUserConn() client := pbUser.NewUserClient(etcdConn) //defer etcdConn.Close() - params := paramsStruct{} + params := queryUserInfoParam{} if err := c.BindJSON(¶ms); err != nil { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) return @@ -44,8 +67,8 @@ func GetUserInfo(c *gin.Context) { if err != nil { log.Error(req.Token, req.OperationID, "err=%s,call get user info rpc server failed", err) c.JSON(http.StatusInternalServerError, gin.H{ - "errorCode": 500, - "errorMsg": "call rpc server failed", + "errCode": 500, + "errMsg": "call rpc server failed", }) return } diff --git a/internal/api/user/get_user_info_test.go b/internal/api/user/get_user_info_test.go new file mode 100644 index 000000000..c8329d761 --- /dev/null +++ b/internal/api/user/get_user_info_test.go @@ -0,0 +1,31 @@ +package user + +import ( + "bytes" + "net/http" + "net/http/httptest" + "testing" + + "github.com/gin-gonic/gin" + "github.com/stretchr/testify/assert" +) + +func init() { + gin.SetMode(gin.TestMode) +} + +func Test_UserRegister(t *testing.T) { + res := httptest.NewRecorder() + c, _ := gin.CreateTestContext(res) + c.Request, _ = http.NewRequest("POST", "/", bytes.NewBufferString(`{"uidList": []}`)) + + GetUserInfo(c) + assert.Equal(t, 400, res.Code) + + res = httptest.NewRecorder() + c, _ = gin.CreateTestContext(res) + c.Request, _ = http.NewRequest("POST", "/", bytes.NewBufferString(`{"operationID": "1", "uidList": []}`)) + + GetUserInfo(c) + assert.Equal(t, 200, res.Code) +} diff --git a/internal/api/user/update_user_info.go b/internal/api/user/update_user_info.go index 1bcc32117..f4a1a3cfd 100644 --- a/internal/api/user/update_user_info.go +++ b/internal/api/user/update_user_info.go @@ -1,38 +1,46 @@ package user import ( - pbUser "Open_IM/pkg/proto/user" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbUser "Open_IM/pkg/proto/user" "context" - "github.com/gin-gonic/gin" "net/http" - "strings" + + "github.com/gin-gonic/gin" ) -type paramsStruct struct { - OperationID string `json:"operationID" binding:"required"` - UIDList []string `json:"uidList"` - Platform int32 `json:"platform"` - Name string `json:"name"` - Icon string `json:"icon"` - Gender int32 `json:"gender"` - Mobile string `json:"mobile"` - Birth string `json:"birth"` - Email string `json:"email"` - Ex string `json:"ex"` - Uid string `json:"uid"` +// updateUserInfoParam struct +type updateUserInfoParam struct { + OperationID string `json:"operationID" binding:"required"` + Name string `json:"name"` + Icon string `json:"icon"` + Gender int32 `json:"gender"` + Mobile string `json:"mobile"` + Birth string `json:"birth"` + Email string `json:"email"` + Ex string `json:"ex"` + Uid string `json:"uid"` } +// @Summary +// @Description update user info +// @Tags user +// @Accept json +// @Produce json +// @Param body body user.updateUserInfoParam true "new user info" +// @Param token header string true "token" +// @Success 200 {object} user.result +// @Failure 500 {object} user.result +// @Router /user/update_user_info [post] func UpdateUserInfo(c *gin.Context) { log.InfoByKv("api update userinfo init...", "") - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) + etcdConn := getcdv3.GetUserConn() client := pbUser.NewUserClient(etcdConn) //defer etcdConn.Close() - params := paramsStruct{} + params := updateUserInfoParam{} if err := c.BindJSON(¶ms); err != nil { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) return diff --git a/internal/msg_gateway/gate/logic.go b/internal/msg_gateway/gate/logic.go index 9eadb529e..3f7f14cf5 100644 --- a/internal/msg_gateway/gate/logic.go +++ b/internal/msg_gateway/gate/logic.go @@ -1,7 +1,6 @@ package gate import ( - "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" @@ -12,10 +11,10 @@ import ( "context" "encoding/gob" "encoding/json" + "runtime" + "github.com/golang/protobuf/proto" "github.com/gorilla/websocket" - "runtime" - "strings" ) func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) { @@ -69,7 +68,7 @@ func (ws *WServer) getSeqReq(conn *UserConn, m *Req) { nReply := new(pbChat.GetMaxAndMinSeqResp) pbData.UserID = m.SendID pbData.OperationID = m.OperationID - grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName) + grpcConn := getcdv3.GetOfflineMessageConn() if grpcConn == nil { log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", m) } @@ -110,7 +109,7 @@ func (ws *WServer) pullMsgReq(conn *UserConn, m *Req) { pbData.OperationID = m.OperationID pbData.SeqBegin = data.(SeqData).SeqBegin pbData.SeqEnd = data.(SeqData).SeqEnd - grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName) + grpcConn := getcdv3.GetOfflineMessageConn() msgClient := pbChat.NewChatClient(grpcConn) reply, err := msgClient.PullMessage(context.Background(), &pbData) if err != nil { @@ -176,7 +175,7 @@ func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) { pbData.SeqList = data.(open_im_sdk.PullMessageBySeqListReq).SeqList pbData.UserID = m.SendID pbData.OperationID = m.OperationID - grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName) + grpcConn := getcdv3.GetOfflineMessageConn() msgClient := pbChat.NewChatClient(grpcConn) reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData) if err != nil { @@ -219,7 +218,7 @@ func (ws *WServer) sendMsgReq(conn *UserConn, m *Req, sendTime int64) { SendTime: sendTime, } log.NewInfo(m.OperationID, "Ws call success to sendMsgReq middle", m.ReqIdentifier, m.SendID, m.MsgIncr, data) - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName) + etcdConn := getcdv3.GetOfflineMessageConn() client := pbChat.NewChatClient(etcdConn) reply, err := client.UserSendMsg(context.Background(), &pbData) if err != nil { diff --git a/internal/msg_transfer/logic/history_msg_handler.go b/internal/msg_transfer/logic/history_msg_handler.go index e3b5efb05..9ae3c5a0f 100644 --- a/internal/msg_transfer/logic/history_msg_handler.go +++ b/internal/msg_transfer/logic/history_msg_handler.go @@ -10,9 +10,10 @@ import ( pbPush "Open_IM/pkg/proto/push" "Open_IM/pkg/utils" "context" + "strings" + "github.com/Shopify/sarama" "github.com/golang/protobuf/proto" - "strings" ) type fcb func(msg []byte, msgKey string) @@ -138,7 +139,7 @@ func sendMessageToPush(message *pbMsg.MsgSvrToPushSvrChatMsg) { msg.SendTime = message.SendTime msg.MsgID = message.MsgID msg.OfflineInfo = message.OfflineInfo - grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImPushName) + grpcConn := getcdv3.GetPushConn() if grpcConn == nil { log.ErrorByKv("rpc dial failed", msg.OperationID, "push data", msg.String()) pid, offset, err := producer.SendMessage(message) diff --git a/internal/push/logic/push_to_client.go b/internal/push/logic/push_to_client.go index 8f5a004d9..e6754212c 100644 --- a/internal/push/logic/push_to_client.go +++ b/internal/push/logic/push_to_client.go @@ -19,7 +19,6 @@ import ( "Open_IM/pkg/utils" "context" "encoding/json" - "strings" ) type OpenIMContent struct { @@ -40,7 +39,7 @@ func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) { //isSenderSync := utils.GetSwitchFromOptions(MOptions, "senderSync") isOfflinePush := utils.GetSwitchFromOptions(MOptions, "offlinePush") log.InfoByKv("Get chat from msg_transfer And push chat", sendPbData.OperationID, "PushData", sendPbData) - grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName) + grpcCons := getcdv3.GetOnlineMessageConn() //Online push message log.InfoByKv("test", sendPbData.OperationID, "len grpc", len(grpcCons), "data", sendPbData) for _, v := range grpcCons { @@ -120,7 +119,7 @@ func SendMsgByWS(m *pbChat.WSToMsgSvrChatMsg) { sendMsgToKafka(m, m.SendID, "msgKey--sendID") sendMsgToKafka(m, m.RecvID, "msgKey--recvID") case constant.GroupChatType: - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := pbGroup.NewGroupClient(etcdConn) req := &pbGroup.GetGroupAllMemberReq{ GroupID: m.RecvID, diff --git a/internal/rpc/chat/send_msg.go b/internal/rpc/chat/send_msg.go index 5cfc4ee71..3c31ab2dc 100644 --- a/internal/rpc/chat/send_msg.go +++ b/internal/rpc/chat/send_msg.go @@ -16,7 +16,6 @@ import ( "math/rand" "net/http" "strconv" - "strings" "time" ) @@ -103,7 +102,7 @@ func (rpc *rpcChat) UserSendMsg(_ context.Context, pb *pbChat.UserSendMsgReq) (* } return returnMsg(&replay, pb, 0, "", serverMsgID, pbData.SendTime) case constant.GroupChatType: - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) + etcdConn := getcdv3.GetGroupConn() client := pbGroup.NewGroupClient(etcdConn) req := &pbGroup.GetGroupAllMemberReq{ GroupID: pbData.RecvID, diff --git a/internal/rpc/user/internal_service/get_user_info_to_client.go b/internal/rpc/user/internal_service/get_user_info_to_client.go index 4cd0d0d2d..bda770824 100644 --- a/internal/rpc/user/internal_service/get_user_info_to_client.go +++ b/internal/rpc/user/internal_service/get_user_info_to_client.go @@ -1,15 +1,13 @@ package internal_service import ( - pbUser "Open_IM/pkg/proto/user" - "Open_IM/pkg/common/config" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbUser "Open_IM/pkg/proto/user" "context" - "strings" ) func GetUserInfoClient(req *pbUser.GetUserInfoReq) (*pbUser.GetUserInfoResp, error) { - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) + etcdConn := getcdv3.GetUserConn() client := pbUser.NewUserClient(etcdConn) RpcResp, err := client.GetUserInfo(context.Background(), req) return RpcResp, err diff --git a/internal/rpc/user/update_user_info.go b/internal/rpc/user/update_user_info.go index 14fe9f0db..dce22ab06 100644 --- a/internal/rpc/user/update_user_info.go +++ b/internal/rpc/user/update_user_info.go @@ -12,7 +12,6 @@ import ( pbUser "Open_IM/pkg/proto/user" "Open_IM/pkg/utils" "context" - "strings" ) func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserInfoReq) (*pbUser.CommonResp, error) { @@ -36,7 +35,7 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI log.Error(req.Token, req.OperationID, "update user some attribute failed,err=%s", err.Error()) return &pbUser.CommonResp{ErrorCode: config.ErrModifyUserInfo.ErrCode, ErrorMsg: config.ErrModifyUserInfo.ErrMsg}, nil } - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) + etcdConn := getcdv3.GetFriendConn() client := pbFriend.NewFriendClient(etcdConn) newReq := &pbFriend.GetFriendListReq{ OperationID: req.OperationID, diff --git a/pkg/grpc-etcdv3/getcdv3/resolver.go b/pkg/grpc-etcdv3/getcdv3/resolver.go index aa41f86c4..94e03aaf1 100644 --- a/pkg/grpc-etcdv3/getcdv3/resolver.go +++ b/pkg/grpc-etcdv3/getcdv3/resolver.go @@ -1,17 +1,21 @@ package getcdv3 import ( + "Open_IM/pkg/common/config" "context" "fmt" + "go.etcd.io/etcd/clientv3" "go.etcd.io/etcd/mvcc/mvccpb" + //"google.golang.org/genproto/googleapis/ads/googleads/v1/services" - "google.golang.org/grpc" - "google.golang.org/grpc/balancer/roundrobin" - "google.golang.org/grpc/resolver" "strings" "sync" "time" + + "google.golang.org/grpc" + "google.golang.org/grpc/balancer/roundrobin" + "google.golang.org/grpc/resolver" ) type Resolver struct { @@ -88,6 +92,34 @@ func GetConn(schema, etcdaddr, serviceName string) *grpc.ClientConn { return r.grpcClientConn } +func GetAuthConn() *grpc.ClientConn { + return GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName) +} + +func GetOfflineMessageConn() *grpc.ClientConn { + return GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName) +} + +func GetFriendConn() *grpc.ClientConn { + return GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) +} + +func GetGroupConn() *grpc.ClientConn { + return GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) +} + +func GetUserConn() *grpc.ClientConn { + return GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) +} + +func GetPushConn() *grpc.ClientConn { + return GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImPushName) +} + +func GetOnlineMessageConn() []*grpc.ClientConn { + return GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName) +} + func (r *Resolver) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) { if r.cli == nil { return nil, fmt.Errorf("etcd clientv3 client failed, etcd:%s", target) diff --git a/pkg/proto/group/group.pb.go b/pkg/proto/group/group.pb.go index fae312019..a17cc979c 100644 --- a/pkg/proto/group/group.pb.go +++ b/pkg/proto/group/group.pb.go @@ -163,6 +163,7 @@ func (m *CreateGroupReq) GetEx() string { return "" } +// GroupAddMemberInfo struct type GroupAddMemberInfo struct { Uid string `protobuf:"bytes,1,opt,name=uid" json:"uid,omitempty"` SetRole int32 `protobuf:"varint,2,opt,name=setRole" json:"setRole,omitempty"` @@ -1879,6 +1880,7 @@ func (m *GetJoinedGroupListReq) GetOperationID() string { return "" } +// GroupInfo struct type GroupInfo struct { GroupId string `protobuf:"bytes,1,opt,name=groupId" json:"groupId,omitempty"` GroupName string `protobuf:"bytes,2,opt,name=groupName" json:"groupName,omitempty"`