add room ID server_name as backfill server, make servers
a vector
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
690928ec81
commit
9b2ccff7dd
1 changed files with 20 additions and 5 deletions
|
@ -7,6 +7,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use data::Data;
|
pub use data::Data;
|
||||||
|
use rand::prelude::SliceRandom;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{client::error::ErrorKind, federation},
|
api::{client::error::ErrorKind, federation},
|
||||||
canonical_json::to_canonical_value,
|
canonical_json::to_canonical_value,
|
||||||
|
@ -938,16 +939,30 @@ impl Service {
|
||||||
})
|
})
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let mut admin_servers = power_levels
|
|
||||||
|
let mut servers = power_levels
|
||||||
.users
|
.users
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_, level)| **level > power_levels.users_default)
|
.filter(|(_, level)| **level > power_levels.users_default)
|
||||||
.map(|(user_id, _)| user_id.server_name())
|
.map(|(user_id, _)| user_id.server_name())
|
||||||
.collect::<HashSet<_>>();
|
.collect::<Vec<_>>();
|
||||||
admin_servers.remove(services().globals.server_name());
|
|
||||||
|
|
||||||
// Request backfill
|
// don't backfill from ourselves
|
||||||
for backfill_server in admin_servers {
|
if let Some(server_index) =
|
||||||
|
servers.clone().into_iter().position(|server| server == services().globals.server_name())
|
||||||
|
{
|
||||||
|
servers.remove(server_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(server) = room_id.server_name() {
|
||||||
|
servers.push(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
servers.sort_unstable();
|
||||||
|
servers.dedup();
|
||||||
|
servers.shuffle(&mut rand::thread_rng());
|
||||||
|
|
||||||
|
for backfill_server in servers {
|
||||||
info!("Asking {backfill_server} for backfill");
|
info!("Asking {backfill_server} for backfill");
|
||||||
let response = services()
|
let response = services()
|
||||||
.sending
|
.sending
|
||||||
|
|
Loading…
Add table
Reference in a new issue