Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve get wellknown task and store the homeserver url entered by the user during the session creation phase. #3572

Closed
bmarty opened this issue Jun 25, 2021 · 0 comments · Fixed by #3585
Assignees

Comments

@bmarty
Copy link
Member

bmarty commented Jun 25, 2021

Well-known feature has been introduced to let any Matrix client to discover where is located the client-server Matrix API, either when the user enters a domain or if the user enter a matrixId (userId) from which the domain can be extracted.

For instance, for the domain matrix.org, the well-known URL is https://matrix.org/.well-known/matrix/client

And the result is:

{
    "m.homeserver": {
        "base_url": "https://matrix-client.matrix.org"
    },
    "m.identity_server": {
        "base_url": "https://vector.im"
    }
}

So the base url for the client-server API has to be https://matrix-client.matrix.org.

Element Android handles this correctly (#2843 exists though), but in fact the well-known file has been hacked on some servers to also store extra data, for instance some client configuration settings.

Moreover, when the user logins, the login response can contain another client-server URL, see https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-login , the parameter Discovery Information, which is also supported by Element Android. This URL will override the previous store homeserver url, and the url entered by the client is lost (can be changed twice!).

We can see that in the current general setting screen in Element Android:

image

This is the same in the homeserver setting screen:

image

It's also worth noting that https://matrix-client.matrix.org/.well-known/matrix/client does not return anything (it's actually a non sense).

What we have to do

  • GetWellknownTask.Params should not take a matrixId anymore, but rather take a domain name. It will allow to perform a wellknown request after the login phase, to any desire domain. Also there will be no need anymore to create fake userId from a domain to do that.

  • We should store in HomeServerConnectionConfig object the homeserver url which has been entered by the user, to be able to later perform the same Wellknown request, even if the URL has been overridden by wellknown, or by the login response. On some circumstances, this is not OK to retrieve the domain from the userId. New field will be:

val userHomeServer: Uri

Also this URL could be used in the settings screen. A new section could be added to see the actual client-server API URL (the one which is displayed now).

Other

There are some old sessions which are still using matrix.org as a base URL for CS-API. This can be an opportunity to migrate the session database (SessionParamsEntity):

  • deserialize HomeServerConnectionConfig
  • force the usage of https://matrix-client.matrix.org if and only if the server url is matrix.org. For other servers, we can assume that the URL are the same. So userHomeServer will be https://matrix.org and homeServerUri will be overridden to https://matrix-client.matrix.org
  • serialize the object and write it to DB.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant