Skip to content

Commit

Permalink
Merge pull request #11 from arktronic/main
Browse files Browse the repository at this point in the history
Fix Slack notification webhook
  • Loading branch information
arktronic-sep authored Jul 3, 2023
2 parents 09305e8 + 045c65e commit 6626bce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion sama/Services/SlackNotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ protected virtual void SendNotification(string message)
using var httpHandler = _serviceProvider.GetRequiredService<HttpClientHandler>();
using var client = new HttpClient(httpHandler, false);
var data = JsonConvert.SerializeObject(new { text = message });
client.PostAsync(url, new StringContent(data)).Wait();
var content = new StringContent(data);
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
using var response = client.PostAsync(url, content).Result;
if (!response.IsSuccessStatusCode)
{
_logger.LogError(0, $"Unable to send Slack notification: HTTP {(int)response.StatusCode}", new Exception(response.Content.ReadAsStringAsync().Result));
}
}
catch (Exception ex)
{
Expand Down
4 changes: 2 additions & 2 deletions sama/sama.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<UserSecretsId>aspnet-WebApplication1-1C1369D5-B3C7-4414-ADD2-629BA88766C5</UserSecretsId>
<AssemblyVersion>1.2.2</AssemblyVersion>
<VersionPrefix>1.2.2</VersionPrefix>
<AssemblyVersion>1.2.3</AssemblyVersion>
<VersionPrefix>1.2.3</VersionPrefix>
<VersionSuffix>$([System.DateTime]::UtcNow.ToString(`yyyyMMdd-HHmm`))</VersionSuffix>
</PropertyGroup>

Expand Down

0 comments on commit 6626bce

Please sign in to comment.