add interface to get file metadata w/ admin command
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
e7b2c14280
commit
7b0e830f4c
3 changed files with 27 additions and 2 deletions
|
@ -31,7 +31,7 @@ pub struct FileMeta {
|
|||
|
||||
pub struct Service {
|
||||
url_preview_mutex: MutexMap<String, ()>,
|
||||
pub(crate) db: Data,
|
||||
pub(super) db: Data,
|
||||
services: Services,
|
||||
}
|
||||
|
||||
|
@ -347,6 +347,18 @@ impl Service {
|
|||
Ok(file)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_metadata(&self, mxc: &Mxc<'_>) -> Option<FileMeta> {
|
||||
self.db
|
||||
.search_file_metadata(mxc, 0, 0)
|
||||
.map(|metadata| FileMeta {
|
||||
content_disposition: metadata.content_disposition,
|
||||
content_type: metadata.content_type,
|
||||
content: None,
|
||||
})
|
||||
.ok()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn get_media_file(&self, key: &[u8]) -> PathBuf { self.get_media_file_sha256(key) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue