support backwards compat with raqia redeem
This commit is contained in:
parent
c4cbe0f6bb
commit
8579f2fd2d
3 changed files with 9 additions and 9 deletions
|
|
@ -797,8 +797,8 @@ exports.getPhoneCode = function getPhoneCode (phone) {
|
||||||
.then(() => code)
|
.then(() => code)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.updatePhone = function updatePhone (session, tx) {
|
exports.updatePhone = function updatePhone (session, tx, notified) {
|
||||||
return db.addIncomingPhone(session, tx)
|
return db.addIncomingPhone(session, tx, notified)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.registerRedeem = function registerRedeem (session) {
|
exports.registerRedeem = function registerRedeem (session) {
|
||||||
|
|
|
||||||
|
|
@ -487,14 +487,14 @@ function insertDispense (client, session, tx, cartridges, transactionId, cb) {
|
||||||
client.query(sql, values, cb)
|
client.query(sql, values, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.addIncomingPhone = function addIncomingPhone (session, tx, cb) {
|
exports.addIncomingPhone = function addIncomingPhone (session, tx, notified, cb) {
|
||||||
var sql = 'UPDATE transactions SET phone=$1 ' +
|
var sql = 'UPDATE transactions SET phone=$1, notified=$2 ' +
|
||||||
'WHERE incoming=$2 AND device_fingerprint=$3 AND session_id=$4'
|
'WHERE incoming=$3 AND device_fingerprint=$4 AND session_id=$5'
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
connect(function (cerr, client, done) {
|
connect(function (cerr, client, done) {
|
||||||
if (cerr) return reject(cerr)
|
if (cerr) return reject(cerr)
|
||||||
var values = [tx.phone, true, session.fingerprint, session.id]
|
var values = [tx.phone, notified, true, session.fingerprint, tx.sessionId]
|
||||||
query(client, sql, values, function (err) {
|
query(client, sql, values, function (err) {
|
||||||
done(err)
|
done(err)
|
||||||
if (err) return reject(err)
|
if (err) return reject(err)
|
||||||
|
|
|
||||||
|
|
@ -225,9 +225,9 @@ function pair (req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function phoneCode (req, res) {
|
function phoneCode (req, res) {
|
||||||
console.log('DEBUG10')
|
|
||||||
var phone = req.body.phone
|
var phone = req.body.phone
|
||||||
|
|
||||||
|
logger.debug('Phone code requested for: ' + phone)
|
||||||
return plugins.getPhoneCode(phone)
|
return plugins.getPhoneCode(phone)
|
||||||
.then(code => res.json({code: code}))
|
.then(code => res.json({code: code}))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
@ -238,7 +238,8 @@ function phoneCode (req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePhone (req, res) {
|
function updatePhone (req, res) {
|
||||||
return plugins.updatePhone(session(req), req.body.phone)
|
const notified = req.query.notified === 'true'
|
||||||
|
return plugins.updatePhone(session(req), req.body, notified)
|
||||||
.then(code => res.json(200))
|
.then(code => res.json(200))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
logger.error(err)
|
logger.error(err)
|
||||||
|
|
@ -267,7 +268,6 @@ function registerRedeem (req, res) {
|
||||||
function waitForDispense (req, res) {
|
function waitForDispense (req, res) {
|
||||||
return plugins.fetchTx(session(req))
|
return plugins.fetchTx(session(req))
|
||||||
.then(tx => {
|
.then(tx => {
|
||||||
console.log('%j', tx)
|
|
||||||
if (!tx) return res.send(404)
|
if (!tx) return res.send(404)
|
||||||
if (tx.status === req.query.status) return res.send(304)
|
if (tx.status === req.query.status) return res.send(304)
|
||||||
res.json({tx: tx})
|
res.json({tx: tx})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue