Verified Commit fdccd0ab authored by Jordan Petridis's avatar Jordan Petridis 🌱

matrix-api/util.rs: Convert thumb! to a function

parent 7e4c47fd
......@@ -11,6 +11,7 @@ use util::cache_dir_path;
use util::get_room_media_list;
use util::resolve_media_url;
use util::semaphore;
use util::thumb;
use util;
use types::Message;
......@@ -19,7 +20,7 @@ pub fn get_thumb_async(bk: &Backend, media: String, tx: Sender<String>) -> Resul
let baseu = bk.get_base_url()?;
semaphore(bk.limit_threads.clone(), move || {
match thumb!(&baseu, &media) {
match thumb(&baseu, &media) {
Ok(fname) => {
tx.send(fname).unwrap();
}
......
......@@ -153,19 +153,6 @@ macro_rules! query {
};
}
#[macro_export]
macro_rules! thumb {
($base: expr, $url: expr) => {
dw_media($base, $url, true, None, 64, 64)
};
($base: expr, $url: expr, $size: expr) => {
dw_media($base, $url, true, None, $size, $size)
};
($base: expr, $url: expr, $w: expr, $h: expr) => {
dw_media($base, $url, true, None, $w, $h)
};
}
pub fn evc(events: &JsonValue, t: &str, field: &str) -> String {
events
.as_array()
......@@ -569,6 +556,10 @@ pub fn media(base: &Url, url: &str, dest: Option<&str>) -> Result<String, Error>
dw_media(base, url, false, dest, 0, 0)
}
pub fn thumb(base: &Url, url: &str)-> Result<String, Error> {
dw_media(base, url, true, None, 64, 64)
}
pub fn download_file(url: &str, fname: String, dest: Option<&str>) -> Result<String, Error> {
let pathname = fname.clone();
let p = Path::new(&pathname);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment