From dd1e31bee7b96c0e7e1697b21f7f1119b5cc4622 Mon Sep 17 00:00:00 2001 From: sumitks866 <31448420+sumitks866@users.noreply.github.com> Date: Mon, 18 Jan 2021 18:39:28 +0530 Subject: [PATCH] Mention unstable features in /_matrix/client/versions (#1710) * Mention unstable features in /_matrix/client/versions * list enabled mscs * Don't update go.mod/go.sum * goimports Co-authored-by: Neil Alexander --- clientapi/routing/routing.go | 12 +++++++++--- setup/config/config.go | 1 + setup/config/config_clientapi.go | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 8dbfc551..7c320253 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -62,13 +62,19 @@ func Setup( rateLimits := newRateLimits(&cfg.RateLimiting) userInteractiveAuth := auth.NewUserInteractive(accountDB.GetAccountByPassword, cfg) + unstableFeatures := make(map[string]bool) + for _, msc := range cfg.MSCs.MSCs { + unstableFeatures["org.matrix."+msc] = true + } + publicAPIMux.Handle("/versions", httputil.MakeExternalAPI("versions", func(req *http.Request) util.JSONResponse { return util.JSONResponse{ Code: http.StatusOK, JSON: struct { - Versions []string `json:"versions"` - }{[]string{ + Versions []string `json:"versions"` + UnstableFeatures map[string]bool `json:"unstable_features"` + }{Versions: []string{ "r0.0.1", "r0.1.0", "r0.2.0", @@ -76,7 +82,7 @@ func Setup( "r0.4.0", "r0.5.0", "r0.6.1", - }}, + }, UnstableFeatures: unstableFeatures}, } }), ).Methods(http.MethodGet, http.MethodOptions) diff --git a/setup/config/config.go b/setup/config/config.go index b8b12d0c..b9114407 100644 --- a/setup/config/config.go +++ b/setup/config/config.go @@ -344,6 +344,7 @@ func (c *Dendrite) Wiring() { c.ClientAPI.Derived = &c.Derived c.AppServiceAPI.Derived = &c.Derived + c.ClientAPI.MSCs = &c.MSCs } // Error returns a string detailing how many errors were contained within a diff --git a/setup/config/config_clientapi.go b/setup/config/config_clientapi.go index 52115491..c7cb9c33 100644 --- a/setup/config/config_clientapi.go +++ b/setup/config/config_clientapi.go @@ -37,6 +37,8 @@ type ClientAPI struct { // Rate-limiting options RateLimiting RateLimiting `yaml:"rate_limiting"` + + MSCs *MSCs `yaml:"mscs"` } func (c *ClientAPI) Defaults() {