mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-16 18:28:22 -07:00
improvement: randomize server order for alias joins
This commit is contained in:
parent
3a1a72df98
commit
fd1ccbd3ad
@ -1,4 +1,5 @@
|
|||||||
use crate::{services, Error, Result, Ruma};
|
use crate::{services, Error, Result, Ruma};
|
||||||
|
use rand::seq::SliceRandom;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{
|
api::{
|
||||||
@ -90,10 +91,10 @@ pub(crate) async fn get_alias_helper(
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
return Ok(get_alias::v3::Response::new(
|
let mut servers = response.servers;
|
||||||
response.room_id,
|
servers.shuffle(&mut rand::thread_rng());
|
||||||
response.servers,
|
|
||||||
));
|
return Ok(get_alias::v3::Response::new(response.room_id, servers));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut room_id = None;
|
let mut room_id = None;
|
||||||
|
@ -112,7 +112,7 @@ pub async fn join_room_by_id_or_alias_route(
|
|||||||
Err(room_alias) => {
|
Err(room_alias) => {
|
||||||
let response = get_alias_helper(room_alias).await?;
|
let response = get_alias_helper(room_alias).await?;
|
||||||
|
|
||||||
(response.servers.into_iter().collect(), response.room_id)
|
(response.servers, response.room_id)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user