Optimize user and appservice token queries.

Split/cleanup api::router auth delegator.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-07-27 14:59:16 +00:00
parent 1c24ed09fa
commit 066097a83d
2 changed files with 78 additions and 84 deletions

View File

@@ -166,12 +166,13 @@ impl Service {
.map(|info| info.registration)
}
pub async fn find_from_access_token(&self, token: &str) -> Option<RegistrationInfo> {
pub async fn find_from_access_token(&self, token: &str) -> Result<RegistrationInfo> {
self.read()
.await
.values()
.find(|info| info.registration.as_token == token)
.cloned()
.ok_or_else(|| err!(Request(NotFound("Missing or invalid appservice token"))))
}
/// Checks if a given user id matches any exclusive appservice regex