mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 00:01:24 +01:00
rename RumaResponse to Ra
It's very commonly used so having a short name is worthwhile, I think.
This commit is contained in:
parent
230ebd3884
commit
7ea98dac72
38 changed files with 332 additions and 351 deletions
|
|
@ -19,9 +19,7 @@ use ruma::{
|
|||
use tracing::{info, warn};
|
||||
|
||||
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH};
|
||||
use crate::{
|
||||
api::client_server, services, utils, Error, Result, Ruma, RumaResponse,
|
||||
};
|
||||
use crate::{api::client_server, services, utils, Error, Ra, Result, Ruma};
|
||||
|
||||
const RANDOM_USER_ID_LENGTH: usize = 10;
|
||||
|
||||
|
|
@ -38,7 +36,7 @@ const RANDOM_USER_ID_LENGTH: usize = 10;
|
|||
/// invalid when trying to register
|
||||
pub(crate) async fn get_register_available_route(
|
||||
body: Ruma<get_username_availability::v3::Request>,
|
||||
) -> Result<RumaResponse<get_username_availability::v3::Response>> {
|
||||
) -> Result<Ra<get_username_availability::v3::Response>> {
|
||||
// Validate user id
|
||||
let user_id = UserId::parse_with_server_name(
|
||||
body.username.to_lowercase(),
|
||||
|
|
@ -65,7 +63,7 @@ pub(crate) async fn get_register_available_route(
|
|||
// TODO add check for appservice namespaces
|
||||
|
||||
// If no if check is true we have an username that's available to be used.
|
||||
Ok(RumaResponse(get_username_availability::v3::Response {
|
||||
Ok(Ra(get_username_availability::v3::Response {
|
||||
available: true,
|
||||
}))
|
||||
}
|
||||
|
|
@ -90,7 +88,7 @@ pub(crate) async fn get_register_available_route(
|
|||
#[allow(clippy::too_many_lines)]
|
||||
pub(crate) async fn register_route(
|
||||
body: Ruma<register::v3::Request>,
|
||||
) -> Result<RumaResponse<register::v3::Response>> {
|
||||
) -> Result<Ra<register::v3::Response>> {
|
||||
if !services().globals.allow_registration()
|
||||
&& body.appservice_info.is_none()
|
||||
{
|
||||
|
|
@ -250,7 +248,7 @@ pub(crate) async fn register_route(
|
|||
|
||||
// Inhibit login does not work for guests
|
||||
if !is_guest && body.inhibit_login {
|
||||
return Ok(RumaResponse(register::v3::Response {
|
||||
return Ok(Ra(register::v3::Response {
|
||||
access_token: None,
|
||||
user_id,
|
||||
device_id: None,
|
||||
|
|
@ -302,7 +300,7 @@ pub(crate) async fn register_route(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(RumaResponse(register::v3::Response {
|
||||
Ok(Ra(register::v3::Response {
|
||||
access_token: Some(token),
|
||||
user_id,
|
||||
device_id: Some(device_id),
|
||||
|
|
@ -330,7 +328,7 @@ pub(crate) async fn register_route(
|
|||
/// - Triggers device list updates
|
||||
pub(crate) async fn change_password_route(
|
||||
body: Ruma<change_password::v3::Request>,
|
||||
) -> Result<RumaResponse<change_password::v3::Response>> {
|
||||
) -> Result<Ra<change_password::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let sender_device =
|
||||
body.sender_device.as_ref().expect("user is authenticated");
|
||||
|
|
@ -383,7 +381,7 @@ pub(crate) async fn change_password_route(
|
|||
format!("User {sender_user} changed their password."),
|
||||
));
|
||||
|
||||
Ok(RumaResponse(change_password::v3::Response {}))
|
||||
Ok(Ra(change_password::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `GET _matrix/client/r0/account/whoami`
|
||||
|
|
@ -393,11 +391,11 @@ pub(crate) async fn change_password_route(
|
|||
/// Note: Also works for Application Services
|
||||
pub(crate) async fn whoami_route(
|
||||
body: Ruma<whoami::v3::Request>,
|
||||
) -> Result<RumaResponse<whoami::v3::Response>> {
|
||||
) -> Result<Ra<whoami::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let device_id = body.sender_device.as_ref().cloned();
|
||||
|
||||
Ok(RumaResponse(whoami::v3::Response {
|
||||
Ok(Ra(whoami::v3::Response {
|
||||
user_id: sender_user.clone(),
|
||||
device_id,
|
||||
is_guest: services().users.is_deactivated(sender_user)?
|
||||
|
|
@ -418,7 +416,7 @@ pub(crate) async fn whoami_route(
|
|||
/// - Removes ability to log in again
|
||||
pub(crate) async fn deactivate_route(
|
||||
body: Ruma<deactivate::v3::Request>,
|
||||
) -> Result<RumaResponse<deactivate::v3::Response>> {
|
||||
) -> Result<Ra<deactivate::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let sender_device =
|
||||
body.sender_device.as_ref().expect("user is authenticated");
|
||||
|
|
@ -463,7 +461,7 @@ pub(crate) async fn deactivate_route(
|
|||
format!("User {sender_user} deactivated their account."),
|
||||
));
|
||||
|
||||
Ok(RumaResponse(deactivate::v3::Response {
|
||||
Ok(Ra(deactivate::v3::Response {
|
||||
id_server_unbind_result: ThirdPartyIdRemovalStatus::NoSupport,
|
||||
}))
|
||||
}
|
||||
|
|
@ -475,11 +473,11 @@ pub(crate) async fn deactivate_route(
|
|||
/// - Currently always returns empty list
|
||||
pub(crate) async fn third_party_route(
|
||||
body: Ruma<get_3pids::v3::Request>,
|
||||
) -> Result<RumaResponse<get_3pids::v3::Response>> {
|
||||
) -> Result<Ra<get_3pids::v3::Response>> {
|
||||
let _sender_user =
|
||||
body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
Ok(RumaResponse(get_3pids::v3::Response::new(Vec::new())))
|
||||
Ok(Ra(get_3pids::v3::Response::new(Vec::new())))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/v3/account/3pid/email/requestToken`
|
||||
|
|
@ -491,8 +489,7 @@ pub(crate) async fn third_party_route(
|
|||
/// as a contact option.
|
||||
pub(crate) async fn request_3pid_management_token_via_email_route(
|
||||
_body: Ruma<request_3pid_management_token_via_email::v3::Request>,
|
||||
) -> Result<RumaResponse<request_3pid_management_token_via_email::v3::Response>>
|
||||
{
|
||||
) -> Result<Ra<request_3pid_management_token_via_email::v3::Response>> {
|
||||
Err(Error::BadRequest(
|
||||
ErrorKind::ThreepidDenied,
|
||||
"Third party identifier is not allowed",
|
||||
|
|
@ -506,12 +503,9 @@ pub(crate) async fn request_3pid_management_token_via_email_route(
|
|||
///
|
||||
/// - 403 signals that The homeserver does not allow the third party identifier
|
||||
/// as a contact option.
|
||||
#[rustfmt::skip]
|
||||
pub(crate) async fn request_3pid_management_token_via_msisdn_route(
|
||||
_body: Ruma<request_3pid_management_token_via_msisdn::v3::Request>,
|
||||
)
|
||||
-> Result<RumaResponse<request_3pid_management_token_via_msisdn::v3::Response>>
|
||||
{
|
||||
) -> Result<Ra<request_3pid_management_token_via_msisdn::v3::Response>> {
|
||||
Err(Error::BadRequest(
|
||||
ErrorKind::ThreepidDenied,
|
||||
"Third party identifier is not allowed",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue