Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Allow optional arguments for Webhooks::QueueRequests (#11626)
Aleksandar Petrushevf75eb5ac7b25
diff --git a/api/app/models/concerns/spree/webhooks/has_webhooks.rb b/api/app/models/concerns/spree/webhooks/has_webhooks.rbindex dc6088bd7f..42b5ec2326 100644--- a/api/app/models/concerns/spree/webhooks/has_webhooks.rb+++ b/api/app/models/concerns/spree/webhooks/has_webhooks.rb@@ -14,7 +14,9 @@ module Spreereturn if update_event?(event_name) && updating_only_ignored_attributes?return if webhook_payload_body.blank?- Spree::Webhooks::Subscribers::QueueRequests.call(event_name: event_name, webhook_payload_body: webhook_payload_body)+ Spree::Webhooks::Subscribers::QueueRequests.call(+ event_name: event_name, webhook_payload_body: webhook_payload_body, **webhooks_request_options+ )enddef self.default_webhook_events@@ -73,6 +75,10 @@ module Spreedef disable_spree_webhooks?ENV['DISABLE_SPREE_WEBHOOKS'] == 'true'end++ def webhooks_request_options+ {}+ endendendenddiff --git a/api/app/services/spree/webhooks/subscribers/queue_requests.rb b/api/app/services/spree/webhooks/subscribers/queue_requests.rbindex 00598a2ae5..eb2f28461b 100644--- a/api/app/services/spree/webhooks/subscribers/queue_requests.rb+++ b/api/app/services/spree/webhooks/subscribers/queue_requests.rb@@ -4,8 +4,8 @@ module Spreeclass QueueRequestsprepend Spree::ServiceModule::Base- def call(event_name:, webhook_payload_body:)- filtered_subscribers(event_name, webhook_payload_body).each do |subscriber|+ def call(event_name:, webhook_payload_body:, **options)+ filtered_subscribers(event_name, webhook_payload_body, options).each do |subscriber|Spree::Webhooks::Subscribers::MakeRequestJob.perform_later(webhook_payload_body, event_name, subscriber)@@ -14,7 +14,7 @@ module Spreeprivate- def filtered_subscribers(event_name, _)+ def filtered_subscribers(event_name, _, _)Spree::Webhooks::Subscriber.active.with_urls_for(event_name)endend