Envoie un email à l'expert en cas de nouveau commentaire de l'usager dans la messagerie
This commit is contained in:
parent
6253188a77
commit
ac29cfbfdb
7 changed files with 71 additions and 5 deletions
|
@ -97,6 +97,8 @@ class Commentaire < ApplicationRecord
|
|||
# - Otherwise, a instructeur posted a commentaire, we need to notify the user
|
||||
if sent_by_instructeur? || sent_by_expert?
|
||||
notify_user(wait: 5.minutes)
|
||||
elsif !sent_by_system?
|
||||
notify_administration
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -108,6 +110,26 @@ class Commentaire < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def notify_administration
|
||||
dossier.followers_instructeurs
|
||||
.with_instant_email_message_notifications
|
||||
.find_each do |instructeur|
|
||||
DossierMailer.notify_new_commentaire_to_instructeur(dossier, instructeur.email).deliver_later
|
||||
end
|
||||
|
||||
experts_contactes = Set.new
|
||||
|
||||
dossier.avis.includes(:expert).find_each do |avis|
|
||||
if avis.expert.present?
|
||||
expert_id = avis.expert.id
|
||||
if !experts_contactes.include?(expert_id)
|
||||
AvisMailer.notify_new_commentaire_to_expert(dossier, avis, avis.expert).deliver_later
|
||||
experts_contactes.add(expert_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def messagerie_available?
|
||||
return if sent_by_system?
|
||||
if dossier.present? && !dossier.messagerie_available?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue