@@ -5,6 +5,11 @@ import (
55 "fmt"
66 "time"
77
8+ "go.mongodb.org/mongo-driver/bson"
9+ "go.mongodb.org/mongo-driver/bson/primitive"
10+ "go.mongodb.org/mongo-driver/mongo"
11+ "go.mongodb.org/mongo-driver/mongo/options"
12+
813 "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
914 "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
1015 "github.com/openimsdk/protocol/constant"
@@ -14,10 +19,6 @@ import (
1419 "github.com/openimsdk/tools/errs"
1520 "github.com/openimsdk/tools/utils/datautil"
1621 "github.com/openimsdk/tools/utils/jsonutil"
17- "go.mongodb.org/mongo-driver/bson"
18- "go.mongodb.org/mongo-driver/bson/primitive"
19- "go.mongodb.org/mongo-driver/mongo"
20- "go.mongodb.org/mongo-driver/mongo/options"
2122)
2223
2324func NewMsgMongo (db * mongo.Database ) (database.Msg , error ) {
@@ -1154,7 +1155,7 @@ func (m *MsgMgo) findBeforeDocSendTime(ctx context.Context, docID string, limit
11541155 if err != nil {
11551156 return 0 , 0 , err
11561157 }
1157- for i := len (res ) - 1 ; i > 0 ; i -- {
1158+ for i := len (res ) - 1 ; i >= 0 ; i -- {
11581159 v := res [i ]
11591160 if v .Msgs != nil && v .Msgs .Msg != nil && v .Msgs .Msg .SendTime > 0 {
11601161 return v .Msgs .Msg .Seq , v .Msgs .Msg .SendTime , nil
@@ -1169,7 +1170,7 @@ func (m *MsgMgo) findBeforeSendTime(ctx context.Context, conversationID string,
11691170 limit := int64 (- 1 )
11701171 if first {
11711172 first = false
1172- limit = m .model .GetMsgIndex (seq )
1173+ limit = m .model .GetLimitForSingleDoc (seq )
11731174 }
11741175 docID := m .model .BuildDocIDByIndex (conversationID , i )
11751176 msgSeq , msgSendTime , err := m .findBeforeDocSendTime (ctx , docID , limit )
0 commit comments