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.

Fix race condition between saving invitation and sending email (#13584)

Kacper Mękarskib8656ae28ea8
diff --git a/backend/engines/core/app/models/spree/invitation.rb b/backend/engines/core/app/models/spree/invitation.rb
index 59cc435940..9377111895 100644
--- a/backend/engines/core/app/models/spree/invitation.rb
+++ b/backend/engines/core/app/models/spree/invitation.rb
@@ -56,7 +56,7 @@ module Spree
#
after_initialize :set_defaults, if: :new_record?
before_validation :set_invitee_from_email, on: :create
- after_create :publish_invitation_created_event, unless: :skip_email
+ after_commit :publish_invitation_created_event, on: :create, unless: :skip_email
# returns the store for the invitation
# if the resource is a store, return the resource