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), conversationNotificationSender: notification.NewConversationNotificationSender(&msgRpcClient),
groupRpcClient: &groupRpcClient, groupRpcClient: &groupRpcClient,
conversationDatabase: controller.NewConversationDatabase(conversationDB, cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), conversationDB), tx.NewGorm(db)), conversationDatabase: controller.NewConversationDatabase(conversationDB, cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), conversationDB), tx.NewGorm(db)),
Online: false,
}) })
return nil return nil
} }
@ -122,19 +123,19 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbConver
} }
if req.Conversation.ConversationType == constant.GroupChatType { if req.Conversation.ConversationType == constant.GroupChatType {
groupInfo, err := c.groupRpcClient.GetGroupInfo(ctx, req.Conversation.GroupID) groupInfo, err := c.groupRpcClient.GetGroupInfo(ctx, req.Conversation.GroupID)
func (c *conversationServer) SetConversations(ctx context.Context, req *pbConversation.SetConversationsReq) (*pbConversation.SetConversationsResp, error) { if err != nil {
if req.Conversation == nil { return nil, err
return nil, errs.ErrArgs.Wrap("conversation must not be nil") }
} if groupInfo.Status == constant.GroupStatusDismissed {
if req.Conversation.ConversationType == constant.GroupChatType { return nil, err
groupInfo, err := c.groupRpcClient.GetGroupInfo(ctx, req.Conversation.GroupID) }
if err != nil { for _, userID := range req.UserIDs {
return nil, err 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)
if groupInfo.Status == constant.GroupStatusDismissed { return nil, err
return nil, err }
} }
} }
var conversation tableRelation.ConversationModel var conversation tableRelation.ConversationModel
conversation.ConversationID = req.Conversation.ConversationID conversation.ConversationID = req.Conversation.ConversationID
conversation.ConversationType = req.Conversation.ConversationType conversation.ConversationType = req.Conversation.ConversationType

Loading…
Cancel
Save