From 117d7d52c7c404157694c5710a07c963720eaa4f Mon Sep 17 00:00:00 2001 From: Tatsuro Shibamura Date: Thu, 17 Aug 2023 00:51:14 +0900 Subject: [PATCH] Adding ACME endpoint info for webhook (#622) --- KeyVault.Acmebot/Functions/SharedActivity.cs | 2 +- KeyVault.Acmebot/Internal/WebhookInvoker.cs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/KeyVault.Acmebot/Functions/SharedActivity.cs b/KeyVault.Acmebot/Functions/SharedActivity.cs index a9bac632..860c59ef 100644 --- a/KeyVault.Acmebot/Functions/SharedActivity.cs +++ b/KeyVault.Acmebot/Functions/SharedActivity.cs @@ -456,6 +456,6 @@ public Task SendCompletedEvent([ActivityTrigger] (string, DateTimeOffset?, IRead { var (certificateName, expirationDate, dnsNames) = input; - return _webhookInvoker.SendCompletedEventAsync(certificateName, expirationDate, dnsNames); + return _webhookInvoker.SendCompletedEventAsync(certificateName, expirationDate, dnsNames, _options.Endpoint.Host); } } diff --git a/KeyVault.Acmebot/Internal/WebhookInvoker.cs b/KeyVault.Acmebot/Internal/WebhookInvoker.cs index 5ccd3322..70b32d3f 100644 --- a/KeyVault.Acmebot/Internal/WebhookInvoker.cs +++ b/KeyVault.Acmebot/Internal/WebhookInvoker.cs @@ -26,7 +26,7 @@ public WebhookInvoker(IHttpClientFactory httpClientFactory, IOptions _logger; - public Task SendCompletedEventAsync(string certificateName, DateTimeOffset? expirationDate, IEnumerable dnsNames) + public Task SendCompletedEventAsync(string certificateName, DateTimeOffset? expirationDate, IEnumerable dnsNames, string acmeEndpoint) { if (string.IsNullOrEmpty(_options.Webhook)) { @@ -61,6 +61,12 @@ public Task SendCompletedEventAsync(string certificateName, DateTimeOffset? expi @short = true }, new + { + title = "ACME Endpoint", + value = acmeEndpoint, + @short = true + }, + new { title = "DNS Names", value = string.Join("\n", dnsNames) @@ -75,7 +81,7 @@ public Task SendCompletedEventAsync(string certificateName, DateTimeOffset? expi model = new { title = "Acmebot", - text = $"A new certificate has been issued.\n\n**Certificate Name**: {certificateName}\n\n**Expiration Date**: {expirationDate}\n\n**DNS Names**: {string.Join(", ", dnsNames)}", + text = $"A new certificate has been issued.\n\n**Certificate Name**: {certificateName}\n\n**Expiration Date**: {expirationDate}\n\n**ACME Endpoint**: {acmeEndpoint}\n\n**DNS Names**: {string.Join(", ", dnsNames)}", themeColor = "2EB886" }; } @@ -84,7 +90,9 @@ public Task SendCompletedEventAsync(string certificateName, DateTimeOffset? expi model = new { certificateName, - dnsNames + expirationDate, + dnsNames, + acmeEndpoint }; }