Merge pull request #5629 from betagouv/fix-deserialization-issues-delayed_job
Fix deserialization issues delayed job
This commit is contained in:
commit
9417f4f012
3 changed files with 12 additions and 7 deletions
|
@ -15,12 +15,7 @@ class InvitesController < ApplicationController
|
|||
)
|
||||
|
||||
if invite.valid?
|
||||
if invite.user.present?
|
||||
InviteMailer.invite_user(invite).deliver_later
|
||||
else
|
||||
InviteMailer.invite_guest(invite).deliver_later
|
||||
end
|
||||
|
||||
# The notification is sent through an after commit hook in order to avoir concurrency issues
|
||||
flash.notice = "Une invitation a été envoyée à #{invite.email}."
|
||||
else
|
||||
flash.alert = invite.errors.full_messages
|
||||
|
|
|
@ -308,7 +308,7 @@ class Dossier < ApplicationRecord
|
|||
|
||||
after_save :send_dossier_received
|
||||
after_save :send_web_hook
|
||||
after_create :send_draft_notification_email
|
||||
after_create_commit :send_draft_notification_email
|
||||
|
||||
validates :user, presence: true
|
||||
validates :individual, presence: true, if: -> { revision.procedure.for_individual? }
|
||||
|
|
|
@ -19,6 +19,8 @@ class Invite < ApplicationRecord
|
|||
|
||||
before_validation -> { sanitize_email(:email) }
|
||||
|
||||
after_create_commit :send_notification
|
||||
|
||||
validates :email, presence: true
|
||||
validates :email, uniqueness: { scope: :dossier_id }
|
||||
|
||||
|
@ -32,4 +34,12 @@ class Invite < ApplicationRecord
|
|||
scope :kept, -> { joins(:dossier).merge(Dossier.kept) }
|
||||
|
||||
default_scope { kept }
|
||||
|
||||
def send_notification
|
||||
if self.user.present?
|
||||
InviteMailer.invite_user(self).deliver_later
|
||||
else
|
||||
InviteMailer.invite_guest(self).deliver_later
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue