mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 08:11:24 +01:00
Factor content out of FileMeta
That's not what *meta*data means
This commit is contained in:
parent
a06c8db996
commit
84850a163d
3 changed files with 68 additions and 47 deletions
|
|
@ -430,11 +430,13 @@ async fn get_content_route_ruma(
|
|||
) -> Result<authenticated_media_client::get_content::v1::Response> {
|
||||
let mxc = MxcData::new(&body.server_name, &body.media_id)?;
|
||||
|
||||
if let Some(FileMeta {
|
||||
content_type,
|
||||
if let Some((
|
||||
FileMeta {
|
||||
content_type,
|
||||
..
|
||||
},
|
||||
file,
|
||||
..
|
||||
}) = services().media.get(mxc.to_string()).await?
|
||||
)) = services().media.get(mxc.to_string()).await?
|
||||
{
|
||||
Ok(authenticated_media_client::get_content::v1::Response {
|
||||
file,
|
||||
|
|
@ -554,11 +556,13 @@ pub(crate) async fn get_content_as_filename_route_ruma(
|
|||
) -> Result<authenticated_media_client::get_content_as_filename::v1::Response> {
|
||||
let mxc = MxcData::new(&body.server_name, &body.media_id)?;
|
||||
|
||||
if let Some(FileMeta {
|
||||
content_type,
|
||||
if let Some((
|
||||
FileMeta {
|
||||
content_type,
|
||||
..
|
||||
},
|
||||
file,
|
||||
..
|
||||
}) = services().media.get(mxc.to_string()).await?
|
||||
)) = services().media.get(mxc.to_string()).await?
|
||||
{
|
||||
Ok(authenticated_media_client::get_content_as_filename::v1::Response {
|
||||
file,
|
||||
|
|
@ -811,11 +815,13 @@ async fn get_content_thumbnail_route_ruma(
|
|||
}
|
||||
};
|
||||
|
||||
if let Some(FileMeta {
|
||||
content_type,
|
||||
if let Some((
|
||||
FileMeta {
|
||||
content_type,
|
||||
..
|
||||
},
|
||||
file,
|
||||
..
|
||||
}) =
|
||||
)) =
|
||||
services().media.get_thumbnail(mxc.to_string(), width, height).await?
|
||||
{
|
||||
return Ok(make_response(file, content_type));
|
||||
|
|
@ -866,11 +872,13 @@ async fn get_content_thumbnail_route_ruma(
|
|||
|
||||
get_remote_content(&mxc).await?;
|
||||
|
||||
if let Some(FileMeta {
|
||||
content_type,
|
||||
if let Some((
|
||||
FileMeta {
|
||||
content_type,
|
||||
..
|
||||
},
|
||||
file,
|
||||
..
|
||||
}) = services()
|
||||
)) = services()
|
||||
.media
|
||||
.get_thumbnail(mxc.to_string(), width, height)
|
||||
.await?
|
||||
|
|
|
|||
|
|
@ -2046,11 +2046,13 @@ pub(crate) async fn media_download_route(
|
|||
body: Ar<authenticated_media::get_content::v1::Request>,
|
||||
) -> Result<Ra<authenticated_media::get_content::v1::Response>> {
|
||||
let mxc = MxcData::new(services().globals.server_name(), &body.media_id)?;
|
||||
let Some(crate::service::media::FileMeta {
|
||||
content_disposition,
|
||||
content_type,
|
||||
let Some((
|
||||
crate::service::media::FileMeta {
|
||||
content_disposition,
|
||||
content_type,
|
||||
},
|
||||
file,
|
||||
}) = services().media.get(mxc.to_string()).await?
|
||||
)) = services().media.get(mxc.to_string()).await?
|
||||
else {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::NotYetUploaded,
|
||||
|
|
@ -2091,11 +2093,13 @@ pub(crate) async fn media_thumbnail_route(
|
|||
Error::BadRequest(ErrorKind::InvalidParam, "Height is invalid.")
|
||||
})?;
|
||||
|
||||
let Some(crate::service::media::FileMeta {
|
||||
content_type,
|
||||
let Some((
|
||||
crate::service::media::FileMeta {
|
||||
content_type,
|
||||
..
|
||||
},
|
||||
file,
|
||||
..
|
||||
}) = services().media.get_thumbnail(mxc.to_string(), width, height).await?
|
||||
)) = services().media.get_thumbnail(mxc.to_string(), width, height).await?
|
||||
else {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::NotYetUploaded,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue