Files
continuwuity/src/core/info/room_version.rs
T
nexy7574 7e4071c117 Implement room v12 (#943)
**Does not yet work!** Currently, state resolution does not correctly resolve conflicting states. Everything else appears to work as expected, so stateres will be fixed soon, then we should be clear for takeoff.

Also: a lot of things currently accept a nullable room ID that really just don't need to. This will need tidying up before merge. Some authentication checks have also been disabled temporarily but nothing important.

A lot of things are tagged with `TODO(hydra)`, those need resolving before merge. External contributors should PR to the `hydra/public` branch, *not* ` main`.

---

This PR should be squash merged.

Reviewed-on: https://forgejo.ellis.link/continuwuation/continuwuity/pulls/943
Co-authored-by: nexy7574 <git@nexy7574.co.uk>
Co-committed-by: nexy7574 <git@nexy7574.co.uk>
2025-09-17 20:46:03 +00:00

61 lines
1.6 KiB
Rust

//! Room version support
use std::iter::once;
use ruma::{RoomVersionId, api::client::discovery::get_capabilities::RoomVersionStability};
use crate::{at, is_equal_to};
/// Supported and stable room versions
pub const STABLE_ROOM_VERSIONS: &[RoomVersionId] = &[
RoomVersionId::V6,
RoomVersionId::V7,
RoomVersionId::V8,
RoomVersionId::V9,
RoomVersionId::V10,
RoomVersionId::V11,
];
/// Experimental, partially supported room versions
pub const UNSTABLE_ROOM_VERSIONS: &[RoomVersionId] =
&[RoomVersionId::V3, RoomVersionId::V4, RoomVersionId::V5, RoomVersionId::V12];
type RoomVersion = (RoomVersionId, RoomVersionStability);
impl crate::Server {
#[inline]
pub fn supported_room_version(&self, version: &RoomVersionId) -> bool {
self.supported_room_versions().any(is_equal_to!(*version))
}
#[inline]
pub fn supported_room_versions(&self) -> impl Iterator<Item = RoomVersionId> + '_ {
Self::available_room_versions()
.filter(|(_, stability)| self.supported_stability(stability))
.map(at!(0))
}
#[inline]
pub fn available_room_versions() -> impl Iterator<Item = RoomVersion> {
available_room_versions()
}
#[inline]
fn supported_stability(&self, stability: &RoomVersionStability) -> bool {
self.config.allow_unstable_room_versions || *stability == RoomVersionStability::Stable
}
}
pub fn available_room_versions() -> impl Iterator<Item = RoomVersion> {
let unstable_room_versions = UNSTABLE_ROOM_VERSIONS
.iter()
.cloned()
.zip(once(RoomVersionStability::Unstable).cycle());
STABLE_ROOM_VERSIONS
.iter()
.cloned()
.zip(once(RoomVersionStability::Stable).cycle())
.chain(unstable_room_versions)
}