refactor: minor appservice code cleanup

This commit is contained in:
Timo Kösters 2024-03-22 08:52:39 +01:00
parent fa930182ae
commit 0bb28f60cf
No known key found for this signature in database
GPG key ID: 0B25E636FBA7E4CB
8 changed files with 136 additions and 163 deletions

View file

@ -80,19 +80,19 @@ where
let mut json_body = serde_json::from_slice::<CanonicalJsonValue>(&body).ok();
let appservices = services().appservice.all().unwrap();
let appservices = services().appservice.all().await;
let appservice_registration = appservices
.iter()
.find(|(_id, registration)| Some(registration.as_token.as_str()) == token);
.find(|info| Some(info.registration.as_token.as_str()) == token);
let (sender_user, sender_device, sender_servername, from_appservice) =
if let Some((_id, registration)) = appservice_registration {
if let Some(info) = appservice_registration {
match metadata.authentication {
AuthScheme::AccessToken => {
let user_id = query_params.user_id.map_or_else(
|| {
UserId::parse_with_server_name(
registration.sender_localpart.as_str(),
info.registration.sender_localpart.as_str(),
services().globals.server_name(),
)
.unwrap()