From 252682bc3cb897c053c1d78745e8ed1aaf6f6cd6 Mon Sep 17 00:00:00 2001 From: niladic Date: Wed, 3 Nov 2021 10:15:35 +0100 Subject: [PATCH] Ajoute Reply-To et permet la configuration du From (#1222) --- app/services/NotificationService.scala | 14 +++++++++++++- conf/application.conf | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/services/NotificationService.scala b/app/services/NotificationService.scala index 5bf2ece7d..aab0136b6 100644 --- a/app/services/NotificationService.scala +++ b/app/services/NotificationService.scala @@ -75,7 +75,11 @@ class NotificationService @Inject() ( private val https = configuration.underlying.getString("app.https") === "true" - private val from = s"Administration+ <${Constants.supportEmail}>" + private val from: String = configuration + .getOptional[String]("app.emailsFrom") + .getOrElse(s"Administration+ <${Constants.supportEmail}>") + + private val replyTo = List(s"Administration+ <${Constants.supportEmail}>") private def emailIsBlacklisted(email: Email): Boolean = notificationEmailBlacklist.exists(black => email.to.exists(_.contains(black))) @@ -230,6 +234,7 @@ class NotificationService @Inject() ( val email = Email( subject = common.magicLinkSubject, from = from, + replyTo = replyTo, to = List( userName .filter(_.nonEmpty) @@ -248,6 +253,7 @@ class NotificationService @Inject() ( val email = Email( subject = common.mandatSmsSentSubject, from = from, + replyTo = replyTo, to = List(s"${quoteEmailPhrase(user.name)} <${user.email}>"), bodyHtml = Some(common.renderEmail(bodyInner)) ) @@ -261,6 +267,7 @@ class NotificationService @Inject() ( val email = Email( subject = common.mandatSmsClosedSubject, from = from, + replyTo = replyTo, to = List(s"${quoteEmailPhrase(user.name)} <${user.email}>"), bodyHtml = Some(common.renderEmail(bodyInner)) ) @@ -289,6 +296,7 @@ class NotificationService @Inject() ( Email( subject = subject, from = from, + replyTo = replyTo, to = List(s"${quoteEmailPhrase(group.name)} <${group.email.get}>"), bodyHtml = Some(bodyHtml) ) @@ -299,6 +307,7 @@ class NotificationService @Inject() ( Email( subject = "[A+] Bienvenue sur Administration+", from = from, + replyTo = replyTo, to = List( userName .filter(_.nonEmpty) @@ -318,6 +327,7 @@ class NotificationService @Inject() ( Email( subject = s"[A+] Nouvelle demande d'aide : ${application.subject}", from = from, + replyTo = replyTo, to = List(s"${quoteEmailPhrase(invitedUser.name)} <${invitedUser.email}>"), bodyHtml = Some(common.renderEmail(bodyInner)) ) @@ -330,6 +340,7 @@ class NotificationService @Inject() ( Email( subject = s"[A+] Nouvelle réponse pour : ${application.subject}", from = from, + replyTo = replyTo, to = List(s"${quoteEmailPhrase(user.name)} <${user.email}>"), bodyHtml = Some(common.renderEmail(bodyInner)) ) @@ -370,6 +381,7 @@ class NotificationService @Inject() ( val email = Email( subject = common.weeklyEmailSubject, from = from, + replyTo = replyTo, to = List(s"${quoteEmailPhrase(infos.user.name)} <${infos.user.email}>"), bodyHtml = Some(common.renderEmail(bodyInner)) ) diff --git a/conf/application.conf b/conf/application.conf index 778fc2f30..1fe241ddc 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -93,6 +93,7 @@ app.groupsWhichCannotHaveInstructors = "" app.groupsWhichCannotHaveInstructors = ${?GROUPS_WHICH_CANNOT_HAVE_INSTRUCTORS} app.topHeaderWarningMessage = ${?TOP_HEADER_WARNING_MESSAGE} app.personalDataRetentionInMonths = ${?PERSONAL_DATA_RETENTION_IN_MONTHS} +app.emailsFrom = ${?EMAILS_FROM} ### Sentry