You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-05 17:02:07 +03:00
Refresh safe room versions when the server looks more modern than us
Fixes https://github.com/vector-im/riot-web/issues/9845
This commit is contained in:
@@ -263,6 +263,33 @@ Room.prototype.getRecommendedVersion = async function() {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
if (!caps) {
|
||||
logger.warn("No server capabilities - assuming upgrade needed");
|
||||
return result;
|
||||
} else {
|
||||
versionCap = caps["m.room_versions"];
|
||||
result = this._checkVersionAgainstCapability(versionCap);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Room.prototype._checkVersionAgainstCapability = function(versionCap) {
|
||||
const currentVersion = this.getVersion();
|
||||
logger.log(`[${this.roomId}] Current version: ${currentVersion}`);
|
||||
logger.log(`[${this.roomId}] Version capability: `, versionCap);
|
||||
@@ -291,12 +318,12 @@ Room.prototype.getRecommendedVersion = async function() {
|
||||
} else {
|
||||
logger.warn(`Non-urgent upgrade required on ${this.roomId}`);
|
||||
}
|
||||
return Promise.resolve(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// The room is on a stable, but non-default, version by this point.
|
||||
// No upgrade needed.
|
||||
return Promise.resolve(result);
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user