You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-11 20:22:36 +03:00
Fetch homeUrl from .well-known (#7790)
* Fetch homeUrl from .well-known * homeUrl: prefer config.json over .well-known * homeUrl: prefer deprecated config.json variant over .well-known * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
This commit is contained in:
@@ -24,6 +24,7 @@ const E2EE_WK_KEY = "io.element.e2ee";
|
|||||||
const E2EE_WK_KEY_DEPRECATED = "im.vector.riot.e2ee";
|
const E2EE_WK_KEY_DEPRECATED = "im.vector.riot.e2ee";
|
||||||
export const TILE_SERVER_WK_KEY = new UnstableValue(
|
export const TILE_SERVER_WK_KEY = new UnstableValue(
|
||||||
"m.tile_server", "org.matrix.msc3488.tile_server");
|
"m.tile_server", "org.matrix.msc3488.tile_server");
|
||||||
|
const EMBEDDED_PAGES_WK_PROPERTY = "io.element.embedded_pages";
|
||||||
|
|
||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
export interface ICallBehaviourWellKnown {
|
export interface ICallBehaviourWellKnown {
|
||||||
@@ -39,6 +40,10 @@ export interface IE2EEWellKnown {
|
|||||||
export interface ITileServerWellKnown {
|
export interface ITileServerWellKnown {
|
||||||
map_style_url?: string;
|
map_style_url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IEmbeddedPagesWellKnown {
|
||||||
|
home_url?: string;
|
||||||
|
}
|
||||||
/* eslint-enable camelcase */
|
/* eslint-enable camelcase */
|
||||||
|
|
||||||
export function getCallBehaviourWellKnown(): ICallBehaviourWellKnown {
|
export function getCallBehaviourWellKnown(): ICallBehaviourWellKnown {
|
||||||
@@ -70,6 +75,16 @@ export function tileServerFromWellKnown(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getEmbeddedPagesWellKnown(): IEmbeddedPagesWellKnown | undefined {
|
||||||
|
return embeddedPagesFromWellKnown(MatrixClientPeg.get()?.getClientWellKnown());
|
||||||
|
}
|
||||||
|
|
||||||
|
export function embeddedPagesFromWellKnown(
|
||||||
|
clientWellKnown?: IClientWellKnown,
|
||||||
|
): IEmbeddedPagesWellKnown {
|
||||||
|
return (clientWellKnown?.[EMBEDDED_PAGES_WK_PROPERTY]);
|
||||||
|
}
|
||||||
|
|
||||||
export function isSecureBackupRequired(): boolean {
|
export function isSecureBackupRequired(): boolean {
|
||||||
const wellKnown = getE2EEWellKnown();
|
const wellKnown = getE2EEWellKnown();
|
||||||
return wellKnown && wellKnown["secure_backup_required"] === true;
|
return wellKnown && wellKnown["secure_backup_required"] === true;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
|
||||||
import { IConfigOptions } from "../IConfigOptions";
|
import { IConfigOptions } from "../IConfigOptions";
|
||||||
|
import { getEmbeddedPagesWellKnown } from '../utils/WellKnownUtils';
|
||||||
import { SnakedObject } from "./SnakedObject";
|
import { SnakedObject } from "./SnakedObject";
|
||||||
|
|
||||||
export function getHomePageUrl(appConfig: IConfigOptions): string | null {
|
export function getHomePageUrl(appConfig: IConfigOptions): string | null {
|
||||||
@@ -38,6 +39,10 @@ export function getHomePageUrl(appConfig: IConfigOptions): string | null {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pageUrl) {
|
||||||
|
pageUrl = getEmbeddedPagesWellKnown()?.home_url;
|
||||||
|
}
|
||||||
|
|
||||||
return pageUrl;
|
return pageUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user