From f17c3982d3c7faa01e40529bbb7912c0be16f4cb Mon Sep 17 00:00:00 2001 From: withchao <48119764+withchao@users.noreply.github.com> Date: Wed, 20 Sep 2023 14:44:36 +0800 Subject: [PATCH 1/3] fix: admin face_url length too short (#205) * fix: im api UserToken error non-responsive body * fix: set rand seed * fix: set rand seed * update version * fix: optimize error code * fix: optimize error code * fix: chat admin userID * fix: chat admin userID * fix: chat admin userID * feat: add SearchFriend * feat: add SearchFriend * feat: add SearchFriend * feat: add SearchFriend * feat: add SearchFriend * fix: admin char length * fix: phone already register code --- internal/rpc/chat/login.go | 2 +- pkg/common/db/table/admin/admin.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/rpc/chat/login.go b/internal/rpc/chat/login.go index b0edf91af..a70c125d0 100644 --- a/internal/rpc/chat/login.go +++ b/internal/rpc/chat/login.go @@ -62,7 +62,7 @@ func (o *chatSvr) SendVerifyCode(ctx context.Context, req *chat.SendVerifyCodeRe } _, err := o.Database.TakeAttributeByPhone(ctx, req.AreaCode, req.PhoneNumber) if err == nil { - return nil, errs.ErrArgs.Wrap("phone already register") + return nil, eerrs.ErrPhoneAlreadyRegister.Wrap("phone already register") } else if !o.Database.IsNotFound(err) { return nil, err } diff --git a/pkg/common/db/table/admin/admin.go b/pkg/common/db/table/admin/admin.go index f915174e7..41500f576 100644 --- a/pkg/common/db/table/admin/admin.go +++ b/pkg/common/db/table/admin/admin.go @@ -21,11 +21,11 @@ import ( // Admin 后台管理员. type Admin struct { - Account string `gorm:"column:account;primary_key;type:char(64)"` - Password string `gorm:"column:password;type:char(64)"` - FaceURL string `gorm:"column:face_url;type:char(64)"` - Nickname string `gorm:"column:nickname;type:char(64)"` - UserID string `gorm:"column:user_id;type:char(64)"` // openIM userID + Account string `gorm:"column:account;primary_key;type:varchar(64)"` + Password string `gorm:"column:password;type:varchar(64)"` + FaceURL string `gorm:"column:face_url;type:varchar(255)"` + Nickname string `gorm:"column:nickname;type:varchar(64)"` + UserID string `gorm:"column:user_id;type:varchar(64)"` // openIM userID Level int32 `gorm:"column:level;default:1" ` CreateTime time.Time `gorm:"column:create_time"` } From 99834ac1ecd6fbab1945b516e3454cb9d270bf1d Mon Sep 17 00:00:00 2001 From: CNCSMonster <99234657+CNCSMonster@users.noreply.github.com> Date: Wed, 20 Sep 2023 14:51:50 +0800 Subject: [PATCH 2/3] feat: make listening only after connection to components prepared (#214) * feat: make listening only when connection to components prepared * feat: use utils.Wrap1 to srround ret err --- pkg/common/chatrpcstart/start.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/common/chatrpcstart/start.go b/pkg/common/chatrpcstart/start.go index d3575d9e7..882487da5 100644 --- a/pkg/common/chatrpcstart/start.go +++ b/pkg/common/chatrpcstart/start.go @@ -35,11 +35,7 @@ import ( func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error, options ...grpc.ServerOption) error { fmt.Println("start", rpcRegisterName, "server, port: ", rpcPort, "prometheusPort:", prometheusPort, ", OpenIM version: ", config.Version) - listener, err := net.Listen("tcp", net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort))) - if err != nil { - return err - } - defer listener.Close() + zkClient, 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())) @@ -50,7 +46,7 @@ func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c zkClient.AddOption(chatMw.AddUserType(), mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials())) registerIP, err := network.GetRpcRegisterIP(config.Config.Rpc.RegisterIP) if err != nil { - return err + return utils.Wrap1(err) } srv := grpc.NewServer(append(options, mw.GrpcServer())...) defer srv.GracefulStop() @@ -62,5 +58,10 @@ func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c if err != nil { return utils.Wrap1(err) } + listener, err := net.Listen("tcp", net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort))) + if err != nil { + return utils.Wrap1(err) + } + defer listener.Close() return utils.Wrap1(srv.Serve(listener)) } From 72bb2d5c81d2ff99ac9cac2bdfe0a300ace59fc1 Mon Sep 17 00:00:00 2001 From: CNCSMonster <99234657+CNCSMonster@users.noreply.github.com> Date: Tue, 10 Oct 2023 15:59:41 +0800 Subject: [PATCH 3/3] Feat/fixscript:check and build binary if needed when make start (#224) * feat: make listening only when connection to components prepared * feat: use utils.Wrap1 to srround ret err * feat:check and build binary if needed when make start --- scripts/start_all.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/start_all.sh b/scripts/start_all.sh index b2ee16214..c0616ebf0 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -89,8 +89,14 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do list_to_string ${portList} service_ports=($ports_array) + #Start related rpc services based on the number of ports for ((j = 0; j < ${#service_ports[*]}; j++)); do + if [ ! -e "$bin_dir/${service_filename[$i]}" ]; then + echo -e ${RED_PREFIX}"Error: ${service_filename[$i]} does not exist,Start fail!"${COLOR_SUFFIX} + echo "start build these binary" + "./build_all_service.sh" + fi #Start the service in the background cmd="$bin_dir/${service_filename[$i]} -port ${service_ports[$j]} --config_folder_path ${config_path}" if [ $i -eq 0 -o $i -eq 1 ]; then @@ -102,4 +108,4 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do # pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" # echo -e "${GREEN_PREFIX}${service_filename[$i]} start success,port number:${service_ports[$j]} pid:$(eval $pid)$COLOR_SUFFIX" done -done \ No newline at end of file +done