aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2016-09-18 15:55:47 -0700
committerAdam Soltys <[email protected]>2016-09-18 15:55:47 -0700
commit11d8decbb3b444561ee51daa0f0d2a609da13e47 (patch)
tree27176229e447f47dad06689e7d96dd3bc6012cda
parent90da658fe477005ad8ab140d205b0d0e1dce00ea (diff)
downloadcoinos-server-11d8decbb3b444561ee51daa0f0d2a609da13e47.tar.gz
coinos-server-11d8decbb3b444561ee51daa0f0d2a609da13e47.zip
Send basic notification on transaction receipt
-rw-r--r--routes/transactions.js19
-rw-r--r--src/routes/transactions.coffee17
-rw-r--r--views/transactions/notification.html3
3 files changed, 39 insertions, 0 deletions
diff --git a/routes/transactions.js b/routes/transactions.js
index 759ec14a..31875918 100644
--- a/routes/transactions.js
+++ b/routes/transactions.js
@@ -62,6 +62,25 @@
if (result) {
return finish();
}
+ res.render('notification', {
+ layout: 'mail',
+ js: (function() {
+ return global.js;
+ }),
+ css: (function() {
+ return global.css;
+ })
+ }, function(err, html) {
+ var email, sendgrid;
+ sendgrid = require('sendgrid')(config.sendgrid_user, config.sendgrid_password);
+ email = new sendgrid.Email({
+ subject: 'Transaction Sent',
+ html: html
+ });
+ return sendgrid.send(email);
+ });
multi = db.multi();
multi.hmset(req.body.txid, req.body);
multi.rpush("" + req.params.user + ":transactions", req.body.txid);
diff --git a/src/routes/transactions.coffee b/src/routes/transactions.coffee
index 25ccbbc9..cadb73b1 100644
--- a/src/routes/transactions.coffee
+++ b/src/routes/transactions.coffee
@@ -46,6 +46,23 @@ module.exports =
db.exists(req.body.txid, (err, result) ->
return finish() if result
+ res.render('notification',
+ layout: 'mail',
+ js: (-> global.js),
+ css: (-> global.css),
+ (err, html) ->
+ sendgrid = require('sendgrid')(config.sendgrid_user, config.sendgrid_password)
+
+ email = new sendgrid.Email(
+ subject: 'Transaction Sent'
+ html: html
+ )
+
+ sendgrid.send(email)
+ )
+
multi = db.multi()
multi.hmset(req.body.txid, req.body)
multi.rpush("#{req.params.user}:transactions", req.body.txid)
diff --git a/views/transactions/notification.html b/views/transactions/notification.html
new file mode 100644
index 00000000..49a045a7
--- /dev/null
+++ b/views/transactions/notification.html
@@ -0,0 +1,3 @@
+<h1>Transaction Received</h1>
+
+You got paid