diff --git a/changedetectionio/notification/handler.py b/changedetectionio/notification/handler.py index fbc06846..6a951014 100644 --- a/changedetectionio/notification/handler.py +++ b/changedetectionio/notification/handler.py @@ -259,9 +259,12 @@ def apply_service_tweaks(url, n_body, n_title, requested_output_format): elif (url.startswith('discord://') or url.startswith('https://discordapp.com/api/webhooks') or url.startswith('https://discord.com/api'))\ and 'html' in requested_output_format: - # Discord doesn't support HTML, replace
with newlines + # Discord doesn't render HTML — convert markup to plain text equivalents. + #   is injected upstream to preserve double-spaces for HTML email clients; + # Discord displays it as the literal string " " so strip it here. n_body = n_body.strip().replace('
', '\n') n_body = n_body.replace('
', '\n') + n_body = n_body.replace(' ', ' ') n_body = newline_re.sub('\n', n_body) # Don't replace placeholders or truncate here - let the custom Discord plugin handle it diff --git a/changedetectionio/static/js/notifications.js b/changedetectionio/static/js/notifications.js index 98c271b1..ce65f6a5 100644 --- a/changedetectionio/static/js/notifications.js +++ b/changedetectionio/static/js/notifications.js @@ -1,5 +1,20 @@ +function checkDiscordHtmlWarning() { + var urls = $('textarea.notification-urls').val() || ''; + var format = $('select.notification-format').val() || ''; + var isDiscord = /discord:\/\/|https:\/\/discord(?:app)?\.com\/api/i.test(urls); + var isHtml = format === 'html' || format === 'htmlcolor'; + if (isDiscord && isHtml) { + $('#discord-html-format-warning').show(); + } else { + $('#discord-html-format-warning').hide(); + } +} + $(document).ready(function () { + $('textarea.notification-urls, select.notification-format').on('change input', checkDiscordHtmlWarning); + checkDiscordHtmlWarning(); + $('#add-email-helper').click(function (e) { e.preventDefault(); email = prompt("Destination email"); diff --git a/changedetectionio/templates/_common_fields.html b/changedetectionio/templates/_common_fields.html index 3df25af2..71cf7676 100644 --- a/changedetectionio/templates/_common_fields.html +++ b/changedetectionio/templates/_common_fields.html @@ -195,6 +195,10 @@
{{ render_field(form.notification_format , class="notification-format") }} {{ _('Format for all notifications') }} +
{% endmacro %}