From b43ed01958ed8b5e8765f8c3ffd30ee51f8f40dc Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Thu, 28 Dec 2023 10:30:42 -0500 Subject: [PATCH 1/2] Fix /r/popular localization - set geo filter to global --- src/subreddit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/subreddit.rs b/src/subreddit.rs index 6dc91f4..560b487 100644 --- a/src/subreddit.rs +++ b/src/subreddit.rs @@ -104,7 +104,7 @@ pub async fn community(req: Request) -> Result, String> { return Ok(nsfw_landing(req, req_url).await.unwrap_or_default()); } - let path = format!("/r/{}/{}.json?{}&raw_json=1", sub_name.clone(), sort, req.uri().query().unwrap_or_default()); + let path = format!("/r/{sub_name}/{sort}.json?{}&raw_json=1&geo_filter=GLOBAL", req.uri().query().unwrap_or_default()); let url = String::from(req.uri().path_and_query().map_or("", |val| val.as_str())); let redirect_url = url[1..].replace('?', "%3F").replace('&', "%26").replace('+', "%2B"); let filters = get_filters(&req); From 42902cc8d029c854d3f33aa5202c7cc809e90c2a Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Thu, 28 Dec 2023 10:40:17 -0500 Subject: [PATCH 2/2] Add test for popular globalization --- src/client.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client.rs b/src/client.rs index 451893d..6cda26c 100644 --- a/src/client.rs +++ b/src/client.rs @@ -331,3 +331,9 @@ pub async fn json(path: String, quarantine: bool) -> Result { Err(e) => err("Couldn't send request to Reddit", e), } } + +#[tokio::test(flavor = "multi_thread", worker_threads = 1)] +async fn test_localization_popular() { + let val = json("/r/popular/hot.json?&raw_json=1&geo_filter=GLOBAL".to_string(), false).await.unwrap(); + assert_eq!("GLOBAL", val["data"]["geo_filter"].as_str().unwrap()); +}