aboutsummaryrefslogtreecommitdiff
path: root/clientapi
diff options
context:
space:
mode:
authorSam Wedgwood <28223854+swedgwood@users.noreply.github.com>2023-08-08 14:20:05 +0100
committerGitHub <noreply@github.com>2023-08-08 14:20:05 +0100
commit35804f8493a7a51542b27ff98bc60814685d5020 (patch)
tree0138df2ced6da0f8d03a51d38ace5a3651f68cd2 /clientapi
parent294eff8a7f42f11b3559ca941468c766358fcae1 (diff)
Add config key for default room version (#3171)
This PR adds a config key `room_server.default_config_key` to set the default room version for the room server. Signed-off-by: `Sam Wedgwood <sam@wedgwood.dev>`
Diffstat (limited to 'clientapi')
-rw-r--r--clientapi/clientapi_test.go6
-rw-r--r--clientapi/routing/capabilities.go5
-rw-r--r--clientapi/routing/createroom.go2
-rw-r--r--clientapi/routing/routing.go2
-rw-r--r--clientapi/routing/server_notices.go3
5 files changed, 11 insertions, 7 deletions
diff --git a/clientapi/clientapi_test.go b/clientapi/clientapi_test.go
index ae14d271..82ec9fea 100644
--- a/clientapi/clientapi_test.go
+++ b/clientapi/clientapi_test.go
@@ -923,13 +923,17 @@ func TestCapabilities(t *testing.T) {
}
}
+ var tempRoomServerCfg config.RoomServer
+ tempRoomServerCfg.Defaults(config.DefaultOpts{})
+ defaultRoomVersion := tempRoomServerCfg.DefaultRoomVersion
+
expectedMap := map[string]interface{}{
"capabilities": map[string]interface{}{
"m.change_password": map[string]bool{
"enabled": true,
},
"m.room_versions": map[string]interface{}{
- "default": version.DefaultRoomVersion(),
+ "default": defaultRoomVersion,
"available": versionsMap,
},
},
diff --git a/clientapi/routing/capabilities.go b/clientapi/routing/capabilities.go
index fa50fa1a..38e5bd46 100644
--- a/clientapi/routing/capabilities.go
+++ b/clientapi/routing/capabilities.go
@@ -17,6 +17,7 @@ package routing
import (
"net/http"
+ roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/roomserver/version"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
@@ -24,7 +25,7 @@ import (
// GetCapabilities returns information about the server's supported feature set
// and other relevant capabilities to an authenticated user.
-func GetCapabilities() util.JSONResponse {
+func GetCapabilities(rsAPI roomserverAPI.ClientRoomserverAPI) util.JSONResponse {
versionsMap := map[gomatrixserverlib.RoomVersion]string{}
for v, desc := range version.SupportedRoomVersions() {
if desc.Stable() {
@@ -40,7 +41,7 @@ func GetCapabilities() util.JSONResponse {
"enabled": true,
},
"m.room_versions": map[string]interface{}{
- "default": version.DefaultRoomVersion(),
+ "default": rsAPI.DefaultRoomVersion(),
"available": versionsMap,
},
},
diff --git a/clientapi/routing/createroom.go b/clientapi/routing/createroom.go
index 320f236c..47e3ba1c 100644
--- a/clientapi/routing/createroom.go
+++ b/clientapi/routing/createroom.go
@@ -171,7 +171,7 @@ func createRoom(
// Clobber keys: creator, room_version
- roomVersion := roomserverVersion.DefaultRoomVersion()
+ roomVersion := rsAPI.DefaultRoomVersion()
if createRequest.RoomVersion != "" {
candidateVersion := gomatrixserverlib.RoomVersion(createRequest.RoomVersion)
_, roomVersionError := roomserverVersion.SupportedRoomVersion(candidateVersion)
diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go
index 8cd207b7..8b3ae5e1 100644
--- a/clientapi/routing/routing.go
+++ b/clientapi/routing/routing.go
@@ -1256,7 +1256,7 @@ func Setup(
if r := rateLimits.Limit(req, device); r != nil {
return *r
}
- return GetCapabilities()
+ return GetCapabilities(rsAPI)
}, httputil.WithAllowGuests()),
).Methods(http.MethodGet, http.MethodOptions)
diff --git a/clientapi/routing/server_notices.go b/clientapi/routing/server_notices.go
index 66258a68..1c5d693c 100644
--- a/clientapi/routing/server_notices.go
+++ b/clientapi/routing/server_notices.go
@@ -28,7 +28,6 @@ import (
"github.com/sirupsen/logrus"
"github.com/matrix-org/dendrite/roomserver/types"
- "github.com/matrix-org/dendrite/roomserver/version"
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
"github.com/matrix-org/dendrite/clientapi/httputil"
@@ -135,7 +134,7 @@ func SendServerNotice(
var (
roomID string
- roomVersion = version.DefaultRoomVersion()
+ roomVersion = rsAPI.DefaultRoomVersion()
)
// create a new room for the user