aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/routes/transactions.coffee45
-rw-r--r--src/routes/users.coffee39
2 files changed, 53 insertions, 31 deletions
diff --git a/src/routes/transactions.coffee b/src/routes/transactions.coffee
index cadb73b1..696eefba 100644
--- a/src/routes/transactions.coffee
+++ b/src/routes/transactions.coffee
@@ -1,4 +1,6 @@
db = require('../redis')
+config = require("../config")
+moment = require('moment')
module.exports =
index: (req, res) ->
@@ -39,6 +41,32 @@ module.exports =
create: (req, res) ->
finish = ->
+ db.hgetall("user:"+req.params.user.toLowerCase(), (err, user) ->
+ res.render('transactions/notification',
+ layout: 'mail'
+ amount: (req.body.received * req.body.exchange).toFixed(2).toString() + ' ' + user.currency
+ address: req.body.address
+ txid: req.body.txid
+ js: (-> global.js)
+ css: (-> global.css)
+ (err, html) ->
+ helper = require('sendgrid').mail
+ from_email = new helper.Email('[email protected]')
+ to_email = new helper.Email(user.email)
+ subject = 'Transaction Sent'
+ content = new helper.Content('text/html', html)
+ mail = new helper.Mail(from_email, subject, to_email, content)
+
+ sg = require('sendgrid')(config.sendgrid_token)
+ request = sg.emptyRequest(
+ method: 'POST'
+ path: '/v3/mail/send'
+ body: mail.toJSON()
+ )
+
+ sg.API(request)
+ )
+ )
res.write(JSON.stringify(req.body))
res.end()
@@ -46,23 +74,6 @@ 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/src/routes/users.coffee b/src/routes/users.coffee
index e682602b..d1c8f602 100644
--- a/src/routes/users.coffee
+++ b/src/routes/users.coffee
@@ -112,16 +112,22 @@ module.exports = (sessions) ->
js: (-> global.js),
css: (-> global.css),
(err, html) ->
- sendgrid = require('sendgrid')(config.sendgrid_user, config.sendgrid_password)
- email = new sendgrid.Email(
- to: req.body.email
- subject: 'Welcome to CoinOS'
- html: html
+ helper = require('sendgrid').mail
+ from_email = new helper.Email('[email protected]')
+ to_email = new helper.Email(req.body.email)
+ subject = 'Welcome to CoinOS'
+ content = new helper.Content('text/html', html)
+ mail = new helper.Mail(from_email, subject, to_email, content)
+
+ sg = require('sendgrid')(config.sendgrid_token)
+ request = sg.emptyRequest(
+ method: 'POST'
+ path: '/v3/mail/send'
+ body: mail.toJSON()
)
- sendgrid.send(email)
+ sg.API(request)
)
)
)
@@ -178,16 +184,21 @@ module.exports = (sessions) ->
js: (-> global.js),
css: (-> global.css),
(err, html) ->
- sendgrid = require('sendgrid')(config.sendgrid_user, config.sendgrid_password)
+ helper = require('sendgrid').mail
+ from_email = new helper.Email('[email protected]')
+ to_email = new helper.Email(req.body.email)
+ subject = 'CoinOS Wallet Key'
+ content = new helper.Content('text/html', html)
+ mail = new helper.Mail(from_email, subject, to_email, content)
- email = new sendgrid.Email(
- to: req.body.email
- subject: 'CoinOS Wallet Key'
- html: html
+ sg = require('sendgrid')(config.sendgrid_token)
+ request = sg.emptyRequest(
+ method: 'POST'
+ path: '/v3/mail/send'
+ body: mail.toJSON()
)
- sendgrid.send(email)
+ sg.API(request)
)
verify: (req, res) ->