Use room version cache in Events()

This commit is contained in:
Neil Alexander 2020-09-21 16:49:37 +01:00
parent a06c18bb56
commit 45de9dc1c0
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -320,9 +320,14 @@ func (d *Database) Events(
if err != nil { if err != nil {
return nil, err return nil, err
} }
roomVersion, err = d.RoomsTable.SelectRoomVersionForRoomNID(ctx, roomNID) if roomID, ok := d.Cache.GetRoomServerRoomID(roomNID); ok {
if err != nil { roomVersion, _ = d.Cache.GetRoomVersion(roomID)
return nil, err }
if roomVersion == "" {
roomVersion, err = d.RoomsTable.SelectRoomVersionForRoomNID(ctx, roomNID)
if err != nil {
return nil, err
}
} }
result.Event, err = gomatrixserverlib.NewEventFromTrustedJSON( result.Event, err = gomatrixserverlib.NewEventFromTrustedJSON(
eventJSON.EventJSON, false, roomVersion, eventJSON.EventJSON, false, roomVersion,