Upgrade to v0.11.0

This commit is contained in:
spikecodes 2021-05-06 12:31:59 -07:00
parent 242ffab0da
commit c1560f4eba
No known key found for this signature in database
GPG key ID: 004CECFF9B463BCB
3 changed files with 54 additions and 49 deletions

View file

@ -101,10 +101,15 @@ pub async fn subscriptions(req: Request<Body>) -> Result<Response<Body>, String>
// Retrieve list of posts for these subreddits to extract display names
let display = json(format!("/r/{}/hot.json?raw_json=1", sub)).await?;
let display_lookup: Vec<(String, &str)> = display["data"]["children"].as_array().unwrap().iter().map(|post| {
let display_name = post["data"]["subreddit"].as_str().unwrap();
(display_name.to_lowercase(), display_name)
}).collect();
let display_lookup: Vec<(String, &str)> = display["data"]["children"]
.as_array()
.unwrap()
.iter()
.map(|post| {
let display_name = post["data"]["subreddit"].as_str().unwrap();
(display_name.to_lowercase(), display_name)
})
.collect();
// Find each subreddit name (separated by '+') in sub parameter
for part in sub.split('+') {
@ -221,7 +226,7 @@ async fn moderators_list(sub: &str) -> Result<Vec<String>, String> {
.iter()
.map(|m| m["name"].as_str().unwrap_or(""))
.filter(|m| !m.is_empty())
.map(|m| m.to_string())
.map(std::string::ToString::to_string)
.collect::<Vec<_>>()
} else {
vec![]