mirror of
https://github.com/jellyfin/jellyfin-plugin-webhook.git
synced 2024-11-27 00:00:28 +00:00
Implement option to trim leading/trailing whitespace from message body (#220)
This commit is contained in:
parent
01ce5b2041
commit
a9171e837e
@ -116,6 +116,10 @@
|
||||
<input is="emby-checkbox" type="checkbox" data-name="chkSendAllProperties"/>
|
||||
<span>Send All Properties (ignores template)</span>
|
||||
</label>
|
||||
<label class="checkboxContainer">
|
||||
<input is="emby-checkbox" type="checkbox" data-name="chkTrimWhitespace"/>
|
||||
<span>Trim leading and trailing whitespace from message body before sending</span>
|
||||
</label>
|
||||
<label class="checkboxContainer">
|
||||
<input is="emby-checkbox" type="checkbox" data-name="chkSkipEmptyMessageBody"/>
|
||||
<span>Do not send when message body is empty</span>
|
||||
|
@ -162,6 +162,7 @@
|
||||
element.querySelector("[data-name=txtWebhookName]").value = config.WebhookName || "";
|
||||
element.querySelector("[data-name=txtWebhookUri]").value = config.WebhookUri || "";
|
||||
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=txtTemplate]").value = Webhook.atou(config.Template || "");
|
||||
|
||||
@ -183,6 +184,7 @@
|
||||
config.WebhookName = element.querySelector("[data-name=txtWebhookName]").value || "";
|
||||
config.WebhookUri = element.querySelector("[data-name=txtWebhookUri]").value || "";
|
||||
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.Template = Webhook.utoa(element.querySelector("[data-name=txtTemplate]").value || "");
|
||||
|
||||
|
@ -67,6 +67,11 @@ public abstract class BaseOption
|
||||
/// </summary>
|
||||
public bool SendAllProperties { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to trim the message body before sending.
|
||||
/// </summary>
|
||||
public bool TrimWhitespace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to skip sending an empty message body.
|
||||
/// </summary>
|
||||
@ -98,8 +103,10 @@ public abstract class BaseOption
|
||||
/// <returns>The string message body.</returns>
|
||||
public string GetMessageBody(Dictionary<string, object> data)
|
||||
{
|
||||
return SendAllProperties
|
||||
var body = SendAllProperties
|
||||
? JsonSerializer.Serialize(data, JsonDefaults.Options)
|
||||
: GetCompiledTemplate()(data);
|
||||
|
||||
return TrimWhitespace ? body.Trim() : body;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user