diff --git a/src/publish.rs b/src/publish.rs index cb976b4..34b2b8a 100644 --- a/src/publish.rs +++ b/src/publish.rs @@ -6,6 +6,9 @@ use elefren::{ status_builder::Visibility, Language, Mastodon, MastodonClient, Registration, StatusBuilder, }; + +const FEDIVERSE_TOML_PATH: &str = "fediverse.toml"; + pub trait Publisher { fn publish(&self, content: String) -> Option>; } @@ -16,7 +19,7 @@ pub struct FediversePublisher { impl FediversePublisher { pub fn new(fedi_url: String) -> Result> { - let fedi = if let Ok(data) = toml::from_file("fediverse.toml") { + let fedi = if let Ok(data) = toml::from_file(FEDIVERSE_TOML_PATH.to_string()) { Mastodon::from(data) } else { register(fedi_url)? @@ -56,7 +59,7 @@ fn register(fedi_url: String) -> Result> { let fediverse = cli::authenticate(registration)?; // Save app data for using on the next run. - toml::to_file(&*fediverse, "fediverse.toml")?; + toml::to_file(&*fediverse, FEDIVERSE_TOML_PATH.to_string())?; Ok(fediverse) }