Compare commits
No commits in common. "c8f236b6c028d16435a8415e84db32b713feed8a" and "6e782a72f7aefc12c9530c7ebda46292ee7f15aa" have entirely different histories.
c8f236b6c0
...
6e782a72f7
|
@ -437,9 +437,9 @@ checksum = "3a4f925191b4367301851c6d99b09890311d74b0d43f274c0b34c86d308a3663"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.74"
|
||||
version = "1.0.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574"
|
||||
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
|
@ -565,7 +565,7 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
|||
|
||||
[[package]]
|
||||
name = "corobel"
|
||||
version = "0.5.1"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"atom_syndication",
|
||||
"cached",
|
||||
|
@ -1278,9 +1278,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
|
|||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.22"
|
||||
version = "0.14.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abfba89e19b959ca163c7752ba59d737c1ceea53a5d31a149c805446fc958064"
|
||||
checksum = "02c929dc5c39e335a03c405292728118860721b10190d98c2a0f0efd5baafbac"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
|
@ -1571,9 +1571,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "native-tls"
|
||||
version = "0.2.11"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e"
|
||||
checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"libc",
|
||||
|
@ -1624,9 +1624,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.14.0"
|
||||
version = "1.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5"
|
||||
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
|
@ -1942,18 +1942,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ref-cast"
|
||||
version = "1.0.13"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53b15debb4f9d60d767cd8ca9ef7abb2452922f3214671ff052defc7f3502c44"
|
||||
checksum = "12a733f1746c929b4913fe48f8697fcf9c55e3304ba251a79ffb41adfeaf49c2"
|
||||
dependencies = [
|
||||
"ref-cast-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ref-cast-impl"
|
||||
version = "1.0.13"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abfa8511e9e94fd3de6585a3d3cd00e01ed556dc9814829280af0e8dc72a8f36"
|
||||
checksum = "5887de4a01acafd221861463be6113e6e87275e79804e56779f4cdc131c60368"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -2173,9 +2173,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "scoped-tls"
|
||||
version = "1.0.1"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
|
||||
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "corobel"
|
||||
version = "0.5.1"
|
||||
version = "0.5.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
29
src/main.rs
29
src/main.rs
|
@ -124,7 +124,7 @@ async fn get_full_post_data(project_id: String) -> Result<CohostPostsPage, Error
|
|||
// Not cached because it's never used individually.
|
||||
async fn get_page_data(project_id: String, page: u64) -> Result<CohostPostsPage, ErrorResponse> {
|
||||
let posts_url = cohost_posts_api_url(&project_id, page);
|
||||
eprintln!("[INT] making request to {}", posts_url);
|
||||
eprintln!("making request to {}", posts_url);
|
||||
match CLIENT.get(posts_url).send().await {
|
||||
Ok(v) => match v.status() {
|
||||
StatusCode::OK => match v.json::<CohostPostsPage>().await {
|
||||
|
@ -134,14 +134,14 @@ async fn get_page_data(project_id: String, page: u64) -> Result<CohostPostsPage,
|
|||
"Couldn't deserialize Cohost posts page for '{}': {:?}",
|
||||
project_id, e
|
||||
);
|
||||
eprintln!("[ERR] {}", err);
|
||||
eprintln!("{}", err);
|
||||
return Err(ErrorResponse::InternalError(err));
|
||||
}
|
||||
},
|
||||
// TODO NORA: Handle possible redirects
|
||||
s => {
|
||||
let err = format!("Didn't receive status code 200 for posts for Cohost project '{}'; got {:?} instead.", page, s);
|
||||
eprintln!("[ERR] {}", err);
|
||||
eprintln!("{}", err);
|
||||
return Err(ErrorResponse::NotFound(err));
|
||||
}
|
||||
},
|
||||
|
@ -150,7 +150,7 @@ async fn get_page_data(project_id: String, page: u64) -> Result<CohostPostsPage,
|
|||
"Error making request to Cohost for posts for project '{}': {:?}",
|
||||
project_id, e
|
||||
);
|
||||
eprintln!("[ERR] {}", err);
|
||||
eprintln!("{}", err);
|
||||
return Err(ErrorResponse::InternalError(err));
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ async fn get_page_data(project_id: String, page: u64) -> Result<CohostPostsPage,
|
|||
#[cached(time = 60, result)]
|
||||
async fn get_project_data(project_id: String) -> Result<CohostAccount, ErrorResponse> {
|
||||
let project_url = format!("{}{}", COHOST_ACCOUNT_API_URL, project_id);
|
||||
eprintln!("[INT] making request to {}", project_url);
|
||||
eprintln!("making request to {}", project_url);
|
||||
match CLIENT.get(project_url).send().await {
|
||||
Ok(v) => match v.status() {
|
||||
StatusCode::OK => match v.json::<CohostAccount>().await {
|
||||
|
@ -169,7 +169,7 @@ async fn get_project_data(project_id: String) -> Result<CohostAccount, ErrorResp
|
|||
"Couldn't deserialize Cohost project '{}': {:?}",
|
||||
project_id, e
|
||||
);
|
||||
eprintln!("[ERR] {}", err);
|
||||
eprintln!("{}", err);
|
||||
Err(ErrorResponse::InternalError(err))
|
||||
}
|
||||
},
|
||||
|
@ -179,7 +179,7 @@ async fn get_project_data(project_id: String) -> Result<CohostAccount, ErrorResp
|
|||
"Didn't receive status code 200 for Cohost project '{}'; got {:?} instead.",
|
||||
project_id, s
|
||||
);
|
||||
eprintln!("[ERR] {}", err);
|
||||
eprintln!("{}", err);
|
||||
Err(ErrorResponse::NotFound(err))
|
||||
}
|
||||
},
|
||||
|
@ -188,7 +188,7 @@ async fn get_project_data(project_id: String) -> Result<CohostAccount, ErrorResp
|
|||
"Error making request to Cohost for project '{}': {:?}",
|
||||
project_id, e
|
||||
);
|
||||
eprintln!("[ERR] {}", err);
|
||||
eprintln!("{}", err);
|
||||
Err(ErrorResponse::InternalError(err))
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,6 @@ async fn get_project_data(project_id: String) -> Result<CohostAccount, ErrorResp
|
|||
|
||||
#[get("/<project>/originals.rss")]
|
||||
async fn syndication_originals_rss_route(project: String) -> Result<RssResponse, ErrorResponse> {
|
||||
eprintln!("[EXT] Request to /{}/originals.rss", project);
|
||||
let project_data = get_project_data(project.clone()).await?;
|
||||
let page_data = get_full_post_data(project.clone()).await?;
|
||||
Ok(RssResponse {
|
||||
|
@ -207,7 +206,6 @@ async fn syndication_originals_rss_route(project: String) -> Result<RssResponse,
|
|||
|
||||
#[get("/<project>/feed.rss")]
|
||||
async fn syndication_rss_route(project: String) -> Result<RssResponse, ErrorResponse> {
|
||||
eprintln!("[EXT] Request to /{}/feed.rss", project);
|
||||
let project_data = get_project_data(project.clone()).await?;
|
||||
let page_data = get_full_post_data(project.clone()).await?;
|
||||
Ok(RssResponse {
|
||||
|
@ -218,7 +216,6 @@ async fn syndication_rss_route(project: String) -> Result<RssResponse, ErrorResp
|
|||
|
||||
#[get("/<project>/<id>")]
|
||||
async fn post_md_route(project: String, id: u64) -> Result<MdResponse, ErrorResponse> {
|
||||
eprintln!("[EXT] Request to /{}/{}", project, id);
|
||||
let _project_data = get_project_data(project.clone()).await?;
|
||||
let post_data = get_post_from_page(project.clone(), id).await?;
|
||||
Ok(MdResponse {
|
||||
|
@ -230,20 +227,12 @@ async fn post_md_route(project: String, id: u64) -> Result<MdResponse, ErrorResp
|
|||
async fn webfinger_route(
|
||||
params: HashMap<String, String>,
|
||||
) -> Result<Json<CohostWebfingerResource>, ErrorResponse> {
|
||||
let mut url_params_string = String::new();
|
||||
for (k, v) in params.iter() {
|
||||
url_params_string.push_str(&format!("{}={}&", k, v));
|
||||
}
|
||||
eprintln!(
|
||||
"[EXT] Request to /.well_known/webfinger?{}",
|
||||
url_params_string
|
||||
);
|
||||
if params.len() != 1 {
|
||||
let err = format!(
|
||||
"Too may or too few parameters. Expected 1, got {}",
|
||||
params.len()
|
||||
);
|
||||
eprintln!("[ERR] {}", err);
|
||||
eprintln!("{}", err);
|
||||
return Err(ErrorResponse::InternalError(err));
|
||||
}
|
||||
if let Some(param) = params.iter().next() {
|
||||
|
|
Loading…
Reference in New Issue