This commit is contained in:
qwqtoday 2024-08-09 19:25:26 +08:00
parent 133c77d93b
commit 1f44a77037
2 changed files with 5 additions and 2 deletions

View file

@ -86,6 +86,9 @@ func Threads(
headeredEvents, _, res.NextBatch, err = snapshot.ThreadsFor(
req.Context(), roomID.String(), userID, from, limit,
)
if err != nil {
return util.ErrorResponse(err)
}
for _, event := range headeredEvents {
ce, err := synctypes.ToClientEvent(event, synctypes.FormatAll, func(roomID spec.RoomID, senderID spec.SenderID) (*spec.UserID, error) {

View file

@ -834,7 +834,7 @@ func (d *DatabaseTransaction) ThreadsFor(ctx context.Context, roomID, userID str
// First look up any threads from the database. We add one to the limit here
// so that we can tell if we're overflowing, as we will only set the "next_batch"
// in the response if we are.
eventIDs, _, err := d.Relations.SelectThreads(ctx, d.txn, roomID, userID, from, limit+1)
eventIDs, pos, err := d.Relations.SelectThreads(ctx, d.txn, roomID, userID, from, limit+1)
if err != nil {
return nil, "", "", fmt.Errorf("d.Relations.SelectRelationsInRange: %w", err)
@ -845,5 +845,5 @@ func (d *DatabaseTransaction) ThreadsFor(ctx context.Context, roomID, userID str
return nil, "", "", fmt.Errorf("d.OutputEvents.SelectEvents: %w", err)
}
return events, prevBatch, nextBatch, nil
return events, prevBatch, fmt.Sprintf("%d", pos), nil
}