removed email model from send email

This commit is contained in:
Tankred Hase 2013-06-06 20:41:25 +02:00
parent 8f54f1c544
commit c9522fcb5e
3 changed files with 6 additions and 12 deletions

View File

@ -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);
}
};

View File

@ -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) {

View File

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