Skip to content

Commit

Permalink
fix: Estimation should be sent to webhook URL even if output is disabled
Browse files Browse the repository at this point in the history
Fixes #274
  • Loading branch information
kamil-mrzyglod committed Sep 3, 2024
1 parent c98d8bd commit e725e7e
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions ace/Output/OutputHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,35 +56,35 @@ public async Task GenerateOutputIfNeeded(EstimateOptions options, EstimationOutp
var generator = new MarkdownOutputGenerator(output, logger, options.MarkdownOutputFilename);
generator.Generate();
}
}

if (!string.IsNullOrEmpty(options.WebhookUrl))
{
logger.AddEstimatorMessage("Sending estimation result to webhook URL {0}", options.WebhookUrl);
if (!string.IsNullOrEmpty(options.WebhookUrl))
{
logger.AddEstimatorMessage("Sending estimation result to webhook URL {0}", options.WebhookUrl);

var client = new HttpClient();
var message = new HttpRequestMessage(HttpMethod.Post, options.WebhookUrl)
{
Content = new StringContent(JsonSerializer.Serialize(output), Encoding.UTF8, "application/json")
};
using var client = new HttpClient();
var message = new HttpRequestMessage(HttpMethod.Post, options.WebhookUrl)
{
Content = new StringContent(JsonSerializer.Serialize(output), Encoding.UTF8, "application/json")
};

if (string.IsNullOrEmpty(options.WebhookAuthorization))
{
logger.AddEstimatorMessage("Webhook authorization header not set, skipping.");
}
else
{
message.Headers.Add("Authorization", options.WebhookAuthorization);
}
if (string.IsNullOrEmpty(options.WebhookAuthorization))
{
logger.AddEstimatorMessage("Webhook authorization header not set, skipping.");
}
else
{
message.Headers.Add("Authorization", options.WebhookAuthorization);
}

var response = await client.SendAsync(message);
if (!response.IsSuccessStatusCode)
{
logger.LogError("Couldn't send estimation result to webhook URL {url}. Status code: {code}", options.WebhookUrl, response.StatusCode);
}
else
{
logger.AddEstimatorMessage("Estimation result sent successfully to webhook URL {0}", options.WebhookUrl);
}
var response = await client.SendAsync(message);
if (!response.IsSuccessStatusCode)
{
logger.LogError("Couldn't send estimation result to webhook URL {url}. Status code: {code}", options.WebhookUrl, response.StatusCode);
}
else
{
logger.AddEstimatorMessage("Estimation result sent successfully to webhook URL {0}", options.WebhookUrl);
}
}

Expand Down

0 comments on commit e725e7e

Please sign in to comment.