feedreader: Handle entries with no link attribute
This commit is contained in:
parent
cd590b73fe
commit
50f0bcd3c7
@ -56,7 +56,7 @@ pub async fn fetch_and_parse_feed(uri: &str) -> Result<Feed, Box<dyn Error>> {
|
|||||||
let http_client = reqwest::Client::builder().default_headers(headers).build()?;
|
let http_client = reqwest::Client::builder().default_headers(headers).build()?;
|
||||||
let response = http_client.get(uri).send().await?.text().await?;
|
let response = http_client.get(uri).send().await?.text().await?;
|
||||||
|
|
||||||
info!("Got response, parsing feed");
|
info!("Got response, parsing feed from {}", uri);
|
||||||
let feed = parser::parse(response.as_bytes())?;
|
let feed = parser::parse(response.as_bytes())?;
|
||||||
|
|
||||||
let feed_title = match feed.title.clone() {
|
let feed_title = match feed.title.clone() {
|
||||||
@ -82,7 +82,11 @@ pub fn format_entry(feed: Feed, entry: model::Entry) -> Result<Entry, Box<dyn Er
|
|||||||
Some(t) => t.content,
|
Some(t) => t.content,
|
||||||
None => String::from("Untitled")
|
None => String::from("Untitled")
|
||||||
},
|
},
|
||||||
link: entry.links[0].href.clone(),
|
link: if entry.links.len() > 0 {
|
||||||
|
entry.links[0].href.clone()
|
||||||
|
} else {
|
||||||
|
String::from("#")
|
||||||
|
},
|
||||||
ts: match entry.updated {
|
ts: match entry.updated {
|
||||||
Some(d) => d,
|
Some(d) => d,
|
||||||
None => entry.published.unwrap_or(Utc::now())
|
None => entry.published.unwrap_or(Utc::now())
|
||||||
|
Loading…
Reference in New Issue
Block a user