aboutsummaryrefslogtreecommitdiff
path: root/roomserver/storage
diff options
context:
space:
mode:
authorkegsay <kegan@matrix.org>2023-04-20 19:07:31 +0100
committerGitHub <noreply@github.com>2023-04-20 19:07:31 +0100
commit71eeccf34a2ea4434c315c19778d80a7b2469270 (patch)
treee6d5bd8f91a9a90b2b076f842c183bae332c6311 /roomserver/storage
parent72285b2659a31ebd52c91799c17105d81d996f40 (diff)
refactor: funnel event creation through room versions (#3060)
In preparation of interfacing up the room version value.
Diffstat (limited to 'roomserver/storage')
-rw-r--r--roomserver/storage/postgres/state_snapshot_table.go2
-rw-r--r--roomserver/storage/shared/storage.go12
2 files changed, 7 insertions, 7 deletions
diff --git a/roomserver/storage/postgres/state_snapshot_table.go b/roomserver/storage/postgres/state_snapshot_table.go
index 0e83cfc2..c1efdad3 100644
--- a/roomserver/storage/postgres/state_snapshot_table.go
+++ b/roomserver/storage/postgres/state_snapshot_table.go
@@ -232,7 +232,7 @@ func (s *stateSnapshotStatements) BulkSelectMembershipForHistoryVisibility(
result[eventID] = ev
continue
}
- event, err := gomatrixserverlib.NewEventFromTrustedJSON(evJson, false, roomInfo.RoomVersion)
+ event, err := roomInfo.RoomVersion.NewEventFromTrustedJSON(evJson, false)
if err != nil {
result[eventID] = &gomatrixserverlib.HeaderedEvent{}
// not fatal
diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go
index 17095709..c9eb0ca0 100644
--- a/roomserver/storage/shared/storage.go
+++ b/roomserver/storage/shared/storage.go
@@ -581,8 +581,8 @@ func (d *EventDatabase) events(
for _, eventJSON := range eventJSONs {
redacted := gjson.GetBytes(eventJSON.EventJSON, "unsigned.redacted_because").Exists()
- events[eventJSON.EventNID], err = gomatrixserverlib.NewEventFromTrustedJSONWithEventID(
- eventIDs[eventJSON.EventNID], eventJSON.EventJSON, redacted, roomInfo.RoomVersion,
+ events[eventJSON.EventNID], err = roomInfo.RoomVersion.NewEventFromTrustedJSONWithEventID(
+ eventIDs[eventJSON.EventNID], eventJSON.EventJSON, redacted,
)
if err != nil {
return nil, err
@@ -1131,7 +1131,7 @@ func (d *Database) GetHistoryVisibilityState(ctx context.Context, roomInfo *type
if err != nil {
return nil, err
}
- ev, err := gomatrixserverlib.NewEventFromTrustedJSONWithEventID(eventIDs[eventNID], data[0].EventJSON, false, roomInfo.RoomVersion)
+ ev, err := roomInfo.RoomVersion.NewEventFromTrustedJSONWithEventID(eventIDs[eventNID], data[0].EventJSON, false)
if err != nil {
return nil, err
}
@@ -1195,7 +1195,7 @@ func (d *Database) GetStateEvent(ctx context.Context, roomID, evType, stateKey s
if len(data) == 0 {
return nil, fmt.Errorf("GetStateEvent: no json for event nid %d", e.EventNID)
}
- ev, err := gomatrixserverlib.NewEventFromTrustedJSONWithEventID(eventIDs[e.EventNID], data[0].EventJSON, false, roomInfo.RoomVersion)
+ ev, err := roomInfo.RoomVersion.NewEventFromTrustedJSONWithEventID(eventIDs[e.EventNID], data[0].EventJSON, false)
if err != nil {
return nil, err
}
@@ -1252,7 +1252,7 @@ func (d *Database) GetStateEventsWithEventType(ctx context.Context, roomID, evTy
}
var result []*gomatrixserverlib.HeaderedEvent
for _, pair := range eventPairs {
- ev, err := gomatrixserverlib.NewEventFromTrustedJSONWithEventID(eventIDs[pair.EventNID], pair.EventJSON, false, roomInfo.RoomVersion)
+ ev, err := roomInfo.RoomVersion.NewEventFromTrustedJSONWithEventID(eventIDs[pair.EventNID], pair.EventJSON, false)
if err != nil {
return nil, err
}
@@ -1372,7 +1372,7 @@ func (d *Database) GetBulkStateContent(ctx context.Context, roomIDs []string, tu
result := make([]tables.StrippedEvent, len(events))
for i := range events {
roomVer := eventNIDToVer[events[i].EventNID]
- ev, err := gomatrixserverlib.NewEventFromTrustedJSONWithEventID(eventIDs[events[i].EventNID], events[i].EventJSON, false, roomVer)
+ ev, err := roomVer.NewEventFromTrustedJSONWithEventID(eventIDs[events[i].EventNID], events[i].EventJSON, false)
if err != nil {
return nil, fmt.Errorf("GetBulkStateContent: failed to load event JSON for event NID %v : %w", events[i].EventNID, err)
}