mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 22:22:46 +00:00
Rudimentary pagination of rooms in the rooms filter
This commit is contained in:
parent
ce112cf21b
commit
10c41a7a18
8 changed files with 185 additions and 13 deletions
|
@ -956,3 +956,23 @@ func (d *Database) GetRoomReceipts(ctx context.Context, roomIDs []string, stream
|
|||
_, receipts, err := d.Receipts.SelectRoomReceiptsAfter(ctx, roomIDs, streamPos)
|
||||
return receipts, err
|
||||
}
|
||||
|
||||
func (d *Database) GetPaginatedRooms(ctx context.Context, userID string, offset, count int) ([]string, error) {
|
||||
memberships, err := d.Memberships.SelectMemberships(ctx, nil, userID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("d.Memberships.SelectMemberships: %w", err)
|
||||
}
|
||||
rooms := []string{}
|
||||
for roomID := range memberships {
|
||||
rooms = append(rooms, roomID)
|
||||
}
|
||||
positions, err := d.OutputEvents.BulkSelectMaxStreamPositions(ctx, nil, rooms, offset, count)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("d.Events.BulkSelectMaxStreamPositions: %w", err)
|
||||
}
|
||||
rooms = rooms[:0]
|
||||
for roomID := range positions {
|
||||
rooms = append(rooms, roomID)
|
||||
}
|
||||
return rooms, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue