diff --git a/lib/thinx/transfer.js b/lib/thinx/transfer.js index fc3ef2a3e..7a2d3be63 100644 --- a/lib/thinx/transfer.js +++ b/lib/thinx/transfer.js @@ -241,9 +241,9 @@ module.exports = class Transfer { return Promise.resolve(false); // transfer not pending } - store_pending_transfer(udid, transfer_id) { - this.redis.set("dtr:" + udid, transfer_id); - this.redis.expire("dtr:" + udid, 86400); // expire pending transfer in one day... + async store_pending_transfer(udid, transfer_id) { + await this.redis.set("dtr:" + udid, transfer_id); + await this.redis.expire("dtr:" + udid, 86400); // expire pending transfer in one day... } // public @@ -364,11 +364,13 @@ module.exports = class Transfer { // 3. store as "dt:uuid()" to redis var transfer_uuid = uuidV4(); // used for email var transfer_id = "dt:" + transfer_uuid; - this.redis.set(transfer_id, JSON.stringify(body)); + await this.redis.set(transfer_id, JSON.stringify(body)); + + console.log("[debug] [transfer] setting dtid with body", transfer_id, {body}); // 4. store pending transfer for each device for (var did in body.udids) { - this.store_pending_transfer(did, transfer_id); + await this.store_pending_transfer(did, transfer_id); } // 6. send the e-mail diff --git a/spec/jasmine/TransferSpec.js b/spec/jasmine/TransferSpec.js index 1ced5124f..2b06229ad 100644 --- a/spec/jasmine/TransferSpec.js +++ b/spec/jasmine/TransferSpec.js @@ -53,7 +53,7 @@ describe("Transfer", function () { var owner = envi.oid; // create transfer request - let response = await transfer.request(owner, body); + let response = await transfer.request(owner, body); // should return transfer_id without prefix console.log("[spec] CHECKME! transfer request response:", response); @@ -66,8 +66,9 @@ describe("Transfer", function () { // 00-02 Decline await transfer.decline(tbody).catch((e) => { - // may throw various exceptions, like invalid_device_transfer_identifier - console.log("[spec] CHECKME! exception", e); + // may throw various exceptions, like `invalid_device_transfer_identifier` + expect(e.indexOf("invalid_device_transfer_identifier") !== -1); + console.log("[spec] CHECKME! exception", e); }); //expect(d_response).to.be.a('string');