From 1cea9f7a1cae62b796de3bc2cebf7c7bcc19de4a Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 26 Aug 2020 14:40:58 +0100 Subject: [PATCH] Fix state block retrieval --- roomserver/storage/shared/storage.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index 345337407..a2c86ea2d 100644 --- a/roomserver/storage/shared/storage.go +++ b/roomserver/storage/shared/storage.go @@ -182,14 +182,15 @@ func (d *Database) StateForRoomID( // the room doesn't exist or it doesn't have state return nil, nil } - stateBlockNIDs, err := d.StateSnapshotTable.BulkSelectStateBlockNIDs(ctx, []types.StateSnapshotNID{stateSnapshotNID}) + stateBlockLists, err := d.StateSnapshotTable.BulkSelectStateBlockNIDs(ctx, []types.StateSnapshotNID{stateSnapshotNID}) if err != nil { return nil, fmt.Errorf("d.StateSnapshotTable.BulkSelectStateBlockNIDs: %w", err) } - if len(stateBlockNIDs) != 1 { - return nil, fmt.Errorf("expected one StateBlockNIDList, got %d", len(stateBlockNIDs)) + stateBlockNIDs := []types.StateBlockNID{} + for _, stateBlockList := range stateBlockLists { + stateBlockNIDs = append(stateBlockNIDs, stateBlockList.StateBlockNIDs...) } - stateEventLists, err := d.StateBlockTable.BulkSelectStateBlockEntries(ctx, stateBlockNIDs[0].StateBlockNIDs) + stateEventLists, err := d.StateBlockTable.BulkSelectStateBlockEntries(ctx, stateBlockNIDs) if err != nil { return nil, fmt.Errorf("d.StateBlockTable.BulkSelectStateBlockEntries: %w", err) }