diff --git a/src/Ombi.Api.Webhook/IWebhookApi.cs b/src/Ombi.Api.Webhook/IWebhookApi.cs index 755c7c789..6a22a8b02 100644 --- a/src/Ombi.Api.Webhook/IWebhookApi.cs +++ b/src/Ombi.Api.Webhook/IWebhookApi.cs @@ -5,6 +5,6 @@ namespace Ombi.Api.Webhook { public interface IWebhookApi { - Task PushAsync(string endpoint, string accessToken, IReadOnlyDictionary parameters); + Task PushAsync(string endpoint, string accessToken, IDictionary parameters); } } \ No newline at end of file diff --git a/src/Ombi.Api.Webhook/WebhookApi.cs b/src/Ombi.Api.Webhook/WebhookApi.cs index 509de2622..b794c3d2f 100644 --- a/src/Ombi.Api.Webhook/WebhookApi.cs +++ b/src/Ombi.Api.Webhook/WebhookApi.cs @@ -17,17 +17,22 @@ namespace Ombi.Api.Webhook private readonly IApi _api; - public async Task PushAsync(string baseUrl, string accessToken, IReadOnlyDictionary parameters) + public async Task PushAsync(string baseUrl, string accessToken, IDictionary parameters) { var request = new Request("/", baseUrl, HttpMethod.Post); - request.AddHeader("Access-Token", accessToken); - request.ApplicationJsonContentType(); + + if (!string.IsNullOrWhiteSpace(accessToken)) + { + request.AddQueryString("token", accessToken); + request.AddHeader("Access-Token", accessToken); + } var body = parameters.ToDictionary( x => _nameResolver.GetResolvedPropertyName(x.Key), x => x.Value ); + request.ApplicationJsonContentType(); request.AddJsonBody(body); await _api.Request(request); diff --git a/src/Ombi.Notifications/Agents/WebhookNotification.cs b/src/Ombi.Notifications/Agents/WebhookNotification.cs index fbbb1d352..05a9c3763 100644 --- a/src/Ombi.Notifications/Agents/WebhookNotification.cs +++ b/src/Ombi.Notifications/Agents/WebhookNotification.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Ombi.Api.Webhook; @@ -105,9 +106,11 @@ namespace Ombi.Notifications.Agents return; } + var notificationData = parsed.Data.ToDictionary(x => x.Key, x => x.Value); + notificationData[nameof(NotificationType)] = type.ToString(); var notification = new NotificationMessage { - Data = parsed.Data, + Data = notificationData, }; await Send(notification, settings); diff --git a/src/Ombi.Notifications/Models/NotificationMessage.cs b/src/Ombi.Notifications/Models/NotificationMessage.cs index d336d830e..7ffd48e63 100644 --- a/src/Ombi.Notifications/Models/NotificationMessage.cs +++ b/src/Ombi.Notifications/Models/NotificationMessage.cs @@ -9,6 +9,6 @@ namespace Ombi.Notifications.Models public string To { get; set; } public Dictionary Other { get; set; } = new Dictionary(); - public IReadOnlyDictionary Data { get; set; } + public IDictionary Data { get; set; } } } \ No newline at end of file