use webhook urls instead of encrypted configs

This commit is contained in:
Alex Turchyn
2024-10-28 20:39:09 +02:00
committed by Pete Matsyburka
parent f669045362
commit 84edb6dbda
50 changed files with 1350 additions and 269 deletions
+16 -2
View File
@@ -66,7 +66,7 @@ class TemplatesController < ApplicationController
if @template.save
Templates::CloneAttachments.call(template: @template, original_template: @base_template) if @base_template
SendTemplateUpdatedWebhookRequestJob.perform_async('template_id' => @template.id)
enqueue_template_created_webhooks(@template)
maybe_redirect_to_template(@template)
else
@@ -77,7 +77,7 @@ class TemplatesController < ApplicationController
def update
@template.update!(template_params)
SendTemplateUpdatedWebhookRequestJob.perform_async('template_id' => @template.id)
enqueue_template_updated_webhooks(@template)
head :ok
end
@@ -128,6 +128,20 @@ class TemplatesController < ApplicationController
end
end
def enqueue_template_created_webhooks(template)
template.account.webhook_urls.with_event('template.updated').each do |webhook_url|
SendTemplateCreatedWebhookRequestJob.perform_async({ 'template_id' => template.id,
'webhook_url_id' => webhook_url.id })
end
end
def enqueue_template_updated_webhooks(template)
template.account.webhook_urls.with_event('template.updated').each do |webhook_url|
SendTemplateUpdatedWebhookRequestJob.perform_async({ 'template_id' => template.id,
'webhook_url_id' => webhook_url.id })
end
end
def load_base_template
return if params[:base_template_id].blank?