diff options
author | kegsay <kegan@matrix.org> | 2023-04-20 19:07:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-20 19:07:31 +0100 |
commit | 71eeccf34a2ea4434c315c19778d80a7b2469270 (patch) | |
tree | e6d5bd8f91a9a90b2b076f842c183bae332c6311 /syncapi | |
parent | 72285b2659a31ebd52c91799c17105d81d996f40 (diff) |
refactor: funnel event creation through room versions (#3060)
In preparation of interfacing up the room version value.
Diffstat (limited to 'syncapi')
-rw-r--r-- | syncapi/synctypes/clientevent_test.go | 8 | ||||
-rw-r--r-- | syncapi/types/types_test.go | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/syncapi/synctypes/clientevent_test.go b/syncapi/synctypes/clientevent_test.go index ac07917a..7fd33de9 100644 --- a/syncapi/synctypes/clientevent_test.go +++ b/syncapi/synctypes/clientevent_test.go @@ -24,7 +24,7 @@ import ( ) func TestToClientEvent(t *testing.T) { // nolint: gocyclo - ev, err := gomatrixserverlib.NewEventFromTrustedJSON([]byte(`{ + ev, err := gomatrixserverlib.RoomVersionV1.NewEventFromTrustedJSON([]byte(`{ "type": "m.room.name", "state_key": "", "event_id": "$test:localhost", @@ -39,7 +39,7 @@ func TestToClientEvent(t *testing.T) { // nolint: gocyclo "name": "Goodbye World" } } - }`), false, gomatrixserverlib.RoomVersionV1) + }`), false) if err != nil { t.Fatalf("failed to create Event: %s", err) } @@ -79,7 +79,7 @@ func TestToClientEvent(t *testing.T) { // nolint: gocyclo } func TestToClientFormatSync(t *testing.T) { - ev, err := gomatrixserverlib.NewEventFromTrustedJSON([]byte(`{ + ev, err := gomatrixserverlib.RoomVersionV1.NewEventFromTrustedJSON([]byte(`{ "type": "m.room.name", "state_key": "", "event_id": "$test:localhost", @@ -94,7 +94,7 @@ func TestToClientFormatSync(t *testing.T) { "name": "Goodbye World" } } - }`), false, gomatrixserverlib.RoomVersionV1) + }`), false) if err != nil { t.Fatalf("failed to create Event: %s", err) } diff --git a/syncapi/types/types_test.go b/syncapi/types/types_test.go index 8bb887ff..e06a66b7 100644 --- a/syncapi/types/types_test.go +++ b/syncapi/types/types_test.go @@ -50,7 +50,7 @@ func TestNewInviteResponse(t *testing.T) { event := `{"auth_events":["$SbSsh09j26UAXnjd3RZqf2lyA3Kw2sY_VZJVZQAV9yA","$EwL53onrLwQ5gL8Dv3VrOOCvHiueXu2ovLdzqkNi3lo","$l2wGmz9iAwevBDGpHT_xXLUA5O8BhORxWIGU1cGi1ZM","$GsWFJLXgdlF5HpZeyWkP72tzXYWW3uQ9X28HBuTztHE"],"content":{"avatar_url":"","displayname":"neilalexander","membership":"invite"},"depth":9,"hashes":{"sha256":"8p+Ur4f8vLFX6mkIXhxI0kegPG7X3tWy56QmvBkExAg"},"origin":"matrix.org","origin_server_ts":1602087113066,"prev_events":["$1v-O6tNwhOZcA8bvCYY-Dnj1V2ZDE58lLPxtlV97S28"],"prev_state":[],"room_id":"!XbeXirGWSPXbEaGokF:matrix.org","sender":"@neilalexander:matrix.org","signatures":{"dendrite.neilalexander.dev":{"ed25519:BMJi":"05KQ5lPw0cSFsE4A0x1z7vi/3cc8bG4WHUsFWYkhxvk/XkXMGIYAYkpNThIvSeLfdcHlbm/k10AsBSKH8Uq4DA"},"matrix.org":{"ed25519:a_RXGa":"jeovuHr9E/x0sHbFkdfxDDYV/EyoeLi98douZYqZ02iYddtKhfB7R3WLay/a+D3V3V7IW0FUmPh/A404x5sYCw"}},"state_key":"@neilalexander:dendrite.neilalexander.dev","type":"m.room.member","unsigned":{"age":2512,"invite_room_state":[{"content":{"join_rule":"invite"},"sender":"@neilalexander:matrix.org","state_key":"","type":"m.room.join_rules"},{"content":{"avatar_url":"mxc://matrix.org/BpDaozLwgLnlNStxDxvLzhPr","displayname":"neilalexander","membership":"join"},"sender":"@neilalexander:matrix.org","state_key":"@neilalexander:matrix.org","type":"m.room.member"},{"content":{"name":"Test room"},"sender":"@neilalexander:matrix.org","state_key":"","type":"m.room.name"}]},"_room_version":"5"}` expected := `{"invite_state":{"events":[{"content":{"join_rule":"invite"},"sender":"@neilalexander:matrix.org","state_key":"","type":"m.room.join_rules"},{"content":{"avatar_url":"mxc://matrix.org/BpDaozLwgLnlNStxDxvLzhPr","displayname":"neilalexander","membership":"join"},"sender":"@neilalexander:matrix.org","state_key":"@neilalexander:matrix.org","type":"m.room.member"},{"content":{"name":"Test room"},"sender":"@neilalexander:matrix.org","state_key":"","type":"m.room.name"},{"content":{"avatar_url":"","displayname":"neilalexander","membership":"invite"},"event_id":"$GQmw8e8-26CQv1QuFoHBHpKF1hQj61Flg3kvv_v_XWs","origin_server_ts":1602087113066,"sender":"@neilalexander:matrix.org","state_key":"@neilalexander:dendrite.neilalexander.dev","type":"m.room.member"}]}}` - ev, err := gomatrixserverlib.NewEventFromTrustedJSON([]byte(event), false, gomatrixserverlib.RoomVersionV5) + ev, err := gomatrixserverlib.RoomVersionV5.NewEventFromTrustedJSON([]byte(event), false) if err != nil { t.Fatal(err) } |