Skip to content

Commit

Permalink
debugging transfer request creation/pending device transfer storage
Browse files Browse the repository at this point in the history
  • Loading branch information
suculent committed Nov 16, 2023
1 parent 1f860ab commit 90ee627
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 7 additions & 5 deletions lib/thinx/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions spec/jasmine/TransferSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

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

Expand Down

0 comments on commit 90ee627

Please sign in to comment.