Initialize Online field and reintroduce checks in SetConversations

pull/861/head
sweep-ai[bot] 2 years ago committed by GitHub
parent 89a8428afd
commit d2ec39ed7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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
}
@ -116,12 +117,6 @@ func (c *conversationServer) SetConversation(ctx context.Context, req *pbConvers
return resp, nil
}
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)
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")
@ -134,6 +129,12 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbConver
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

Loading…
Cancel
Save