From 44a9724827ec42b6ba13991ee9e4338e4f00421c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Wed, 23 Nov 2022 09:47:24 +0800 Subject: [PATCH 1/7] readme --- README.md | 80 +++++++++++++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 6a3d03465..ff6d83888 100644 --- a/README.md +++ b/README.md @@ -36,75 +36,69 @@ By deployment of the Open-IM-Server on the customer's server, developers can int > Open-IM relies on five open source high-performance components: ETCD, MySQL, MongoDB, Redis, and Kafka. Privatization deployment Before Open-IM-Server, please make sure that the above five components have been installed. If your server does not have the above components, you must first install Missing components. If you have the above components, it is recommended to use them directly. If not, it is recommended to use Docker-compose, no To install dependencies, one-click deployment, faster and more convenient. -#### Source code deployment +#### Deploy using Docker -1. Install [Go environment](https://golang.org/doc/install). Make sure Go version is at least 1.15. +1. Install [Go environment](https://golang.org/doc/install). Make sure Go version is at least 1.17 -2. Clone the Open-IM project to your server. +2. Clone the Open-IM project to your server ``` git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive ``` -3. Build and start Service. +3. Deploy - 1. Shell authorization + 1. Modify env ``` - #cd Open-IM-server/script - - chmod +x *.sh + #cd Open-IM-server + USER=root + PASSWORD=openIM123 #Password with more than 8 digits, excluding special characters + ENDPOINT=http://127.0.0.1:10005 #Replace 127.0.0.1 with Internet IP + DATA_DIR=./ ``` - 2. Execute the build shell - + 2. Deploy && Start + ``` - ./build_all_service.sh + chmod +x install_im_server.sh; + ./install_im_server.sh; ``` - - 3. Start service - - ``` - ./start_all.sh - ``` - + 4. Check service - + ``` - ./check_all.sh + cd script; + ./docker_check_service.sh./check_all.sh ``` - + ![OpenIMServersonSystempng](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/Open-IM-Servers-on-System.png) -#### Docker deployment +#### Deploy using source code -All images are available at https://hub.docker.com/r/lyt1123/open_im_server +1. Go 1.17 or above。 +2. Clone -1. [Install Docker](https://docs.docker.com/install/) 1.13 or above. +```shell +git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive +cd cmd/Open-IM-SDK-Core +git checkout mainCopy to clipboardErrorCopied +``` -2. [Install Docker Compose](https://docs.docker.com/compose/install/) 1.22 or above. +1. Set executable permissions -3. Clone the Open-IM project to your server. +```shell +cd ../../script/ +chmod +x *.shCopy to clipboardErrorCopied +``` - ``` - git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive - ``` +1. build -4. Start docker-compose with one click(Docker automatically pulls all images) +```shell +./batch_build_all_service.shCopy +``` - ``` - cd Open-IM-Server - docker-compose up -d - ``` - -5. Check service - - ``` - ./docker_check_service.sh - ./check_all.sh - ``` - - ![OpenIMServersondockerpng](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/Open-IM-Servers-on-docker.png) +all services build success ### CONFIGURATION INSTRUCTIONS From 10a0666de931085cc263a231dc52ede12c072287 Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Fri, 25 Nov 2022 19:56:28 +0800 Subject: [PATCH 2/7] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ff6d83888..9f9e09ebc 100644 --- a/README.md +++ b/README.md @@ -82,20 +82,20 @@ By deployment of the Open-IM-Server on the customer's server, developers can int ```shell git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive cd cmd/Open-IM-SDK-Core -git checkout mainCopy to clipboardErrorCopied +git checkout main ``` 1. Set executable permissions ```shell cd ../../script/ -chmod +x *.shCopy to clipboardErrorCopied +chmod +x *.sh ``` 1. build ```shell -./batch_build_all_service.shCopy +./batch_build_all_service.sh ``` all services build success From 3013af8e622e5cce763707f504b855505fcd1bd0 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Tue, 13 Dec 2022 12:42:04 +0800 Subject: [PATCH 3/7] upgrade enterprise --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index dac735657..6ba7a43ca 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -139,7 +139,7 @@ services: max-file: "2" open_im_enterprise: - image: openim/open_im_enterprise:v1.0.0 + image: openim/open_im_enterprise:v1.0.1 container_name: open_im_enterprise volumes: - ./logs:/Open-IM-Enterprise/logs From d42d4308e55039405306a787716c6229c76c07ce Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Tue, 13 Dec 2022 13:59:58 +0800 Subject: [PATCH 4/7] upgrade enterprise --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 6ba7a43ca..18c13b274 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -115,7 +115,7 @@ services: open_im_server: - image: openim/open_im_server:v2.3.5 + image: openim/open_im_server:v2.3.6 container_name: open_im_server volumes: - ./logs:/Open-IM-Server/logs From 83f128ddcce878fa13ee267992f3adb39502277b Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Tue, 13 Dec 2022 15:11:42 +0800 Subject: [PATCH 5/7] upgrade open_im_enterprise --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 18c13b274..4188bbdf8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -139,7 +139,7 @@ services: max-file: "2" open_im_enterprise: - image: openim/open_im_enterprise:v1.0.1 + image: openim/open_im_enterprise:v1.0.2 container_name: open_im_enterprise volumes: - ./logs:/Open-IM-Enterprise/logs From 0b9d9fa8d707acca1ba520a67420155f9817cdcb Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 15 Dec 2022 18:43:52 +0800 Subject: [PATCH 6/7] install script --- install_im_server.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/install_im_server.sh b/install_im_server.sh index b2b9b9649..ea641d0f8 100644 --- a/install_im_server.sh +++ b/install_im_server.sh @@ -1,5 +1,14 @@ #!/usr/bin/env bash +internet_ip=`curl ifconfig.me -s` +echo $internet_ip +source .env +echo $MINIO_ENDPOINT +if [ $MINIO_ENDPOINT == "http://127.0.0.1:10005" ]; then + sed -i "s/127.0.0.1/${internet_ip}/" .env + +fi + cd script ; chmod +x *.sh ; ./init_pwd.sh From 920a7cfdac197a592fee7fb32cce26f00c9e0662 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 16 Dec 2022 16:54:18 +0800 Subject: [PATCH 7/7] set groupMemberInfo callback --- config/config.yaml | 2 +- internal/rpc/group/callback.go | 55 +++++++++++++++++++++++++++++++++ internal/rpc/group/group.go | 46 +++++++++++++++++++++++++-- pkg/call_back_struct/group.go | 19 ++++++++++++ pkg/common/config/config.go | 2 +- pkg/common/constant/constant.go | 29 ++++++++--------- 6 files changed, 135 insertions(+), 18 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 966c613f4..474832f34 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -345,7 +345,7 @@ callback: enable: false callbackTimeOut: 2 callbackFailedContinue: true # 回调超时是否继续 - callbackBeforeExtendMsgModify: + callbackBeforeSetGroupMemberInfo: enable: false callbackTimeOut: 2 callbackFailedContinue: true # 回调超时是否继续 diff --git a/internal/rpc/group/callback.go b/internal/rpc/group/callback.go index 90dc63af0..5bf450a69 100644 --- a/internal/rpc/group/callback.go +++ b/internal/rpc/group/callback.go @@ -10,6 +10,8 @@ import ( pbGroup "Open_IM/pkg/proto/group" "Open_IM/pkg/utils" http2 "net/http" + + "google.golang.org/protobuf/types/known/wrapperspb" ) func callbackBeforeCreateGroup(req *pbGroup.CreateGroupReq) cbApi.CommonCallbackResp { @@ -126,3 +128,56 @@ func CallbackBeforeMemberJoinGroup(operationID string, groupMember *db.GroupMemb } return callbackResp } + +func CallbackBeforeSetGroupMemberInfo(req *pbGroup.SetGroupMemberInfoReq) cbApi.CommonCallbackResp { + callbackResp := cbApi.CommonCallbackResp{OperationID: req.OperationID} + if !config.Config.Callback.CallbackBeforeSetGroupMemberInfo.Enable { + return callbackResp + } + callbackReq := cbApi.CallbackBeforeSetGroupMemberInfoReq{ + CallbackCommand: constant.CallbackBeforeSetGroupMemberInfoCommand, + OperationID: req.OperationID, + GroupID: req.GroupID, + UserID: req.UserID, + } + if req.Nickname != nil { + callbackReq.Nickname = req.Nickname.Value + } + if req.FaceURL != nil { + callbackReq.FaceURL = req.FaceURL.Value + } + if req.RoleLevel != nil { + callbackReq.RoleLevel = req.RoleLevel.Value + } + if req.Ex != nil { + callbackReq.Ex = req.Ex.Value + } + resp := &cbApi.CallbackBeforeSetGroupMemberInfoResp{ + CommonCallbackResp: &callbackResp, + } + + if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSetGroupMemberInfoCommand, callbackReq, resp, config.Config.Callback.CallbackBeforeSetGroupMemberInfo.CallbackTimeOut); err != nil { + callbackResp.ErrCode = http2.StatusInternalServerError + callbackResp.ErrMsg = err.Error() + if !config.Config.Callback.CallbackBeforeSetGroupMemberInfo.CallbackFailedContinue { + callbackResp.ActionCode = constant.ActionForbidden + return callbackResp + } else { + callbackResp.ActionCode = constant.ActionAllow + return callbackResp + } + } + if resp.FaceURL != nil { + req.FaceURL = &wrapperspb.StringValue{Value: *resp.FaceURL} + } + if resp.Nickname != nil { + req.Nickname = &wrapperspb.StringValue{Value: *resp.Nickname} + } + if resp.RoleLevel != nil { + req.RoleLevel = &wrapperspb.Int32Value{Value: *resp.RoleLevel} + } + if resp.Ex != nil { + req.Ex = &wrapperspb.StringValue{Value: *resp.Ex} + } + return callbackResp +} diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 64cddba02..4d68582e5 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -30,6 +30,7 @@ import ( grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus" "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/wrapperspb" "gorm.io/gorm" ) @@ -1765,11 +1766,35 @@ func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.S log.Error(req.OperationID, errMsg) return &pbGroup.SetGroupMemberNicknameResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil } + cbReq := &pbGroup.SetGroupMemberInfoReq{ + GroupID: req.GroupID, + UserID: req.UserID, + OperationID: req.OperationID, + OpUserID: req.OpUserID, + Nickname: &wrapperspb.StringValue{Value: req.Nickname}, + } + callbackResp := CallbackBeforeSetGroupMemberInfo(cbReq) + if callbackResp.ErrCode != 0 { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "CallbackBeforeMemberJoinGroup resp: ", callbackResp) + } + if callbackResp.ActionCode != constant.ActionAllow { + if callbackResp.ErrCode == 0 { + callbackResp.ErrCode = 201 + } + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CallbackBeforeMemberJoinGroup result", "end rpc and return", callbackResp) + return &pbGroup.SetGroupMemberNicknameResp{ + CommonResp: &pbGroup.CommonResp{ + ErrCode: int32(callbackResp.ErrCode), + ErrMsg: callbackResp.ErrMsg, + }, + }, nil + } + nickName := cbReq.Nickname.Value groupMemberInfo := db.GroupMember{} groupMemberInfo.UserID = req.UserID groupMemberInfo.GroupID = req.GroupID - if req.Nickname == "" { + if nickName == "" { userNickname, err := imdb.GetUserNameByUserID(groupMemberInfo.UserID) if err != nil { errMsg := req.OperationID + " GetUserNameByUserID failed " + err.Error() @@ -1778,7 +1803,7 @@ func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.S } groupMemberInfo.Nickname = userNickname } else { - groupMemberInfo.Nickname = req.Nickname + groupMemberInfo.Nickname = nickName } if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil { @@ -1805,6 +1830,23 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr resp.CommonResp.ErrMsg = err.Error() return resp, nil } + callbackResp := CallbackBeforeSetGroupMemberInfo(req) + if callbackResp.ErrCode != 0 { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "CallbackBeforeMemberJoinGroup resp: ", callbackResp) + } + if callbackResp.ActionCode != constant.ActionAllow { + if callbackResp.ErrCode == 0 { + callbackResp.ErrCode = 201 + } + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CallbackBeforeMemberJoinGroup result", "end rpc and return", callbackResp) + return &pbGroup.SetGroupMemberInfoResp{ + CommonResp: &pbGroup.CommonResp{ + ErrCode: int32(callbackResp.ErrCode), + ErrMsg: callbackResp.ErrMsg, + }, + }, nil + } + groupMember := db.GroupMember{ GroupID: req.GroupID, UserID: req.UserID, diff --git a/pkg/call_back_struct/group.go b/pkg/call_back_struct/group.go index 33a18d9c0..a040adcf0 100644 --- a/pkg/call_back_struct/group.go +++ b/pkg/call_back_struct/group.go @@ -46,3 +46,22 @@ type CallbackBeforeMemberJoinGroupResp struct { MuteEndTime *int64 `json:"muteEndTime"` Ex *string `json:"ex"` } + +type CallbackBeforeSetGroupMemberInfoReq struct { + CallbackCommand string `json:"callbackCommand"` + OperationID string `json:"operationID"` + GroupID string `json:"groupID"` + UserID string `json:"userID"` + Nickname string `json:"nickName"` + FaceURL string `json:"faceURL"` + RoleLevel int32 `json:"roleLevel"` + Ex string `json:"ex"` +} + +type CallbackBeforeSetGroupMemberInfoResp struct { + *CommonCallbackResp + Ex *string `json:"ex"` + Nickname *string `json:"nickName"` + FaceURL *string `json:"faceURL"` + RoleLevel *int32 `json:"roleLevel"` +} diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 855d5c6fb..32ad9391b 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -292,7 +292,7 @@ type config struct { CallbackBeforeAddFriend callBackConfig `yaml:"callbackBeforeAddFriend"` CallbackBeforeCreateGroup callBackConfig `yaml:"callbackBeforeCreateGroup"` CallbackBeforeMemberJoinGroup callBackConfig `yaml:"callbackBeforeMemberJoinGroup"` - CallbackBeforeExtendMsgModify callBackConfig `yaml:"callbackBeforeExtendMsgModify"` + CallbackBeforeSetGroupMemberInfo callBackConfig `yaml:"callbackBeforeSetGroupMemberInfo"` } `yaml:"callback"` Notification struct { ///////////////////////group///////////////////////////// diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go index ff2e0097f..250bf5856 100644 --- a/pkg/common/constant/constant.go +++ b/pkg/common/constant/constant.go @@ -202,20 +202,21 @@ const ( VerificationCodeForResetSuffix = "_forReset" //callbackCommand - CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand" - CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand" - CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand" - CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand" - CallbackMsgModifyCommand = "callbackMsgModifyCommand" - CallbackUserOnlineCommand = "callbackUserOnlineCommand" - CallbackUserOfflineCommand = "callbackUserOfflineCommand" - CallbackUserKickOffCommand = "callbackUserKickOffCommand" - CallbackOfflinePushCommand = "callbackOfflinePushCommand" - CallbackOnlinePushCommand = "callbackOnlinePushCommand" - CallbackSuperGroupOnlinePushCommand = "callbackSuperGroupOnlinePushCommand" - CallbackBeforeAddFriendCommand = "callbackBeforeAddFriendCommand" - CallbackBeforeCreateGroupCommand = "callbackBeforeCreateGroupCommand" - CallbackBeforeMemberJoinGroupCommand = "callbackBeforeMemberJoinGroupCommand" + CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand" + CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand" + CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand" + CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand" + CallbackMsgModifyCommand = "callbackMsgModifyCommand" + CallbackUserOnlineCommand = "callbackUserOnlineCommand" + CallbackUserOfflineCommand = "callbackUserOfflineCommand" + CallbackUserKickOffCommand = "callbackUserKickOffCommand" + CallbackOfflinePushCommand = "callbackOfflinePushCommand" + CallbackOnlinePushCommand = "callbackOnlinePushCommand" + CallbackSuperGroupOnlinePushCommand = "callbackSuperGroupOnlinePushCommand" + CallbackBeforeAddFriendCommand = "callbackBeforeAddFriendCommand" + CallbackBeforeCreateGroupCommand = "callbackBeforeCreateGroupCommand" + CallbackBeforeMemberJoinGroupCommand = "callbackBeforeMemberJoinGroupCommand" + CallbackBeforeSetGroupMemberInfoCommand = "CallbackBeforeSetGroupMemberInfoCommand" //callback actionCode ActionAllow = 0