From 669d8002d24bf357bee2c1ed9619bbb45dc71c87 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Tue, 23 Apr 2013 16:35:01 +0200 Subject: [PATCH] deleting vinbox item after sync works --- src/js/dao/cloudstorage-dao.js | 23 +++++++++++++++++++++++ src/js/dao/email-dao.js | 16 ++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/js/dao/cloudstorage-dao.js b/src/js/dao/cloudstorage-dao.js index 5fc27b6..f02218a 100644 --- a/src/js/dao/cloudstorage-dao.js +++ b/src/js/dao/cloudstorage-dao.js @@ -92,6 +92,29 @@ app.dao.CloudStorage = function(window, $) { }); }; + /** + * Delete an encrypted item from the cloud + * @param type [String] The type of item e.g. 'email' + */ + this.deleteEncryptedItem = function(id, type, emailAddress, folderName, callback) { + var uri; + + uri = app.config.cloudUrl + '/' + type + '/user/' + emailAddress + '/folder/' + folderName + '/' + id; + $.ajax({ + url: uri, + type: 'DELETE', + success: function() { + callback(); + }, + error: function(xhr, textStatus, err) { + callback({ + error: err, + status: textStatus + }); + } + }); + }; + /** * Lists the encrypted items * @param type [String] The type of item e.g. 'email' diff --git a/src/js/dao/email-dao.js b/src/js/dao/email-dao.js index 8213c25..a211664 100644 --- a/src/js/dao/email-dao.js +++ b/src/js/dao/email-dao.js @@ -133,9 +133,15 @@ app.dao.EmailDAO = function(_, crypto, devicestorage, cloudstorage, naclCrypto, return; } - // TODO: delete items from virtual inbox + // delete asymmetricall encrypted item from virtual inbox + deleteVinboxItem(asymCt, function(err) { + if (err) { + callback(err); + return; + } - after(); // asynchronously iterate through objects + after(); // asynchronously iterate through objects + }); }); }); }); @@ -184,6 +190,12 @@ app.dao.EmailDAO = function(_, crypto, devicestorage, cloudstorage, naclCrypto, }); }); } + + function deleteVinboxItem(email, callback) { + cloudstorage.deleteEncryptedItem(email.id, 'email', self.account.get('emailAddress'), 'vinbox', function(err) { + callback(err); + }); + } }; /**