Skip to content

Commit

Permalink
Add Enable/Disable options for webhooks (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragkrishna authored Sep 9, 2024
1 parent aa60e5a commit 4a50fa2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Jellyfin.Plugin.Webhook/Configuration/Web/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ <h2 class="sectionTitle">Webhook</h2>
<input is="emby-input" type="text" data-name="txtWebhookUri" required="required" label="Webhook Url:"/>
<span>The webhook destination url</span>
</div>
<div class="inputContainer">
<label>Status:</label>
<label class="checkboxContainer">
<input is="emby-checkbox" type="checkbox" data-name="chkEnableWebhook"/>
<span>Enable</span>
</label>
</div>
<div>
<label>Notification Type:</label>
<div data-name="notificationTypeContainer">
Expand Down
2 changes: 2 additions & 0 deletions Jellyfin.Plugin.Webhook/Configuration/Web/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export default function (view) {
element.querySelector("[data-name=chkSendAllProperties]").checked = config.SendAllProperties || false;
element.querySelector("[data-name=chkTrimWhitespace]").checked = config.TrimWhitespace || false;
element.querySelector("[data-name=chkSkipEmptyMessageBody]").checked = config.SkipEmptyMessageBody || false;
element.querySelector("[data-name=chkEnableWebhook]").checked = config.EnableWebhook !== undefined ? config.EnableWebhook : true;
element.querySelector("[data-name=txtTemplate]").value = Webhook.atou(config.Template || "");

const notificationTypeContainer = element.querySelector("[data-name=notificationTypeContainer]");
Expand All @@ -187,6 +188,7 @@ export default function (view) {
config.SendAllProperties = element.querySelector("[data-name=chkSendAllProperties]").checked || false;
config.TrimWhitespace = element.querySelector("[data-name=chkTrimWhitespace]").checked || false;
config.SkipEmptyMessageBody = element.querySelector("[data-name=chkSkipEmptyMessageBody]").checked || false;
config.EnableWebhook = element.querySelector("[data-name=chkEnableWebhook]").checked;
config.Template = Webhook.utoa(element.querySelector("[data-name=txtTemplate]").value || "");

config.NotificationTypes = [];
Expand Down
5 changes: 5 additions & 0 deletions Jellyfin.Plugin.Webhook/Destinations/BaseOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public abstract class BaseOption
/// </summary>
public bool SkipEmptyMessageBody { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to Enable or Disable Webhook.
/// </summary>
public bool EnableWebhook { get; set; } = true;

/// <summary>
/// Gets or sets the handlebars template.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Webhook/WebhookSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private static bool NotifyOnItem<T>(T baseOptions, Type? itemType)
private async Task SendNotification<T>(IWebhookClient<T> webhookClient, T option, Dictionary<string, object> itemData, Type? itemType)
where T : BaseOption
{
if (NotifyOnItem(option, itemType))
if (option.EnableWebhook && NotifyOnItem(option, itemType))
{
try
{
Expand Down

0 comments on commit 4a50fa2

Please sign in to comment.