Move permalink host check into permalink constructors
Without the requirement for a room to work
This commit is contained in:
parent
926e1146f9
commit
f879185aef
4 changed files with 15 additions and 13 deletions
|
@ -34,4 +34,8 @@ export default class PermalinkConstructor {
|
|||
forUser(userId: string): string {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
isPermalinkHost(host: string): boolean {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,7 @@ limitations under the License.
|
|||
import MatrixClientPeg from "../../MatrixClientPeg";
|
||||
import isIp from "is-ip";
|
||||
import utils from 'matrix-js-sdk/lib/utils';
|
||||
import SpecPermalinkConstructor, {
|
||||
baseUrl as matrixtoBaseUrl,
|
||||
host as matrixtoHost
|
||||
} from "./SpecPermalinkConstructor";
|
||||
import SpecPermalinkConstructor from "./SpecPermalinkConstructor";
|
||||
import PermalinkConstructor from "./PermalinkConstructor";
|
||||
|
||||
const SdkConfig = require("../../SdkConfig");
|
||||
|
@ -127,10 +124,6 @@ export class RoomPermalinkCreator {
|
|||
return this._started;
|
||||
}
|
||||
|
||||
isPermalinkHost(host: string): boolean {
|
||||
return host === matrixtoHost;
|
||||
}
|
||||
|
||||
forEvent(eventId) {
|
||||
return getPermalinkConstructor().forEvent(this._roomId, eventId, this._serverCandidates);
|
||||
}
|
||||
|
@ -285,6 +278,10 @@ export function makeGroupPermalink(groupId) {
|
|||
return getPermalinkConstructor().forGroup(groupId);
|
||||
}
|
||||
|
||||
export function isPermalinkHost(host: string): boolean {
|
||||
return getPermalinkConstructor().isPermalinkHost(host);
|
||||
}
|
||||
|
||||
function getPermalinkConstructor(): PermalinkConstructor {
|
||||
if (SdkConfig.get()['useRiotToCreatePermalinks']) {
|
||||
// TODO: Return a RiotPermalinkConstructor
|
||||
|
|
|
@ -43,6 +43,10 @@ export default class SpecPermalinkConstructor extends PermalinkConstructor {
|
|||
return `${baseUrl}/#/${groupId}`;
|
||||
}
|
||||
|
||||
isPermalinkHost(testHost: string): boolean {
|
||||
return testHost === host;
|
||||
}
|
||||
|
||||
encodeServerCandidates(candidates: string[]) {
|
||||
if (!candidates || candidates.length === 0) return '';
|
||||
return `?via=${candidates.map(c => encodeURIComponent(c)).join("&via=")}`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue