DEV: call 'enqueue_hooks' method only if active webhooks exist

This commit is contained in:
Vinoth Kannan 2019-02-19 12:43:08 +05:30
parent f2c3415548
commit 27e7f2bee0
1 changed files with 11 additions and 6 deletions

View File

@ -7,11 +7,16 @@ module HasDestroyedWebHook
def enqueue_destroyed_web_hook def enqueue_destroyed_web_hook
type = self.class.name.underscore.to_sym type = self.class.name.underscore.to_sym
payload = WebHook.generate_payload(type, self) if WebHook.active_web_hooks(type).exists?
if WebHook.active_web_hooks(type).exists?
payload = WebHook.generate_payload(type, self)
yield yield
WebHook.enqueue_hooks(type, "#{type}_destroyed".to_sym, WebHook.enqueue_hooks(type, "#{type}_destroyed".to_sym,
id: id, id: id,
payload: payload payload: payload
) )
else
yield
end
end end
end end