Fix state block retrieval

This commit is contained in:
Neil Alexander 2020-08-26 14:40:58 +01:00
parent db5a99e82b
commit 1cea9f7a1c
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -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)
}