aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorkegsay <kegan@matrix.org>2023-04-21 17:06:29 +0100
committerGitHub <noreply@github.com>2023-04-21 17:06:29 +0100
commit1647213facae52e2c8889fbc848ffc5d3a5792f0 (patch)
tree684206b99582df20ae144e19db37591cc35b789d /internal
parent71eeccf34a2ea4434c315c19778d80a7b2469270 (diff)
Implement new RoomVersionImpl API (#3062)
As outlined in https://github.com/matrix-org/gomatrixserverlib/pull/368 The main change Dendrite side is that `RoomVersion` no longer has any methods on it. Instead, you need to bounce via `gmsl.GetRoomVersion`. It's very interesting to see where exactly Dendrite cares about this. For some places it's creating events (fine) but others are way more specific. Those areas will need to migrate to GMSL at some point.
Diffstat (limited to 'internal')
-rw-r--r--internal/eventutil/events.go5
-rw-r--r--internal/pushrules/evaluate_test.go2
-rw-r--r--internal/transactionrequest.go6
-rw-r--r--internal/transactionrequest_test.go2
4 files changed, 10 insertions, 5 deletions
diff --git a/internal/eventutil/events.go b/internal/eventutil/events.go
index c7dee346..283c91d8 100644
--- a/internal/eventutil/events.go
+++ b/internal/eventutil/events.go
@@ -112,10 +112,11 @@ func addPrevEventsToEvent(
return ErrRoomNoExists
}
- eventFormat, err := queryRes.RoomVersion.EventFormat()
+ verImpl, err := gomatrixserverlib.GetRoomVersion(queryRes.RoomVersion)
if err != nil {
- return fmt.Errorf("queryRes.RoomVersion.EventFormat: %w", err)
+ return fmt.Errorf("GetRoomVersion: %w", err)
}
+ eventFormat := verImpl.EventFormat()
builder.Depth = queryRes.Depth
diff --git a/internal/pushrules/evaluate_test.go b/internal/pushrules/evaluate_test.go
index d2f6cecc..4fa17b29 100644
--- a/internal/pushrules/evaluate_test.go
+++ b/internal/pushrules/evaluate_test.go
@@ -189,7 +189,7 @@ func TestPatternMatches(t *testing.T) {
}
func mustEventFromJSON(t *testing.T, json string) *gomatrixserverlib.Event {
- ev, err := gomatrixserverlib.RoomVersionV7.NewEventFromTrustedJSON([]byte(json), false)
+ ev, err := gomatrixserverlib.MustGetRoomVersion(gomatrixserverlib.RoomVersionV7).NewEventFromTrustedJSON([]byte(json), false)
if err != nil {
t.Fatal(err)
}
diff --git a/internal/transactionrequest.go b/internal/transactionrequest.go
index a7c192e3..bb16cefe 100644
--- a/internal/transactionrequest.go
+++ b/internal/transactionrequest.go
@@ -137,7 +137,11 @@ func (t *TxnReq) ProcessTransaction(ctx context.Context) (*fclient.RespSend, *ut
continue
}
roomVersion := getRoomVersion(header.RoomID)
- event, err := roomVersion.NewEventFromUntrustedJSON(pdu)
+ verImpl, err := gomatrixserverlib.GetRoomVersion(roomVersion)
+ if err != nil {
+ continue
+ }
+ event, err := verImpl.NewEventFromUntrustedJSON(pdu)
if err != nil {
if _, ok := err.(gomatrixserverlib.BadJSONError); ok {
// Room version 6 states that homeservers should strictly enforce canonical JSON
diff --git a/internal/transactionrequest_test.go b/internal/transactionrequest_test.go
index e178e0a4..6b4c6129 100644
--- a/internal/transactionrequest_test.go
+++ b/internal/transactionrequest_test.go
@@ -633,7 +633,7 @@ func TestProcessTransactionRequestEDUUnhandled(t *testing.T) {
func init() {
for _, j := range testData {
- e, err := testRoomVersion.NewEventFromTrustedJSON(j, false)
+ e, err := gomatrixserverlib.MustGetRoomVersion(testRoomVersion).NewEventFromTrustedJSON(j, false)
if err != nil {
panic("cannot load test data: " + err.Error())
}