Refactor join, alias services

Split knock, user register from api into services

Fix autojoin not working with v12 rooms

Fix 'm.login.registration_token/validity' for reloaded registration tokens

Change join servers order

Move autojoin for ldap
This commit is contained in:
dasha_uwu
2025-12-05 14:00:28 +05:00
committed by Jason Volk
parent 959c559bd8
commit 7115fb2796
25 changed files with 1153 additions and 1334 deletions

View File

@@ -1,5 +1,5 @@
use std::{
collections::{BTreeMap, HashSet},
collections::BTreeMap,
sync::{Arc, RwLock},
};
@@ -45,32 +45,6 @@ impl crate::Service for Service {
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
}
#[implement(Service)]
pub async fn read_tokens(&self) -> Result<HashSet<String>> {
let mut tokens = HashSet::new();
if let Some(file) = &self
.services
.config
.registration_token_file
.as_ref()
{
match std::fs::read_to_string(file) {
| Err(e) => error!("Failed to read the registration token file: {e}"),
| Ok(text) => {
text.split_ascii_whitespace().for_each(|token| {
tokens.insert(token.to_owned());
});
},
}
}
if let Some(token) = &self.services.config.registration_token {
tokens.insert(token.to_owned());
}
Ok(tokens)
}
/// Creates a new Uiaa session. Make sure the session token is unique.
#[implement(Service)]
pub fn create(
@@ -175,7 +149,11 @@ pub async fn try_auth(
uiaainfo.completed.push(AuthType::Password);
},
| AuthData::RegistrationToken(t) => {
let tokens = self.read_tokens().await?;
let tokens = self
.services
.globals
.get_registration_tokens()
.await;
if tokens.contains(t.token.trim()) {
uiaainfo
.completed