Skip to content

armgit / spree

Public Imported from GitHub
0

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.

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.rb
index 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 Spree
return 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
+ )
end
def self.default_webhook_events
@@ -73,6 +75,10 @@ module Spree
def disable_spree_webhooks?
ENV['DISABLE_SPREE_WEBHOOKS'] == 'true'
end
+
+ def webhooks_request_options
+ {}
+ end
end
end
end
diff --git a/api/app/services/spree/webhooks/subscribers/queue_requests.rb b/api/app/services/spree/webhooks/subscribers/queue_requests.rb
index 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 Spree
class QueueRequests
prepend 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 Spree
private
- def filtered_subscribers(event_name, _)
+ def filtered_subscribers(event_name, _, _)
Spree::Webhooks::Subscriber.active.with_urls_for(event_name)
end
end