diff --git a/app/models/commentaire.rb b/app/models/commentaire.rb index 895bc2f3f..f68b462a5 100644 --- a/app/models/commentaire.rb +++ b/app/models/commentaire.rb @@ -18,7 +18,7 @@ class Commentaire < ApplicationRecord belongs_to :instructeur, optional: true belongs_to :expert, optional: true - validate :messagerie_available?, on: :create + validate :messagerie_available?, on: :create, unless: -> { dossier.brouillon? } has_one_attached :piece_jointe @@ -95,7 +95,7 @@ class Commentaire < ApplicationRecord end def notify_user - DossierMailer.notify_new_answer(dossier).deliver_later + DossierMailer.notify_new_answer(dossier, body).deliver_later end def messagerie_available? diff --git a/app/models/instructeur.rb b/app/models/instructeur.rb index d3e2fc21b..588502504 100644 --- a/app/models/instructeur.rb +++ b/app/models/instructeur.rb @@ -26,6 +26,7 @@ class Instructeur < ApplicationRecord has_many :previously_followed_dossiers, -> { distinct }, through: :previous_follows, source: :dossier has_many :trusted_device_tokens, dependent: :destroy has_many :archives + has_many :bulk_messages, dependent: :destroy has_one :user, dependent: :nullify