2020-02-05 18:06:39 +00:00
|
|
|
// Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package routing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2023-08-08 14:20:05 +01:00
|
|
|
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
|
2023-04-03 20:42:46 +01:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/version"
|
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
2020-02-05 18:06:39 +00:00
|
|
|
"github.com/matrix-org/util"
|
|
|
|
)
|
|
|
|
|
2020-09-29 10:06:59 +01:00
|
|
|
// GetCapabilities returns information about the server's supported feature set
|
|
|
|
// and other relevant capabilities to an authenticated user.
|
2023-08-08 14:20:05 +01:00
|
|
|
func GetCapabilities(rsAPI roomserverAPI.ClientRoomserverAPI) util.JSONResponse {
|
2023-04-03 20:42:46 +01:00
|
|
|
versionsMap := map[gomatrixserverlib.RoomVersion]string{}
|
|
|
|
for v, desc := range version.SupportedRoomVersions() {
|
2023-04-24 11:50:37 +01:00
|
|
|
if desc.Stable() {
|
2023-04-03 20:42:46 +01:00
|
|
|
versionsMap[v] = "stable"
|
|
|
|
} else {
|
|
|
|
versionsMap[v] = "unstable"
|
|
|
|
}
|
2020-02-05 18:06:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
response := map[string]interface{}{
|
|
|
|
"capabilities": map[string]interface{}{
|
2020-09-29 10:06:59 +01:00
|
|
|
"m.change_password": map[string]bool{
|
|
|
|
"enabled": true,
|
|
|
|
},
|
2023-04-03 20:42:46 +01:00
|
|
|
"m.room_versions": map[string]interface{}{
|
2023-08-08 14:20:05 +01:00
|
|
|
"default": rsAPI.DefaultRoomVersion(),
|
2023-04-03 20:42:46 +01:00
|
|
|
"available": versionsMap,
|
|
|
|
},
|
2020-02-05 18:06:39 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return util.JSONResponse{
|
|
|
|
Code: http.StatusOK,
|
|
|
|
JSON: response,
|
|
|
|
}
|
|
|
|
}
|