10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/forcast/jobs/rule_engine/jobs_webhooks.rb', line 10
def perform(webhook_model:, webhook_model_id:, changed_attrs_json:, created_at:)
changed_attrs = JSON.parse(changed_attrs_json)
puts 'ValidateModelWebhook'
object = c_to_m(webhook_model).find(webhook_model_id.to_i)
webhooks = triggered_webhooks(object: object, changed_attrs: changed_attrs.keys)
puts "Webhooks: #{webhooks.size}"
return if webhooks.empty?
webhooks.each do |webhook|
next unless webhook.validate_duration_time
begin
rule = webhook.rule
puts "Webhook Validate Rule #{rule.id}"
validate_rule(object, rule, webhook)
rescue Exception => e
puts 'Somethings where wrong: ' + e.to_s
end
end
end
|