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 <neilalexander@users.noreply.github.com>
main
sumitks866 2021-01-18 18:39:28 +05:30 committed by GitHub
parent 534c29ab02
commit dd1e31bee7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -62,13 +62,19 @@ func Setup(
rateLimits := newRateLimits(&cfg.RateLimiting) rateLimits := newRateLimits(&cfg.RateLimiting)
userInteractiveAuth := auth.NewUserInteractive(accountDB.GetAccountByPassword, cfg) 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", publicAPIMux.Handle("/versions",
httputil.MakeExternalAPI("versions", func(req *http.Request) util.JSONResponse { httputil.MakeExternalAPI("versions", func(req *http.Request) util.JSONResponse {
return util.JSONResponse{ return util.JSONResponse{
Code: http.StatusOK, Code: http.StatusOK,
JSON: struct { JSON: struct {
Versions []string `json:"versions"` Versions []string `json:"versions"`
}{[]string{ UnstableFeatures map[string]bool `json:"unstable_features"`
}{Versions: []string{
"r0.0.1", "r0.0.1",
"r0.1.0", "r0.1.0",
"r0.2.0", "r0.2.0",
@ -76,7 +82,7 @@ func Setup(
"r0.4.0", "r0.4.0",
"r0.5.0", "r0.5.0",
"r0.6.1", "r0.6.1",
}}, }, UnstableFeatures: unstableFeatures},
} }
}), }),
).Methods(http.MethodGet, http.MethodOptions) ).Methods(http.MethodGet, http.MethodOptions)

View File

@ -344,6 +344,7 @@ func (c *Dendrite) Wiring() {
c.ClientAPI.Derived = &c.Derived c.ClientAPI.Derived = &c.Derived
c.AppServiceAPI.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 // Error returns a string detailing how many errors were contained within a

View File

@ -37,6 +37,8 @@ type ClientAPI struct {
// Rate-limiting options // Rate-limiting options
RateLimiting RateLimiting `yaml:"rate_limiting"` RateLimiting RateLimiting `yaml:"rate_limiting"`
MSCs *MSCs `yaml:"mscs"`
} }
func (c *ClientAPI) Defaults() { func (c *ClientAPI) Defaults() {