Compare commits
No commits in common. "master" and "master" have entirely different histories.
4 changed files with 35 additions and 52 deletions
|
@ -31,6 +31,7 @@ steps:
|
|||
when:
|
||||
event: [push, tag, deployment]
|
||||
branch: master
|
||||
secrets: [docker_token]
|
||||
settings:
|
||||
repo: realaravinth/libmedium
|
||||
username: realaravinth
|
||||
|
|
28
Cargo.lock
generated
28
Cargo.lock
generated
|
@ -21,9 +21,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "actix-http"
|
||||
version = "3.9.0"
|
||||
version = "3.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d48f96fc3003717aeb9856ca3d02a8c7de502667ad76eeacd830b48d2e91fac4"
|
||||
checksum = "3ae682f693a9cd7b058f2b0b5d9a6d7728a8555779bedbbc35dd88528611d020"
|
||||
dependencies = [
|
||||
"actix-codec",
|
||||
"actix-rt",
|
||||
|
@ -134,9 +134,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "actix-web"
|
||||
version = "4.9.0"
|
||||
version = "4.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9180d76e5cc7ccbc4d60a506f2c727730b154010262df5b910eb17dbe4b8cb38"
|
||||
checksum = "1988c02af8d2b718c05bc4aeb6a66395b7cdf32858c2c71131e5637a8c05a9ff"
|
||||
dependencies = [
|
||||
"actix-codec",
|
||||
"actix-http",
|
||||
|
@ -156,7 +156,6 @@ dependencies = [
|
|||
"encoding_rs",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"impl-more",
|
||||
"itoa",
|
||||
"language-tags",
|
||||
"log",
|
||||
|
@ -1076,12 +1075,6 @@ dependencies = [
|
|||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "impl-more"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "206ca75c9c03ba3d4ace2460e57b189f39f43de612c2f85836e65c929701bb2d"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.2.6"
|
||||
|
@ -1920,18 +1913,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.210"
|
||||
version = "1.0.204"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
|
||||
checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.210"
|
||||
version = "1.0.204"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
|
||||
checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -1940,12 +1933,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.128"
|
||||
version = "1.0.120"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8"
|
||||
checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
|
16
src/data.rs
16
src/data.rs
|
@ -164,14 +164,14 @@ impl Data {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn get_post_light(&self, id: &str) -> Option<PostUrl> {
|
||||
pub async fn get_post_light(&self, id: &str) -> PostUrl {
|
||||
match self.posts.get(id) {
|
||||
Ok(Some(v)) => {
|
||||
let cached: PostResp = bincode::deserialize(&v[..]).unwrap();
|
||||
Some(PostUrl {
|
||||
PostUrl {
|
||||
slug: cached.unique_slug,
|
||||
username: cached.creator.username,
|
||||
})
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
let vars = get_post_light::Variables { id: id.to_owned() };
|
||||
|
@ -180,16 +180,10 @@ impl Data {
|
|||
let res = post_graphql::<GetPostLight, _>(&self.client, URL, vars)
|
||||
.await
|
||||
.unwrap();
|
||||
if res.data.is_none() {
|
||||
None
|
||||
} else {
|
||||
match res.data.expect("missing response data").post {
|
||||
None => None,
|
||||
Some(res) => Some(PostUrl {
|
||||
let res = res.data.expect("missing response data").post.unwrap();
|
||||
PostUrl {
|
||||
slug: res.unique_slug,
|
||||
username: res.creator.username,
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
16
src/proxy.rs
16
src/proxy.rs
|
@ -158,33 +158,29 @@ async fn assets(path: web::Path<String>, data: AppData) -> impl Responder {
|
|||
|
||||
#[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.proxy.by_post_id")]
|
||||
async fn by_post_id(path: web::Path<String>, data: AppData) -> impl Responder {
|
||||
match data.get_post_light(&path).await {
|
||||
None => HttpResponse::NotFound().body("Post not found"),
|
||||
Some(post_data) => HttpResponse::Found()
|
||||
let post_data = data.get_post_light(&path).await;
|
||||
HttpResponse::Found()
|
||||
.append_header((
|
||||
header::LOCATION,
|
||||
crate::V1_API_ROUTES
|
||||
.proxy
|
||||
.get_page(&post_data.username, &post_data.slug),
|
||||
))
|
||||
.finish(),
|
||||
}
|
||||
.finish()
|
||||
}
|
||||
|
||||
#[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.proxy.top_level_post")]
|
||||
async fn by_top_level_post(path: web::Path<String>, data: AppData) -> impl Responder {
|
||||
if let Some(post_id) = path.split('-').last() {
|
||||
match data.get_post_light(post_id).await {
|
||||
None => HttpResponse::NotFound().body("Post not found"),
|
||||
Some(post_data) => HttpResponse::Found()
|
||||
let post_data = data.get_post_light(post_id).await;
|
||||
HttpResponse::Found()
|
||||
.append_header((
|
||||
header::LOCATION,
|
||||
crate::V1_API_ROUTES
|
||||
.proxy
|
||||
.get_page(&post_data.username, &post_data.slug),
|
||||
))
|
||||
.finish(),
|
||||
}
|
||||
.finish()
|
||||
} else {
|
||||
HttpResponse::NotFound().body("Post not found, please file bug report")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue