diff --git a/go.mod b/go.mod index 01e6b146a..958706db4 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/matrix-org/go-http-js-libp2p v0.0.0-20200310180544-7f3fad43b51c github.com/matrix-org/go-sqlite3-js v0.0.0-20200304164012-aa524245b658 github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26 - github.com/matrix-org/gomatrixserverlib v0.0.0-20200317114945-9a368ea4620d + github.com/matrix-org/gomatrixserverlib v0.0.0-20200317140257-ddc7feaaf2fd github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1 github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7 github.com/mattn/go-sqlite3 v2.0.2+incompatible diff --git a/go.sum b/go.sum index 140da7df8..517d0bf1c 100644 --- a/go.sum +++ b/go.sum @@ -266,6 +266,8 @@ github.com/matrix-org/gomatrixserverlib v0.0.0-20200317103236-134415251e65 h1:ll github.com/matrix-org/gomatrixserverlib v0.0.0-20200317103236-134415251e65/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI= github.com/matrix-org/gomatrixserverlib v0.0.0-20200317114945-9a368ea4620d h1:0GYO2Jye1TNVzsn02IF5tqV80psDi0KIWC4+glH6+/Q= github.com/matrix-org/gomatrixserverlib v0.0.0-20200317114945-9a368ea4620d/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI= +github.com/matrix-org/gomatrixserverlib v0.0.0-20200317140257-ddc7feaaf2fd h1:n95A8YyiCZ8Nu2beqw4akCaPIRrZr/nesHYDZV8WkXI= +github.com/matrix-org/gomatrixserverlib v0.0.0-20200317140257-ddc7feaaf2fd/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI= github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1 h1:osLoFdOy+ChQqVUn2PeTDETFftVkl4w9t/OW18g3lnk= github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1/go.mod h1:cXoYQIENbdWIQHt1SyCo6Bl3C3raHwJ0wgVrXHSqf+A= github.com/matrix-org/util v0.0.0-20171127121716-2e2df66af2f5 h1:W7l5CP4V7wPyPb4tYE11dbmeAOwtFQBTW0rf4OonOS8= diff --git a/roomserver/storage/postgres/storage.go b/roomserver/storage/postgres/storage.go index 46b4f4d0b..b2b4159c9 100644 --- a/roomserver/storage/postgres/storage.go +++ b/roomserver/storage/postgres/storage.go @@ -71,6 +71,9 @@ func (d *Database) StoreEvent( } } + // TODO: Here we should aim to have two different code paths for new rooms + // vs existing ones. + // Get the default room version. If the client doesn't supply a room_version // then we will use our configured default to create the room. // https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-createroom @@ -135,24 +138,26 @@ func (d *Database) StoreEvent( } func extractRoomVersionFromCreateEvent(event gomatrixserverlib.Event) ( - roomVersion gomatrixserverlib.RoomVersion, err error, + gomatrixserverlib.RoomVersion, error, ) { + var err error + var roomVersion gomatrixserverlib.RoomVersion // Look for m.room.create events. if event.Type() != gomatrixserverlib.MRoomCreate { - return + return gomatrixserverlib.RoomVersion(""), nil } roomVersion = roomserverVersion.DefaultRoomVersion() var createContent gomatrixserverlib.CreateContent // The m.room.create event contains an optional "room_version" key in // the event content, so we need to unmarshal that first. if err = json.Unmarshal(event.Content(), &createContent); err != nil { - return + return gomatrixserverlib.RoomVersion(""), err } // A room version was specified in the event content? if createContent.RoomVersion != nil { roomVersion = *createContent.RoomVersion } - return + return roomVersion, err } func (d *Database) assignRoomNID( diff --git a/roomserver/storage/sqlite3/storage.go b/roomserver/storage/sqlite3/storage.go index 32ddceb37..b912b1c0e 100644 --- a/roomserver/storage/sqlite3/storage.go +++ b/roomserver/storage/sqlite3/storage.go @@ -70,6 +70,7 @@ func Open(dataSourceName string) (*Database, error) { } // StoreEvent implements input.EventDatabase +// nolint:gocyclo func (d *Database) StoreEvent( ctx context.Context, event gomatrixserverlib.Event, txnAndSessionID *api.TransactionID, authEventNIDs []types.EventNID, @@ -93,6 +94,9 @@ func (d *Database) StoreEvent( } } + // TODO: Here we should aim to have two different code paths for new rooms + // vs existing ones. + // Get the default room version. If the client doesn't supply a room_version // then we will use our configured default to create the room. // https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-createroom @@ -164,24 +168,26 @@ func (d *Database) StoreEvent( } func extractRoomVersionFromCreateEvent(event gomatrixserverlib.Event) ( - roomVersion gomatrixserverlib.RoomVersion, err error, + gomatrixserverlib.RoomVersion, error, ) { + var err error + var roomVersion gomatrixserverlib.RoomVersion // Look for m.room.create events. if event.Type() != gomatrixserverlib.MRoomCreate { - return + return gomatrixserverlib.RoomVersion(""), nil } roomVersion = roomserverVersion.DefaultRoomVersion() var createContent gomatrixserverlib.CreateContent // The m.room.create event contains an optional "room_version" key in // the event content, so we need to unmarshal that first. if err = json.Unmarshal(event.Content(), &createContent); err != nil { - return + return gomatrixserverlib.RoomVersion(""), err } // A room version was specified in the event content? if createContent.RoomVersion != nil { roomVersion = *createContent.RoomVersion } - return + return roomVersion, err } func (d *Database) assignRoomNID( diff --git a/sytest-whitelist b/sytest-whitelist index eb91b3f0c..613114b6e 100644 --- a/sytest-whitelist +++ b/sytest-whitelist @@ -104,12 +104,6 @@ Newly banned rooms appear in the leave section of incremental sync Newly banned rooms appear in the leave section of incremental sync local user can join room with version 1 User can invite local user to room with version 1 -local user can join room with version 2 -User can invite local user to room with version 2 -local user can join room with version 3 -User can invite local user to room with version 3 -local user can join room with version 4 -User can invite local user to room with version 4 Should reject keys claiming to belong to a different user Can add account data Can add account data to room @@ -198,10 +192,6 @@ Local non-members don't see posted message events Remote room members also see posted message events Lazy loading parameters in the filter are strictly boolean remote user can join room with version 1 -remote user can join room with version 2 -remote user can join room with version 3 -remote user can join room with version 4 -remote user can join room with version 5 Inbound federation can query room alias directory Outbound federation can query v2 /send_join Inbound federation can receive v2 /send_join