aboutsummaryrefslogtreecommitdiff
path: root/roomserver
diff options
context:
space:
mode:
Diffstat (limited to 'roomserver')
-rw-r--r--roomserver/internal/helpers/helpers.go2
-rw-r--r--roomserver/internal/input/input_missing.go2
-rw-r--r--roomserver/internal/input/input_test.go4
-rw-r--r--roomserver/internal/query/query_test.go4
-rw-r--r--roomserver/storage/postgres/state_snapshot_table.go2
-rw-r--r--roomserver/storage/shared/storage.go12
6 files changed, 13 insertions, 13 deletions
diff --git a/roomserver/internal/helpers/helpers.go b/roomserver/internal/helpers/helpers.go
index 959f5cf7..6834ec82 100644
--- a/roomserver/internal/helpers/helpers.go
+++ b/roomserver/internal/helpers/helpers.go
@@ -149,7 +149,7 @@ func IsInvitePending(
return false, "", "", nil, fmt.Errorf("missing user for NID %d (%+v)", senderUserNIDs[0], senderUsers)
}
- event, err := gomatrixserverlib.NewEventFromTrustedJSON(eventJSON, false, info.RoomVersion)
+ event, err := info.RoomVersion.NewEventFromTrustedJSON(eventJSON, false)
return true, senderUser, userNIDToEventID[senderUserNIDs[0]], event, err
}
diff --git a/roomserver/internal/input/input_missing.go b/roomserver/internal/input/input_missing.go
index c7b64797..61dd05bf 100644
--- a/roomserver/internal/input/input_missing.go
+++ b/roomserver/internal/input/input_missing.go
@@ -865,7 +865,7 @@ func (t *missingStateReq) lookupEvent(ctx context.Context, roomVersion gomatrixs
}
continue
}
- event, err = gomatrixserverlib.NewEventFromUntrustedJSON(txn.PDUs[0], roomVersion)
+ event, err = roomVersion.NewEventFromUntrustedJSON(txn.PDUs[0])
if err != nil {
t.log.WithError(err).WithField("missing_event_id", missingEventID).Warnf("Failed to parse event JSON of event returned from /event")
continue
diff --git a/roomserver/internal/input/input_test.go b/roomserver/internal/input/input_test.go
index 51c50c37..e7bc4471 100644
--- a/roomserver/internal/input/input_test.go
+++ b/roomserver/internal/input/input_test.go
@@ -35,9 +35,9 @@ func TestSingleTransactionOnInput(t *testing.T) {
ctx, cancel := context.WithDeadline(processCtx.Context(), deadline)
defer cancel()
- event, err := gomatrixserverlib.NewEventFromTrustedJSON(
+ event, err := gomatrixserverlib.RoomVersionV6.NewEventFromTrustedJSON(
[]byte(`{"auth_events":[],"content":{"creator":"@neilalexander:dendrite.matrix.org","room_version":"6"},"depth":1,"hashes":{"sha256":"jqOqdNEH5r0NiN3xJtj0u5XUVmRqq9YvGbki1wxxuuM"},"origin":"dendrite.matrix.org","origin_server_ts":1644595362726,"prev_events":[],"prev_state":[],"room_id":"!jSZZRknA6GkTBXNP:dendrite.matrix.org","sender":"@neilalexander:dendrite.matrix.org","signatures":{"dendrite.matrix.org":{"ed25519:6jB2aB":"bsQXO1wketf1OSe9xlndDIWe71W9KIundc6rBw4KEZdGPW7x4Tv4zDWWvbxDsG64sS2IPWfIm+J0OOozbrWIDw"}},"state_key":"","type":"m.room.create"}`),
- false, gomatrixserverlib.RoomVersionV6,
+ false,
)
if err != nil {
t.Fatal(err)
diff --git a/roomserver/internal/query/query_test.go b/roomserver/internal/query/query_test.go
index 265f326d..907f7625 100644
--- a/roomserver/internal/query/query_test.go
+++ b/roomserver/internal/query/query_test.go
@@ -54,8 +54,8 @@ func (db *getEventDB) addFakeEvent(eventID string, authIDs []string) error {
return err
}
- event, err := gomatrixserverlib.NewEventFromTrustedJSON(
- eventJSON, false, gomatrixserverlib.RoomVersionV1,
+ event, err := gomatrixserverlib.RoomVersionV1.NewEventFromTrustedJSON(
+ eventJSON, false,
)
if err != nil {
return err
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)
}