From d2ec39ed7efb5eeee5f93af00afc4aa386697cb3 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Mon, 14 Aug 2023 10:40:34 +0000 Subject: [PATCH] Initialize Online field and reintroduce checks in SetConversations --- internal/rpc/conversation/conversaion.go | 27 ++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/internal/rpc/conversation/conversaion.go b/internal/rpc/conversation/conversaion.go index b48a3fc8d..10d21165a 100644 --- a/internal/rpc/conversation/conversaion.go +++ b/internal/rpc/conversation/conversaion.go @@ -64,6 +64,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e conversationNotificationSender: notification.NewConversationNotificationSender(&msgRpcClient), groupRpcClient: &groupRpcClient, conversationDatabase: controller.NewConversationDatabase(conversationDB, cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), conversationDB), tx.NewGorm(db)), + Online: false, }) return nil } @@ -122,19 +123,19 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbConver } if req.Conversation.ConversationType == constant.GroupChatType { groupInfo, err := c.groupRpcClient.GetGroupInfo(ctx, req.Conversation.GroupID) - func (c *conversationServer) SetConversations(ctx context.Context, req *pbConversation.SetConversationsReq) (*pbConversation.SetConversationsResp, error) { - if req.Conversation == nil { - return nil, errs.ErrArgs.Wrap("conversation must not be nil") - } - if req.Conversation.ConversationType == constant.GroupChatType { - groupInfo, err := c.groupRpcClient.GetGroupInfo(ctx, req.Conversation.GroupID) - if err != nil { - return nil, err - } - if groupInfo.Status == constant.GroupStatusDismissed { - return nil, err - } - } + if err != nil { + return nil, err + } + if groupInfo.Status == constant.GroupStatusDismissed { + return nil, err + } + for _, userID := range req.UserIDs { + if _, err := c.groupRpcClient.GetGroupMemberCache(ctx, req.Conversation.GroupID, userID); err != nil { + log.ZError(ctx, "user not in group", err, "userID", userID, "groupID", req.Conversation.GroupID) + return nil, err + } + } + } var conversation tableRelation.ConversationModel conversation.ConversationID = req.Conversation.ConversationID conversation.ConversationType = req.Conversation.ConversationType