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