Merge branch 'joinfix' into 'next'

improvement: randomize server order for alias joins

See merge request famedly/conduit!491
This commit is contained in:
Timo Kösters 2023-06-28 15:47:36 +00:00
commit 6a6f8e80f1
2 changed files with 6 additions and 5 deletions

View file

@ -1,4 +1,5 @@
use crate::{services, Error, Result, Ruma};
use rand::seq::SliceRandom;
use regex::Regex;
use ruma::{
api::{
@ -90,10 +91,10 @@ pub(crate) async fn get_alias_helper(
)
.await?;
return Ok(get_alias::v3::Response::new(
response.room_id,
response.servers,
));
let mut servers = response.servers;
servers.shuffle(&mut rand::thread_rng());
return Ok(get_alias::v3::Response::new(response.room_id, servers));
}
let mut room_id = None;

View file

@ -112,7 +112,7 @@ pub async fn join_room_by_id_or_alias_route(
Err(room_alias) => {
let response = get_alias_helper(room_alias).await?;
(response.servers.into_iter().collect(), response.room_id)
(response.servers, response.room_id)
}
};