diff --git a/src/Ombi.Api.Discord/DiscordApi.cs b/src/Ombi.Api.Discord/DiscordApi.cs
index 34342e559..122c51a87 100644
--- a/src/Ombi.Api.Discord/DiscordApi.cs
+++ b/src/Ombi.Api.Discord/DiscordApi.cs
@@ -1,4 +1,6 @@
-using System.Net.Http;
+using System;
+using System.Net;
+using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Ombi.Api.Discord.Models;
@@ -23,7 +25,20 @@ namespace Ombi.Api.Discord
request.ApplicationJsonContentType();
- await Api.Request(request);
+ var response = await Api.Request(request);
+
+ if (!response.IsSuccessStatusCode)
+ {
+ var content = await response.Content.ReadAsStringAsync();
+ throw new DiscordException(content, response.StatusCode);
+ }
+ }
+
+ public class DiscordException : Exception
+ {
+ public DiscordException(string content, HttpStatusCode code) : base($"Exception when calling Discord with status code {code} and message: {content}")
+ {
+ }
}
}
}
diff --git a/src/Ombi/Controllers/V1/External/TesterController.cs b/src/Ombi/Controllers/V1/External/TesterController.cs
index 6ee0ebe22..bedf207b1 100644
--- a/src/Ombi/Controllers/V1/External/TesterController.cs
+++ b/src/Ombi/Controllers/V1/External/TesterController.cs
@@ -110,12 +110,12 @@ namespace Ombi.Controllers.V1.External
/// The settings.
///
[HttpPost("discord")]
- public bool Discord([FromBody] DiscordNotificationSettings settings)
+ public async Task Discord([FromBody] DiscordNotificationSettings settings)
{
try
{
settings.Enabled = true;
- DiscordNotification.NotifyAsync(
+ await DiscordNotification.NotifyAsync(
new NotificationOptions { NotificationType = NotificationType.Test, RequestId = -1 }, settings);
return true;
@@ -133,13 +133,13 @@ namespace Ombi.Controllers.V1.External
/// The settings.
///
[HttpPost("pushbullet")]
- public bool Pushbullet([FromBody] PushbulletSettings settings)
+ public async Task Pushbullet([FromBody] PushbulletSettings settings)
{
try
{
settings.Enabled = true;
- PushbulletNotification.NotifyAsync(
+ await PushbulletNotification.NotifyAsync(
new NotificationOptions { NotificationType = NotificationType.Test, RequestId = -1 }, settings);
return true;
@@ -157,12 +157,12 @@ namespace Ombi.Controllers.V1.External
/// The settings.
///
[HttpPost("pushover")]
- public bool Pushover([FromBody] PushoverSettings settings)
+ public async Task Pushover([FromBody] PushoverSettings settings)
{
try
{
settings.Enabled = true;
- PushoverNotification.NotifyAsync(
+ await PushoverNotification.NotifyAsync(
new NotificationOptions { NotificationType = NotificationType.Test, RequestId = -1 }, settings);
return true;
@@ -181,12 +181,12 @@ namespace Ombi.Controllers.V1.External
/// The settings.
///
[HttpPost("gotify")]
- public bool Gotify([FromBody] GotifySettings settings)
+ public async Task Gotify([FromBody] GotifySettings settings)
{
try
{
settings.Enabled = true;
- GotifyNotification.NotifyAsync(
+ await GotifyNotification.NotifyAsync(
new NotificationOptions { NotificationType = NotificationType.Test, RequestId = -1 }, settings);
return true;
@@ -205,12 +205,12 @@ namespace Ombi.Controllers.V1.External
/// The settings.
///
[HttpPost("webhook")]
- public bool Webhook([FromBody] WebhookSettings settings)
+ public async Task Webhook([FromBody] WebhookSettings settings)
{
try
{
settings.Enabled = true;
- WebhookNotification.NotifyAsync(
+ await WebhookNotification.NotifyAsync(
new NotificationOptions { NotificationType = NotificationType.Test, RequestId = -1 }, settings);
return true;
@@ -229,12 +229,12 @@ namespace Ombi.Controllers.V1.External
/// The settings.
///
[HttpPost("mattermost")]
- public bool Mattermost([FromBody] MattermostNotificationSettings settings)
+ public async Task Mattermost([FromBody] MattermostNotificationSettings settings)
{
try
{
settings.Enabled = true;
- MattermostNotification.NotifyAsync(
+ await MattermostNotification.NotifyAsync(
new NotificationOptions { NotificationType = NotificationType.Test, RequestId = -1 }, settings);
return true;
@@ -255,12 +255,12 @@ namespace Ombi.Controllers.V1.External
/// The settings.
///
[HttpPost("slack")]
- public bool Slack([FromBody] SlackNotificationSettings settings)
+ public async Task Slack([FromBody] SlackNotificationSettings settings)
{
try
{
settings.Enabled = true;
- SlackNotification.NotifyAsync(
+ await SlackNotification.NotifyAsync(
new NotificationOptions { NotificationType = NotificationType.Test, RequestId = -1 }, settings);
return true;