diff --git a/Cargo.lock b/Cargo.lock index 46f1a55..b8b2b2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -486,7 +486,7 @@ dependencies = [ "memchr", "num_cpus", "once_cell", - "pin-project-lite", + "pin-project-lite 0.1.11", "pin-utils", "slab", "wasm-bindgen-futures", @@ -1006,7 +1006,7 @@ dependencies = [ "futures-io", "memchr", "parking", - "pin-project-lite", + "pin-project-lite 0.1.11", "waker-fn", ] @@ -1236,7 +1236,7 @@ dependencies = [ "cookie", "futures-lite", "infer", - "pin-project-lite", + "pin-project-lite 0.1.11", "rand", "serde", "serde_json", @@ -1724,6 +1724,12 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" +[[package]] +name = "pin-project-lite" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" + [[package]] name = "pin-utils" version = "0.1.0" @@ -1908,9 +1914,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.16.16" +version = "0.16.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b72b84d47e8ec5a4f2872e8262b8f8256c5be1c938a7d6d3a867a3ba8f722f74" +checksum = "c5911690c9b773bab7e657471afc207f3827b249a657241327e3544d79bcabdd" dependencies = [ "cc", "libc", @@ -2234,7 +2240,7 @@ dependencies = [ "log", "mime_guess", "once_cell", - "pin-project-lite", + "pin-project-lite 0.1.11", "serde", "serde_json", "web-sys", @@ -2378,7 +2384,7 @@ dependencies = [ "memchr", "mio", "mio-uds", - "pin-project-lite", + "pin-project-lite 0.1.11", "signal-hook-registry", "slab", "winapi 0.3.9", @@ -2406,7 +2412,7 @@ dependencies = [ "futures-core", "futures-sink", "log", - "pin-project-lite", + "pin-project-lite 0.1.11", "tokio", ] @@ -2421,13 +2427,13 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" +checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "log", - "pin-project-lite", + "pin-project-lite 0.2.0", "tracing-attributes", "tracing-core", ] diff --git a/Cargo.toml b/Cargo.toml index 8b93c7f..be5bd1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,12 @@ version = "0.1.6" authors = ["spikecodes <19519553+spikecodes@users.noreply.github.com>"] edition = "2018" +[features] +default = ["proxy"] +proxy = ["actix-web/rustls"] + [dependencies] -actix-web = { version = "3.2.0", features = ["rustls"] } +actix-web = "3.2.0" surf = "2.1.0" askama = "0.8.0" serde = "1.0.117" diff --git a/src/post.rs b/src/post.rs index 73c3234..31e478a 100644 --- a/src/post.rs +++ b/src/post.rs @@ -74,18 +74,20 @@ async fn media(data: &serde_json::Value) -> String { let post_hint: &str = data["data"]["post_hint"].as_str().unwrap_or(""); let has_media: bool = data["data"]["media"].is_object(); + let prefix = if cfg!(feature = "proxy") { "/imageproxy/" } else { "" }; + let media: String = if !has_media { format!(r#"

{u}

"#, u = data["data"]["url"].as_str().unwrap()) } else { - format!(r#""#, data["data"]["url"].as_str().unwrap()) + format!(r#""#, prefix, data["data"]["url"].as_str().unwrap()) }; match post_hint { "hosted:video" => format!( - r#"