mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
fix: fix the getSortedConversation api
This commit is contained in:
parent
89b59eb82e
commit
159822e207
@ -90,7 +90,7 @@ func (c *conversationServer) GetConversation(ctx context.Context, req *pbconvers
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *conversationServer) GetSortedConversationList(ctx context.Context, req *pbconversation.GetSortedConversationListReq) (resp *pbconversation.GetSortedConversationListResp, err error) {
|
func (m *conversationServer) GetSortedConversationList(ctx context.Context, req *pbconversation.GetSortedConversationListReq) (resp *pbconversation.GetSortedConversationListResp, err error) {
|
||||||
log.ZDebug(ctx, "GetConversationList", "seqs", req, "userID", req.UserID)
|
log.ZDebug(ctx, "GetSortedConversationList", "seqs", req, "userID", req.UserID)
|
||||||
var conversationIDs []string
|
var conversationIDs []string
|
||||||
if len(req.ConversationIDs) == 0 {
|
if len(req.ConversationIDs) == 0 {
|
||||||
conversationIDs, err = m.conversationDatabase.GetConversationIDs(ctx, req.UserID)
|
conversationIDs, err = m.conversationDatabase.GetConversationIDs(ctx, req.UserID)
|
||||||
@ -129,9 +129,12 @@ func (m *conversationServer) GetSortedConversationList(ctx context.Context, req
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var unreadTotal int64
|
||||||
conversation_unreadCount := make(map[string]int64)
|
conversation_unreadCount := make(map[string]int64)
|
||||||
for conversationID, maxSeq := range maxSeqs {
|
for conversationID, maxSeq := range maxSeqs {
|
||||||
conversation_unreadCount[conversationID] = maxSeq - hasReadSeqs[conversationID]
|
unreadCount := maxSeq - hasReadSeqs[conversationID]
|
||||||
|
conversation_unreadCount[conversationID] = unreadCount
|
||||||
|
unreadTotal += unreadCount
|
||||||
}
|
}
|
||||||
|
|
||||||
conversation_isPinTime := make(map[int64]string)
|
conversation_isPinTime := make(map[int64]string)
|
||||||
@ -148,11 +151,15 @@ func (m *conversationServer) GetSortedConversationList(ctx context.Context, req
|
|||||||
conversation_notPinTime[time] = conversationID
|
conversation_notPinTime[time] = conversationID
|
||||||
}
|
}
|
||||||
resp = &pbconversation.GetSortedConversationListResp{
|
resp = &pbconversation.GetSortedConversationListResp{
|
||||||
|
ConversationTotal: int64(len(chatLogs)),
|
||||||
ConversationElems: []*pbconversation.ConversationElem{},
|
ConversationElems: []*pbconversation.ConversationElem{},
|
||||||
|
UnreadTotal: unreadTotal,
|
||||||
}
|
}
|
||||||
|
|
||||||
m.conversationSort(conversation_isPinTime, resp, conversation_unreadCount, conversationMsg)
|
m.conversationSort(conversation_isPinTime, resp, conversation_unreadCount, conversationMsg)
|
||||||
m.conversationSort(conversation_notPinTime, resp, conversation_unreadCount, conversationMsg)
|
m.conversationSort(conversation_notPinTime, resp, conversation_unreadCount, conversationMsg)
|
||||||
|
|
||||||
|
resp.ConversationElems = utils.Paginate(resp.ConversationElems, int(req.Pagination.GetPageNumber()), int(req.Pagination.GetShowNumber()))
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,6 +429,11 @@ func (s *userServer) AddNotificationAccount(ctx context.Context, req *pbuser.Add
|
|||||||
if req.UserID == "" {
|
if req.UserID == "" {
|
||||||
return nil, errs.ErrInternalServer.Wrap("gen user id failed")
|
return nil, errs.ErrInternalServer.Wrap("gen user id failed")
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_, err := s.UserDatabase.FindWithError(ctx, []string{req.UserID})
|
||||||
|
if err == nil {
|
||||||
|
return nil, errs.ErrArgs.Wrap("userID is used")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
user := &tablerelation.UserModel{
|
user := &tablerelation.UserModel{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user