Convert Notifiarr Payload to JSON, Standardize with Webhook (#1194)
* Convert Notifiarr Payload to JSON, Standardize with Webhook * fixup!pull/1205/head
parent
4f4c011436
commit
9ff0b90626
@ -0,0 +1,51 @@
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public abstract class WebhookBase<TSettings> : NotificationBase<TSettings>
|
||||
where TSettings : IProviderConfig, new()
|
||||
{
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
|
||||
protected WebhookBase(IConfigFileProvider configFileProvider)
|
||||
: base()
|
||||
{
|
||||
_configFileProvider = configFileProvider;
|
||||
}
|
||||
|
||||
protected WebhookHealthPayload BuildHealthPayload(HealthCheck.HealthCheck healthCheck)
|
||||
{
|
||||
return new WebhookHealthPayload
|
||||
{
|
||||
EventType = WebhookEventType.Health,
|
||||
InstanceName = _configFileProvider.InstanceName,
|
||||
Level = healthCheck.Type,
|
||||
Message = healthCheck.Message,
|
||||
Type = healthCheck.Source.Name,
|
||||
WikiUrl = healthCheck.WikiUrl?.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
protected WebhookApplicationUpdatePayload BuildApplicationUploadPayload(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
return new WebhookApplicationUpdatePayload
|
||||
{
|
||||
EventType = WebhookEventType.ApplicationUpdate,
|
||||
InstanceName = _configFileProvider.InstanceName,
|
||||
Message = updateMessage.Message,
|
||||
PreviousVersion = updateMessage.PreviousVersion.ToString(),
|
||||
NewVersion = updateMessage.NewVersion.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
protected WebhookPayload BuildTestPayload()
|
||||
{
|
||||
return new WebhookPayload
|
||||
{
|
||||
EventType = WebhookEventType.Test,
|
||||
InstanceName = _configFileProvider.InstanceName
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue