Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajoute Reply-To et permet la configuration du From des emails #1222

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion app/services/NotificationService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -230,6 +234,7 @@ class NotificationService @Inject() (
val email = Email(
subject = common.magicLinkSubject,
from = from,
replyTo = replyTo,
to = List(
userName
.filter(_.nonEmpty)
Expand All @@ -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))
)
Expand All @@ -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))
)
Expand Down Expand Up @@ -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)
)
Expand All @@ -299,6 +307,7 @@ class NotificationService @Inject() (
Email(
subject = "[A+] Bienvenue sur Administration+",
from = from,
replyTo = replyTo,
to = List(
userName
.filter(_.nonEmpty)
Expand All @@ -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))
)
Expand All @@ -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))
)
Expand Down Expand Up @@ -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))
)
Expand Down
1 change: 1 addition & 0 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down