mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 21:45:50 +01:00
(refs #10) Creates a E-mail sending. still working on...
This commit is contained in:
@@ -35,6 +35,7 @@ object MyBuild extends Build {
|
|||||||
"commons-io" % "commons-io" % "2.4",
|
"commons-io" % "commons-io" % "2.4",
|
||||||
"org.pegdown" % "pegdown" % "1.3.0",
|
"org.pegdown" % "pegdown" % "1.3.0",
|
||||||
"org.apache.commons" % "commons-compress" % "1.5",
|
"org.apache.commons" % "commons-compress" % "1.5",
|
||||||
|
"org.apache.commons" % "commons-email" % "1.3.1",
|
||||||
"com.typesafe.slick" %% "slick" % "1.0.1",
|
"com.typesafe.slick" %% "slick" % "1.0.1",
|
||||||
"com.novell.ldap" % "jldap" % "2009-10-07",
|
"com.novell.ldap" % "jldap" % "2009-10-07",
|
||||||
"com.h2database" % "h2" % "1.3.171",
|
"com.h2database" % "h2" % "1.3.171",
|
||||||
|
|||||||
37
src/main/scala/util/Notifier.scala
Normal file
37
src/main/scala/util/Notifier.scala
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package util
|
||||||
|
|
||||||
|
import org.apache.commons.mail.{DefaultAuthenticator, SimpleEmail}
|
||||||
|
|
||||||
|
import service.SystemSettingsService.{SystemSettings, Smtp}
|
||||||
|
|
||||||
|
trait Notifier {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
object Notifier {
|
||||||
|
def apply(settings: SystemSettings) = {
|
||||||
|
new Mailer(settings.smtp.get)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Mailer(val smtp: Smtp) extends Notifier {
|
||||||
|
def notifyTo(issue: model.Issue) = {
|
||||||
|
val email = new SimpleEmail
|
||||||
|
email.setHostName(smtp.host)
|
||||||
|
email.setSmtpPort(smtp.port.get)
|
||||||
|
smtp.user.foreach { user =>
|
||||||
|
email.setAuthenticator(new DefaultAuthenticator(user, smtp.password.getOrElse("")))
|
||||||
|
}
|
||||||
|
smtp.ssl.foreach { ssl =>
|
||||||
|
email.setSSLOnConnect(ssl)
|
||||||
|
}
|
||||||
|
email.setFrom("TODO address", "TODO name")
|
||||||
|
email.addTo("TODO")
|
||||||
|
email.setSubject(s"[${issue.repositoryName}] ${issue.title} (#${issue.issueId})")
|
||||||
|
email.setMsg("TODO")
|
||||||
|
|
||||||
|
email.send
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class MockMailer extends Notifier
|
||||||
Reference in New Issue
Block a user