send invite notifications using a hook

This commit is contained in:
clemkeirua 2020-09-25 11:10:12 +02:00 committed by Keirua (Rebase PR Action)
parent dd7840cdc4
commit d23b1136ad
2 changed files with 11 additions and 6 deletions

View file

@ -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