From 42dfe1af3259ab56addf500da30b4fc849755927 Mon Sep 17 00:00:00 2001 From: kubbot <3293172751ysy@gmail.com> Date: Thu, 28 Mar 2024 02:19:12 +0000 Subject: [PATCH] cicd: bump League Patch --- cmd/api/admin-api/main.go | 8 ++-- cmd/api/chat-api/main.go | 9 ++-- cmd/rpc/admin-rpc/main.go | 5 +- cmd/rpc/chat-rpc/main.go | 5 +- example/callback/callback.go | 29 ++++++------ go.mod | 2 +- go.sum | 46 +++++++++++++++++++ internal/api/admin.go | 12 ++--- internal/api/router.go | 2 +- internal/rpc/admin/admin.go | 10 ++-- internal/rpc/chat/login.go | 1 - internal/rpc/chat/password.go | 1 + internal/rpc/chat/user.go | 3 +- pkg/common/apicall/caller.go | 5 +- pkg/common/apistruct/chat.go | 2 +- pkg/common/chatrpcstart/start.go | 5 +- pkg/common/config/parse.go | 9 ++-- pkg/common/config/version | 2 +- pkg/common/constant/constant.go | 6 +-- pkg/common/db/database/admin.go | 2 + pkg/common/db/database/chat.go | 5 +- pkg/common/db/model/admin/admin.go | 4 +- pkg/common/db/model/admin/applet.go | 4 +- pkg/common/db/model/admin/client_config.go | 2 +- .../db/model/admin/forbidden_account.go | 1 + .../db/model/admin/invitation_register.go | 2 +- pkg/common/db/model/admin/ip_forbidden.go | 3 +- .../db/model/admin/limit_user_login_ip.go | 2 +- .../db/model/admin/register_add_friend.go | 1 + .../db/model/admin/register_add_group.go | 1 + pkg/common/db/model/chat/account.go | 3 +- pkg/common/db/model/chat/attribute.go | 1 + pkg/common/db/model/chat/log.go | 3 +- pkg/common/db/model/chat/register.go | 3 +- pkg/common/db/model/chat/user_login_record.go | 3 +- pkg/common/db/model/chat/verify_code.go | 3 +- pkg/common/db/table/admin/admin.go | 2 +- pkg/common/db/table/admin/applet.go | 2 +- .../db/table/admin/forbidden_account.go | 2 +- .../db/table/admin/invitation_register.go | 2 +- pkg/common/db/table/admin/ip_forbidden.go | 2 +- .../db/table/admin/limit_user_login_ip.go | 2 +- .../db/table/admin/register_add_friend.go | 2 +- .../db/table/admin/register_add_group.go | 2 +- pkg/common/db/table/chat/attribute.go | 4 +- pkg/common/db/table/chat/log.go | 2 +- pkg/common/db/table/chat/register.go | 2 +- pkg/common/db/table/chat/user_login_record.go | 2 +- pkg/common/dbconn/mongo.go | 7 +-- pkg/common/rtc/gene_token.go | 2 +- pkg/common/version/base.go | 6 +-- pkg/common/version/types.go | 2 +- pkg/common/version/version.go | 10 ++-- pkg/common/xlsx/main.go | 3 +- pkg/common/xlsx/utils.go | 17 +++---- .../k8s_discovery_register.go | 7 ++- pkg/email/mail.go | 1 + tools/component/component.go | 15 +++--- tools/mysql2mongo/internal/main.go | 9 ++-- tools/mysql2mongo/mysql2mongo.go | 1 + 60 files changed, 198 insertions(+), 113 deletions(-) diff --git a/cmd/api/admin-api/main.go b/cmd/api/admin-api/main.go index 19fb2769..b8de9d98 100644 --- a/cmd/api/admin-api/main.go +++ b/cmd/api/admin-api/main.go @@ -17,7 +17,6 @@ package main import ( "context" "fmt" - "github.com/OpenIMSDK/chat/pkg/util" "math/rand" "net" "net/http" @@ -27,6 +26,10 @@ import ( "syscall" "time" + "github.com/OpenIMSDK/chat/pkg/util" + + "github.com/OpenIMSDK/chat/pkg/util" + "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/chat/pkg/discovery_register" @@ -79,7 +82,7 @@ func main() { } var zk discoveryregistry.SvcDiscoveryRegistry zk, err = discovery_register.NewDiscoveryRegister(config.Config.Envs.Discovery) - //zk, err = openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema, + // zk, err = openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema, // openKeeper.WithFreq(time.Hour), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username, config.Config.Zookeeper.Password), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger())) if err != nil { util.ExitWithError(err) @@ -126,5 +129,4 @@ func main() { close(netDone) util.ExitWithError(netErr) } - } diff --git a/cmd/api/chat-api/main.go b/cmd/api/chat-api/main.go index 20ce3f09..457152f2 100644 --- a/cmd/api/chat-api/main.go +++ b/cmd/api/chat-api/main.go @@ -18,7 +18,6 @@ import ( "context" "flag" "fmt" - "github.com/OpenIMSDK/chat/pkg/util" "net" "net/http" "os" @@ -27,6 +26,10 @@ import ( "syscall" "time" + "github.com/OpenIMSDK/chat/pkg/util" + + "github.com/OpenIMSDK/chat/pkg/util" + "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/chat/pkg/discovery_register" @@ -46,7 +49,6 @@ import ( ) func main() { - configFile, ginPort, showVersion, err := config.FlagParse() if err != nil { util.ExitWithError(err) @@ -83,8 +85,7 @@ func main() { zk, err = discovery_register.NewDiscoveryRegister(config.Config.Envs.Discovery) /*zk, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema, openKeeper.WithFreq(time.Hour), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username, - config.Config.Zookeeper.Password), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))*/ - if err != nil { + config.Config.Zookeeper.Password), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))*/if err != nil { util.ExitWithError(err) } if err := zk.CreateRpcRootNodes([]string{config.Config.RpcRegisterName.OpenImAdminName, config.Config.RpcRegisterName.OpenImChatName}); err != nil { diff --git a/cmd/rpc/admin-rpc/main.go b/cmd/rpc/admin-rpc/main.go index 0f9793e9..f4d686a6 100644 --- a/cmd/rpc/admin-rpc/main.go +++ b/cmd/rpc/admin-rpc/main.go @@ -17,10 +17,13 @@ package main import ( "flag" "fmt" - "github.com/OpenIMSDK/chat/pkg/util" "math/rand" "time" + "github.com/OpenIMSDK/chat/pkg/util" + + "github.com/OpenIMSDK/chat/pkg/util" + "github.com/OpenIMSDK/chat/pkg/common/chatrpcstart" "github.com/OpenIMSDK/chat/pkg/common/version" "github.com/OpenIMSDK/tools/log" diff --git a/cmd/rpc/chat-rpc/main.go b/cmd/rpc/chat-rpc/main.go index 35bbdbe3..37664ebc 100644 --- a/cmd/rpc/chat-rpc/main.go +++ b/cmd/rpc/chat-rpc/main.go @@ -16,10 +16,13 @@ package main import ( "fmt" - "github.com/OpenIMSDK/chat/pkg/util" "math/rand" "time" + "github.com/OpenIMSDK/chat/pkg/util" + + "github.com/OpenIMSDK/chat/pkg/util" + "github.com/OpenIMSDK/chat/pkg/common/chatrpcstart" "github.com/OpenIMSDK/tools/log" diff --git a/example/callback/callback.go b/example/callback/callback.go index e22b8eb5..2f94b84c 100644 --- a/example/callback/callback.go +++ b/example/callback/callback.go @@ -7,6 +7,12 @@ import ( "encoding/hex" "encoding/json" "errors" + "io" + "net/http" + "reflect" + "strings" + "time" + "github.com/OpenIMSDK/chat/pkg/common/apistruct" "github.com/OpenIMSDK/chat/pkg/common/config" "github.com/OpenIMSDK/chat/pkg/proto/admin" @@ -17,11 +23,6 @@ import ( "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/utils" "github.com/gin-gonic/gin" - "io" - "net/http" - "reflect" - "strings" - "time" ) func CallbackExample(c *gin.Context) { @@ -73,7 +74,7 @@ func CallbackExample(c *gin.Context) { } } -// struct to map +// struct to map. func convertStructToMap(input interface{}) (map[string]interface{}, error) { result := make(map[string]interface{}) inputType := reflect.TypeOf(input) @@ -100,12 +101,11 @@ func convertStructToMap(input interface{}) (map[string]interface{}, error) { } func Post(ctx context.Context, url string, header map[string]string, data any, timeout int) (content []byte, err error) { - var ( - // define http client. - client = &http.Client{ - Timeout: 15 * time.Second, // max timeout is 15s - } - ) + + // define http client. + client := &http.Client{ + Timeout: 15 * time.Second, // max timeout is 15s + } if timeout > 0 { var cancel func() @@ -145,9 +145,8 @@ func Post(ctx context.Context, url string, header map[string]string, data any, t return result, nil } -// handlingCallbackAfterSendMsg Handling callbacks after sending a message +// handlingCallbackAfterSendMsg Handling callbacks after sending a message. func handlingCallbackAfterSendMsg(c *gin.Context) (*apistruct.CallbackAfterSendSingleMsgReq, error) { - var req apistruct.CallbackAfterSendSingleMsgReq if err := c.BindJSON(&req); err != nil { @@ -200,7 +199,7 @@ func getAdminToken(c *gin.Context) (*apistruct.AdminLoginResp, error) { return &apistruct.AdminLoginResp{AdminToken: adminOutput.Data.AdminToken, ImToken: adminOutput.Data.ImToken}, nil } -// CheckRobotAccount Verify if the robot account exists +// CheckRobotAccount Verify if the robot account exists. func getRobotAccountInfo(c *gin.Context, token, robotics string) (*common.UserPublicInfo, error) { header := make(map[string]string) header["token"] = token diff --git a/go.mod b/go.mod index c073ef9c..0ed154ba 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/OpenIMSDK/chat go 1.21 -toolchain go1.21.2 +toolchain go1.21.2 require ( github.com/gin-gonic/gin v1.9.1 diff --git a/go.sum b/go.sum index 99ad17f1..da9c7e9c 100644 --- a/go.sum +++ b/go.sum @@ -35,8 +35,11 @@ github.com/alibabacloud-go/tea-xml v1.1.2/go.mod h1:Rq08vgCcCAjHyRi/M7xlHKUykZCE github.com/aliyun/credentials-go v1.1.2 h1:qU1vwGIBb3UJ8BwunHDRFtAhS6jnQLnde/yk0+Ih2GY= github.com/aliyun/credentials-go v1.1.2/go.mod h1:ozcZaMR5kLM7pwtCMEpVmQ242suV6qTJya2bDq4X1Tw= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= +github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= +github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0= github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= @@ -59,6 +62,7 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cu github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/eapache/channels v1.1.0 h1:F1taHcn7/F0i8DYqKXJnyhJcVpp2kgFcNePxXtnyu4k= +github.com/eapache/channels v1.1.0/go.mod h1:jMm2qB5Ubtg9zLd+inMZd2/NUvXgzmWXsDaLyQIGfH0= github.com/eapache/go-resiliency v1.4.0 h1:3OK9bWpPk5q6pbFAaYSEwD9CLUSHG8bnZuqX2yMt3B0= github.com/eapache/go-resiliency v1.4.0/go.mod h1:5yPzW0MIvSe0JDsv0v+DvcjEv2FyD6iZYSs1ZI+iQho= github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4ALJ04o5Qqpdz8XLIpNA3WM/iSIXqxtqo7UGVws= @@ -66,10 +70,13 @@ github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1 github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frostbyte73/core v0.0.10 h1:D4DQXdPb8ICayz0n75rs4UYTXrUSdxzUfeleuNJORsU= +github.com/frostbyte73/core v0.0.10/go.mod h1:XsOGqrqe/VEV7+8vJ+3a8qnCIXNbKsoEiu/czs7nrcU= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/gammazero/deque v0.2.1 h1:qSdsbG6pgp6nL7A0+K/B7s12mcCY/5l5SIUpMOl+dC0= +github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU= 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.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= @@ -77,7 +84,9 @@ github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SU github.com/go-jose/go-jose/v3 v3.0.2 h1:2Edjn8Nrb44UvTdp84KU0bBPs1cO7noRCybtS3eJEUQ= github.com/go-jose/go-jose/v3 v3.0.2/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= @@ -103,6 +112,7 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -136,11 +146,13 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= +github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/jxskiss/base62 v1.1.0 h1:A5zbF8v8WXx2xixnAKD2w+abC+sIzYJX+nxmhA6HWFw= +github.com/jxskiss/base62 v1.1.0/go.mod h1:HhWAlUXvxKThfOlZbcuFzsqwtF5TcqS9ru3y5GfjWAc= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI= github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= @@ -163,11 +175,15 @@ github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECae github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205AhTIGQQ= github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw= github.com/lithammer/shortuuid/v4 v4.0.0 h1:QRbbVkfgNippHOS8PXDkti4NaWeyYfcBTHtw7k08o4c= +github.com/lithammer/shortuuid/v4 v4.0.0/go.mod h1:Zs8puNcrvf2rV9rTH51ZLLcj7ZXqQI3lv67aw4KiB1Y= github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 h1:jm09419p0lqTkDaKb5iXdynYrzB84ErPPO4LbRASk58= +github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ= github.com/livekit/protocol v1.10.1 h1:upe6pKRqH8wpsMuR2OLtgizEm94iia3pDYm3O4/2PRY= github.com/livekit/protocol v1.10.1/go.mod h1:eWPz45pnxwpCwB84qqhHxG0bCRgasa2itN6GAHCDddc= github.com/livekit/psrpc v0.5.3-0.20240227154351-b7f99eaaf7b3 h1:bvjzDR+Rvdf3JgzQMtLiGVHBQ8KoOWM7x7sHj79jevQ= +github.com/livekit/psrpc v0.5.3-0.20240227154351-b7f99eaaf7b3/go.mod h1:CQUBSPfYYAaevg1TNCc6/aYsa8DJH4jSRFdCeSZk5u0= github.com/mackerelio/go-osstat v0.2.4 h1:qxGbdPkFo65PXOb/F/nhDKpF2nGmGaCFDLXoZjJTtUs= +github.com/mackerelio/go-osstat v0.2.4/go.mod h1:Zy+qzGdZs3A9cuIqmgbJvwbmLQH9dJvtio5ZjJTbdlQ= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= @@ -188,8 +204,11 @@ github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwd github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/nats-io/nats.go v1.31.0 h1:/WFBHEc/dOKBF6qf1TZhrdEfTmOZ5JzdJ+Y3m6Y/p7E= +github.com/nats-io/nats.go v1.31.0/go.mod h1:di3Bm5MLsoB4Bx61CBTsxuarI36WbhAwOm8QrW39+i8= github.com/nats-io/nkeys v0.4.6 h1:IzVe95ru2CT6ta874rt9saQRkWfe2nFj1NtvYSLqMzY= +github.com/nats-io/nkeys v0.4.6/go.mod h1:4DxZNzenSVd1cYQoAa8948QY3QDjrHfcfVADymtkpts= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= 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= @@ -198,31 +217,52 @@ github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNc github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ= github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pion/datachannel v1.5.5 h1:10ef4kwdjije+M9d7Xm9im2Y3O6A6ccQb0zcqZcJew8= +github.com/pion/datachannel v1.5.5/go.mod h1:iMz+lECmfdCMqFRhXhcA/219B0SQlbpoR2V118yimL0= github.com/pion/dtls/v2 v2.2.7 h1:cSUBsETxepsCSFSxC3mc/aDo14qQLMSL+O6IjG28yV8= +github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s= github.com/pion/ice/v2 v2.3.13 h1:xOxP+4V9nSDlUaGFRf/LvAuGHDXRcjIdsbbXPK/w7c8= +github.com/pion/ice/v2 v2.3.13/go.mod h1:KXJJcZK7E8WzrBEYnV4UtqEZsGeWfHxsNqhVcVvgjxw= github.com/pion/interceptor v0.1.25 h1:pwY9r7P6ToQ3+IF0bajN0xmk/fNw/suTgaTdlwTDmhc= +github.com/pion/interceptor v0.1.25/go.mod h1:wkbPYAak5zKsfpVDYMtEfWEy8D4zL+rpxCxPImLOg3Y= github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= +github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= github.com/pion/mdns v0.0.12 h1:CiMYlY+O0azojWDmxdNr7ADGrnZ+V6Ilfner+6mSVK8= +github.com/pion/mdns v0.0.12/go.mod h1:VExJjv8to/6Wqm1FXK+Ii/Z9tsVk/F5sD/N70cnYFbk= github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA= +github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8= github.com/pion/rtcp v1.2.12 h1:bKWiX93XKgDZENEXCijvHRU/wRifm6JV5DGcH6twtSM= +github.com/pion/rtcp v1.2.12/go.mod h1:sn6qjxvnwyAkkPzPULIbVqSKI5Dv54Rv7VG0kNxh9L4= github.com/pion/rtp v1.8.3 h1:VEHxqzSVQxCkKDSHro5/4IUUG1ea+MFdqR2R3xSpNU8= +github.com/pion/rtp v1.8.3/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU= github.com/pion/sctp v1.8.12 h1:2VX50pedElH+is6FI+OKyRTeN5oy4mrk2HjnGa3UCmY= +github.com/pion/sctp v1.8.12/go.mod h1:cMLT45jqw3+jiJCrtHVwfQLnfR0MGZ4rgOJwUOIqLkI= github.com/pion/sdp/v3 v3.0.6 h1:WuDLhtuFUUVpTfus9ILC4HRyHsW6TdugjEX/QY9OiUw= +github.com/pion/sdp/v3 v3.0.6/go.mod h1:iiFWFpQO8Fy3S5ldclBkpXqmWy02ns78NOKoLLL0YQw= github.com/pion/srtp/v2 v2.0.18 h1:vKpAXfawO9RtTRKZJbG4y0v1b11NZxQnxRl85kGuUlo= +github.com/pion/srtp/v2 v2.0.18/go.mod h1:0KJQjA99A6/a0DOVTu1PhDSw0CXF2jTkqOoMg3ODqdA= github.com/pion/stun v0.6.1 h1:8lp6YejULeHBF8NmV8e2787BogQhduZugh5PdhDyyN4= +github.com/pion/stun v0.6.1/go.mod h1:/hO7APkX4hZKu/D0f2lHzNyvdkTGtIy3NDmLR7kSz/8= github.com/pion/transport/v2 v2.2.3 h1:XcOE3/x41HOSKbl1BfyY1TF1dERx7lVvlMCbXU7kfvA= +github.com/pion/transport/v2 v2.2.3/go.mod h1:q2U/tf9FEfnSBGSW6w5Qp5PFWRLRj3NjLhCCgpRK4p0= github.com/pion/turn/v2 v2.1.3 h1:pYxTVWG2gpC97opdRc5IGsQ1lJ9O/IlNhkzj7MMrGAA= +github.com/pion/turn/v2 v2.1.3/go.mod h1:huEpByKKHix2/b9kmTAM3YoX6MKP+/D//0ClgUYR2fY= github.com/pion/webrtc/v3 v3.2.28 h1:ienStxZ6HcjtH2UlmnFpMM0loENiYjaX437uIUpQSKo= +github.com/pion/webrtc/v3 v3.2.28/go.mod h1:PNRCEuQlibrmuBhOTnol9j6KkIbUG11aHLEfNpUYey0= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= 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 v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE= +github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/puzpuzpuz/xsync v1.5.2 h1:yRAP4wqSOZG+/4pxJ08fPTwrfL0IzE/LKQ/cw509qGY= +github.com/puzpuzpuz/xsync v1.5.2/go.mod h1:K98BYhX3k1dQ2M63t1YNVDanbwUPmBCAhNmVrrxfiGg= 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/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8= @@ -234,6 +274,7 @@ github.com/richardlehane/msoleps v1.0.3 h1:aznSZzrwYRl3rLKRT3gUk9am7T/mLNSnJINvN github.com/richardlehane/msoleps v1.0.3/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= @@ -255,6 +296,7 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tjfoc/gmsm v1.3.2 h1:7JVkAn5bvUJ7HtU08iW6UiD+UTmJTIToHCfeFzkcCxM= github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w= github.com/twitchtv/twirp v8.1.3+incompatible h1:+F4TdErPgSUbMZMwp13Q/KgDVuI7HJXP61mNV3/7iuU= @@ -281,10 +323,13 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.30/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0= +github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= go.mongodb.org/mongo-driver v1.12.0 h1:aPx33jmn/rQuJXPQLZQ8NtfPQG8CaqgLThFtqRb0PiE= go.mongodb.org/mongo-driver v1.12.0/go.mod h1:AZkxhPnFJUoH7kZlFkVKucV20K387miPfm7oimrSmK0= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= +go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= @@ -393,6 +438,7 @@ gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE= gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw= gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= diff --git a/internal/api/admin.go b/internal/api/admin.go index 97d9244c..29e3fbdc 100644 --- a/internal/api/admin.go +++ b/internal/api/admin.go @@ -19,6 +19,12 @@ import ( "crypto/md5" "encoding/hex" "fmt" + "net" + "net/http" + "strconv" + "strings" + "time" + "github.com/OpenIMSDK/chat/pkg/common/apicall" "github.com/OpenIMSDK/chat/pkg/common/apistruct" "github.com/OpenIMSDK/chat/pkg/common/config" @@ -39,11 +45,6 @@ import ( "github.com/OpenIMSDK/tools/utils" "github.com/gin-gonic/gin" "google.golang.org/grpc" - "net" - "net/http" - "strconv" - "strings" - "time" ) func NewAdmin(chatConn, adminConn grpc.ClientConnInterface) *AdminApi { @@ -160,7 +161,6 @@ func (o *AdminApi) AddUserAccount(c *gin.Context) { } apiresp.GinSuccess(c, nil) - } func (o *AdminApi) DelAdminAccount(c *gin.Context) { diff --git a/internal/api/router.go b/internal/api/router.go index 550efcbf..bce2ec3b 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -91,7 +91,7 @@ func NewAdminRoute(router gin.IRouter, discov discoveryregistry.SvcDiscoveryRegi adminRouterGroup.POST("/add_user", mw.CheckAdmin, admin.AddUserAccount) // Add user account adminRouterGroup.POST("/del_admin", mw.CheckAdmin, admin.DelAdminAccount) // Delete admin adminRouterGroup.POST("/search", mw.CheckAdmin, admin.SearchAdminAccount) // Get admin list - //account.POST("/add_notification_account") + // account.POST("/add_notification_account") importGroup := router.Group("/user/import") importGroup.POST("/json", mw.CheckAdminOrNil, admin.ImportUserByJson) diff --git a/internal/rpc/admin/admin.go b/internal/rpc/admin/admin.go index d0666ead..8cd20587 100644 --- a/internal/rpc/admin/admin.go +++ b/internal/rpc/admin/admin.go @@ -17,14 +17,15 @@ package admin import ( "context" "fmt" + "math/rand" + "time" + "github.com/OpenIMSDK/chat/pkg/common/db/cache" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/utils" "google.golang.org/grpc" - "math/rand" - "time" "github.com/OpenIMSDK/chat/pkg/common/config" "github.com/OpenIMSDK/chat/pkg/common/constant" @@ -60,8 +61,9 @@ func Start(discov discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e return errs.Wrap(err, "CreateRpcRootNodes error") } - admin.RegisterAdminServer(server, &adminServer{Database: adminDatabase, - Chat: chat.NewChatClient(discov), + admin.RegisterAdminServer(server, &adminServer{ + Database: adminDatabase, + Chat: chat.NewChatClient(discov), }) return nil } diff --git a/internal/rpc/chat/login.go b/internal/rpc/chat/login.go index f35141a0..3d09dc42 100644 --- a/internal/rpc/chat/login.go +++ b/internal/rpc/chat/login.go @@ -290,7 +290,6 @@ func (o *chatSvr) RegisterUser(ctx context.Context, req *chat.RegisterUserReq) ( return nil, err } } - } if req.User.UserID == "" { for i := 0; i < 20; i++ { diff --git a/internal/rpc/chat/password.go b/internal/rpc/chat/password.go index dc1932b9..50a6ef45 100644 --- a/internal/rpc/chat/password.go +++ b/internal/rpc/chat/password.go @@ -16,6 +16,7 @@ package chat import ( "context" + "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/chat/pkg/common/constant" diff --git a/internal/rpc/chat/user.go b/internal/rpc/chat/user.go index 28624342..ed2d8e2f 100644 --- a/internal/rpc/chat/user.go +++ b/internal/rpc/chat/user.go @@ -16,12 +16,13 @@ package chat import ( "context" + "time" + "github.com/OpenIMSDK/chat/pkg/common/db/dbutil" chat2 "github.com/OpenIMSDK/chat/pkg/common/db/table/chat" "github.com/OpenIMSDK/chat/pkg/common/rtc" constant2 "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/mcontext" - "time" "github.com/OpenIMSDK/chat/pkg/common/constant" "github.com/OpenIMSDK/chat/pkg/common/mctx" diff --git a/pkg/common/apicall/caller.go b/pkg/common/apicall/caller.go index f60fbb6d..cc863420 100644 --- a/pkg/common/apicall/caller.go +++ b/pkg/common/apicall/caller.go @@ -16,10 +16,13 @@ package apicall import ( "context" - "github.com/OpenIMSDK/tools/log" "sync" "time" + "github.com/OpenIMSDK/tools/log" + + "github.com/OpenIMSDK/tools/log" + "github.com/OpenIMSDK/chat/pkg/common/config" "github.com/OpenIMSDK/protocol/auth" "github.com/OpenIMSDK/protocol/constant" diff --git a/pkg/common/apistruct/chat.go b/pkg/common/apistruct/chat.go index 4496c230..17c37ee5 100644 --- a/pkg/common/apistruct/chat.go +++ b/pkg/common/apistruct/chat.go @@ -130,4 +130,4 @@ type SendMsg struct { // OfflinePushInfo contains information for offline push notifications. OfflinePushInfo *sdkws.OfflinePushInfo `json:"offlinePushInfo"` -} \ No newline at end of file +} diff --git a/pkg/common/chatrpcstart/start.go b/pkg/common/chatrpcstart/start.go index 5d9c3aea..9e4e1658 100644 --- a/pkg/common/chatrpcstart/start.go +++ b/pkg/common/chatrpcstart/start.go @@ -18,7 +18,6 @@ import ( "context" "errors" "fmt" - "github.com/OpenIMSDK/chat/pkg/util" "net" "os" "os/signal" @@ -27,6 +26,10 @@ import ( "syscall" "time" + "github.com/OpenIMSDK/chat/pkg/util" + + "github.com/OpenIMSDK/chat/pkg/util" + "github.com/OpenIMSDK/chat/pkg/common/config" chatMw "github.com/OpenIMSDK/chat/pkg/common/mw" "github.com/OpenIMSDK/chat/pkg/discovery_register" diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index ad7b41ba..a61a4166 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -19,7 +19,6 @@ import ( "errors" "flag" "fmt" - "github.com/OpenIMSDK/tools/errs" "os" "path/filepath" "runtime" @@ -27,6 +26,10 @@ import ( "strings" "time" + "github.com/OpenIMSDK/tools/errs" + + "github.com/OpenIMSDK/tools/errs" + Constant "github.com/OpenIMSDK/chat/pkg/common/constant" "gopkg.in/yaml.v3" ) @@ -154,7 +157,6 @@ func findConfigFile(paths []string) (string, error) { } func CreateCatalogPath(path string) []string { - path1 := filepath.Dir(path) path1 = filepath.Dir(path1) // the parent of binary file @@ -169,7 +171,6 @@ func CreateCatalogPath(path string) []string { pa3 := filepath.Join(path3, Constant.ConfigPath) return []string{pa1, pa2, pa3} - } func findConfigPath(configFile string) (string, error) { @@ -184,7 +185,7 @@ func findConfigPath(configFile string) (string, error) { } // Second, check for OPENIMCONFIG environment variable - //envConfigPath := os.Getenv(Constant.OpenIMConfig) + // envConfigPath := os.Getenv(Constant.OpenIMConfig) envConfigPath := os.Getenv(Constant.OpenIMConfig) if envConfigPath != "" { if _, err := findConfigFile([]string{envConfigPath}); err != nil { diff --git a/pkg/common/config/version b/pkg/common/config/version index 7c7d607d..9c6d6293 100644 --- a/pkg/common/config/version +++ b/pkg/common/config/version @@ -1 +1 @@ -v3.3.5 \ No newline at end of file +1.6.1 diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go index 914385d5..7c002c1b 100644 --- a/pkg/common/constant/constant.go +++ b/pkg/common/constant/constant.go @@ -16,7 +16,7 @@ package constant import "github.com/OpenIMSDK/protocol/constant" -// config path +// config path. const ( ConfigPath = "/config/config.yaml" @@ -128,7 +128,7 @@ const ( NeedInvitationCodeRegister = 1 // Invitation code required ) -// mini-app +// mini-app. const ( StatusOnShelf = 1 // OnShelf StatusUnShelf = 2 // UnShelf @@ -155,7 +155,7 @@ const ( InvitationCodeUnused = 2 // Unused ) -// Default discovery page +// Default discovery page. const DefaultDiscoverPageURL = "https://doc.rentsoft.cn/#/" // const OperationID = "operationID" diff --git a/pkg/common/db/database/admin.go b/pkg/common/db/database/admin.go index 73b5e369..1aa975bb 100644 --- a/pkg/common/db/database/admin.go +++ b/pkg/common/db/database/admin.go @@ -16,6 +16,7 @@ package database import ( "context" + "github.com/OpenIMSDK/tools/pagination" "go.mongodb.org/mongo-driver/mongo" @@ -166,6 +167,7 @@ func (o *AdminDatabase) UpdateAdmin(ctx context.Context, userID string, update m func (o *AdminDatabase) ChangePassword(ctx context.Context, userID string, newPassword string) error { return o.admin.ChangePassword(ctx, userID, newPassword) } + func (o *AdminDatabase) AddAdminAccount(ctx context.Context, admins []*table.Admin) error { return o.admin.Create(ctx, admins) } diff --git a/pkg/common/db/database/chat.go b/pkg/common/db/database/chat.go index ce5c4bef..7b36e54c 100644 --- a/pkg/common/db/database/chat.go +++ b/pkg/common/db/database/chat.go @@ -16,10 +16,11 @@ package database import ( "context" + "time" + "github.com/OpenIMSDK/chat/pkg/common/db/dbutil" "github.com/OpenIMSDK/tools/pagination" "go.mongodb.org/mongo-driver/mongo" - "time" constant2 "github.com/OpenIMSDK/chat/pkg/common/constant" admin2 "github.com/OpenIMSDK/chat/pkg/common/db/model/admin" @@ -245,9 +246,11 @@ func (o *ChatDatabase) GetAttributeByAccount(ctx context.Context, account string func (o *ChatDatabase) GetAttributeByPhone(ctx context.Context, areaCode string, phoneNumber string) (*table.Attribute, error) { return o.attribute.TakePhone(ctx, areaCode, phoneNumber) } + func (o *ChatDatabase) GetAttributeByEmail(ctx context.Context, email string) (*table.Attribute, error) { return o.attribute.TakeEmail(ctx, email) } + func (o *ChatDatabase) LoginRecord(ctx context.Context, record *table.UserLoginRecord, verifyCodeID *string) error { return o.tx.Transaction(ctx, func(ctx context.Context) error { if err := o.userLoginRecord.Create(ctx, record); err != nil { diff --git a/pkg/common/db/model/admin/admin.go b/pkg/common/db/model/admin/admin.go index 92c72b0c..c02607af 100644 --- a/pkg/common/db/model/admin/admin.go +++ b/pkg/common/db/model/admin/admin.go @@ -18,13 +18,14 @@ import ( "context" "crypto/md5" "encoding/hex" + "time" + "github.com/OpenIMSDK/chat/pkg/common/constant" "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "time" "github.com/OpenIMSDK/chat/pkg/common/config" "github.com/OpenIMSDK/chat/pkg/common/db/table/admin" @@ -72,7 +73,6 @@ func (o *Admin) Create(ctx context.Context, admins []*admin.Admin) error { func (o *Admin) ChangePassword(ctx context.Context, userID string, newPassword string) error { return mgoutil.UpdateOne(ctx, o.coll, bson.M{"user_id": userID}, bson.M{"$set": bson.M{"password": newPassword}}, false) - } func (o *Admin) Delete(ctx context.Context, userIDs []string) error { diff --git a/pkg/common/db/model/admin/applet.go b/pkg/common/db/model/admin/applet.go index b5ec6932..e35bdc09 100644 --- a/pkg/common/db/model/admin/applet.go +++ b/pkg/common/db/model/admin/applet.go @@ -16,6 +16,7 @@ package admin import ( "context" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" "go.mongodb.org/mongo-driver/bson" @@ -67,7 +68,6 @@ func (o *Applet) Update(ctx context.Context, id string, data map[string]any) err func (o *Applet) Take(ctx context.Context, id string) (*admin.Applet, error) { return mgoutil.FindOne[*admin.Applet](ctx, o.coll, bson.M{"id": id}) - } func (o *Applet) Search(ctx context.Context, keyword string, pagination pagination.Pagination) (int64, []*admin.Applet, error) { @@ -88,10 +88,8 @@ func (o *Applet) Search(ctx context.Context, keyword string, pagination paginati func (o *Applet) FindOnShelf(ctx context.Context) ([]*admin.Applet, error) { return mgoutil.Find[*admin.Applet](ctx, o.coll, bson.M{"status": constant.StatusOnShelf}) - } func (o *Applet) FindID(ctx context.Context, ids []string) ([]*admin.Applet, error) { return mgoutil.Find[*admin.Applet](ctx, o.coll, bson.M{"id": bson.M{"$in": ids}}) - } diff --git a/pkg/common/db/model/admin/client_config.go b/pkg/common/db/model/admin/client_config.go index 7d75516d..6e161752 100644 --- a/pkg/common/db/model/admin/client_config.go +++ b/pkg/common/db/model/admin/client_config.go @@ -16,6 +16,7 @@ package admin import ( "context" + "github.com/OpenIMSDK/tools/mgoutil" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" @@ -55,7 +56,6 @@ func (o *ClientConfig) Set(ctx context.Context, config map[string]string) error if err != nil { return err } - } return nil } diff --git a/pkg/common/db/model/admin/forbidden_account.go b/pkg/common/db/model/admin/forbidden_account.go index 96ce29a0..ee129576 100644 --- a/pkg/common/db/model/admin/forbidden_account.go +++ b/pkg/common/db/model/admin/forbidden_account.go @@ -16,6 +16,7 @@ package admin import ( "context" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" "go.mongodb.org/mongo-driver/bson" diff --git a/pkg/common/db/model/admin/invitation_register.go b/pkg/common/db/model/admin/invitation_register.go index 250af19f..f81b919a 100644 --- a/pkg/common/db/model/admin/invitation_register.go +++ b/pkg/common/db/model/admin/invitation_register.go @@ -16,6 +16,7 @@ package admin import ( "context" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" "go.mongodb.org/mongo-driver/bson" @@ -95,5 +96,4 @@ func (o *InvitationRegister) Search(ctx context.Context, keyword string, state i } } return mgoutil.FindPage[*admin.InvitationRegister](ctx, o.coll, filter, pagination) - } diff --git a/pkg/common/db/model/admin/ip_forbidden.go b/pkg/common/db/model/admin/ip_forbidden.go index 29fe6756..c7967d29 100644 --- a/pkg/common/db/model/admin/ip_forbidden.go +++ b/pkg/common/db/model/admin/ip_forbidden.go @@ -16,6 +16,7 @@ package admin import ( "context" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" "go.mongodb.org/mongo-driver/bson" @@ -49,12 +50,10 @@ type IPForbidden struct { func (o *IPForbidden) Take(ctx context.Context, ip string) (*admin.IPForbidden, error) { return mgoutil.FindOne[*admin.IPForbidden](ctx, o.coll, bson.M{"ip": ip}) - } func (o *IPForbidden) Find(ctx context.Context, ips []string) ([]*admin.IPForbidden, error) { return mgoutil.Find[*admin.IPForbidden](ctx, o.coll, bson.M{"ip": bson.M{"$in": ips}}) - } func (o *IPForbidden) Search(ctx context.Context, keyword string, state int32, pagination pagination.Pagination) (int64, []*admin.IPForbidden, error) { diff --git a/pkg/common/db/model/admin/limit_user_login_ip.go b/pkg/common/db/model/admin/limit_user_login_ip.go index 7b896254..dba68d6e 100644 --- a/pkg/common/db/model/admin/limit_user_login_ip.go +++ b/pkg/common/db/model/admin/limit_user_login_ip.go @@ -16,6 +16,7 @@ package admin import ( "context" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" "go.mongodb.org/mongo-driver/bson" @@ -75,7 +76,6 @@ func (o *LimitUserLoginIP) Search(ctx context.Context, keyword string, paginatio }, } return mgoutil.FindPage[*admin.LimitUserLoginIP](ctx, o.coll, filter, pagination) - } func (o *LimitUserLoginIP) limitUserLoginIPFilter(ips []*admin.LimitUserLoginIP) bson.M { diff --git a/pkg/common/db/model/admin/register_add_friend.go b/pkg/common/db/model/admin/register_add_friend.go index 9ed535d8..ac6343bd 100644 --- a/pkg/common/db/model/admin/register_add_friend.go +++ b/pkg/common/db/model/admin/register_add_friend.go @@ -16,6 +16,7 @@ package admin import ( "context" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" "go.mongodb.org/mongo-driver/bson" diff --git a/pkg/common/db/model/admin/register_add_group.go b/pkg/common/db/model/admin/register_add_group.go index 30378f57..9ace3e07 100644 --- a/pkg/common/db/model/admin/register_add_group.go +++ b/pkg/common/db/model/admin/register_add_group.go @@ -16,6 +16,7 @@ package admin import ( "context" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" "go.mongodb.org/mongo-driver/bson" diff --git a/pkg/common/db/model/chat/account.go b/pkg/common/db/model/chat/account.go index ad888850..bf69b0bf 100644 --- a/pkg/common/db/model/chat/account.go +++ b/pkg/common/db/model/chat/account.go @@ -16,12 +16,13 @@ package chat import ( "context" + "time" + "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/mgoutil" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "time" "github.com/OpenIMSDK/chat/pkg/common/db/table/chat" ) diff --git a/pkg/common/db/model/chat/attribute.go b/pkg/common/db/model/chat/attribute.go index c853c595..cd87348a 100644 --- a/pkg/common/db/model/chat/attribute.go +++ b/pkg/common/db/model/chat/attribute.go @@ -16,6 +16,7 @@ package chat import ( "context" + "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" diff --git a/pkg/common/db/model/chat/log.go b/pkg/common/db/model/chat/log.go index f6d77992..1252b088 100644 --- a/pkg/common/db/model/chat/log.go +++ b/pkg/common/db/model/chat/log.go @@ -16,13 +16,14 @@ package chat import ( "context" + "time" + "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "time" "github.com/OpenIMSDK/chat/pkg/common/db/table/chat" ) diff --git a/pkg/common/db/model/chat/register.go b/pkg/common/db/model/chat/register.go index b3ff0f6b..08e2e8cb 100644 --- a/pkg/common/db/model/chat/register.go +++ b/pkg/common/db/model/chat/register.go @@ -16,11 +16,12 @@ package chat import ( "context" + "time" + "github.com/OpenIMSDK/tools/mgoutil" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "time" "github.com/OpenIMSDK/chat/pkg/common/db/table/chat" "github.com/OpenIMSDK/tools/errs" diff --git a/pkg/common/db/model/chat/user_login_record.go b/pkg/common/db/model/chat/user_login_record.go index fc47f753..1e46259b 100644 --- a/pkg/common/db/model/chat/user_login_record.go +++ b/pkg/common/db/model/chat/user_login_record.go @@ -16,10 +16,11 @@ package chat import ( "context" + "time" + "github.com/OpenIMSDK/tools/mgoutil" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" - "time" "github.com/OpenIMSDK/chat/pkg/common/db/table/chat" ) diff --git a/pkg/common/db/model/chat/verify_code.go b/pkg/common/db/model/chat/verify_code.go index 756f75e1..3b439cdc 100644 --- a/pkg/common/db/model/chat/verify_code.go +++ b/pkg/common/db/model/chat/verify_code.go @@ -16,12 +16,13 @@ package chat import ( "context" + "time" + "github.com/OpenIMSDK/tools/mgoutil" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "time" "github.com/OpenIMSDK/chat/pkg/common/db/table/chat" "github.com/OpenIMSDK/tools/errs" diff --git a/pkg/common/db/table/admin/admin.go b/pkg/common/db/table/admin/admin.go index a32d522d..988fd657 100644 --- a/pkg/common/db/table/admin/admin.go +++ b/pkg/common/db/table/admin/admin.go @@ -16,8 +16,8 @@ package admin import ( "context" - "github.com/OpenIMSDK/tools/pagination" "time" + ) // Admin 后台管理员. diff --git a/pkg/common/db/table/admin/applet.go b/pkg/common/db/table/admin/applet.go index 6979fc17..127c93dc 100644 --- a/pkg/common/db/table/admin/applet.go +++ b/pkg/common/db/table/admin/applet.go @@ -16,8 +16,8 @@ package admin import ( "context" - "github.com/OpenIMSDK/tools/pagination" "time" + ) type Applet struct { diff --git a/pkg/common/db/table/admin/forbidden_account.go b/pkg/common/db/table/admin/forbidden_account.go index df9f7709..ac016979 100644 --- a/pkg/common/db/table/admin/forbidden_account.go +++ b/pkg/common/db/table/admin/forbidden_account.go @@ -16,8 +16,8 @@ package admin import ( "context" - "github.com/OpenIMSDK/tools/pagination" "time" + ) // ForbiddenAccount 封号表. diff --git a/pkg/common/db/table/admin/invitation_register.go b/pkg/common/db/table/admin/invitation_register.go index 8362bfa3..6e600e39 100644 --- a/pkg/common/db/table/admin/invitation_register.go +++ b/pkg/common/db/table/admin/invitation_register.go @@ -16,8 +16,8 @@ package admin import ( "context" - "github.com/OpenIMSDK/tools/pagination" "time" + ) // 邀请码被注册使用. diff --git a/pkg/common/db/table/admin/ip_forbidden.go b/pkg/common/db/table/admin/ip_forbidden.go index 02a0a1bb..7538acf8 100644 --- a/pkg/common/db/table/admin/ip_forbidden.go +++ b/pkg/common/db/table/admin/ip_forbidden.go @@ -16,8 +16,8 @@ package admin import ( "context" - "github.com/OpenIMSDK/tools/pagination" "time" + ) // 禁止ip登录 注册. diff --git a/pkg/common/db/table/admin/limit_user_login_ip.go b/pkg/common/db/table/admin/limit_user_login_ip.go index bbb81d90..bedb4b2b 100644 --- a/pkg/common/db/table/admin/limit_user_login_ip.go +++ b/pkg/common/db/table/admin/limit_user_login_ip.go @@ -16,8 +16,8 @@ package admin import ( "context" - "github.com/OpenIMSDK/tools/pagination" "time" + ) // 限制userID只能在某些ip登录. diff --git a/pkg/common/db/table/admin/register_add_friend.go b/pkg/common/db/table/admin/register_add_friend.go index b00df718..d1c8f320 100644 --- a/pkg/common/db/table/admin/register_add_friend.go +++ b/pkg/common/db/table/admin/register_add_friend.go @@ -16,8 +16,8 @@ package admin import ( "context" - "github.com/OpenIMSDK/tools/pagination" "time" + ) // RegisterAddFriend 注册时默认好友. diff --git a/pkg/common/db/table/admin/register_add_group.go b/pkg/common/db/table/admin/register_add_group.go index 93ce7475..68eb0e05 100644 --- a/pkg/common/db/table/admin/register_add_group.go +++ b/pkg/common/db/table/admin/register_add_group.go @@ -16,8 +16,8 @@ package admin import ( "context" - "github.com/OpenIMSDK/tools/pagination" "time" + ) // RegisterAddGroup 注册时默认群组. diff --git a/pkg/common/db/table/chat/attribute.go b/pkg/common/db/table/chat/attribute.go index 19d55ea2..a5123f92 100644 --- a/pkg/common/db/table/chat/attribute.go +++ b/pkg/common/db/table/chat/attribute.go @@ -16,8 +16,8 @@ package chat import ( "context" - "github.com/OpenIMSDK/tools/pagination" "time" + ) // Attribute 用户属性表. @@ -46,7 +46,7 @@ func (Attribute) TableName() string { } type AttributeInterface interface { - //NewTx(tx any) AttributeInterface + // NewTx(tx any) AttributeInterface Create(ctx context.Context, attribute ...*Attribute) error Update(ctx context.Context, userID string, data map[string]any) error Find(ctx context.Context, userIds []string) ([]*Attribute, error) diff --git a/pkg/common/db/table/chat/log.go b/pkg/common/db/table/chat/log.go index fa94018b..7c1226a9 100644 --- a/pkg/common/db/table/chat/log.go +++ b/pkg/common/db/table/chat/log.go @@ -16,8 +16,8 @@ package chat import ( "context" - "github.com/OpenIMSDK/tools/pagination" "time" + ) type Log struct { diff --git a/pkg/common/db/table/chat/register.go b/pkg/common/db/table/chat/register.go index 72d51436..5db5a1c7 100644 --- a/pkg/common/db/table/chat/register.go +++ b/pkg/common/db/table/chat/register.go @@ -35,7 +35,7 @@ func (Register) TableName() string { } type RegisterInterface interface { - //NewTx(tx any) RegisterInterface + // NewTx(tx any) RegisterInterface Create(ctx context.Context, registers ...*Register) error CountTotal(ctx context.Context, before *time.Time) (int64, error) } diff --git a/pkg/common/db/table/chat/user_login_record.go b/pkg/common/db/table/chat/user_login_record.go index 1bae166e..5c5383a8 100644 --- a/pkg/common/db/table/chat/user_login_record.go +++ b/pkg/common/db/table/chat/user_login_record.go @@ -33,7 +33,7 @@ func (UserLoginRecord) TableName() string { } type UserLoginRecordInterface interface { - //NewTx(tx any) UserLoginRecordInterface + // NewTx(tx any) UserLoginRecordInterface Create(ctx context.Context, records ...*UserLoginRecord) error CountTotal(ctx context.Context, before *time.Time) (int64, error) CountRangeEverydayTotal(ctx context.Context, start *time.Time, end *time.Time) (map[string]int64, int64, error) diff --git a/pkg/common/dbconn/mongo.go b/pkg/common/dbconn/mongo.go index fd6ab9a8..2dbcadca 100644 --- a/pkg/common/dbconn/mongo.go +++ b/pkg/common/dbconn/mongo.go @@ -3,14 +3,15 @@ package dbconn import ( "context" "fmt" + "os" + "strings" + "time" + "github.com/OpenIMSDK/chat/pkg/common/config" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/mw/specialerror" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "os" - "strings" - "time" ) const ( diff --git a/pkg/common/rtc/gene_token.go b/pkg/common/rtc/gene_token.go index efa9e721..8980a413 100644 --- a/pkg/common/rtc/gene_token.go +++ b/pkg/common/rtc/gene_token.go @@ -19,7 +19,7 @@ func GetLiveKitToken(room string, identity string) (string, error) { token, err := geneLiveKitToken(apiKey, apiSecret, room, identity) - //fmt.Printf("livekit token=%s\n", token) + // fmt.Printf("livekit token=%s\n", token) return token, err } diff --git a/pkg/common/version/base.go b/pkg/common/version/base.go index 0ca04cd8..5addbb03 100644 --- a/pkg/common/version/base.go +++ b/pkg/common/version/base.go @@ -29,7 +29,7 @@ package version // When releasing a new Kubernetes version, this file is updated by // build/mark_new_version.sh to reflect the new version, and then a // git annotated tag (using format vX.Y where X == Major version and Y -// == Minor version) is created to point to the commit that updates +// == Minor version) is created to point to the commit that updates. var ( // TODO: Deprecate gitMajor and gitMinor, use only gitVersion // instead. First step in deprecation, keep the fields but make @@ -55,7 +55,7 @@ var ( // directory. See also https://git-scm.com/docs/gitattributes gitVersion string = "latest" gitCommit string = "" // sha1 from git, output of $(git rev-parse HEAD) - gitTreeState string = "" // state of git tree, either "clean" or "dirty" + gitTreeState string = "" // state of git tree, either "clean" or "dirty" buildDate string = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') -) \ No newline at end of file +) diff --git a/pkg/common/version/types.go b/pkg/common/version/types.go index c2bd8bb4..bc6b7c4d 100644 --- a/pkg/common/version/types.go +++ b/pkg/common/version/types.go @@ -31,4 +31,4 @@ type Info struct { // String returns info as a human-friendly version string. func (info Info) String() string { return info.GitVersion -} \ No newline at end of file +} diff --git a/pkg/common/version/version.go b/pkg/common/version/version.go index 24cfee7a..b8498882 100644 --- a/pkg/common/version/version.go +++ b/pkg/common/version/version.go @@ -36,17 +36,17 @@ func Get() Info { } } -// GetSingleVersion returns single version of sealer +// GetSingleVersion returns single version of sealer. func GetSingleVersion() string { return gitVersion } type Output struct { - OpenIMChatVersion Info `json:"OpenIMChatVersion,omitempty" yaml:"OpenIMChatVersion,omitempty"` - OpenIMServerVersion *OpenIMServerVersion `json:"OpenIMServerVersion,omitempty" yaml:"OpenIMServerVersion,omitempty"` + OpenIMChatVersion Info `json:"OpenIMChatVersion,omitempty" yaml:"OpenIMChatVersion,omitempty"` + OpenIMServerVersion *OpenIMServerVersion `json:"OpenIMServerVersion,omitempty" yaml:"OpenIMServerVersion,omitempty"` } type OpenIMServerVersion struct { ServerVersion string `json:"serverVersion,omitempty" yaml:"serverVersion,omitempty"` - ClientVersion string `json:"clientVersion,omitempty" yaml:"clientVersion,omitempty"` //sdk core version -} \ No newline at end of file + ClientVersion string `json:"clientVersion,omitempty" yaml:"clientVersion,omitempty"` //sdk core version +} diff --git a/pkg/common/xlsx/main.go b/pkg/common/xlsx/main.go index c170bd19..0f1c7d22 100644 --- a/pkg/common/xlsx/main.go +++ b/pkg/common/xlsx/main.go @@ -2,9 +2,10 @@ package xlsx import ( "errors" - "github.com/xuri/excelize/v2" "io" "reflect" + + "github.com/xuri/excelize/v2" ) func ParseSheet(file *excelize.File, v interface{}) error { diff --git a/pkg/common/xlsx/utils.go b/pkg/common/xlsx/utils.go index 885bb962..f0d2d8be 100644 --- a/pkg/common/xlsx/utils.go +++ b/pkg/common/xlsx/utils.go @@ -3,11 +3,12 @@ package xlsx import ( "errors" "fmt" - "github.com/xuri/excelize/v2" "io" "reflect" "strconv" "strings" + + "github.com/xuri/excelize/v2" ) func Open(r io.Reader) (*excelize.File, error) { @@ -22,22 +23,22 @@ func Num2AZ(num int) string { var ( str string k int - temp []int //保存转化后每一位数据的值,然后通过索引的方式匹配A-Z + temp []int // 保存转化后每一位数据的值,然后通过索引的方式匹配A-Z ) - //用来匹配的字符A-Z + // 用来匹配的字符A-Z slices := []string{"", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"} - if num > 26 { //数据大于26需要进行拆分 + if num > 26 { // 数据大于26需要进行拆分 for { - k = num % 26 //从个位开始拆分,如果求余为0,说明末尾为26,也就是Z,如果是转化为26进制数,则末尾是可以为0的,这里必须为A-Z中的一个 + k = num % 26 // 从个位开始拆分,如果求余为0,说明末尾为26,也就是Z,如果是转化为26进制数,则末尾是可以为0的,这里必须为A-Z中的一个 if k == 0 { temp = append(temp, 26) k = 26 } else { temp = append(temp, k) } - num = (num - k) / 26 //减去num最后一位数的值,因为已经记录在temp中 - if num <= 26 { //小于等于26直接进行匹配,不需要进行数据拆分 + num = (num - k) / 26 // 减去num最后一位数的值,因为已经记录在temp中 + if num <= 26 { // 小于等于26直接进行匹配,不需要进行数据拆分 temp = append(temp, num) break } @@ -46,7 +47,7 @@ func Num2AZ(num int) string { return slices[num] } for _, value := range temp { - str = slices[value] + str //因为数据切分后存储顺序是反的,所以str要放在后面 + str = slices[value] + str // 因为数据切分后存储顺序是反的,所以str要放在后面 } return str } diff --git a/pkg/discovery_register/k8s_discovery_register.go b/pkg/discovery_register/k8s_discovery_register.go index 248beff2..8ad72097 100644 --- a/pkg/discovery_register/k8s_discovery_register.go +++ b/pkg/discovery_register/k8s_discovery_register.go @@ -18,10 +18,13 @@ import ( "context" "errors" "fmt" - "github.com/OpenIMSDK/tools/errs" "strings" "time" + "github.com/OpenIMSDK/tools/errs" + + "github.com/OpenIMSDK/tools/errs" + "github.com/OpenIMSDK/chat/pkg/common/config" "github.com/OpenIMSDK/tools/discoveryregistry" openkeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper" @@ -61,7 +64,7 @@ type K8sDR struct { } func (cli *K8sDR) GetUserIdHashGatewayHost(ctx context.Context, userId string) (string, error) { - //TODO implement me + // TODO implement me panic("implement me") } diff --git a/pkg/email/mail.go b/pkg/email/mail.go index 9c15296e..af0055ef 100644 --- a/pkg/email/mail.go +++ b/pkg/email/mail.go @@ -17,6 +17,7 @@ package email import ( "context" "fmt" + "github.com/OpenIMSDK/chat/pkg/common/config" "github.com/OpenIMSDK/tools/errs" "gopkg.in/gomail.v2" diff --git a/tools/component/component.go b/tools/component/component.go index 8abde4e9..50dacf93 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -17,11 +17,14 @@ package main import ( "flag" "fmt" - "github.com/OpenIMSDK/tools/errs" "os" "strings" "time" + "github.com/OpenIMSDK/tools/errs" + + "github.com/OpenIMSDK/tools/errs" + "github.com/OpenIMSDK/chat/pkg/common/config" component "github.com/OpenIMSDK/tools/component" ) @@ -32,9 +35,7 @@ const ( MaxConnectTimes = 100 ) -var ( - cfgPath = flag.String("config_folder_path", defaultCfgPath, "Path to the configuration file") -) +var cfgPath = flag.String("config_folder_path", defaultCfgPath, "Path to the configuration file") type checkFunc struct { name string @@ -91,7 +92,7 @@ func main() { os.Exit(-1) } -// checkZookeeper checks the Zookeeper connection +// checkZookeeper checks the Zookeeper connection. func checkZookeeper() error { zkStu := &component.Zookeeper{ Schema: config.Config.Zookeeper.Schema, @@ -103,7 +104,7 @@ func checkZookeeper() error { return err } -// checkRedis checks the Redis connection +// checkRedis checks the Redis connection. func checkRedis() error { redisStu := &component.Redis{ Address: *config.Config.Redis.Address, @@ -114,7 +115,7 @@ func checkRedis() error { return err } -// checkMongo checks the MongoDB connection without retries +// checkMongo checks the MongoDB connection without retries. func checkMongo() error { mongoStu := &component.Mongo{ URL: config.Config.Mongo.Uri, diff --git a/tools/mysql2mongo/internal/main.go b/tools/mysql2mongo/internal/main.go index a0d952ae..5507db9c 100644 --- a/tools/mysql2mongo/internal/main.go +++ b/tools/mysql2mongo/internal/main.go @@ -4,6 +4,10 @@ import ( "context" "errors" "fmt" + "os" + "reflect" + "strconv" + "github.com/OpenIMSDK/chat/pkg/common/config" "github.com/OpenIMSDK/chat/pkg/common/db/model/admin" "github.com/OpenIMSDK/chat/pkg/common/db/model/chat" @@ -16,9 +20,6 @@ import ( gormmysql "gorm.io/driver/mysql" "gorm.io/gorm" "gorm.io/gorm/logger" - "os" - "reflect" - "strconv" ) const ( @@ -65,7 +66,7 @@ func getColl(obj any) (_ *mongo.Collection, err error) { return nil, errors.New("not found model collection") } -// NewTask A mysql table B mongodb model C mongodb table +// NewTask A mysql table B mongodb model C mongodb table. func NewTask[A interface{ TableName() string }, B any, C any](gormDB *gorm.DB, mongoDB *mongo.Database, mongoDBInit func(db *mongo.Database) (B, error), convert func(v A) C) error { var zero A tableName := zero.TableName() diff --git a/tools/mysql2mongo/mysql2mongo.go b/tools/mysql2mongo/mysql2mongo.go index b840feef..f5edeffa 100644 --- a/tools/mysql2mongo/mysql2mongo.go +++ b/tools/mysql2mongo/mysql2mongo.go @@ -3,6 +3,7 @@ package main import ( "flag" "fmt" + "github.com/OpenIMSDK/chat/pkg/util" "github.com/OpenIMSDK/chat/tools/mysql2mongo/internal" )