add webhook secret

This commit is contained in:
Pete Matsyburka
2024-08-05 13:30:04 +03:00
parent 6b1c3bba19
commit 478167ea4f
12 changed files with 93 additions and 12 deletions
@@ -13,7 +13,8 @@ class SendFormStartedWebhookRequestJob
submitter = Submitter.find(params['submitter_id'])
attempt = params['attempt'].to_i
url = Accounts.load_webhook_url(submitter.submission.account)
config = Accounts.load_webhook_config(submitter.submission.account)
url = config&.value.presence
return if url.blank?
@@ -30,6 +31,8 @@ class SendFormStartedWebhookRequestJob
timestamp: Time.current,
data: Submitters::SerializeForWebhook.call(submitter)
}.to_json,
**EncryptedConfig.find_or_initialize_by(account_id: config.account_id,
key: EncryptedConfig::WEBHOOK_SECRET_KEY)&.value.to_h,
'Content-Type' => 'application/json',
'User-Agent' => USER_AGENT)
rescue Faraday::Error