1
0
Fork 0
forked from alemi/upub

fix: more resilient priv key selection

This commit is contained in:
əlemi 2024-03-26 03:21:00 +01:00
parent e6b30975cc
commit 8ba25d511e
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -65,18 +65,14 @@ async fn worker(db: DatabaseConnection, domain: String, poll_interval: u64) -> R
},
};
let Some(key_pem) = model::user::Entity::find_by_id(&delivery.actor)
.select_only()
.select_column(model::user::Column::PrivateKey)
.into_tuple::<String>()
.one(&db)
.await?
let Some(model::user::Model{ private_key: Some(key), .. }) = model::user::Entity::find_by_id(&delivery.actor)
.one(&db).await?
else {
tracing::error!("can not dispatch activity for user without private key: {}", delivery.actor);
continue;
};
let Ok(key) = PKey::private_key_from_pem(key_pem.as_bytes())
let Ok(key) = PKey::private_key_from_pem(key.as_bytes())
else {
tracing::error!("failed parsing private key for user {}", delivery.actor);
continue;