aboutsummaryrefslogtreecommitdiff
path: root/roomserver
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-06-02 16:20:50 +0100
committerGitHub <noreply@github.com>2020-06-02 16:20:50 +0100
commite598e80d7659f3da323a92c07e5092172e16ca2c (patch)
treeea56d039e5d86488114b565af4c4d1056e34feba /roomserver
parente37720be441aa57aa8b30ce80b73cc151d1b2b0c (diff)
Delegate responsibility for marking room versions as supported/stable to gomatrixserverlib (#1082)
Diffstat (limited to 'roomserver')
-rw-r--r--roomserver/version/version.go62
1 files changed, 10 insertions, 52 deletions
diff --git a/roomserver/version/version.go b/roomserver/version/version.go
index ddd0f23a..f2b15ec3 100644
--- a/roomserver/version/version.go
+++ b/roomserver/version/version.go
@@ -20,42 +20,6 @@ import (
"github.com/matrix-org/gomatrixserverlib"
)
-// RoomVersionDescription contains information about a room version,
-// namely whether it is marked as supported or stable in this server
-// version.
-// A version is supported if the server has some support for rooms
-// that are this version. A version is marked as stable or unstable
-// in order to hint whether the version should be used to clients
-// calling the /capabilities endpoint.
-// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-capabilities
-type RoomVersionDescription struct {
- Supported bool
- Stable bool
-}
-
-var roomVersions = map[gomatrixserverlib.RoomVersion]RoomVersionDescription{
- gomatrixserverlib.RoomVersionV1: RoomVersionDescription{
- Supported: true,
- Stable: true,
- },
- gomatrixserverlib.RoomVersionV2: RoomVersionDescription{
- Supported: true,
- Stable: true,
- },
- gomatrixserverlib.RoomVersionV3: RoomVersionDescription{
- Supported: true,
- Stable: true,
- },
- gomatrixserverlib.RoomVersionV4: RoomVersionDescription{
- Supported: true,
- Stable: true,
- },
- gomatrixserverlib.RoomVersionV5: RoomVersionDescription{
- Supported: true,
- Stable: true,
- },
-}
-
// DefaultRoomVersion contains the room version that will, by
// default, be used to create new rooms on this server.
func DefaultRoomVersion() gomatrixserverlib.RoomVersion {
@@ -64,43 +28,37 @@ func DefaultRoomVersion() gomatrixserverlib.RoomVersion {
// RoomVersions returns a map of all known room versions to this
// server.
-func RoomVersions() map[gomatrixserverlib.RoomVersion]RoomVersionDescription {
- return roomVersions
+func RoomVersions() map[gomatrixserverlib.RoomVersion]gomatrixserverlib.RoomVersionDescription {
+ return gomatrixserverlib.RoomVersions()
}
// SupportedRoomVersions returns a map of descriptions for room
// versions that are supported by this homeserver.
-func SupportedRoomVersions() map[gomatrixserverlib.RoomVersion]RoomVersionDescription {
- versions := make(map[gomatrixserverlib.RoomVersion]RoomVersionDescription)
- for id, version := range RoomVersions() {
- if version.Supported {
- versions[id] = version
- }
- }
- return versions
+func SupportedRoomVersions() map[gomatrixserverlib.RoomVersion]gomatrixserverlib.RoomVersionDescription {
+ return gomatrixserverlib.SupportedRoomVersions()
}
// RoomVersion returns information about a specific room version.
// An UnknownVersionError is returned if the version is not known
// to the server.
-func RoomVersion(version gomatrixserverlib.RoomVersion) (RoomVersionDescription, error) {
- if version, ok := roomVersions[version]; ok {
+func RoomVersion(version gomatrixserverlib.RoomVersion) (gomatrixserverlib.RoomVersionDescription, error) {
+ if version, ok := gomatrixserverlib.RoomVersions()[version]; ok {
return version, nil
}
- return RoomVersionDescription{}, UnknownVersionError{version}
+ return gomatrixserverlib.RoomVersionDescription{}, UnknownVersionError{version}
}
// SupportedRoomVersion returns information about a specific room
// version. An UnknownVersionError is returned if the version is not
// known to the server, or an UnsupportedVersionError is returned if
// the version is known but specifically marked as unsupported.
-func SupportedRoomVersion(version gomatrixserverlib.RoomVersion) (RoomVersionDescription, error) {
+func SupportedRoomVersion(version gomatrixserverlib.RoomVersion) (gomatrixserverlib.RoomVersionDescription, error) {
result, err := RoomVersion(version)
if err != nil {
- return RoomVersionDescription{}, err
+ return gomatrixserverlib.RoomVersionDescription{}, err
}
if !result.Supported {
- return RoomVersionDescription{}, UnsupportedVersionError{version}
+ return gomatrixserverlib.RoomVersionDescription{}, UnsupportedVersionError{version}
}
return result, nil
}