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

@ -1,7 +1,7 @@
use std::io::Cursor;
use image::imageops::FilterType;
use ruma::http_headers::ContentDisposition;
use ruma::{http_headers::ContentDisposition, OwnedMxcUri};
use tokio::{
fs::File,
io::{AsyncReadExt, AsyncWriteExt},
@ -46,7 +46,7 @@ impl Service {
#[tracing::instrument(skip(self, file))]
pub(crate) async fn create(
&self,
mxc: String,
mxc: OwnedMxcUri,
content_disposition: Option<&ContentDisposition>,
content_type: Option<String>,
file: &[u8],
@ -69,7 +69,7 @@ impl Service {
#[tracing::instrument(skip(self, file))]
pub(crate) async fn upload_thumbnail(
&self,
mxc: String,
mxc: OwnedMxcUri,
content_disposition: Option<String>,
content_type: Option<String>,
width: u32,
@ -93,7 +93,7 @@ impl Service {
#[tracing::instrument(skip(self))]
pub(crate) async fn get(
&self,
mxc: String,
mxc: OwnedMxcUri,
) -> Result<Option<(FileMeta, Vec<u8>)>> {
if let Ok((meta, key)) = self.db.search_file_metadata(mxc, 0, 0) {
let path = services().globals.get_media_file(&key);
@ -224,7 +224,7 @@ impl Service {
#[tracing::instrument(skip(self))]
pub(crate) async fn get_thumbnail(
&self,
mxc: String,
mxc: OwnedMxcUri,
width: u32,
height: u32,
) -> Result<Option<(FileMeta, Vec<u8>)>> {