diff --git a/src/js/app-controller.js b/src/js/app-controller.js index fc65f2b..dda453e 100644 --- a/src/js/app-controller.js +++ b/src/js/app-controller.js @@ -89,7 +89,7 @@ app.Controller = function() { } else if (cmd === 'sendEmail') { // list emails from folder - sendEmail(args.email, function(err) { + emailDao.sendEmail(args.email, function(err) { callback({ err: err }); @@ -119,9 +119,4 @@ app.Controller = function() { emailDao.init(account, password, callback); } - function sendEmail(email, callback) { - var em = new app.model.Email(email); - emailDao.sendEmail(em, callback); - } - }; \ No newline at end of file diff --git a/src/js/dao/email-dao.js b/src/js/dao/email-dao.js index 996a855..e3f42d3 100644 --- a/src/js/dao/email-dao.js +++ b/src/js/dao/email-dao.js @@ -185,7 +185,7 @@ app.dao.EmailDAO = function(jsonDB, crypto, devicestorage, cloudstorage, util, k // validate email addresses var invalidRecipient; - _.each(email.get('to'), function(address) { + _.each(email.to, function(address) { if (!validateEmail(address)) { invalidRecipient = address; } @@ -196,7 +196,7 @@ app.dao.EmailDAO = function(jsonDB, crypto, devicestorage, cloudstorage, util, k }); return; } - if (!validateEmail(email.get('from'))) { + if (!validateEmail(email.from)) { callback({ errMsg: 'Invalid sender: ' + email.from }); @@ -204,7 +204,7 @@ app.dao.EmailDAO = function(jsonDB, crypto, devicestorage, cloudstorage, util, k } // generate a new UUID for the new email - email.set('id', util.UUID()); + email.id = util.UUID(); // send email to cloud service cloudstorage.putEncryptedItem(email, 'email', userId, 'outbox', function(err) { diff --git a/test/integration/cloudstorage-dao-test.js b/test/integration/cloudstorage-dao-test.js index 45e584e..58e64a1 100644 --- a/test/integration/cloudstorage-dao-test.js +++ b/test/integration/cloudstorage-dao-test.js @@ -164,13 +164,12 @@ asyncTest("Init", 1, function() { }); asyncTest("Send Plaintext Email item", 1, function() { - var email = new app.model.Email({ - id: cloudstoragedao_test.util.UUID(), + var email = { from: cloudstoragedao_test.user, // sender address to: [cloudstoragedao_test.user], // list of receivers subject: 'Client Email DAO Test', // Subject line body: 'Hello world' // plaintext body - }); + }; cloudstoragedao_test.emailDao.sendEmail(email, function(err) { ok(!err, 'Email sent');