|
|
@ -25,6 +25,7 @@ use elefren::prelude::*; |
|
|
|
use crate::storage::data::Data; |
|
|
|
use crate::storage::data::Data; |
|
|
|
use crate::storage::filesystem::Filesystem; |
|
|
|
use crate::storage::filesystem::Filesystem; |
|
|
|
use crate::storage::joplin::Joplin; |
|
|
|
use crate::storage::joplin::Joplin; |
|
|
|
|
|
|
|
use crate::storage::storage::Storage; |
|
|
|
|
|
|
|
|
|
|
|
mod config; |
|
|
|
mod config; |
|
|
|
mod storage; |
|
|
|
mod storage; |
|
|
@ -33,12 +34,17 @@ fn main() { |
|
|
|
let config = dbg!(config::Config::get()); |
|
|
|
let config = dbg!(config::Config::get()); |
|
|
|
let client = dbg!(get_mastodon_connection()); |
|
|
|
let client = dbg!(get_mastodon_connection()); |
|
|
|
let top = dbg!(config.last_favorite.to_string()); |
|
|
|
let top = dbg!(config.last_favorite.to_string()); |
|
|
|
let joplin_storage = if let Some(joplin_config) = &config.joplin { |
|
|
|
// let joplin_storage = if let Some(joplin_config) = &config.joplin {
|
|
|
|
Some(Joplin::new_from_config(&joplin_config)) |
|
|
|
// Some(Joplin::new_from_config(&joplin_config))
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// None
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// let fs_storage = Filesystem::new();
|
|
|
|
|
|
|
|
let storage: Box<dyn Storage> = if let Some(joplin) = &config.joplin { |
|
|
|
|
|
|
|
Box::new(Joplin::new_from_config(&joplin)) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
None |
|
|
|
Box::new(Filesystem::new()) |
|
|
|
}; |
|
|
|
}; |
|
|
|
let fs_storage = Filesystem::new(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let most_recent_favourite = client |
|
|
|
let most_recent_favourite = client |
|
|
|
.favourites() |
|
|
|
.favourites() |
|
|
@ -47,11 +53,7 @@ fn main() { |
|
|
|
.take_while(|record| dbg!(record).id != top) |
|
|
|
.take_while(|record| dbg!(record).id != top) |
|
|
|
.map(|record| { |
|
|
|
.map(|record| { |
|
|
|
let conversion = dbg!(Data::from(dbg!(&record))); |
|
|
|
let conversion = dbg!(Data::from(dbg!(&record))); |
|
|
|
if let Some(joplin) = &joplin_storage { |
|
|
|
storage.save(&conversion); |
|
|
|
conversion.save(joplin); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
conversion.save(&fs_storage); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
record |
|
|
|
record |
|
|
|
}) |
|
|
|
}) |
|
|
|
.fold(None, { |
|
|
|
.fold(None, { |
|
|
|