Added missing get error handling
This commit is contained in:
parent
5740d83d11
commit
890e6baef5
2 changed files with 41 additions and 17 deletions
src/config
|
@ -98,16 +98,17 @@ impl Config {
|
|||
}
|
||||
|
||||
pub(crate) fn check_feeds(&mut self, post_history: &mut Vec<PrevPost>
|
||||
, community_ids: &CommunitiesVector, auth: &Sensitive<String>) -> Vec<CreatePost> {
|
||||
, community_ids: &CommunitiesVector, auth: &Sensitive<String>) -> Result<Vec<CreatePost>, ()> {
|
||||
let mut post_queue: Vec<CreatePost> = vec![];
|
||||
|
||||
self.feeds.iter().for_each(|feed| {
|
||||
let res = CLIENT
|
||||
let res = match CLIENT
|
||||
.get(feed.feed_url.clone())
|
||||
.send()
|
||||
.unwrap()
|
||||
.text()
|
||||
.unwrap();
|
||||
.send() {
|
||||
Ok(data) => data.text().unwrap(),
|
||||
Err(_) => return ()
|
||||
};
|
||||
|
||||
let data: FeedData = serde_json::from_str(&res).unwrap();
|
||||
|
||||
let mut prev_post_idx: Option<usize> = None;
|
||||
|
@ -154,7 +155,7 @@ impl Config {
|
|||
});
|
||||
|
||||
PrevPost::save(&post_history);
|
||||
return post_queue;
|
||||
return Ok(post_queue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,20 +269,23 @@ impl CommunitiesVector {
|
|||
CommunitiesVector{ids: vec![]}
|
||||
}
|
||||
|
||||
pub(crate) fn load(&mut self, auth: &Sensitive<String>, base: &String) {
|
||||
#[warn(unused_results)]
|
||||
pub(crate) fn load(&mut self, auth: &Sensitive<String>, base: &String) -> bool {
|
||||
let params = ListCommunities {
|
||||
auth: Some(auth.clone()),
|
||||
type_: Some(ListingType::Local),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let res = CLIENT
|
||||
let res = match CLIENT
|
||||
.get(base.clone() + "/api/v3/community/list")
|
||||
.query(¶ms)
|
||||
.send()
|
||||
.unwrap()
|
||||
.text()
|
||||
.unwrap();
|
||||
.send() {
|
||||
Ok(data) => {
|
||||
data.text().unwrap()
|
||||
}
|
||||
Err(_) => return false
|
||||
};
|
||||
|
||||
let site_data: ListCommunitiesResponse = serde_json::from_str(&res).unwrap();
|
||||
|
||||
|
@ -293,6 +297,7 @@ impl CommunitiesVector {
|
|||
});
|
||||
|
||||
self.ids = ids;
|
||||
return true;
|
||||
}
|
||||
|
||||
pub(crate) fn find(&self, name: &LemmyCommunities) -> CommunityId {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue