mirror of https://github.com/docusealco/docuseal
				
				
				
			
							parent
							
								
									9d9e134bb4
								
							
						
					
					
						commit
						3faec9d174
					
				| @ -0,0 +1,22 @@ | |||||||
|  | # frozen_string_literal: true | ||||||
|  | 
 | ||||||
|  | class SendFormStartedWebhookRequestJob < ApplicationJob | ||||||
|  |   USER_AGENT = 'DocuSeal.co Webhook' | ||||||
|  | 
 | ||||||
|  |   def perform(submitter) | ||||||
|  |     config = submitter.submission.account.encrypted_configs.find_by(key: EncryptedConfig::WEBHOOK_URL_KEY) | ||||||
|  | 
 | ||||||
|  |     return if config.blank? || config.value.blank? | ||||||
|  | 
 | ||||||
|  |     ActiveStorage::Current.url_options = Docuseal.default_url_options | ||||||
|  | 
 | ||||||
|  |     Faraday.post(config.value, | ||||||
|  |                  { | ||||||
|  |                    event_type: 'form.started', | ||||||
|  |                    timestamp: Time.current.iso8601, | ||||||
|  |                    data: Submitters::SerializeForWebhook.call(submitter) | ||||||
|  |                  }.to_json, | ||||||
|  |                  'Content-Type' => 'application/json', | ||||||
|  |                  'User-Agent' => USER_AGENT) | ||||||
|  |   end | ||||||
|  | end | ||||||
| @ -0,0 +1,22 @@ | |||||||
|  | # frozen_string_literal: true | ||||||
|  | 
 | ||||||
|  | class SendFormViewedWebhookRequestJob < ApplicationJob | ||||||
|  |   USER_AGENT = 'DocuSeal.co Webhook' | ||||||
|  | 
 | ||||||
|  |   def perform(submitter) | ||||||
|  |     config = submitter.submission.account.encrypted_configs.find_by(key: EncryptedConfig::WEBHOOK_URL_KEY) | ||||||
|  | 
 | ||||||
|  |     return if config.blank? || config.value.blank? | ||||||
|  | 
 | ||||||
|  |     ActiveStorage::Current.url_options = Docuseal.default_url_options | ||||||
|  | 
 | ||||||
|  |     Faraday.post(config.value, | ||||||
|  |                  { | ||||||
|  |                    event_type: 'form.viewed', | ||||||
|  |                    timestamp: Time.current.iso8601, | ||||||
|  |                    data: Submitters::SerializeForWebhook.call(submitter) | ||||||
|  |                  }.to_json, | ||||||
|  |                  'Content-Type' => 'application/json', | ||||||
|  |                  'User-Agent' => USER_AGENT) | ||||||
|  |   end | ||||||
|  | end | ||||||
					Loading…
					
					
				
		Reference in new issue