mail: expose maildata via filemanager

part of cloudron/box#794
This commit is contained in:
Girish Ramakrishnan
2021-09-26 12:19:32 -07:00
parent f7d3f611cd
commit 3c1b01a857
7 changed files with 51 additions and 21 deletions

View File

@@ -2882,8 +2882,14 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
// FileManager API
// mode can be 'download', 'open', 'link' or 'data'
function getObjpath(id, type) {
if (type === 'mail') return 'mailserver';
if (type === 'app') return 'apps/' + id;
if (type === 'volume') return 'volumes/' + id;
}
Client.prototype.filesGet = function (id, type, path, mode, callback) {
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
var objpath = getObjpath(id, type);
if (mode === 'download') {
window.open(client.apiOrigin + '/api/v1/' + objpath + '/files/' + path + '?download=true&access_token=' + token);
@@ -2909,7 +2915,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
};
Client.prototype.filesRemove = function (id, type, path, callback) {
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
var objpath = getObjpath(id, type);
del('/api/v1/' + objpath + '/files/' + path, null, function (error, data, status) {
if (error) return callback(error);
@@ -2920,7 +2926,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
};
Client.prototype.filesExtract = function (id, type, path, callback) {
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
var objpath = getObjpath(id, type);
put('/api/v1/' + objpath + '/files/' + path, { action: 'extract' }, {}, function (error, data, status) {
if (error) return callback(error);
@@ -2931,7 +2937,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
};
Client.prototype.filesChown = function (id, type, path, uid, recursive, callback) {
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
var objpath = getObjpath(id, type);
put('/api/v1/' + objpath + '/files/' + path, { action: 'chown', uid: uid, recursive: recursive }, {}, function (error, data, status) {
if (error) return callback(error);
@@ -2942,7 +2948,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
};
Client.prototype.filesRename = function (id, type, path, newPath, callback) {
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
var objpath = getObjpath(id, type);
put('/api/v1/' + objpath + '/files/' + path, { action: 'rename', newFilePath: decodeURIComponent(newPath) }, {}, function (error, data, status) {
if (error) return callback(error);
@@ -2955,7 +2961,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
Client.prototype.filesCopy = function (id, type, path, newPath, callback) {
var that = this;
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
var objpath = getObjpath(id, type);
put('/api/v1/' + objpath + '/files/' + path, { action: 'copy', newFilePath: decodeURIComponent(newPath) }, {}, function (error, data, status) {
if (error && error.statusCode === 409) return that.filesCopy(id, type, path, newPath + '-copy', callback);
@@ -2967,7 +2973,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
};
Client.prototype.filesCreateDirectory = function (id, type, path, callback) {
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
var objpath = getObjpath(id, type);
post('/api/v1/' + objpath + '/files/' + path, { directory: decodeURIComponent(path) }, {}, function (error, data, status) {
if (error) return callback(error);
@@ -2978,7 +2984,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
};
Client.prototype.filesCreateFile = function (id, type, path, callback) {
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
var objpath = getObjpath(id, type);
post('/api/v1/' + objpath + '/files/' + path, {}, {}, function (error, data, status) {
if (error) return callback(error);
@@ -2989,7 +2995,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
};
Client.prototype.filesUpload = function (id, type, path, file, overwrite, progressHandler, callback) {
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
var objpath = getObjpath(id, type);
var fd = new FormData();
fd.append('file', file);