tolerate no patrone creds

Signed-off-by: Xe Iaso <me@christine.website>
This commit is contained in:
Cadey Ratio 2022-04-06 00:01:52 +00:00
parent e5ee825c0a
commit 3a5c7adc42
2 changed files with 6 additions and 1 deletions

View File

@ -90,7 +90,7 @@ pub enum Error {
URLParse(#[from] url::ParseError), URLParse(#[from] url::ParseError),
} }
#[derive(Debug, Serialize, Deserialize, Clone, Default)] #[derive(Debug, Serialize, Deserialize, Clone, Default, Eq, PartialEq)]
pub struct Credentials { pub struct Credentials {
pub client_id: String, pub client_id: String,
pub client_secret: String, pub client_secret: String,

View File

@ -22,6 +22,11 @@ async fn patrons() -> Result<Option<patreon::Users>> {
let creds: Credentials = envy::prefixed("PATREON_") let creds: Credentials = envy::prefixed("PATREON_")
.from_env() .from_env()
.unwrap_or(Credentials::default()); .unwrap_or(Credentials::default());
if creds == Credentials::default() {
return Ok(None);
}
let mut cli = Client::new(creds)?; let mut cli = Client::new(creds)?;
cli.refresh_token().await?; cli.refresh_token().await?;