Chatwoot/lib/webhooks/trigger.rb

17 lines
633 B
Ruby
Raw Normal View History

2020-02-14 17:49:17 +00:00
class Webhooks::Trigger
def self.execute(url, payload)
response = RestClient::Request.execute(
method: :post,
url: url, payload: payload.to_json,
headers: { content_type: :json, accept: :json },
timeout: 5
)
Rails.logger.info "Performed Request: Code - #{response.code}"
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS, URI::InvalidURIError => e
Rails.logger.error "Exception: invalid webhook url #{url} : #{e.message}"
2020-02-14 17:49:17 +00:00
rescue StandardError => e
Rails.logger.error "Exception: invalid webhook url #{url} : #{e.message}"
ChatwootExceptionTracker.new(e).capture_exception
2020-02-14 17:49:17 +00:00
end
end