How to use the m.room_versions function in m

To help you get started, we’ve selected a few m examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / releases-comm-central / chat / protocols / matrix / lib / matrix-sdk / models / room.js View on Github external
Room.prototype.getRecommendedVersion = async function () {
    const capabilities = await this._client.getCapabilities();
    let versionCap = capabilities["m.room_versions"];
    if (!versionCap) {
        versionCap = {
            default: KNOWN_SAFE_ROOM_VERSION,
            available: {}
        };
        for (const safeVer of SAFE_ROOM_VERSIONS) {
            versionCap.available[safeVer] = "stable";
        }
    }

    let result = this._checkVersionAgainstCapability(versionCap);
    if (result.urgent && result.needsUpgrade) {
        // Something doesn't feel right: we shouldn't need to update
        // because the version we're on should be in the protocol's
        // namespace. This usually means that the server was updated
        // before the client was, making us think the newest possible
github matrix-org / matrix-js-sdk / src / models / room.js View on Github external
let result = this._checkVersionAgainstCapability(versionCap);
    if (result.urgent && result.needsUpgrade) {
        // Something doesn't feel right: we shouldn't need to update
        // because the version we're on should be in the protocol's
        // namespace. This usually means that the server was updated
        // before the client was, making us think the newest possible
        // room version is not stable. As a solution, we'll refresh
        // the capability we're using to determine this.
        logger.warn(
            "Refreshing room version capability because the server looks " +
            "to be supporting a newer room version we don't know about.",
        );

        const caps = await this._client.getCapabilities(true);
        versionCap = caps["m.room_versions"];
        if (!versionCap) {
            logger.warn("No room version capability - assuming upgrade required.");
            return result;
        } else {
            result = this._checkVersionAgainstCapability(versionCap);
        }
    }

    return result;
};
github matrix-org / matrix-js-sdk / src / models / room.js View on Github external
Room.prototype.getRecommendedVersion = async function() {
    const capabilities = await this._client.getCapabilities();
    let versionCap = capabilities["m.room_versions"];
    if (!versionCap) {
        versionCap = {
            default: KNOWN_SAFE_ROOM_VERSION,
            available: {},
        };
        for (const safeVer of SAFE_ROOM_VERSIONS) {
            versionCap.available[safeVer] = "stable";
        }
    }

    let result = this._checkVersionAgainstCapability(versionCap);
    if (result.urgent && result.needsUpgrade) {
        // Something doesn't feel right: we shouldn't need to update
        // because the version we're on should be in the protocol's
        // namespace. This usually means that the server was updated
        // before the client was, making us think the newest possible
github mozilla / releases-comm-central / chat / protocols / matrix / lib / matrix-sdk / models / room.js View on Github external
versionCap.available[safeVer] = "stable";
        }
    }

    let result = this._checkVersionAgainstCapability(versionCap);
    if (result.urgent && result.needsUpgrade) {
        // Something doesn't feel right: we shouldn't need to update
        // because the version we're on should be in the protocol's
        // namespace. This usually means that the server was updated
        // before the client was, making us think the newest possible
        // room version is not stable. As a solution, we'll refresh
        // the capability we're using to determine this.
        _logger2.default.warn("Refreshing room version capability because the server looks " + "to be supporting a newer room version we don't know about.");

        const caps = await this._client.getCapabilities(true);
        versionCap = caps["m.room_versions"];
        if (!versionCap) {
            _logger2.default.warn("No room version capability - assuming upgrade required.");
            return result;
        } else {
            result = this._checkVersionAgainstCapability(versionCap);
        }
    }

    return result;
};