diff --git a/lib/router.transfer.js b/lib/router.transfer.js
index 053159899..eab5b020f 100644
--- a/lib/router.transfer.js
+++ b/lib/router.transfer.js
@@ -24,10 +24,10 @@ module.exports = function (app) {
}
}
- function requestTransfer(req, res) {
+ async function requestTransfer(req, res) {
if (!Util.validateSession(req)) return res.status(401).end();
let owner = sanitka.owner(req.session.owner);
- transfer.request(owner, req.body, (success, response) => {
+ await transfer.request(owner, req.body, (success, response) => {
transferResultRedirect(success, res, response);
});
}
diff --git a/lib/thinx/transfer.js b/lib/thinx/transfer.js
index 98439a7a8..2c5023c39 100644
--- a/lib/thinx/transfer.js
+++ b/lib/thinx/transfer.js
@@ -266,7 +266,7 @@ module.exports = class Transfer {
sendRecipientTransferEmail(body, transfer_uuid) {
- if (!Util.isDefined(body.udids)) { console.log("[error] [sendRecipientTransferEmail] missing body.udids"); return }
+ if (!Util.isDefined(body.udids)) { console.log("[error] [sendRecipientTransferEmail] missing body.udids"); return; }
var htmlDeviceList = "
";
for (var dindex in body.udids) {
@@ -320,7 +320,8 @@ module.exports = class Transfer {
this.sendMail(recipientTransferEmail, "recipient_transfer", () => { /* nop */ });
}
- request(owner, body, callback) {
+ // TODO: refactor from callback to promise?
+ async request(owner, body, callback) {
// body should look like { "to":"some@email.com", "udids" : [ "some-udid", "another-udid" ] }
diff --git a/spec/jasmine/TransferSpec.js b/spec/jasmine/TransferSpec.js
index 0866e2363..c11d59108 100644
--- a/spec/jasmine/TransferSpec.js
+++ b/spec/jasmine/TransferSpec.js
@@ -43,7 +43,7 @@ describe("Transfer", function () {
console.log(`🚸 [chai] <<< completed Transfer spec`);
});
- it("(00) should be able to initiate device transfer, decline and accept another one", function (done) {
+ it("(00) should be able to initiate device transfer, decline and accept another one", async function (done) {
let accepted = false;
@@ -55,7 +55,7 @@ describe("Transfer", function () {
var owner = envi.oid;
// TODO: Turn this into async
- transfer.request(owner, body, (t_success, response) => {
+ await transfer.request(owner, body, (t_success, response) => {
expect(t_success).to.equal(true);
expect(response).to.be.a('string');
const tbody = {
@@ -64,14 +64,14 @@ describe("Transfer", function () {
};
// 00-02 Decline
- transfer.decline(tbody, (d_success, d_response) => {
+ transfer.decline(tbody, async (d_success, d_response) => {
expect(d_success).to.equal(true);
expect(d_response).to.be.a('string');
// TODO: Turn this into async
- transfer.request(owner, body, (b_success, b_response) => {
+ await transfer.request(owner, body, (b_success, b_response) => {
expect(b_success).to.equal(true);
- expect(b_response).to.be.a('string'); // transfer_requested
+ expect(b_response).to.be.a('string'); // transfer_requested
// 00-04 Accept
var transfer_body = {