def emailMessage()

in anghammarad/src/main/scala/com/gu/anghammarad/messages/Messages.scala [36:67]


  def emailMessage(notification: Notification): EmailMessage = {
    val (markdown, plaintext) =
      if (notification.actions.isEmpty) {
        (notification.message, notification.message)
      } else {
        val actionPrefix =
          s"""
             |_____________________
             |
             |""".stripMargin

        val htmlActions = notification.actions.map { action =>
          s"[${action.cta}](${action.url})"
        }.mkString("\n\n")
        val plainTextActions = notification.actions.map { action =>
          s"${action.cta} - ${action.url}"
        }.mkString("\n\n")

        (notification.message + actionPrefix + htmlActions, notification.message + actionPrefix + plainTextActions)
      }

    val markdownWithNotice = markdown + anghammaradNotice(notification)
    val plaintextWithNotice = plaintext + anghammaradNotice(notification)

    val html = mdRenderer.render(mdParser.parse(markdownWithNotice)).replace("\n", "<br>")

    EmailMessage(
      notification.subject,
      plaintextWithNotice,
      html
    )
  }