Initialize GitHub installations on webhook event

This commit is contained in:
Luke Street
2026-01-02 20:43:49 -07:00
parent 48ea309d16
commit 573262f1d5
+9 -9
View File
@@ -88,21 +88,21 @@ pub async fn webhook(
inner.action,
owner.as_deref().unwrap_or("[unknown]")
);
let Some(installation_id) = installation_id else {
tracing::warn!("Received installation event with no installation ID");
return Ok((StatusCode::OK, "No installation ID").into_response());
};
match inner.action {
InstallationWebhookEventAction::Created => {
// Installation client is already created
// Create the installation client
let mut installations = installations.lock().await;
installations.client_for_installation(installation_id).await?;
}
InstallationWebhookEventAction::Deleted => {
// Remove the installation client
let mut installations = installations.lock().await;
if let Some(installation_id) = installation_id {
installations.repo_to_installation.retain(|_, v| *v != installation_id);
installations.clients.remove(&installation_id);
} else {
tracing::warn!(
"Received installation deleted event with no installation ID"
);
}
installations.repo_to_installation.retain(|_, v| *v != installation_id);
installations.clients.remove(&installation_id);
}
_ => {}
}