rename RumaResponse to Ra

It's very commonly used so having a short name is worthwhile, I think.
This commit is contained in:
Charles Hall 2024-05-18 18:59:46 -07:00
parent 230ebd3884
commit 7ea98dac72
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
38 changed files with 332 additions and 351 deletions

View file

@ -9,8 +9,7 @@ use ruma::api::client::{
};
use crate::{
service::media::FileMeta, services, utils, Error, Result, Ruma,
RumaResponse,
service::media::FileMeta, services, utils, Error, Ra, Result, Ruma,
};
const MXC_LENGTH: usize = 32;
@ -20,8 +19,8 @@ const MXC_LENGTH: usize = 32;
/// Returns max upload size.
pub(crate) async fn get_media_config_route(
_body: Ruma<get_media_config::v3::Request>,
) -> Result<RumaResponse<get_media_config::v3::Response>> {
Ok(RumaResponse(get_media_config::v3::Response {
) -> Result<Ra<get_media_config::v3::Response>> {
Ok(Ra(get_media_config::v3::Response {
upload_size: services().globals.max_request_size().into(),
}))
}
@ -34,7 +33,7 @@ pub(crate) async fn get_media_config_route(
/// - Media will be saved in the media/ directory
pub(crate) async fn create_content_route(
body: Ruma<create_content::v3::Request>,
) -> Result<RumaResponse<create_content::v3::Response>> {
) -> Result<Ra<create_content::v3::Response>> {
let mxc = format!(
"mxc://{}/{}",
services().globals.server_name(),
@ -54,7 +53,7 @@ pub(crate) async fn create_content_route(
)
.await?;
Ok(RumaResponse(create_content::v3::Response {
Ok(Ra(create_content::v3::Response {
content_uri: mxc.into(),
blurhash: None,
}))
@ -99,7 +98,7 @@ pub(crate) async fn get_remote_content(
/// - Only allows federation if `allow_remote` is true
pub(crate) async fn get_content_route(
body: Ruma<get_content::v3::Request>,
) -> Result<RumaResponse<get_content::v3::Response>> {
) -> Result<Ra<get_content::v3::Response>> {
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
if let Some(FileMeta {
@ -108,7 +107,7 @@ pub(crate) async fn get_content_route(
file,
}) = services().media.get(mxc.clone()).await?
{
Ok(RumaResponse(get_content::v3::Response {
Ok(Ra(get_content::v3::Response {
file,
content_type,
content_disposition,
@ -120,7 +119,7 @@ pub(crate) async fn get_content_route(
let remote_content_response =
get_remote_content(&mxc, &body.server_name, body.media_id.clone())
.await?;
Ok(RumaResponse(remote_content_response))
Ok(Ra(remote_content_response))
} else {
Err(Error::BadRequest(ErrorKind::NotFound, "Media not found."))
}
@ -133,7 +132,7 @@ pub(crate) async fn get_content_route(
/// - Only allows federation if `allow_remote` is true
pub(crate) async fn get_content_as_filename_route(
body: Ruma<get_content_as_filename::v3::Request>,
) -> Result<RumaResponse<get_content_as_filename::v3::Response>> {
) -> Result<Ra<get_content_as_filename::v3::Response>> {
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
if let Some(FileMeta {
@ -142,7 +141,7 @@ pub(crate) async fn get_content_as_filename_route(
..
}) = services().media.get(mxc.clone()).await?
{
Ok(RumaResponse(get_content_as_filename::v3::Response {
Ok(Ra(get_content_as_filename::v3::Response {
file,
content_type,
content_disposition: Some(format!(
@ -158,7 +157,7 @@ pub(crate) async fn get_content_as_filename_route(
get_remote_content(&mxc, &body.server_name, body.media_id.clone())
.await?;
Ok(RumaResponse(get_content_as_filename::v3::Response {
Ok(Ra(get_content_as_filename::v3::Response {
content_disposition: Some(format!(
"inline: filename={}",
body.filename
@ -179,7 +178,7 @@ pub(crate) async fn get_content_as_filename_route(
/// - Only allows federation if `allow_remote` is true
pub(crate) async fn get_content_thumbnail_route(
body: Ruma<get_content_thumbnail::v3::Request>,
) -> Result<RumaResponse<get_content_thumbnail::v3::Response>> {
) -> Result<Ra<get_content_thumbnail::v3::Response>> {
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
if let Some(FileMeta {
@ -199,7 +198,7 @@ pub(crate) async fn get_content_thumbnail_route(
)
.await?
{
Ok(RumaResponse(get_content_thumbnail::v3::Response {
Ok(Ra(get_content_thumbnail::v3::Response {
file,
content_type,
cross_origin_resource_policy: Some("cross-origin".to_owned()),
@ -236,7 +235,7 @@ pub(crate) async fn get_content_thumbnail_route(
)
.await?;
Ok(RumaResponse(get_thumbnail_response))
Ok(Ra(get_thumbnail_response))
} else {
Err(Error::BadRequest(ErrorKind::NotFound, "Media not found."))
}