This commit is contained in:
Josh Harvey 2016-11-27 20:14:36 +02:00
parent 00d986376e
commit 7bb071fc95
3 changed files with 29 additions and 28 deletions

View file

@ -7,6 +7,7 @@ const BigNumber = require('bignumber.js')
const logger = require('./logger')
const configManager = require('./config-manager')
const db = require('./db')
const dbm = require('./postgresql_interface')
const pairing = require('./pairing')
const settingsLoader = require('./settings')
@ -168,7 +169,7 @@ function updatePhone (req, res, next) {
const notified = req.query.notified === 'true'
const tx = req.body
return plugins.updatePhone(tx, notified)
return dbm.updatePhone(tx, notified)
.then(r => cacheAndRespond(req, res, r))
.catch(next)
}
@ -181,14 +182,14 @@ function fetchPhoneTx (req, res, next) {
function registerRedeem (req, res, next) {
const txId = req.params.txId
return plugins.registerRedeem(txId)
return dbm.registerRedeem(txId)
.then(() => cacheAndRespond(req, res))
.catch(next)
}
function waitForDispense (req, res, next) {
logger.debug('waitForDispense')
return plugins.fetchTx(req.params.txId)
return dbm.fetchTx(req.params.txId)
.then(tx => {
logger.debug('tx fetched')
logger.debug(tx)
@ -202,7 +203,7 @@ function waitForDispense (req, res, next) {
function dispense (req, res, next) {
const tx = req.body.tx
return plugins.requestDispense(tx)
return dbm.addDispenseRequest(tx)
.then(dispenseRec => cacheAndRespond(req, res, dispenseRec))
.catch(next)
}