2015-09-02 12:19:50 +03:00
|
|
|
/**
|
2016-08-03 13:18:05 +03:00
|
|
|
* Mail
|
2015-09-02 12:19:50 +03:00
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later. See the COPYING file.
|
|
|
|
*
|
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2016-03-11 00:03:01 +03:00
|
|
|
* @copyright Christoph Wurst 2015, 2016
|
2015-09-02 12:19:50 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
define(function(require) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var $ = require('jquery');
|
|
|
|
var OC = require('OC');
|
2016-02-06 13:35:44 +03:00
|
|
|
|
2016-03-11 00:03:01 +03:00
|
|
|
/**
|
|
|
|
* @param {Account} account
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
2016-02-22 13:57:39 +03:00
|
|
|
function getFolderEntities(account) {
|
2015-09-02 12:19:50 +03:00
|
|
|
var defer = $.Deferred();
|
|
|
|
|
2016-02-22 13:57:39 +03:00
|
|
|
var url = OC.generateUrl('apps/mail/accounts/{id}/folders',
|
2015-09-02 12:19:50 +03:00
|
|
|
{
|
2016-02-22 13:57:39 +03:00
|
|
|
id: account.get('accountId')
|
2015-09-02 12:19:50 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
var promise = $.get(url);
|
|
|
|
|
|
|
|
promise.done(function(data) {
|
2016-02-22 13:57:39 +03:00
|
|
|
for (var prop in data) {
|
|
|
|
if (prop === 'folders') {
|
2016-09-21 00:33:10 +03:00
|
|
|
account.folders.reset();
|
|
|
|
account.addFolder(data.folders);
|
2016-02-22 13:57:39 +03:00
|
|
|
} else {
|
|
|
|
account.set(prop, data[prop]);
|
|
|
|
}
|
|
|
|
}
|
2016-09-21 00:33:10 +03:00
|
|
|
defer.resolve(account.folders);
|
2015-09-02 12:19:50 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
promise.fail(function() {
|
|
|
|
defer.reject();
|
|
|
|
});
|
2016-08-05 15:01:47 +03:00
|
|
|
|
2015-09-02 12:19:50 +03:00
|
|
|
return defer.promise();
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
getFolderEntities: getFolderEntities
|
|
|
|
};
|
|
|
|
});
|