2020-02-05 19:06:39 +01: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-04-03 21:42:46 +02:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/version"
|
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
2020-02-05 19:06:39 +01:00
|
|
|
"github.com/matrix-org/util"
|
|
|
|
)
|
|
|
|
|
2020-09-29 11:06:59 +02:00
|
|
|
// GetCapabilities returns information about the server's supported feature set
|
|
|
|
// and other relevant capabilities to an authenticated user.
|
2023-04-03 21:42:46 +02:00
|
|
|
func GetCapabilities() util.JSONResponse {
|
|
|
|
versionsMap := map[gomatrixserverlib.RoomVersion]string{}
|
|
|
|
for v, desc := range version.SupportedRoomVersions() {
|
2023-04-24 12:50:37 +02:00
|
|
|
if desc.Stable() {
|
2023-04-03 21:42:46 +02:00
|
|
|
versionsMap[v] = "stable"
|
|
|
|
} else {
|
|
|
|
versionsMap[v] = "unstable"
|
|
|
|
}
|
2020-02-05 19:06:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
response := map[string]interface{}{
|
|
|
|
"capabilities": map[string]interface{}{
|
2020-09-29 11:06:59 +02:00
|
|
|
"m.change_password": map[string]bool{
|
|
|
|
"enabled": true,
|
|
|
|
},
|
2023-04-03 21:42:46 +02:00
|
|
|
"m.room_versions": map[string]interface{}{
|
|
|
|
"default": version.DefaultRoomVersion(),
|
|
|
|
"available": versionsMap,
|
|
|
|
},
|
2020-02-05 19:06:39 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return util.JSONResponse{
|
|
|
|
Code: http.StatusOK,
|
|
|
|
JSON: response,
|
|
|
|
}
|
|
|
|
}
|