feat: do not load more than one own key

This commit is contained in:
link2xt
2026-01-29 21:09:45 +00:00
committed by l
parent 6325a35b5b
commit 3b29469102

View File

@@ -156,24 +156,14 @@ pub(crate) async fn load_self_public_key(context: &Context) -> Result<SignedPubl
} }
/// Returns our own public keyring. /// Returns our own public keyring.
///
/// No keys are generated and at most one key is returned.
pub(crate) async fn load_self_public_keyring(context: &Context) -> Result<Vec<SignedPublicKey>> { pub(crate) async fn load_self_public_keyring(context: &Context) -> Result<Vec<SignedPublicKey>> {
let keys = context if let Some(public_key) = load_self_public_key_opt(context).await? {
.sql Ok(vec![public_key])
.query_map_vec( } else {
r#"SELECT public_key Ok(vec![])
FROM keypairs }
ORDER BY id=(SELECT value FROM config WHERE keyname='key_id') DESC"#,
(),
|row| {
let public_key_bytes: Vec<u8> = row.get(0)?;
Ok(public_key_bytes)
},
)
.await?
.into_iter()
.filter_map(|bytes| SignedPublicKey::from_slice(&bytes).log_err(context).ok())
.collect();
Ok(keys)
} }
/// Returns own public key fingerprint in (not human-readable) hex representation. /// Returns own public key fingerprint in (not human-readable) hex representation.