From 781b13c604e97a8951b7d38c0d41438c3f982208 Mon Sep 17 00:00:00 2001 From: withchao <48119764+withchao@users.noreply.github.com> Date: Mon, 28 Aug 2023 11:27:20 +0800 Subject: [PATCH 1/6] fix: default friends and groups, no new sessions triggered (#960) * fix: create group type limit * fix: group notification * fix: group notification * fix: group notification * chore: group member hash * chore: group member hash * chore: group member hash * chore: group member hash * test: log * test: log * test: log * test: log * test: log * sync: hash code * sync: hash code * sync: hash code * test: log * test: log * test: log * test: log * test: log * fix: time stamp * fix: minio sign endpoint opts * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: minio bucket url * fix: op user info * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: importFriends Conversation * fix: importFriends Notification * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: importFriends Notification --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: withchao --- internal/rpc/friend/friend.go | 27 +++++++++++++++++---------- pkg/common/kafka/consumer_group.go | 3 ++- pkg/common/kafka/util.go | 3 ++- pkg/common/tls/tls.go | 1 - pkg/rpcclient/notification/group.go | 21 ++++++++++++++++----- 5 files changed, 37 insertions(+), 18 deletions(-) diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index 00ea68392..0efcd1d81 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -41,11 +41,12 @@ import ( ) type friendServer struct { - friendDatabase controller.FriendDatabase - blackDatabase controller.BlackDatabase - userRpcClient *rpcclient.UserRpcClient - notificationSender *notification.FriendNotificationSender - RegisterCenter registry.SvcDiscoveryRegistry + friendDatabase controller.FriendDatabase + blackDatabase controller.BlackDatabase + userRpcClient *rpcclient.UserRpcClient + notificationSender *notification.FriendNotificationSender + conversationRpcClient rpcclient.ConversationRpcClient + RegisterCenter registry.SvcDiscoveryRegistry } func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error { @@ -79,9 +80,10 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error { blackDB, cache.NewBlackCacheRedis(rdb, blackDB, cache.GetDefaultOpt()), ), - userRpcClient: &userRpcClient, - notificationSender: notificationSender, - RegisterCenter: client, + userRpcClient: &userRpcClient, + notificationSender: notificationSender, + RegisterCenter: client, + conversationRpcClient: rpcclient.NewConversationRpcClient(client), }) return nil } @@ -131,17 +133,22 @@ func (s *friendServer) ImportFriends( if _, err := s.userRpcClient.GetUsersInfo(ctx, append([]string{req.OwnerUserID}, req.FriendUserIDs...)); err != nil { return nil, err } - if utils.Contain(req.OwnerUserID, req.FriendUserIDs...) { return nil, errs.ErrCanNotAddYourself.Wrap() } if utils.Duplicate(req.FriendUserIDs) { return nil, errs.ErrArgs.Wrap("friend userID repeated") } - if err := s.friendDatabase.BecomeFriends(ctx, req.OwnerUserID, req.FriendUserIDs, constant.BecomeFriendByImport); err != nil { return nil, err } + for _, userID := range req.FriendUserIDs { + s.notificationSender.FriendApplicationAgreedNotification(ctx, &pbfriend.RespondFriendApplyReq{ + FromUserID: req.OwnerUserID, + ToUserID: userID, + HandleResult: constant.FriendResponseAgree, + }) + } return &pbfriend.ImportFriendResp{}, nil } diff --git a/pkg/common/kafka/consumer_group.go b/pkg/common/kafka/consumer_group.go index 38b8c041c..da62fbe65 100644 --- a/pkg/common/kafka/consumer_group.go +++ b/pkg/common/kafka/consumer_group.go @@ -17,9 +17,10 @@ package kafka import ( "context" - "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/tools/log" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" + "github.com/Shopify/sarama" ) diff --git a/pkg/common/kafka/util.go b/pkg/common/kafka/util.go index 833757fb8..9d5678648 100644 --- a/pkg/common/kafka/util.go +++ b/pkg/common/kafka/util.go @@ -1,9 +1,10 @@ package kafka import ( + "github.com/Shopify/sarama" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/tls" - "github.com/Shopify/sarama" ) // SetupTLSConfig set up the TLS config from config file. diff --git a/pkg/common/tls/tls.go b/pkg/common/tls/tls.go index 66d3a0e2b..5f84f87e3 100644 --- a/pkg/common/tls/tls.go +++ b/pkg/common/tls/tls.go @@ -10,7 +10,6 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" ) - func decryptPEM(data []byte, passphrase []byte) ([]byte, error) { if len(passphrase) == 0 { return data, nil diff --git a/pkg/rpcclient/notification/group.go b/pkg/rpcclient/notification/group.go index 87c657efb..ee62f08b4 100644 --- a/pkg/rpcclient/notification/group.go +++ b/pkg/rpcclient/notification/group.go @@ -18,6 +18,8 @@ import ( "context" "fmt" + "github.com/OpenIMSDK/Open-IM-Server/pkg/authverify" + "github.com/OpenIMSDK/protocol/constant" pbgroup "github.com/OpenIMSDK/protocol/group" "github.com/OpenIMSDK/protocol/sdkws" @@ -235,11 +237,20 @@ func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws } userID := mcontext.GetOpUserID(ctx) if groupID != "" { - member, err := g.db.TakeGroupMember(ctx, groupID, userID) - if err == nil { - *opUser = g.groupMemberDB2PB(member, 0) - } else if !errs.ErrRecordNotFound.Is(err) { - return err + if authverify.IsManagerUserID(userID) { + *opUser = &sdkws.GroupMemberFullInfo{ + GroupID: groupID, + UserID: userID, + RoleLevel: constant.GroupAdmin, + AppMangerLevel: constant.AppAdmin, + } + } else { + member, err := g.db.TakeGroupMember(ctx, groupID, userID) + if err == nil { + *opUser = g.groupMemberDB2PB(member, 0) + } else if !errs.ErrRecordNotFound.Is(err) { + return err + } } } user, err := g.getUser(ctx, userID) From f4e4bfd6399d3478ec244f81f10dbeef1797c5bd Mon Sep 17 00:00:00 2001 From: John <139604278+g6619563@users.noreply.github.com> Date: Mon, 28 Aug 2023 10:27:49 +0700 Subject: [PATCH 2/6] Update msg.go (#958) fix: send text message by api doesn't work. (#929) --- internal/api/msg.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/api/msg.go b/internal/api/msg.go index ad89742af..2bbae9765 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -170,7 +170,7 @@ func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendM log.ZDebug(c, "getSendMsgReq", "req", req.Content) switch req.ContentType { case constant.Text: - text, ok := req.Content["content"].(string) + text, ok := req.Content["text"].(string) if !ok { return nil, errs.ErrArgs.WithDetail("text is not string") } From 497302c400868f4e7560854f13ced4979870b48e Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751@qq.com> Date: Mon, 28 Aug 2023 11:37:21 +0800 Subject: [PATCH 3/6] feat: Automating openim-docker synchronization (#962) --- .github/sync.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/sync.yml b/.github/sync.yml index 7ffefc79a..ee667d415 100644 --- a/.github/sync.yml +++ b/.github/sync.yml @@ -75,7 +75,7 @@ OpenIMSDK/OpenKF: dest: .github/.codecov.yml replace: false -openim-docker/openim-docker: +OpenIMSDK/openim-docker: - source: ./config dest: ./openim-server/main/config replace: true @@ -85,6 +85,12 @@ openim-docker/openim-docker: - source: ./scripts dest: ./openim-server/main/scripts replace: true + - source: ./scripts + dest: ./scripts + replace: true + - source: ./Makefile + dest: ./Makefile + replace: true group: # first group:common to all warehouses From cc29fc85d8e309159c8c03cfd7b129ac9964c700 Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751@qq.com> Date: Mon, 28 Aug 2023 11:55:29 +0800 Subject: [PATCH 4/6] Create sync-release.yml (#964) --- .github/sync-release.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/sync-release.yml diff --git a/.github/sync-release.yml b/.github/sync-release.yml new file mode 100644 index 000000000..84303603e --- /dev/null +++ b/.github/sync-release.yml @@ -0,0 +1,16 @@ +OpenIMSDK/openim-docker: + - source: ./config + dest: ./openim-server/main/config + replace: true + - source: ./docs + dest: ./openim-server/main/docs + replace: true + - source: ./scripts + dest: ./openim-server/main/scripts + replace: true + - source: ./scripts + dest: ./scripts + replace: true + - source: ./Makefile + dest: ./Makefile + replace: true From 3ecce40b87e99109bcb3e2bccd5dcbab545a45dd Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751@qq.com> Date: Mon, 28 Aug 2023 11:55:50 +0800 Subject: [PATCH 5/6] Create sync-release.yml (#963) --- .github/workflows/sync-release.yml | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/sync-release.yml diff --git a/.github/workflows/sync-release.yml b/.github/workflows/sync-release.yml new file mode 100644 index 000000000..839040aff --- /dev/null +++ b/.github/workflows/sync-release.yml @@ -0,0 +1,43 @@ +# Copyright © 2023 KubeCub open source community. All rights reserved. +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +# https://github.com/BetaHuhn/repo-file-sync-action +name: Synchronize kubecub public code to other repositories +on: + push: + paths: + - scripts/* + - docs/* + - config/* + branches: + - release-v*.* + workflow_dispatch: + +jobs: + sync: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Run GitHub File Sync + uses: BetaHuhn/repo-file-sync-action@latest + with: + GH_INSTALLATION_TOKEN: "${{ secrets.BOT_GITHUB_TOKEN }}" + CONFIG_PATH: .github/sync-release.yml + ORIGINAL_MESSAGE: true + SKIP_PR: true + COMMIT_EACH_FILE: false + COMMIT_BODY: "🤖 kubbot to synchronize the warehouse" + GIT_EMAIL: "3293172751ysy@gmail.com" + GIT_USERNAME: "kubbot" + PR_BODY: 👌 kubecub provides automated community services + REVIEWERS: | + kubbot + cubxxw + PR_LABELS: | + file-sync + automerge + ASSIGNEES: | + kubbot From 5b478e3d632230aa30f6c6a41a80a7a8bbf13f6d Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751@qq.com> Date: Mon, 28 Aug 2023 11:57:46 +0800 Subject: [PATCH 6/6] Update sync-release.yml (#965) --- .github/sync-release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/sync-release.yml b/.github/sync-release.yml index 84303603e..9d111aefd 100644 --- a/.github/sync-release.yml +++ b/.github/sync-release.yml @@ -1,12 +1,12 @@ OpenIMSDK/openim-docker: - source: ./config - dest: ./openim-server/main/config + dest: ./openim-server/release/config replace: true - source: ./docs - dest: ./openim-server/main/docs + dest: ./openim-server/release/docs replace: true - source: ./scripts - dest: ./openim-server/main/scripts + dest: ./openim-server/release/scripts replace: true - source: ./scripts dest: ./scripts