Skip to content

Use hydra semantics for unknown room versions #4957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/utils/roomVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,19 @@ limitations under the License.
/**
* Room versions strings that we know about and do not use hydra semantics.
*/
const HYDRA_ROOM_VERSIONS = ["org.matrix.hydra.11", "12"];
const PRE_HYDRA_ROOM_VERSIONS = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"];

/**
* Checks if the given room version is one where new "hydra" power level
* semantics (ie. room version 12 or later) should be used
* (see https://github.com/matrix-org/matrix-spec-proposals/pull/4289).
* This will return `true` for versions that are known to the js-sdk and
* use hydra: any room versions unknown to the js-sdk (experimental or
* otherwise) will cause the function to return `false`.
* This will return `false` for versions that are known to the js-sdk and
* do not use hydra: any room versions unknown to the js-sdk (experimental or
* otherwise) will cause the function to return true.
*
* @param roomVersion - The version of the room to check.
* @returns `true` if hydra semantics should be used for the room version, `false` otherwise.
*/
export function shouldUseHydraForRoomVersion(roomVersion: string): boolean {
// Future new room versions must obviously be added to the constant above,
// otherwise the js-sdk will use the old, pre-hydra semantics. At some point
// it would make sense to assume hydra for unknown versions but this will break
// any rooms using unknown versions, so at hydra switch time we've agreed all
// Element clients will only use hydra for the two specific hydra versions.
return HYDRA_ROOM_VERSIONS.includes(roomVersion);
return !PRE_HYDRA_ROOM_VERSIONS.includes(roomVersion);
}