refactor: small improvements

merge-requests/342/head
Timo Kösters 2 years ago
parent ee96a03d60
commit 566833111c
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4

@ -340,14 +340,17 @@ pub async fn change_password_route(
/// Get user_id of the sender user.
///
/// Note: Also works for Application Services
pub async fn whoami_route(body: Ruma<whoami::v3::Request>) -> Result<whoami::v3::Response> {
pub async fn whoami_route(
db: DatabaseGuard,
body: Ruma<whoami::v3::Request>,
) -> Result<whoami::v3::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let device_id = body.sender_device.as_ref().cloned();
let is_guest = device_id.is_none();
Ok(whoami::v3::Response {
user_id: sender_user.clone(),
device_id,
is_guest,
is_guest: db.users.is_deactivated(&sender_user)?,
})
}

@ -62,7 +62,7 @@ pub async fn report_event_route(
pdu.room_id,
pdu.sender,
body.score,
HtmlEscape(&body.reason.clone().unwrap_or(String::new()))
HtmlEscape(body.reason.as_deref().unwrap_or(""))
),
));

@ -8,8 +8,8 @@ use ruma::{
api::client::{
error::ErrorKind,
uiaa::{
AuthType, IncomingAuthData, IncomingPassword, IncomingUserIdentifier::UserIdOrLocalpart,
UiaaInfo,
AuthType, IncomingAuthData, IncomingPassword,
IncomingUserIdentifier::UserIdOrLocalpart, UiaaInfo,
},
},
signatures::CanonicalJsonValue,

@ -2991,6 +2991,11 @@ pub async fn get_devices_route(
return Err(Error::bad_config("Federation is disabled."));
}
let sender_servername = body
.sender_servername
.as_ref()
.expect("server is authenticated");
Ok(get_devices::v1::Response {
user_id: body.user_id.clone(),
stream_id: db
@ -3016,10 +3021,10 @@ pub async fn get_devices_route(
.collect(),
master_key: db
.users
.get_master_key(&body.user_id, |u| u == &body.user_id)?,
.get_master_key(&body.user_id, |u| u.server_name() == sender_servername)?,
self_signing_key: db
.users
.get_self_signing_key(&body.user_id, |u| u == &body.user_id)?,
.get_self_signing_key(&body.user_id, |u| u.server_name() == sender_servername)?,
})
}

Loading…
Cancel
Save