diff --git a/lib/router.transfer.js b/lib/router.transfer.js index 8a3589547..d0baaf6fd 100644 --- a/lib/router.transfer.js +++ b/lib/router.transfer.js @@ -49,7 +49,8 @@ module.exports = function (app) { udids: [] }; - let response = await transfer.decline(body).catch((response)=> { + // may throw + let response = await transfer.decline(body).catch((response) => { transferResultRedirect(false, res, response); }); @@ -69,11 +70,12 @@ module.exports = function (app) { udids: sanitka.udid(req.body.udid) }; - let response = await transfer.decline(body).catch((response) => { - transferResultRedirect(false, res, response); + // may throw + await transfer.decline(body).catch((response) => { + return transferResultRedirect(false, res, response); }); - transferResultRedirect(true, res, response); + transferResultRedirect(true, res); } async function getAcceptTransfer(req, res) { diff --git a/lib/thinx/transfer.js b/lib/thinx/transfer.js index f35cc820a..7538d8422 100644 --- a/lib/thinx/transfer.js +++ b/lib/thinx/transfer.js @@ -527,10 +527,10 @@ module.exports = class Transfer { udids = body.udids; } + var dtid = "dt:" + transfer_id; + console.log(`🔨 [debug] [transfer] getting DTID ${dtid} on decline`); - - var dtid = "dt:" + transfer_id; let json = await this.redis.get(dtid); if (typeof(json) === "undefined") { console.log(`[warning] [transfer] no such DTID ${dtid}`); diff --git a/spec/jasmine/TransferSpec.js b/spec/jasmine/TransferSpec.js index 1727a2088..7fa81bfe6 100644 --- a/spec/jasmine/TransferSpec.js +++ b/spec/jasmine/TransferSpec.js @@ -52,7 +52,10 @@ describe("Transfer", function () { var owner = envi.oid; + // create transfer request let response = await transfer.request(owner, body); + + console.log("transfer init response:", response); expect(response).to.be.a('string'); @@ -62,7 +65,10 @@ describe("Transfer", function () { }; // 00-02 Decline - const d_response = await transfer.decline(tbody); + const d_response = await transfer.decline(tbody).catch((e) => { + // may throw various exceptions, like invalid_device_transfer_identifier + console.log(e); + }); expect(d_response).to.be.a('string'); let b_response = await transfer.request(owner, body);