use OwnedMxcUri in media service

Not using `MxcData` because it borrows it's fields, and so we wouldn't
be able to return an owned `MxcData` from functions that read the db.
This commit is contained in:
Benjamin Lee 2024-09-14 20:43:56 -07:00
parent e2cba15ed2
commit 7672cc8473
No known key found for this signature in database
GPG key ID: FB9624E2885D55A4
5 changed files with 25 additions and 23 deletions

View file

@ -159,7 +159,7 @@ pub(crate) async fn create_content_route(
services()
.media
.create(
mxc.to_string(),
mxc.clone().into(),
body.filename
.clone()
.map(|filename| ContentDisposition {
@ -350,7 +350,7 @@ pub(crate) async fn get_remote_content(
services()
.media
.create(
mxc.to_string(),
mxc.clone().into(),
response.content.content_disposition.as_ref(),
response.content.content_type.clone(),
&response.content.file,
@ -455,7 +455,7 @@ async fn get_content_route_ruma(
..
},
file,
)) = services().media.get(mxc.to_string()).await?
)) = services().media.get(mxc.clone().into()).await?
{
Ok(authenticated_media_client::get_content::v1::Response {
file,
@ -581,7 +581,7 @@ async fn get_content_as_filename_route_ruma(
..
},
file,
)) = services().media.get(mxc.to_string()).await?
)) = services().media.get(mxc.clone().into()).await?
{
Ok(authenticated_media_client::get_content_as_filename::v1::Response {
file,
@ -842,8 +842,10 @@ async fn get_content_thumbnail_route_ruma(
..
},
file,
)) =
services().media.get_thumbnail(mxc.to_string(), width, height).await?
)) = services()
.media
.get_thumbnail(mxc.clone().into(), width, height)
.await?
{
return Ok(make_response(file, content_type));
}
@ -872,7 +874,7 @@ async fn get_content_thumbnail_route_ruma(
services()
.media
.upload_thumbnail(
mxc.to_string(),
mxc.clone().into(),
None,
resp.content.content_type.clone(),
width,
@ -901,10 +903,8 @@ async fn get_content_thumbnail_route_ruma(
..
},
file,
)) = services()
.media
.get_thumbnail(mxc.to_string(), width, height)
.await?
)) =
services().media.get_thumbnail(mxc.into(), width, height).await?
{
return Ok(make_response(file, content_type));
}