mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
New: Add Webhook support to sonarr
Add Form type url (type=url input field) Add isValidUrl input type validation Only allow absolute urls when checking if a url is valid String => string as per comments that sonarr is standarizing on the lowercase primative Remove this before function calls Refactored everything so OnGrab is supported Don't double submit the webhook Wrappers around Series, EpisodeFile, Episode so the entire data structure isn't exposed Add Braces as per style guide Series.ID and Series.TvdbId should be integers Reorder webhook payload as per style guide Upgrade to use ongrab as json instead of string Add method selection to webhook settings include episode directly in download event QualityVersion should be an int and not a string (don't convert it int=>string) Remove the list of episodes Add season number to episode data structure Code Review Fixes: * Remove episodefile from payload, move everything to episode * Change episode to a list convert to var as per code review / style guide Down with internals Everything now uses webhookpayload. None of that payload.Message stuff {"EventType":"Test","Series":{"Id":1,"Title":"Test Title","Path":"C:\\testpath","TvdbId":1234},"Episodes":[{"Id":123,"EpisodeNumber":1,"SeasonNumber":1,"Title":"Test title","AirDate":null,"AirDateUtc":null,"Quality":null,"QualityVersion":0,"ReleaseGroup":null,"SceneName":null}]} Remove logger and processProvider Remove unused constructor
This commit is contained in:
parent
187064101c
commit
c5b25bcfee
15 changed files with 392 additions and 2 deletions
55
src/NzbDrone.Core/Notifications/Webhook/Webhook.cs
Normal file
55
src/NzbDrone.Core/Notifications/Webhook/Webhook.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public class Webhook : NotificationBase<WebhookSettings>
|
||||
{
|
||||
private readonly IWebhookService _service;
|
||||
|
||||
public Webhook(IWebhookService service)
|
||||
{
|
||||
_service = service;
|
||||
}
|
||||
|
||||
public override string Link
|
||||
{
|
||||
get { return "https://github.com/Sonarr/Sonarr/wiki/Webhook"; }
|
||||
}
|
||||
|
||||
public override void OnGrab(GrabMessage message)
|
||||
{
|
||||
_service.OnGrab(message.Series, message.Episode, message.Quality, Settings);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_service.OnDownload(message.Series, message.EpisodeFile, Settings);
|
||||
}
|
||||
|
||||
public override void OnRename(Series series)
|
||||
{
|
||||
_service.OnRename(series, Settings);
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Webhook";
|
||||
}
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
||||
failures.AddIfNotNull(_service.Test(Settings));
|
||||
|
||||
return new ValidationResult(failures);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue