mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +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
|
|
@ -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."))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue