Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode

This commit is contained in:
wangchuxiao
2023-05-26 20:54:54 +08:00
5 changed files with 214 additions and 219 deletions
+16 -8
View File
@@ -182,6 +182,7 @@ func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(ctx context.Context, userID, doc
beginSeq, endSeq := utils.GetSeqsBeginEnd(seqs)
beginIndex := m.model.GetMsgIndex(beginSeq)
num := endSeq - beginSeq + 1
log.ZInfo(ctx, "GetMsgBySeqIndexIn1Doc", "docID", docID, "seqs", seqs, "beginSeq", beginSeq, "endSeq", endSeq, "beginIndex", beginIndex, "num", num)
pipeline := bson.A{
bson.M{
"$match": bson.M{"doc_id": docID},
@@ -200,19 +201,26 @@ func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(ctx context.Context, userID, doc
}
defer cursor.Close(ctx)
var doc table.MsgDocModel
i := 0
for cursor.Next(ctx) {
err := cursor.Decode(&doc)
if err != nil {
if cursor.Next(ctx) {
if err := cursor.Decode(&doc); err != nil {
return nil, err
}
if i == 1 {
break
}
i++
}
////i := 0
//for cursor.Next(ctx) {
// err := cursor.Decode(&doc)
// if err != nil {
// return nil, err
// }
// //if i == 0 {
// // break
// //}
//}
log.ZDebug(ctx, "msgInfos", "num", len(doc.Msg), "docID", docID)
for _, v := range doc.Msg {
if v.Msg == nil {
continue
}
if v.Msg.Seq >= beginSeq && v.Msg.Seq <= endSeq {
log.ZDebug(ctx, "find msg", "msg", v.Msg)
msgs = append(msgs, v)