From b9caccbce89ae1739218b2934fca7f5d38f3fe46 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 4 Sep 2020 19:40:21 +0100 Subject: [PATCH] Update GetStateEvent behaviour (#1399) --- roomserver/storage/shared/storage.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index 7e1ccd16d..a081603f0 100644 --- a/roomserver/storage/shared/storage.go +++ b/roomserver/storage/shared/storage.go @@ -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).