Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Sending welcome email with instructions and links to repos

  • Loading branch information...
commit 66d5c4ac1dc5ad27c3d6821f584b0c80c34d392f 1 parent d0a04b5
Alejandro Lujan authored
View
7 app/controllers/Users.scala
@@ -11,10 +11,12 @@ import play.api.data.Form
import play.api.data.FormError
import play.api.mvc.Action
import play.api.mvc.AnyContent
+import play.api.i18n.Messages
import play.api.Logger
import tools.BigDecimalFormatter
import play.api.mvc.Request
import play.api.mvc.Result
+import jobs.EmailJob._
object Users extends APIController {
@@ -76,7 +78,10 @@ object Users extends APIController {
// Parameters are fine, create user
user => {
user.create match {
- case Some(newUser) => Success(Map("id" -> newUser.id.get))
+ case Some(newUser) => {
+ sendEmail(newUser.email, Messages("email.welcome.subject"), "emailTemplates/welcome.en.html")
+ Success(Map("id" -> newUser.id.get))
+ }
case None => Error("User cannot be created")
}
})
View
26 app/jobs/EmailJob.scala
@@ -0,0 +1,26 @@
+package jobs
+
+import com.typesafe.plugin._
+import play.api.Play.current
+import play.api.libs.concurrent.Akka
+import play.Configuration
+import play.api.i18n.Lang
+import play.api.Logger
+import scala.io.Source
+
+object EmailJob {
+
+ private val from = current.configuration.getString("email.from").getOrElse("")
+
+ def sendEmail(recipient: String, subject: String, templatePath: String) = //Akka.future {
+ {
+ val content = scala.io.Source.fromFile(templatePath).mkString
+ println("Sending email with subject '" + subject + "' to " + recipient + " from " + from + " with content: '" + content + "'")
+
+ val mail = use[MailerPlugin].email
+ mail.setSubject(subject)
+ mail.addRecipient(recipient)
+ mail.addFrom(from)
+ mail.sendHtml(content)
+ }
+}
View
4 app/views/playground.scala.html
@@ -5,9 +5,9 @@
<h1>@Messages("title.playground")</h1>
<p>@Messages("playground.details")</p>
<ol class="steps">
- <li>@Messages("playground.details.step1") <a href="https://github.com/tindr/Scala1">@Messages("playground.details.step1.linkText")</a></li>
+ <li>@Messages("playground.details.step1")</a></li>
<li>@Messages("playground.details.step2")</li>
<li>@Messages("playground.details.step3")</li>
</ol>
-
+ <p>@Messages("playground.instructions")
}
View
5 conf/application.conf
@@ -49,3 +49,8 @@ logger.play=INFO
# Logger provided to your application:
logger.application=DEBUG
+# Email configuration
+smtp.host=smtp.gmail.com
+smtp.ssl=yes
+email.from="scala1@tindr.ca"
+
View
12 conf/messages
@@ -23,8 +23,10 @@ about.discussion.details=Chat with your fellow Scala Enthusiasts via the general
about.find=Find a Like Minded Person
about.find.details=It''s a big conference out there - coordinate on the fly meetups with the "Find an Enthusiast" function. Find other people using the app on the map and click on them to get their information or even enter a one-on-one chat with them. Allowing the app access to your location through this function enables you to be found as well.
-playground.details=This is the playground area. It''s here for you to hack at. Here''s how:
-playground.details.step1=Fork the application repository
-playground.details.step1.linkText=here
-playground.details.step2=Hack away at the backend source code.
-playground.details.step3=Send us a pull request, and we''ll include your changes if they''re safe and fun for everyone :)
+playground.details=This is the playground area. It''s here for you to hack at. Here's how:
+playground.details.step1=Fork the application repository.
+playground.details.step2=Hack away at the source code.
+playground.details.step3=Send us a pull request, and we''ll include your changes if they''re safe and fun for everyone :)
+playground.instructions=We sent you an email with instructions when you registered - if you haven''t yet, now is the perfect time!
+
+email.welcome.subject=Welcome to Scala1
View
1  conf/play.plugins
@@ -0,0 +1 @@
+1500:com.typesafe.plugin.CommonsMailerPlugin
View
23 emailTemplates/welcome.en.html
@@ -0,0 +1,23 @@
+<html>
+ <body>
+ <h1>Welcome to Scala1! </h1>
+ <p>Thank you for trying out the Scala1 app.</p>
+ <p>As you may know, we have released Scala1 as Open Source projects, and we would
+ love to get your feedback. Even better, if you'd like to play with the code, and contribute to it,
+ it's as easy as 1-2-3:</p>
+
+ <ol>
+ <li>Fork the application repository <a href="https://github.com/tindr/Scala1">here</a>.</li>
+ <li>Hack away at the source code.</li>
+ <li>Send us a pull request, and we'll include your changes if they're safe and fun for everyone :)</li>
+ </ol>
+
+ <p>You can also take a look at the
+ <a href="https://github.com/magneticbear/scalaone_iphone">iOS</a> and
+ <a href="https://github.com/magneticbear/scala1_android">Android</a>
+ repositories.</p>
+ <p>Feel free to send us any feedback you have.</p>
+ <p>Have fun, and enjoy the conference!</p>
+ <p>The Typesafe Team</p>
+ </body>
+</html>
View
3  project/Build.scala
@@ -10,7 +10,8 @@ object ApplicationBuild extends Build {
val appDependencies = Seq(
// Add your project dependencies here,
"postgresql" % "postgresql" % "9.1-901-1.jdbc4",
- "tindr" % "play2pusher_2.9.1" % "1.0.1"
+ "tindr" % "play2pusher_2.9.1" % "1.0.1",
+ "com.typesafe" %% "play-plugins-mailer" % "2.0.4"
)
val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings( // Add your own project settings here
View
4 test/controllers/CreateUserTest.scala
@@ -40,7 +40,7 @@ class CreateUserTest extends APISpecification {
"twitter" -> "john",
"facebook" -> "johnDoe",
"phone" -> "987-6543210",
- "email" -> "john@example.com",
+ "email" -> "alex@tindr.ca",
"website" -> "http://example.com",
"token" -> validToken))
@@ -59,7 +59,7 @@ class CreateUserTest extends APISpecification {
user.twitter must beEqualTo(Some("john"))
user.facebook must beEqualTo(Some("johnDoe"))
user.phone must beEqualTo(Some("987-6543210"))
- user.email must beEqualTo("john@example.com")
+ user.email must beEqualTo("alex@tindr.ca")
user.website must beEqualTo(Some("http://example.com"))
}
}

0 comments on commit 66d5c4a

Please sign in to comment.
Something went wrong with that request. Please try again.