diff --git a/changelog.d/1111.feature b/changelog.d/1111.feature new file mode 100644 index 000000000..bddece795 --- /dev/null +++ b/changelog.d/1111.feature @@ -0,0 +1 @@ +Add generic webhook transformation JS snippet to format text as code block, e.g. logs and similar payloads. diff --git a/contrib/jsTransformationFunctions/format-as-code.js b/contrib/jsTransformationFunctions/format-as-code.js new file mode 100644 index 000000000..a56eebf44 --- /dev/null +++ b/contrib/jsTransformationFunctions/format-as-code.js @@ -0,0 +1,7 @@ +// This snippet will receive a webhook containing `text`, e.g. Slack Webhook format and dump it into a codeblock. +// This is useful for hooks which contain monospace-formatted info, for example logs or ZFS event daemon (https://openzfs.github.io/openzfs-docs/man/master/8/zed.8.html) notifications. + +result = { + plain: `\`\`\`\n${data.text}\n\`\`\``, + version: "v2" + };