Update GetStateEvent behaviour (#1399)

This commit is contained in:
Neil Alexander 2020-09-04 19:40:21 +01:00 committed by GitHub
parent 088294ee65
commit b9caccbce8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -724,6 +724,10 @@ func (d *Database) GetStateEvent(ctx context.Context, roomID, evType, stateKey s
return nil, err
}
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
return nil, nil
}
if err != nil {
return nil, err
}
@ -754,7 +758,7 @@ func (d *Database) GetStateEvent(ctx context.Context, roomID, evType, stateKey s
}
}
return nil, fmt.Errorf("GetStateEvent: no event type '%s' with key '%s' exists in room %s", evType, stateKey, roomID)
return nil, nil
}
// GetRoomsByMembership returns a list of room IDs matching the provided membership and user ID (as state_key).