Look up tile server info in homeserver's .well-known area (#7623)
This commit is contained in:
parent
20819df60b
commit
ae490841c6
4 changed files with 138 additions and 41 deletions
|
@ -14,11 +14,16 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { IClientWellKnown } from 'matrix-js-sdk/src/client';
|
||||
import { UnstableValue } from 'matrix-js-sdk/src/NamespacedValue';
|
||||
|
||||
import { MatrixClientPeg } from '../MatrixClientPeg';
|
||||
|
||||
const CALL_BEHAVIOUR_WK_KEY = "io.element.call_behaviour";
|
||||
const E2EE_WK_KEY = "io.element.e2ee";
|
||||
const E2EE_WK_KEY_DEPRECATED = "im.vector.riot.e2ee";
|
||||
const TILE_SERVER_WK_KEY = new UnstableValue(
|
||||
"m.tile_server", "org.matrix.msc3488.tile_server");
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
export interface ICallBehaviourWellKnown {
|
||||
|
@ -30,6 +35,10 @@ export interface IE2EEWellKnown {
|
|||
secure_backup_required?: boolean;
|
||||
secure_backup_setup_methods?: SecureBackupSetupMethod[];
|
||||
}
|
||||
|
||||
export interface ITileServerWellKnown {
|
||||
map_style_url?: string;
|
||||
}
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
export function getCallBehaviourWellKnown(): ICallBehaviourWellKnown {
|
||||
|
@ -48,6 +57,19 @@ export function getE2EEWellKnown(): IE2EEWellKnown {
|
|||
return null;
|
||||
}
|
||||
|
||||
export function getTileServerWellKnown(): ITileServerWellKnown | undefined {
|
||||
return tileServerFromWellKnown(MatrixClientPeg.get().getClientWellKnown());
|
||||
}
|
||||
|
||||
export function tileServerFromWellKnown(
|
||||
clientWellKnown?: IClientWellKnown | undefined,
|
||||
): ITileServerWellKnown {
|
||||
return (
|
||||
clientWellKnown?.[TILE_SERVER_WK_KEY.name] ??
|
||||
clientWellKnown?.[TILE_SERVER_WK_KEY.altName]
|
||||
);
|
||||
}
|
||||
|
||||
export function isSecureBackupRequired(): boolean {
|
||||
const wellKnown = getE2EEWellKnown();
|
||||
return wellKnown && wellKnown["secure_backup_required"] === true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue