Improve logs

This commit is contained in:
Mubelotix
2025-08-04 15:00:26 +02:00
parent c5caac95dd
commit 4ec4710811

View File

@ -125,13 +125,10 @@ async fn get_webhooks(
let results = webhooks let results = webhooks
.webhooks .webhooks
.into_iter() .into_iter()
.map(|(uuid, webhook)| WebhookWithMetadata { .map(|(uuid, webhook)| WebhookWithMetadata::from(uuid, webhook))
uuid,
is_editable: uuid != Uuid::nil(),
webhook,
})
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let results = WebhookResults { results }; let results = WebhookResults { results };
debug!(returns = ?results, "Get webhooks"); debug!(returns = ?results, "Get webhooks");
Ok(HttpResponse::Ok().json(results)) Ok(HttpResponse::Ok().json(results))
} }
@ -248,7 +245,7 @@ fn patch_webhook_inner(
tag = "Webhooks", tag = "Webhooks",
security(("Bearer" = ["webhooks.get", "*.get", "*"])), security(("Bearer" = ["webhooks.get", "*.get", "*"])),
responses( responses(
(status = 200, description = "Webhook found", body = WebhookSettings, content_type = "application/json", example = json!({ (status = 200, description = "Webhook found", body = WebhookWithMetadata, content_type = "application/json", example = json!({
"uuid": "550e8400-e29b-41d4-a716-446655440000", "uuid": "550e8400-e29b-41d4-a716-446655440000",
"url": "https://your.site/on-tasks-completed", "url": "https://your.site/on-tasks-completed",
"headers": { "headers": {
@ -271,12 +268,10 @@ async fn get_webhook(
let mut webhooks = index_scheduler.webhooks(); let mut webhooks = index_scheduler.webhooks();
let webhook = webhooks.webhooks.remove(&uuid).ok_or(WebhookNotFound(uuid))?; let webhook = webhooks.webhooks.remove(&uuid).ok_or(WebhookNotFound(uuid))?;
let webhook = WebhookWithMetadata::from(uuid, webhook);
Ok(HttpResponse::Ok().json(WebhookWithMetadata {
uuid, debug!(returns = ?webhook, "Get webhook");
is_editable: uuid != Uuid::nil(), Ok(HttpResponse::Ok().json(webhook))
webhook,
}))
} }
#[utoipa::path( #[utoipa::path(