From d467fd261a897dfa037ed0933cc745e16fe960f3 Mon Sep 17 00:00:00 2001 From: Emile Date: Fri, 25 Jun 2021 20:48:23 +0100 Subject: [PATCH] Moved fediverse config path to constant --- src/publish.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) }