Compare commits

...

3 Commits

5 changed files with 513 additions and 334 deletions

833
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package]
name = "matrix-feedbot"
version = "0.1.4"
version = "0.1.5"
edition = "2021"
license = "GPL-3.0-or-later"
authors = ["mirsal <mirsal@mirsal.fr>"]

View File

@ -73,7 +73,7 @@ pub async fn fetch_and_parse_feed(uri: &str) -> Result<Feed, Box<dyn Error>> {
})
}
pub fn format_entry(feed: Feed, entry: model::Entry) -> Result<Entry, Box<dyn Error>> {
pub fn format_entry(feed: Feed, entry: model::Entry) -> Entry {
debug!("Formatting entry {}", entry.id);
let mut e = Entry {
@ -112,5 +112,5 @@ pub fn format_entry(feed: Feed, entry: model::Entry) -> Result<Entry, Box<dyn Er
content=e.content
));
Ok(e)
e
}

View File

@ -38,7 +38,7 @@ use crate::{
state::FeedReaderStateDb
};
use std::{ sync::Arc, cmp::max };
use std::{ sync::Arc, cmp::min, cmp::max };
use tracing::{ info, debug, error };
use chrono::DateTime;
@ -81,7 +81,7 @@ async fn main() -> anyhow::Result<()> {
};
let feed = if feed.is_none() {
backoff = max(backoff * 2, 6 * 3600);
backoff = min(backoff * 2, 6 * 3600);
error!("Backing off for {} seconds", backoff);
sleep(Duration::from_secs(backoff)).await;
continue;
@ -104,7 +104,7 @@ async fn main() -> anyhow::Result<()> {
for entry in feed.model.entries.iter().rev() {
// FIXME: nasty clone business going on here... use Arc instead?
let parsed = format_entry(feed.clone(), (*entry).clone()).unwrap();
let parsed = format_entry(feed.clone(), (*entry).clone());
debug!("parsed entry with title: {}, updated on {}", parsed.title, parsed.ts);
if parsed.ts > state_ts {

View File

@ -98,7 +98,7 @@ pub async fn login_and_sync<T: Clone>(
client
.matrix_auth()
.login_username(username, password)
.initial_device_display_name("bender v0.1.4")
.initial_device_display_name("bender v0.1.5")
.await?;
info!("logged in as {username}");