Skip to content

Commit

Permalink
from 13 errors, potential return fix (still working on 0 and sxfx
Browse files Browse the repository at this point in the history
  • Loading branch information
suculent committed Nov 15, 2023
1 parent f656a90 commit eb0d16d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
10 changes: 6 additions & 4 deletions lib/router.transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions lib/thinx/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
8 changes: 7 additions & 1 deletion spec/jasmine/TransferSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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);
Expand Down

0 comments on commit eb0d16d

Please sign in to comment.