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

Redirect starter links to the desired integration manager #1342

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/ScalarAuthClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,21 @@ class ScalarAuthClient {
return url;
}

getScalarInterfaceUrlForPath(path) {
if (path.startsWith("http://") || path.startsWith("https://")) {
// It's already an interface URL, so we'll just give it a token and move on
return this.getStarterLink(path);
}

let url = SdkConfig.get().integrations_ui_url;

// Take off the slashes as we'll be manually adding them later on
if (url.endsWith("/")) url = url.substring(0, url.length - 1);
if (path.startsWith("/")) path = path.substring(1);

return this.getStarterLink(url + "/" + path);
}

getStarterLink(starterLinkUrl) {
return starterLinkUrl + "?scalar_token=" + encodeURIComponent(this.scalarToken);
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/views/messages/TextualBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import MatrixClientPeg from '../../../MatrixClientPeg';
import * as ContextualMenu from '../../structures/ContextualMenu';
import SettingsStore from "../../../settings/SettingsStore";
import PushProcessor from 'matrix-js-sdk/lib/pushprocessor';
import * as url from "url";
import ReplyThread from "../elements/ReplyThread";
import {host as matrixtoHost} from '../../../matrix-to';

Expand Down Expand Up @@ -403,9 +404,9 @@ module.exports = React.createClass({
// Go fetch a scalar token
const scalarClient = new ScalarAuthClient();
scalarClient.connect().then(() => {
const completeUrl = scalarClient.getStarterLink(starterLink);
const completeUrl = scalarClient.getScalarInterfaceUrlForPath(starterLink);
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
const integrationsUrl = SdkConfig.get().integrations_ui_url;
const integrationsUrl = url.parse(completeUrl).host;
Modal.createTrackedDialog('Add an integration', '', QuestionDialog, {
title: _t("Add an Integration"),
description:
Expand Down