Skip to content

Commit

Permalink
Adding ACME endpoint info for webhook (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
shibayan authored Aug 16, 2023
1 parent a894bbb commit 117d7d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion KeyVault.Acmebot/Functions/SharedActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
14 changes: 11 additions & 3 deletions KeyVault.Acmebot/Internal/WebhookInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public WebhookInvoker(IHttpClientFactory httpClientFactory, IOptions<AcmebotOpti
private readonly AcmebotOptions _options;
private readonly ILogger<WebhookInvoker> _logger;

public Task SendCompletedEventAsync(string certificateName, DateTimeOffset? expirationDate, IEnumerable<string> dnsNames)
public Task SendCompletedEventAsync(string certificateName, DateTimeOffset? expirationDate, IEnumerable<string> dnsNames, string acmeEndpoint)
{
if (string.IsNullOrEmpty(_options.Webhook))
{
Expand Down Expand Up @@ -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)
Expand All @@ -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"
};
}
Expand All @@ -84,7 +90,9 @@ public Task SendCompletedEventAsync(string certificateName, DateTimeOffset? expi
model = new
{
certificateName,
dnsNames
expirationDate,
dnsNames,
acmeEndpoint
};
}

Expand Down

0 comments on commit 117d7d5

Please sign in to comment.