From 788b381508fbf65f3fd0bc3342d28b628716abfe Mon Sep 17 00:00:00 2001 From: WangchuXiao Date: Fri, 28 Jul 2023 21:43:29 +0800 Subject: [PATCH 1/4] fix bug: When the previously applied group has a disbanded group, applying to add the group again will fail (#698) * docs: add readme docs Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add script yaml Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add script yaml Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix bug: reject group req bug * feat: add go relase Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix bug: join group failed * fix bug: join group failed --------- Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> Co-authored-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --- internal/rpc/group/group.go | 2 +- pkg/common/db/controller/group.go | 5 +++++ pkg/common/db/relation/group_model.go | 4 ++++ pkg/common/db/table/relation/group.go | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 65beae37e..a7680dfaa 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -1040,7 +1040,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou groupIDs := utils.Distinct(utils.Slice(requests, func(e *relationTb.GroupRequestModel) string { return e.GroupID })) - groups, err := s.GroupDatabase.FindGroup(ctx, groupIDs) + groups, err := s.GroupDatabase.FindNotDismissedGroup(ctx, groupIDs) if err != nil { return nil, err } diff --git a/pkg/common/db/controller/group.go b/pkg/common/db/controller/group.go index e2b5f90b3..ba4ae18df 100644 --- a/pkg/common/db/controller/group.go +++ b/pkg/common/db/controller/group.go @@ -39,6 +39,7 @@ type GroupDatabase interface { CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) + FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) SearchGroup( ctx context.Context, keyword string, @@ -581,3 +582,7 @@ func (g *groupDatabase) CountRangeEverydayTotal(ctx context.Context, start time. func (g *groupDatabase) FindGroupRequests(ctx context.Context, groupID string, userIDs []string) (int64, []*relationTb.GroupRequestModel, error) { return g.groupRequestDB.FindGroupRequests(ctx, groupID, userIDs) } + +func (g *groupDatabase) FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) { + return g.groupDB.FindNotDismissedGroup(ctx, groupIDs) +} diff --git a/pkg/common/db/relation/group_model.go b/pkg/common/db/relation/group_model.go index 697427e04..853f5dccd 100644 --- a/pkg/common/db/relation/group_model.go +++ b/pkg/common/db/relation/group_model.go @@ -99,3 +99,7 @@ func (g *GroupGorm) CountRangeEverydayTotal(ctx context.Context, start time.Time } return v, nil } + +func (g *GroupGorm) FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relation.GroupModel, err error) { + return groups, utils.Wrap(g.DB.Where("group_id in (?) and status != ?", groupIDs, constant.GroupStatusDismissed).Find(&groups).Error, "") +} diff --git a/pkg/common/db/table/relation/group.go b/pkg/common/db/table/relation/group.go index 2bafb53ec..6759e0d35 100644 --- a/pkg/common/db/table/relation/group.go +++ b/pkg/common/db/table/relation/group.go @@ -51,6 +51,7 @@ type GroupModelInterface interface { UpdateMap(ctx context.Context, groupID string, args map[string]interface{}) (err error) UpdateStatus(ctx context.Context, groupID string, status int32) (err error) Find(ctx context.Context, groupIDs []string) (groups []*GroupModel, err error) + FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*GroupModel, err error) Take(ctx context.Context, groupID string) (group *GroupModel, err error) Search( ctx context.Context, From a5eb4dd499181146fbe0509a2a6d3d8887d25d12 Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751@qq.com> Date: Fri, 28 Jul 2023 22:49:55 +0800 Subject: [PATCH 2/4] fix: docker images (#701) Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --- .env | 4 ++-- Dockerfile | 4 ++-- docker-compose.yaml | 4 ++-- scripts/make-rules/golang.mk | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.env b/.env index 910d864b8..412b75076 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ USER=root PASSWORD=openIM123 -MINIO_ENDPOINT=http://113.99.98.99:10005 -API_URL=http://113.99.98.99:10002/object/ +MINIO_ENDPOINT=http://127.0.0.1:10005 +API_URL=http://127.0.0.1:10002/object/ DATA_DIR=./ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8a230a431..85afdf98b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ RUN /bin/sh -c "make build" FROM alpine RUN echo "https://mirrors.aliyun.com/alpine/v3.4/main" > /etc/apk/repositories && \ - apk --no-cache add tzdata ca-certificates + apk --no-cache add tzdata ca-certificates bash # Set directory to map logs, config files, scripts, and SDK VOLUME ["/Open-IM-Server/logs", "/Open-IM-Server/config", "/Open-IM-Server/scripts", "/Open-IM-Server/db/sdk"] @@ -34,4 +34,4 @@ COPY --from=builder /Open-IM-Server/_output/bin/platforms/linux/amd64 /Open-IM-S WORKDIR /Open-IM-Server/scripts -CMD ["docker_start_all.sh"] \ No newline at end of file +CMD ["./docker_start_all.sh"] \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index cd80dbf19..d5565ca52 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -100,7 +100,7 @@ services: openim_server: - image: ghcr.io/openimsdk/openim-server:v3.0 + image: ghcr.io/openimsdk/openim-server:v3.1.0 container_name: openim-server volumes: - ./logs:/Open-IM-Server/logs @@ -124,7 +124,7 @@ services: max-file: "2" openim_chat: - image: ghcr.io/openimsdk/openim-chat:v1.0.0 + image: ghcr.io/openimsdk/openim-chat:v1.1.0 container_name: openim_chat restart: always depends_on: diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk index 00e0fee47..aebf70e68 100644 --- a/scripts/make-rules/golang.mk +++ b/scripts/make-rules/golang.mk @@ -131,11 +131,11 @@ go.build.%: $(BIN_DIR)/platforms/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_DIR)/cmd/$(COMMAND)/main.go; \ fi -## go.install: Install deployment openim -.PHONY: go.install -go.install: - @echo "===========> Installing deployment openim" - @$(ROOT_DIR)/scripts/install_im_server.sh +# ## go.install: Install deployment openim +# .PHONY: go.install +# go.install: +# @echo "===========> Installing deployment openim" +# @$(ROOT_DIR)/scripts/install_im_server.sh ## go.check: Check OpenIM deployment .PHONY: go.check From f894a4546e54562a8bc823d3791b7a5edff10ebe Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Sat, 29 Jul 2023 12:15:12 +0800 Subject: [PATCH 3/4] fix: get userid function call rpc and message gateway add status change callback (#699) * fix: to start im or chat, ZooKeeper must be started first. * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * fix: msg gateway start output err info Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: go mod update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * chore: package path changes Signed-off-by: withchao <993506633@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: token update Signed-off-by: Gordon <1432970085@qq.com> * fix: get all userID Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> * fix: msggateway add online status call Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --------- Signed-off-by: Gordon <1432970085@qq.com> Signed-off-by: withchao <993506633@qq.com> Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com> Co-authored-by: withchao <993506633@qq.com> --- go.mod | 2 +- go.sum | 4 ++-- internal/api/user.go | 2 +- internal/msggateway/n_ws_server.go | 35 +++++++++++++++++++++++------- pkg/rpcclient/user.go | 4 ++++ 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index c18eabd08..c7a2b8309 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( require github.com/google/uuid v1.3.0 require ( - github.com/OpenIMSDK/protocol v0.0.2 + github.com/OpenIMSDK/protocol v0.0.3 github.com/OpenIMSDK/tools v0.0.5 github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible github.com/go-redis/redis v6.15.9+incompatible diff --git a/go.sum b/go.sum index a93a1687a..2ad7b17ff 100644 --- a/go.sum +++ b/go.sum @@ -16,8 +16,8 @@ cloud.google.com/go/storage v1.28.1/go.mod h1:Qnisd4CqDdo6BGs2AD5LLnEsmSQ80wQ5og firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4= firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/OpenIMSDK/protocol v0.0.2 h1:O53/WiqLCHF9aWPLI32GPF82hn7suM8PkhrtL89Klrw= -github.com/OpenIMSDK/protocol v0.0.2/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= +github.com/OpenIMSDK/protocol v0.0.3 h1:CFQtmnyW+1dYKVFaVaHcJ6oYuMiMdNfU2gC1xz3K/9I= +github.com/OpenIMSDK/protocol v0.0.3/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= github.com/OpenIMSDK/tools v0.0.5 h1:yBVHJ3EpIDcp8VFKPjuGr6MQvFa3t4JByZ+vmeC06/Q= github.com/OpenIMSDK/tools v0.0.5/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= diff --git a/internal/api/user.go b/internal/api/user.go index 3eb136b3d..41f6fd4c9 100644 --- a/internal/api/user.go +++ b/internal/api/user.go @@ -51,7 +51,7 @@ func (u *UserApi) GetUsersPublicInfo(c *gin.Context) { } func (u *UserApi) GetAllUsersID(c *gin.Context) { - a2r.Call(user.UserClient.GetDesignateUsers, u.Client, c) + a2r.Call(user.UserClient.GetAllUserID, u.Client, c) } func (u *UserApi) AccountCheck(c *gin.Context) { diff --git a/internal/msggateway/n_ws_server.go b/internal/msggateway/n_ws_server.go index c324f8a22..67c8132ca 100644 --- a/internal/msggateway/n_ws_server.go +++ b/internal/msggateway/n_ws_server.go @@ -18,6 +18,7 @@ import ( "context" "errors" "github.com/OpenIMSDK/Open-IM-Server/pkg/authverify" + "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "net/http" "strconv" "sync" @@ -74,6 +75,7 @@ type WsServer struct { hubServer *Server validate *validator.Validate cache cache.MsgModel + userClient *rpcclient.UserRpcClient Compressor Encoder MessageHandler @@ -86,6 +88,28 @@ type kickHandler struct { func (ws *WsServer) SetDiscoveryRegistry(client discoveryregistry.SvcDiscoveryRegistry) { ws.MessageHandler = NewGrpcHandler(ws.validate, client) + u := rpcclient.NewUserRpcClient(client) + ws.userClient = &u +} +func (ws *WsServer) SetUserOnlineStatus(ctx context.Context, client *Client, status int32) { + err := ws.userClient.SetUserStatus(ctx, client.UserID, status, client.PlatformID) + if err != nil { + log.ZWarn(ctx, "SetUserStatus err", err) + } + switch status { + case constant.Online: + err := CallbackUserOnline(ctx, client.UserID, client.PlatformID, client.IsBackground, client.ctx.GetConnID()) + if err != nil { + log.ZWarn(ctx, "CallbackUserOnline err", err) + } + case constant.Offline: + err := CallbackUserOffline(ctx, client.UserID, client.PlatformID, client.ctx.GetConnID()) + if err != nil { + log.ZWarn(ctx, "CallbackUserOffline err", err) + } + + } + } func (ws *WsServer) SetCacheHandler(cache cache.MsgModel) { @@ -186,6 +210,7 @@ func (ws *WsServer) registerClient(client *Client) { atomic.AddInt64(&ws.onlineUserConnNum, 1) } } + ws.SetUserOnlineStatus(client.ctx, client, constant.Online) log.ZInfo( client.ctx, "user online", @@ -292,14 +317,8 @@ func (ws *WsServer) unregisterClient(client *Client) { atomic.AddInt64(&ws.onlineUserNum, -1) } atomic.AddInt64(&ws.onlineUserConnNum, -1) - log.ZInfo( - client.ctx, - "user offline", - "close reason", - client.closedErr, - "online user Num", - ws.onlineUserNum, - "online user conn Num", + ws.SetUserOnlineStatus(client.ctx, client, constant.Offline) + log.ZInfo(client.ctx, "user offline", "close reason", client.closedErr, "online user Num", ws.onlineUserNum, "online user conn Num", ws.onlineUserConnNum, ) } diff --git a/pkg/rpcclient/user.go b/pkg/rpcclient/user.go index 1ce4fd53c..6ca60dc75 100644 --- a/pkg/rpcclient/user.go +++ b/pkg/rpcclient/user.go @@ -154,3 +154,7 @@ func (u *UserRpcClient) GetAllUserIDs(ctx context.Context, pageNumber, showNumbe } return resp.UserIDs, nil } +func (u *UserRpcClient) SetUserStatus(ctx context.Context, userID string, status int32, platformID int) error { + _, err := u.Client.SetUserStatus(ctx, &user.SetUserStatusReq{StatusList: []*user.OnlineStatus{{UserID: userID, Status: status, PlatformID: int32(platformID)}}}) + return err +} From 1ec33afe3f3549c2ee329f74a7ea147910edf002 Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751@qq.com> Date: Sat, 29 Jul 2023 14:07:59 +0800 Subject: [PATCH 4/4] Update version.md (#703) --- docs/conversions/version.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/conversions/version.md b/docs/conversions/version.md index bf1062b77..8c6caf5ec 100644 --- a/docs/conversions/version.md +++ b/docs/conversions/version.md @@ -14,6 +14,10 @@ In the OpenIM repository, the versioning adheres to the `MAJOR.MINOR.PATCH` form ## Milestones and Branching ++ [OpenIM Milestones](https://github.com/OpenIMSDK/Open-IM-Server/milestones) ++ [OpenIM Tags](https://github.com/OpenIMSDK/Open-IM-Server/tags) ++ [OpenIM Branches](https://github.com/OpenIMSDK/Open-IM-Server/branches) + When a significant milestone like v3.1.0 is achieved, a new branch `release-v3.1` is created. This branch contains all the code pertaining to this stable release. All bug fixes and features intended for the next version, v3.2.0, are merged into this branch. The release of `PATCH` versions (Z in `X.Y.Z`) are driven by bug fixes, and these can be rolled out depending on the bug's priority or over a scheduled time. On the other hand, `MINOR` versions (Y in `X.Y.Z`) are released based on the project's roadmap, milestone completion, or on a scheduled timeline. Importantly, the API of minor versions is always backward-compatible. @@ -59,3 +63,4 @@ Remember, communication with your team is key throughout this process, keeping e ## Docker images version management ++ [OpenIM Docker Images Administration](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/images.md)