return null for tor-key pointer if doesn't exist

This commit is contained in:
Aiden McClelland
2022-01-19 13:39:41 -07:00
committed by Aiden McClelland
parent 666f1bc0eb
commit 75dbc0bd76

View File

@@ -1849,13 +1849,17 @@ impl TorKeyPointer {
*self.package_id, *self.package_id,
*self.interface *self.interface
) )
.fetch_one(secrets) .fetch_optional(secrets)
.await .await
.map_err(|e| ConfigurationError::SystemError(e.into()))?; .map_err(|e| ConfigurationError::SystemError(e.into()))?;
Ok(Value::String(base32::encode( if let Some(x) = x {
base32::Alphabet::RFC4648 { padding: false }, Ok(Value::String(base32::encode(
&x.key, base32::Alphabet::RFC4648 { padding: false },
))) &x.key,
)))
} else {
Ok(Value::Null)
}
} }
} }
impl fmt::Display for TorKeyPointer { impl fmt::Display for TorKeyPointer {