test-errcode
wangchuxiao 1 year ago
parent eb91b83c83
commit 710e67ff83

@ -21,6 +21,16 @@ func (m *msgServer) GetConversationsHasReadAndMaxSeq(ctx context.Context, req *m
if err != nil {
return nil, err
}
conversations, err := m.Conversation.GetConversations(ctx, req.UserID, conversationIDs)
if err != nil {
return nil, err
}
var conversationMaxSeqMap = make(map[string]int64)
for _, conversation := range conversations {
if conversation.MaxSeq != 0 {
conversationMaxSeqMap[conversation.ConversationID] = conversation.MaxSeq
}
}
maxSeqs, err := m.MsgDatabase.GetMaxSeqs(ctx, conversationIDs)
if err != nil {
return nil, err
@ -31,6 +41,9 @@ func (m *msgServer) GetConversationsHasReadAndMaxSeq(ctx context.Context, req *m
HasReadSeq: hasReadSeqs[conversarionID],
MaxSeq: maxSeq,
}
if v, ok := conversationMaxSeqMap[conversarionID]; ok {
resp.Seqs[conversarionID].MaxSeq = v
}
}
return resp, nil
}

@ -107,3 +107,15 @@ func (c *ConversationClient) GetConversationsByConversationID(ctx context.Contex
}
return resp.Conversations, nil
}
func (c *ConversationClient) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*pbConversation.Conversation, error) {
cc, err := c.getConn(ctx)
if err != nil {
return nil, err
}
resp, err := pbConversation.NewConversationClient(cc).GetConversations(ctx, &pbConversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs})
if err != nil {
return nil, err
}
return resp.Conversations, nil
}

Loading…
Cancel
Save