Class: SesDashboard::WebhookForwarder
- Inherits:
-
Object
- Object
- SesDashboard::WebhookForwarder
- Defined in:
- lib/ses_dashboard/webhook_forwarder.rb
Overview
Forwards processed SES events to external webhook URLs based on configurable rules.
Rules are resolved per-project (see Project#effective_webhook_forwards), with a global fallback from SesDashboard.configuration.webhook_forwards.
Each forward entry supports a ‘rules` array — all rules must match (AND logic). If no rules are specified, every event is forwarded.
[
{
"url": "https://hooks.zapier.com/hooks/catch/abc/xyz/",
"rules": [
{ "field": "event_type", "operator": "in", "value": ["bounce", "complaint"] },
{ "field": "source", "operator": "ends_with", "value": "@myapp.com" }
]
}
]
Legacy shorthand ‘event_types` is still supported and auto-converted to a rule:
{ "url": "...", "event_types": ["bounce"] }
⟶ rules: [{ field: "event_type", operator: "in", value: ["bounce"] }]
Constant Summary collapse
- OPEN_TIMEOUT =
seconds
5- READ_TIMEOUT =
seconds
10
Instance Method Summary collapse
- #forward ⇒ Object
-
#initialize(project, result) ⇒ WebhookForwarder
constructor
A new instance of WebhookForwarder.
Constructor Details
#initialize(project, result) ⇒ WebhookForwarder
Returns a new instance of WebhookForwarder.
32 33 34 35 |
# File 'lib/ses_dashboard/webhook_forwarder.rb', line 32 def initialize(project, result) @project = project @result = result end |
Instance Method Details
#forward ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ses_dashboard/webhook_forwarder.rb', line 37 def forward forwards = @project.effective_webhook_forwards return if forwards.empty? forwards.each do |config| url = config[:url] || config["url"] next if url.blank? next unless matches_rules?(config) post_to(url) rescue => e log_warn("Forward to #{url} failed: #{e.}") end end |