mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-06-27 16:35:59 +00:00
???
This commit is contained in:
parent
4c726f4a68
commit
734e84c668
3 changed files with 25 additions and 23 deletions
|
@ -64,7 +64,7 @@ pub async fn get_register_available_route(
|
||||||
Ok(get_username_availability::v3::Response { available: true })
|
Ok(get_username_availability::v3::Response { available: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # `POST /_matrix/client/r0/register
|
/// # `POST /_matrix/client/r0/register`
|
||||||
///
|
///
|
||||||
/// Register an account on this homeserver.
|
/// Register an account on this homeserver.
|
||||||
///
|
///
|
||||||
|
@ -301,11 +301,7 @@ pub async fn register_route(body: Ruma<register::v3::Request>) -> Result<registe
|
||||||
if let Err(e) = join_room_by_id_helper(
|
if let Err(e) = join_room_by_id_helper(
|
||||||
Some(&user_id),
|
Some(&user_id),
|
||||||
room_id,
|
room_id,
|
||||||
services()
|
services().globals.config.default_rooms.join_reason.clone(),
|
||||||
.globals
|
|
||||||
.config
|
|
||||||
.default_rooms_join_reason
|
|
||||||
.as_deref()
|
|
||||||
&servers,
|
&servers,
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
|
|
@ -57,13 +57,12 @@ pub struct Config {
|
||||||
pub allow_room_creation: bool,
|
pub allow_room_creation: bool,
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
pub allow_unstable_room_versions: bool,
|
pub allow_unstable_room_versions: bool,
|
||||||
#[serde(default = "Vec::new")]
|
|
||||||
pub default_rooms: Vec<OwnedRoomOrAliasId>,
|
|
||||||
pub default_rooms_join_reason: Option<String>,
|
|
||||||
#[serde(default = "default_default_room_version")]
|
#[serde(default = "default_default_room_version")]
|
||||||
pub default_room_version: RoomVersionId,
|
pub default_room_version: RoomVersionId,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub well_known: WellKnownConfig,
|
pub well_known: WellKnownConfig,
|
||||||
|
#[serde(default)]
|
||||||
|
pub default_rooms: DefaultRoomsConfig,
|
||||||
#[serde(default = "false_fn")]
|
#[serde(default = "false_fn")]
|
||||||
pub allow_jaeger: bool,
|
pub allow_jaeger: bool,
|
||||||
#[serde(default = "false_fn")]
|
#[serde(default = "false_fn")]
|
||||||
|
@ -104,6 +103,12 @@ pub struct WellKnownConfig {
|
||||||
pub server: Option<OwnedServerName>,
|
pub server: Option<OwnedServerName>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Default)]
|
||||||
|
pub struct DefaultRoomsConfig {
|
||||||
|
pub rooms: Vec<OwnedRoomOrAliasId>,
|
||||||
|
pub join_reason: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
const DEPRECATED_KEYS: &[&str] = &["cache_capacity"];
|
const DEPRECATED_KEYS: &[&str] = &["cache_capacity"];
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
|
|
@ -509,21 +509,22 @@ impl Service {
|
||||||
pub async fn default_rooms(&self) -> Result<BTreeSet<OwnedRoomId>> {
|
pub async fn default_rooms(&self) -> Result<BTreeSet<OwnedRoomId>> {
|
||||||
let mut default_rooms = BTreeSet::new();
|
let mut default_rooms = BTreeSet::new();
|
||||||
|
|
||||||
for id_or_alias in &self.config.default_rooms {
|
for id_or_alias in &self.config.default_rooms.rooms {
|
||||||
// OwnedRoomOrAliasId always starts with a '#' or '!', presence of a ':' is not validated
|
// // `OwnedRoomOrAliasId` always starts with a '#' or '!', presence of a ':' is not validated
|
||||||
let localpart = id_or_alias
|
// let localpart = id_or_alias
|
||||||
.as_str()
|
// .as_str()
|
||||||
.split_once(':')
|
// .split_once(':')
|
||||||
.map(|(localpart, _)| localpart)
|
// .map(|(localpart, _)| localpart)
|
||||||
.unwrap_or(id_or_alias.as_str());
|
// .unwrap_or(id_or_alias.as_str());
|
||||||
let server_name = id_or_alias
|
// let server_name = id_or_alias
|
||||||
.server_name()
|
// .server_name()
|
||||||
.map(ToOwned::to_owned)
|
// .map(ToOwned::to_owned)
|
||||||
.unwrap_or(self.config.server_name.clone());
|
// .unwrap_or(self.config.server_name.clone());
|
||||||
|
|
||||||
let room_id = match OwnedRoomOrAliasId::from_str(&format!("{localpart}:{server_name}"))
|
let room_id = match id_or_alias.try_into()
|
||||||
.expect("this should always be valid")
|
// OwnedRoomOrAliasId::from_str(&format!("{localpart}:{server_name}"))
|
||||||
.try_into()
|
// .expect("this should always be valid")
|
||||||
|
// .try_into()
|
||||||
{
|
{
|
||||||
Ok(room_id) => room_id,
|
Ok(room_id) => room_id,
|
||||||
Err(room_alias) => get_alias_helper(room_alias).await.map(|res| res.room_id)?,
|
Err(room_alias) => get_alias_helper(room_alias).await.map(|res| res.room_id)?,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue