Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Strip path component from IM rest url
Browse files Browse the repository at this point in the history
before passing to js-sdk. We continue to use the full URL for the
calls done by matrix-react-sdk, but the standard terms API called
by the js-sdk lives on the standard _matrix path. This means we
don't support running IMs on a non-root path, but it's the only
realistic way of transitioning to _matrix paths since configs in
the wild contain bits of the API path.

Once we've fully transitioned to _matrix URLs, we can give people
a grace period to update their configs, then use the rest url as
a regular base url.
  • Loading branch information
dbkr committed Jul 22, 2019
1 parent 84bb0eb commit 7d78782
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ScalarAuthClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import url from 'url';
import Promise from 'bluebird';
import SettingsStore from "./settings/SettingsStore";
import { Service, presentTermsForServices, TermsNotSignedError } from './Terms';
Expand Down Expand Up @@ -104,9 +105,15 @@ class ScalarAuthClient {
}).catch((e) => {
if (e instanceof TermsNotSignedError) {
console.log("Integrations manager requires new terms to be agreed to");
// The terms endpoints are new and so live on standard _matrix prefixes,
// but IM rest urls are currently configured with paths, so remove the
// path from the base URL before passing it to the js-sdk
const parsedImRestUrl = url.parse(SdkConfig.get().integrations_rest_url);
parsedImRestUrl.path = '';
parsedImRestUrl.pathname = '';
return presentTermsForServices([new Service(
Matrix.SERVICE_TYPES.IM,
SdkConfig.get().integrations_rest_url,
parsedImRestUrl.format(),
token,
)]).then(() => {
return token;
Expand Down

0 comments on commit 7d78782

Please sign in to comment.