Skip to content

Commit

Permalink
debugging dtid deletions
Browse files Browse the repository at this point in the history
  • Loading branch information
suculent committed Nov 16, 2023
1 parent 209a42a commit 1e89cdd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/router.transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ module.exports = function (app) {

// solves `Headers already sent` issue? Why does it happen? This should not be here!
if ((process.env.ENVIRONMENT === "test") || (process.env.ENVIRONMENT === "development")) {
return Promise.resolve(response);
//if (success) {
return Promise.resolve(response); // return error in case of problem (not in exception!)
//} else {
// return Promise.reject(response);
//}
}

if (success === false) {
if ((success === false) || (typeof(response) === "undefined")) {
res.redirect(app_config.public_url + "/error.html?success=failed&reason=" + response);
} else {
res.redirect(app_config.public_url + "/error.html?success=true");
Expand Down
6 changes: 6 additions & 0 deletions lib/thinx/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ module.exports = class Transfer {
// 3. store as "dt:uuid()" to redis
var transfer_uuid = uuidV4(); // used for email
var transfer_id = "dt:" + transfer_uuid;

await this.redis.set(transfer_id, JSON.stringify(body));

console.log("[debug] [transfer] setting dtid with body", transfer_id, { body });
Expand All @@ -396,6 +397,7 @@ module.exports = class Transfer {
await this.redis.expire(tid, 3600); // 3600 seconds expiration for this transfer request; should be possibly more (like 72h to pass weekends)
} else {
ac(true, "transfer_completed");
console.log("[debug] [transfer] [save_dtid] deleting dtid: ", tid);
await this.redis.del(tid);
}
}
Expand Down Expand Up @@ -492,8 +494,10 @@ module.exports = class Transfer {
// Check if there are some devices left
console.log(`🔨 [debug] [transfer] L2 LEFT keys: ${json_keys.udids}`);
if ((typeof (json_keys.udids) !== "undefined") && json_keys.udids.length === 0) {
console.log("[debug] [transfer] [accept] deleting dtid (2): ", dtid);
this.redis.del(dtid);
for (var udid in udids) {
console.log("[debug] [transfer] deleting dtr: ", udid);
this.redis.del("dtr:" + udid);
}
return Promise.resolve("transfer_completed");
Expand Down Expand Up @@ -526,6 +530,7 @@ module.exports = class Transfer {
// 1 hour to let user accept/decline different devices
await this.redis.expire(dtid, 3600);
} else {
console.log("[debug] [transfer] [storeRemainingKeys] deleting dtid (3): ", dtid);
await this.redis.del(dtid);
}
}
Expand Down Expand Up @@ -582,6 +587,7 @@ module.exports = class Transfer {
console.log(`🔨 [debug] [transfer] L6 udids ${json_keys.udids}`);

if (json_keys.udids.length == 0) {
console.log("[debug] [transfer] [decline] deleting dtid (4): ", dtid);
await this.redis.del(dtid);
}

Expand Down

0 comments on commit 1e89cdd

Please sign in to comment.