diff options
author | kegsay <kegan@matrix.org> | 2022-01-21 14:23:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-21 14:23:37 +0000 |
commit | 0bf5104bbbfb34cf869e74bcc17a039db176e935 (patch) | |
tree | cfe80f91e972a1d595f025fb041c474871e39776 | |
parent | 2c581377a5f6b243300445947fd0fd38a919873d (diff) |
Fix #2027 by gracefully handling stub rooms (#2100)
The server ACL code on startup will grab all known rooms from
the rooms_table and then call `GetStateEvent` with each found
room ID to find the server ACL event. This can fail for stub
rooms, which will be present in the rooms table. Previously
this would result in an error being returned and the server
failing to start (!). Now we just return no event for stub
rooms.
-rw-r--r-- | roomserver/storage/shared/storage.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index f49536f4..d4c5ebb5 100644 --- a/roomserver/storage/shared/storage.go +++ b/roomserver/storage/shared/storage.go @@ -842,9 +842,13 @@ func (d *Database) GetStateEvent(ctx context.Context, roomID, evType, stateKey s if err != nil { return nil, err } - if roomInfo == nil || roomInfo.IsStub { + if roomInfo == nil { return nil, fmt.Errorf("room %s doesn't exist", roomID) } + // e.g invited rooms + if roomInfo.IsStub { + return nil, nil + } eventTypeNID, err := d.EventTypesTable.SelectEventTypeNID(ctx, nil, evType) if err == sql.ErrNoRows { // No rooms have an event of this type, otherwise we'd have an event type NID |