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.interface
)
.fetch_one(secrets)
.fetch_optional(secrets)
.await
.map_err(|e| ConfigurationError::SystemError(e.into()))?;
Ok(Value::String(base32::encode(
base32::Alphabet::RFC4648 { padding: false },
&x.key,
)))
if let Some(x) = x {
Ok(Value::String(base32::encode(
base32::Alphabet::RFC4648 { padding: false },
&x.key,
)))
} else {
Ok(Value::Null)
}
}
}
impl fmt::Display for TorKeyPointer {