Skip to content

Comments

Adds Custom Rules ability for our email integration#149

Merged
armiiller merged 6 commits intomainfrom
feat-email-resolve
Feb 20, 2026
Merged

Adds Custom Rules ability for our email integration#149
armiiller merged 6 commits intomainfrom
feat-email-resolve

Conversation

@armiiller
Copy link
Collaborator

… the email integration

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds custom rules capability to the email integration (Email::V3), allowing users to define YAML-based rules that determine how incoming emails are processed. The implementation follows the pattern established by the CustomWebhook::V3 integration, enabling users to match email properties (subject, body, from, to) against custom rules and trigger different actions (create, acknowledge, resolve, ignore).

Changes:

  • Added custom rule processing support to Email::V3 integration using a custom webhook v3 service
  • Added UI components for enabling and configuring custom YAML definitions
  • Added comprehensive test coverage for all custom rule action types

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
app/models/pager_tree/integrations/email/v3.rb Core implementation of custom rule processing, including HTTP calls to custom webhook service and result parsing
test/models/pager_tree/integrations/email/v3_test.rb Test suite covering custom definition functionality for all action types
test/vcr_cassettes/*.yml VCR cassettes for recording HTTP interactions with custom webhook service
app/views/pager_tree/integrations/email/v3/_form_options.html.erb Form UI for enabling and editing custom YAML definitions
app/views/pager_tree/integrations/email/v3/_show_options.html.erb Display UI showing whether custom definition is enabled
config/locales/en.yml Localization strings for custom definition options
test/fixtures/pager_tree/integrations/integrations.yml Test fixture for email_v3 integration
app/models/pager_tree/integrations/email/v3_examples/example.yml Example YAML configuration showing custom rule syntax

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +300 to +302
@_body = custom_definition? ?
(document.at_css("body")&.inner_html || document.to_html) :
::Sanitize.fragment(document, _sanitize_config)
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When custom_definition is enabled, the _body method extracts unsanitized HTML (document.at_css("body")&.inner_html || document.to_html) directly without applying the sanitization that's used when custom_definition is disabled. This unsanitized HTML body is then sent to the custom webhook service and potentially used in the description field of alerts. If the custom webhook service doesn't properly sanitize this HTML, it could lead to security issues such as XSS vulnerabilities when the alert description is displayed. Consider whether sanitization should still be applied even when using custom definitions, or ensure the downstream service properly sanitizes this content.

Suggested change
@_body = custom_definition? ?
(document.at_css("body")&.inner_html || document.to_html) :
::Sanitize.fragment(document, _sanitize_config)
html_body = document.at_css("body")&.inner_html || document.to_html
@_body = if custom_definition?
::Sanitize.fragment(html_body, _sanitize_config)
else
::Sanitize.fragment(document, _sanitize_config)
end

Copilot uses AI. Check for mistakes.
@armiiller
Copy link
Collaborator Author

Looks good

@armiiller armiiller merged commit 98587cb into main Feb 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant