aboutsummaryrefslogtreecommitdiff
path: root/clientapi
diff options
context:
space:
mode:
authordevonh <devon.dmytro@gmail.com>2023-08-24 21:08:40 +0000
committerGitHub <noreply@github.com>2023-08-24 21:08:40 +0000
commit1c4ec67bb6897859617fea263c658142a694e26d (patch)
treeacc2f160fdd70b2b9849ca43fd68596df0508c67 /clientapi
parent9b5be6b9c552a221e1a6f67d1e632ffc76591d4c (diff)
Add configuration option for sliding sync when hosting /.well-known/matrix/client (#3189)
Adds the `org.matrix.msc3575.proxy` field (used for configuring sliding sync) to /.well-known/matrix/client when Dendrite is serving that endpoint and `well_known_sliding_sync_proxy` has been configured. ie. Config values of: ``` yaml global: well_known_client_name: https://example.com well_known_sliding_sync_proxy: https://syncv3.example.com ``` results in a /.well-known/matrix/client of: ``` json { "m.homeserver": { "base_url": "https://example.com" }, "org.matrix.msc3575.proxy": { "url": "https://syncv3.example.com" } } ``` If `well_known_sliding_sync_proxy` is not provided, the json provided by /.well-known/matrix/client does not include the proxy field. ie. ``` json { "m.homeserver": { "base_url": "https://example.com" } } ```
Diffstat (limited to 'clientapi')
-rw-r--r--clientapi/routing/routing.go37
1 files changed, 26 insertions, 11 deletions
diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go
index 8b3ae5e1..d4aa1d08 100644
--- a/clientapi/routing/routing.go
+++ b/clientapi/routing/routing.go
@@ -44,6 +44,19 @@ import (
"github.com/matrix-org/dendrite/setup/jetstream"
)
+type WellKnownClientHomeserver struct {
+ BaseUrl string `json:"base_url"`
+}
+
+type WellKnownSlidingSyncProxy struct {
+ Url string `json:"url"`
+}
+
+type WellKnownClientResponse struct {
+ Homeserver WellKnownClientHomeserver `json:"m.homeserver"`
+ SlidingSyncProxy *WellKnownSlidingSyncProxy `json:"org.matrix.msc3575.proxy,omitempty"`
+}
+
// Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client
// to clients which need to make outbound HTTP requests.
//
@@ -96,20 +109,22 @@ func Setup(
if cfg.Matrix.WellKnownClientName != "" {
logrus.Infof("Setting m.homeserver base_url as %s at /.well-known/matrix/client", cfg.Matrix.WellKnownClientName)
+ if cfg.Matrix.WellKnownSlidingSyncProxy != "" {
+ logrus.Infof("Setting org.matrix.msc3575.proxy url as %s at /.well-known/matrix/client", cfg.Matrix.WellKnownSlidingSyncProxy)
+ }
wkMux.Handle("/client", httputil.MakeExternalAPI("wellknown", func(r *http.Request) util.JSONResponse {
+ response := WellKnownClientResponse{
+ Homeserver: WellKnownClientHomeserver{cfg.Matrix.WellKnownClientName},
+ }
+ if cfg.Matrix.WellKnownSlidingSyncProxy != "" {
+ response.SlidingSyncProxy = &WellKnownSlidingSyncProxy{
+ Url: cfg.Matrix.WellKnownSlidingSyncProxy,
+ }
+ }
+
return util.JSONResponse{
Code: http.StatusOK,
- JSON: struct {
- HomeserverName struct {
- BaseUrl string `json:"base_url"`
- } `json:"m.homeserver"`
- }{
- HomeserverName: struct {
- BaseUrl string `json:"base_url"`
- }{
- BaseUrl: cfg.Matrix.WellKnownClientName,
- },
- },
+ JSON: response,
}
})).Methods(http.MethodGet, http.MethodOptions)
}