testing/fixing

This commit is contained in:
Josh Harvey 2016-05-09 03:15:55 +03:00
parent 59e93445ec
commit 1df6fe6ed1
5 changed files with 77 additions and 67 deletions

View file

@ -224,7 +224,7 @@ function phoneCode (req, res) {
function updatePhone (req, res) {
return plugins.updatePhone(session(req), req.body.phone)
.then(code => res.send(200))
.then(code => res.json(200))
.catch(err => {
logger.error(err)
res.send(500)
@ -241,11 +241,12 @@ function fetchPhoneTx (req, res) {
}
function waitForDispense (req, res) {
return plugins.fetchTx(session(req), req.query.status)
.then(r => {
if (!r) return res.send(404)
if (r.status === req.query.status) return res.send(304)
res.json(r)
return plugins.fetchTx(session(req))
.then(tx => {
console.log('%j', tx)
if (!tx) return res.send(404)
if (tx.status === req.query.status) return res.send(304)
res.json({tx: tx})
})
.catch(err => {
logger.error(err)
@ -256,7 +257,7 @@ function waitForDispense (req, res) {
function dispense (req, res) {
const tx = req.body.tx
return plugins.requestDispense(session(req), tx)
.then(() => res.send(200))
.then(() => res.json(200))
.catch(err => {
logger.error(err)
res.send(500)