Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / mailServerOut / mailServerOut.controller.js
index 57469c9..e92900a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7f7f=['options','count','includeAll','include','findAll','rows','catch','show','params','create','body','find','html-pdf','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','lodash','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','set','Content-Range','save','update','then','destroy','error','name','send','index','map','MailServerOut','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','sort','where','filter','merge','VIRTUAL'];(function(_0x35887c,_0x5ae247){var _0x2a5458=function(_0x27a21e){while(--_0x27a21e){_0x35887c['push'](_0x35887c['shift']());}};_0x2a5458(++_0x5ae247);}(_0x7f7f,0x1c2));var _0xf7f7=function(_0x393cf4,_0x5902d8){_0x393cf4=_0x393cf4-0x0;var _0x36ffce=_0x7f7f[_0x393cf4];return _0x36ffce;};'use strict';var pdf=require(_0xf7f7('0x0'));var emlformat=require(_0xf7f7('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xf7f7('0x2'));var rp=require(_0xf7f7('0x3'));var moment=require(_0xf7f7('0x4'));var BPromise=require(_0xf7f7('0x5'));var Mustache=require(_0xf7f7('0x6'));var util=require(_0xf7f7('0x7'));var path=require(_0xf7f7('0x8'));var sox=require(_0xf7f7('0x9'));var csv=require('to-csv');var ejs=require(_0xf7f7('0xa'));var fs=require('fs');var _=require(_0xf7f7('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xf7f7('0xc'));var deskjs=require(_0xf7f7('0xd'));var toCsv=require(_0xf7f7('0xe'));var querystring=require(_0xf7f7('0xf'));var Papa=require(_0xf7f7('0x10'));var Redis=require(_0xf7f7('0x11'));var authService=require(_0xf7f7('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xf7f7('0x13'));var hardwareService=require(_0xf7f7('0x14'));var logger=require(_0xf7f7('0x15'))('api');var utils=require(_0xf7f7('0x16'));var config=require(_0xf7f7('0x17'));var licenseUtil=require(_0xf7f7('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x4f8ca3,_0x4174ee){_0x4174ee=_0x4174ee||0xcc;return function(_0x1ebce7){if(_0x1ebce7){return _0x4f8ca3[_0xf7f7('0x19')](_0x4174ee);}return _0x4f8ca3[_0xf7f7('0x1a')](_0x4174ee)[_0xf7f7('0x1b')]();};}function respondWithResult(_0x2bf712,_0x14d571){_0x14d571=_0x14d571||0xc8;return function(_0x24d75a){if(_0x24d75a){return _0x2bf712[_0xf7f7('0x1a')](_0x14d571)[_0xf7f7('0x1c')](_0x24d75a);}};}function respondWithFilteredResult(_0x389918,_0x200e0f){return function(_0xecc55d){if(_0xecc55d){var _0x1852e7=_0xecc55d['count'],_0x2c0f06=_0x200e0f[_0xf7f7('0x1d')],_0x4bc8d9=_0x200e0f[_0xf7f7('0x1d')]+_0x200e0f['limit'],_0x2f8a0e;if(_0x4bc8d9>=_0x1852e7){_0x4bc8d9=_0x1852e7;_0x2f8a0e=0xc8;}else{_0x2f8a0e=0xce;}_0x389918[_0xf7f7('0x1a')](_0x2f8a0e);return _0x389918[_0xf7f7('0x1e')](_0xf7f7('0x1f'),_0x2c0f06+'-'+_0x4bc8d9+'/'+_0x1852e7)[_0xf7f7('0x1c')](_0xecc55d);}return null;};}function patchUpdates(_0x3e6712){return function(_0x14caf7){try{jsonpatch['apply'](_0x14caf7,_0x3e6712,!![]);}catch(_0x288d8b){return BPromise['reject'](_0x288d8b);}return _0x14caf7[_0xf7f7('0x20')]();};}function saveUpdates(_0x4839e8,_0x5a2b49){return function(_0x912948){if(_0x912948){return _0x912948[_0xf7f7('0x21')](_0x4839e8)[_0xf7f7('0x22')](function(_0x584a7c){return _0x584a7c;});}return null;};}function removeEntity(_0x3ceec0,_0x389ef1){return function(_0x13ebe4){if(_0x13ebe4){return _0x13ebe4[_0xf7f7('0x23')]()['then'](function(){_0x3ceec0[_0xf7f7('0x1a')](0xcc)[_0xf7f7('0x1b')]();});}};}function handleEntityNotFound(_0x24a53e,_0x1493e0){return function(_0x388d4b){if(!_0x388d4b){_0x24a53e[_0xf7f7('0x19')](0x194);}return _0x388d4b;};}function handleError(_0x42b539,_0x398640){_0x398640=_0x398640||0x1f4;return function(_0x561013){logger[_0xf7f7('0x24')](_0x561013['stack']);if(_0x561013[_0xf7f7('0x25')]){delete _0x561013[_0xf7f7('0x25')];}_0x42b539['status'](_0x398640)[_0xf7f7('0x26')](_0x561013);};}exports[_0xf7f7('0x27')]=function(_0x336463,_0x262706){var _0x1f124c={},_0x5ccc0c={},_0x9166df={'count':0x0,'rows':[]};var _0x4eb256=_[_0xf7f7('0x28')](db[_0xf7f7('0x29')]['rawAttributes'],function(_0x5e6612){return{'name':_0x5e6612[_0xf7f7('0x2a')],'type':_0x5e6612[_0xf7f7('0x2b')][_0xf7f7('0x2c')]};});_0x5ccc0c[_0xf7f7('0x2d')]=_[_0xf7f7('0x28')](_0x4eb256,_0xf7f7('0x25'));_0x5ccc0c[_0xf7f7('0x2e')]=_[_0xf7f7('0x2f')](_0x336463['query']);_0x5ccc0c[_0xf7f7('0x30')]=_[_0xf7f7('0x31')](_0x5ccc0c[_0xf7f7('0x2d')],_0x5ccc0c['query']);_0x1f124c[_0xf7f7('0x32')]=_[_0xf7f7('0x31')](_0x5ccc0c['model'],qs[_0xf7f7('0x33')](_0x336463[_0xf7f7('0x2e')][_0xf7f7('0x33')]));_0x1f124c[_0xf7f7('0x32')]=_0x1f124c[_0xf7f7('0x32')][_0xf7f7('0x34')]?_0x1f124c['attributes']:_0x5ccc0c[_0xf7f7('0x2d')];if(!_0x336463[_0xf7f7('0x2e')][_0xf7f7('0x35')](_0xf7f7('0x36'))){_0x1f124c[_0xf7f7('0x37')]=qs[_0xf7f7('0x37')](_0x336463['query'][_0xf7f7('0x37')]);_0x1f124c[_0xf7f7('0x1d')]=qs[_0xf7f7('0x1d')](_0x336463[_0xf7f7('0x2e')][_0xf7f7('0x1d')]);}_0x1f124c['order']=qs[_0xf7f7('0x38')](_0x336463['query'][_0xf7f7('0x38')]);_0x1f124c[_0xf7f7('0x39')]=qs['filters'](_['pick'](_0x336463[_0xf7f7('0x2e')],_0x5ccc0c[_0xf7f7('0x30')]),_0x4eb256);if(_0x336463['query'][_0xf7f7('0x3a')]){_0x1f124c[_0xf7f7('0x39')]=_[_0xf7f7('0x3b')](_0x1f124c['where'],{'$or':_[_0xf7f7('0x28')](_0x4eb256,function(_0x36925f){if(_0x36925f[_0xf7f7('0x2b')]!==_0xf7f7('0x3c')){var _0x3f3e54={};_0x3f3e54[_0x36925f[_0xf7f7('0x25')]]={'$like':'%'+_0x336463[_0xf7f7('0x2e')][_0xf7f7('0x3a')]+'%'};return _0x3f3e54;}})});}_0x1f124c=_[_0xf7f7('0x3b')]({},_0x1f124c,_0x336463[_0xf7f7('0x3d')]);var _0x32c32b={'where':_0x1f124c[_0xf7f7('0x39')]};return db[_0xf7f7('0x29')][_0xf7f7('0x3e')](_0x32c32b)[_0xf7f7('0x22')](function(_0x13fcfa){_0x9166df[_0xf7f7('0x3e')]=_0x13fcfa;if(_0x336463['query'][_0xf7f7('0x3f')]){_0x1f124c[_0xf7f7('0x40')]=[{'all':!![]}];}return db[_0xf7f7('0x29')][_0xf7f7('0x41')](_0x1f124c);})[_0xf7f7('0x22')](function(_0x53d688){_0x9166df[_0xf7f7('0x42')]=_0x53d688;return _0x9166df;})['then'](respondWithFilteredResult(_0x262706,_0x1f124c))[_0xf7f7('0x43')](handleError(_0x262706,null));};exports[_0xf7f7('0x44')]=function(_0x16fab7,_0x2f1554){var _0x413551={'raw':!![],'where':{'id':_0x16fab7[_0xf7f7('0x45')]['id']}},_0x1dbb06={};_0x1dbb06[_0xf7f7('0x2d')]=_[_0xf7f7('0x2f')](db[_0xf7f7('0x29')]['rawAttributes']);_0x1dbb06[_0xf7f7('0x2e')]=_[_0xf7f7('0x2f')](_0x16fab7['query']);_0x1dbb06['filters']=_[_0xf7f7('0x31')](_0x1dbb06['model'],_0x1dbb06[_0xf7f7('0x2e')]);_0x413551[_0xf7f7('0x32')]=_[_0xf7f7('0x31')](_0x1dbb06[_0xf7f7('0x2d')],qs[_0xf7f7('0x33')](_0x16fab7['query']['fields']));_0x413551[_0xf7f7('0x32')]=_0x413551['attributes'][_0xf7f7('0x34')]?_0x413551[_0xf7f7('0x32')]:_0x1dbb06[_0xf7f7('0x2d')];if(_0x16fab7[_0xf7f7('0x2e')][_0xf7f7('0x3f')]){_0x413551['include']=[{'all':!![]}];}_0x413551=_[_0xf7f7('0x3b')]({},_0x413551,_0x16fab7[_0xf7f7('0x3d')]);return db[_0xf7f7('0x29')]['find'](_0x413551)[_0xf7f7('0x22')](handleEntityNotFound(_0x2f1554,null))['then'](respondWithResult(_0x2f1554,null))[_0xf7f7('0x43')](handleError(_0x2f1554,null));};exports['create']=function(_0x597e25,_0x34fe77){return db[_0xf7f7('0x29')][_0xf7f7('0x46')](_0x597e25[_0xf7f7('0x47')],{})['then'](respondWithResult(_0x34fe77,0xc9))[_0xf7f7('0x43')](handleError(_0x34fe77,null));};exports['update']=function(_0x7c84b,_0x5970df){if(_0x7c84b['body']['id']){delete _0x7c84b[_0xf7f7('0x47')]['id'];}return db[_0xf7f7('0x29')][_0xf7f7('0x48')]({'where':{'id':_0x7c84b[_0xf7f7('0x45')]['id']}})['then'](handleEntityNotFound(_0x5970df,null))[_0xf7f7('0x22')](saveUpdates(_0x7c84b[_0xf7f7('0x47')],null))[_0xf7f7('0x22')](respondWithResult(_0x5970df,null))[_0xf7f7('0x43')](handleError(_0x5970df,null));};exports[_0xf7f7('0x23')]=function(_0x31a402,_0x471298){return db[_0xf7f7('0x29')]['find']({'where':{'id':_0x31a402[_0xf7f7('0x45')]['id']}})['then'](handleEntityNotFound(_0x471298,null))[_0xf7f7('0x22')](removeEntity(_0x471298,null))[_0xf7f7('0x43')](handleError(_0x471298,null));};
\ No newline at end of file
+var _0x72b7=['options','includeAll','include','findAll','rows','catch','show','params','intersection','fields','create','body','find','destroy','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','json','save','update','then','error','stack','name','send','map','MailServerOut','rawAttributes','fieldName','key','model','query','keys','filters','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','type'];(function(_0x2aa840,_0x1deab0){var _0x19a98b=function(_0x8576f2){while(--_0x8576f2){_0x2aa840['push'](_0x2aa840['shift']());}};_0x19a98b(++_0x1deab0);}(_0x72b7,0xa6));var _0x772b=function(_0x432682,_0x253044){_0x432682=_0x432682-0x0;var _0x463d05=_0x72b7[_0x432682];return _0x463d05;};'use strict';var emlformat=require(_0x772b('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x772b('0x1'));var jsonpatch=require(_0x772b('0x2'));var rp=require(_0x772b('0x3'));var moment=require('moment');var BPromise=require(_0x772b('0x4'));var Mustache=require(_0x772b('0x5'));var util=require('util');var path=require(_0x772b('0x6'));var sox=require(_0x772b('0x7'));var csv=require(_0x772b('0x8'));var ejs=require(_0x772b('0x9'));var fs=require('fs');var fs_extra=require(_0x772b('0xa'));var _=require(_0x772b('0xb'));var squel=require('squel');var crypto=require(_0x772b('0xc'));var jsforce=require(_0x772b('0xd'));var deskjs=require(_0x772b('0xe'));var toCsv=require(_0x772b('0x8'));var querystring=require(_0x772b('0xf'));var Papa=require('papaparse');var Redis=require(_0x772b('0x10'));var authService=require(_0x772b('0x11'));var qs=require(_0x772b('0x12'));var as=require(_0x772b('0x13'));var hardwareService=require(_0x772b('0x14'));var logger=require(_0x772b('0x15'))(_0x772b('0x16'));var utils=require('../../config/utils');var config=require(_0x772b('0x17'));var licenseUtil=require(_0x772b('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0xdb1698,_0x4d3488){_0x4d3488=_0x4d3488||0xcc;return function(_0x58bf60){if(_0x58bf60){return _0xdb1698[_0x772b('0x19')](_0x4d3488);}return _0xdb1698[_0x772b('0x1a')](_0x4d3488)[_0x772b('0x1b')]();};}function respondWithResult(_0x3266c6,_0x218461){_0x218461=_0x218461||0xc8;return function(_0x784ff2){if(_0x784ff2){return _0x3266c6[_0x772b('0x1a')](_0x218461)['json'](_0x784ff2);}};}function respondWithFilteredResult(_0x17325d,_0x42175d){return function(_0x5130a7){if(_0x5130a7){var _0x2db261=typeof _0x42175d[_0x772b('0x1c')]===_0x772b('0x1d')&&typeof _0x42175d[_0x772b('0x1e')]===_0x772b('0x1d');var _0x4057ed=_0x5130a7['count'];var _0x125ea5=_0x2db261?0x0:_0x42175d[_0x772b('0x1c')];var _0x89901b=_0x2db261?_0x5130a7[_0x772b('0x1f')]:_0x42175d[_0x772b('0x1c')]+_0x42175d[_0x772b('0x1e')];var _0x2db5d6;if(_0x89901b>=_0x4057ed){_0x89901b=_0x4057ed;_0x2db5d6=0xc8;}else{_0x2db5d6=0xce;}_0x17325d[_0x772b('0x1a')](_0x2db5d6);return _0x17325d[_0x772b('0x20')](_0x772b('0x21'),_0x125ea5+'-'+_0x89901b+'/'+_0x4057ed)[_0x772b('0x22')](_0x5130a7);}return null;};}function patchUpdates(_0x2bd719){return function(_0x44a0d5){try{jsonpatch['apply'](_0x44a0d5,_0x2bd719,!![]);}catch(_0x22f55d){return BPromise['reject'](_0x22f55d);}return _0x44a0d5[_0x772b('0x23')]();};}function saveUpdates(_0x13e572,_0xfe235c){return function(_0xfd8e5f){if(_0xfd8e5f){return _0xfd8e5f[_0x772b('0x24')](_0x13e572)['then'](function(_0x3e99bf){return _0x3e99bf;});}return null;};}function removeEntity(_0x2ab4c0,_0x12cc07){return function(_0x563ff5){if(_0x563ff5){return _0x563ff5['destroy']()[_0x772b('0x25')](function(){_0x2ab4c0[_0x772b('0x1a')](0xcc)[_0x772b('0x1b')]();});}};}function handleEntityNotFound(_0x5c6762,_0x59bffe){return function(_0xf18429){if(!_0xf18429){_0x5c6762[_0x772b('0x19')](0x194);}return _0xf18429;};}function handleError(_0x34f9ba,_0x3df2a9){_0x3df2a9=_0x3df2a9||0x1f4;return function(_0x27a054){logger[_0x772b('0x26')](_0x27a054[_0x772b('0x27')]);if(_0x27a054[_0x772b('0x28')]){delete _0x27a054[_0x772b('0x28')];}_0x34f9ba['status'](_0x3df2a9)[_0x772b('0x29')](_0x27a054);};}exports['index']=function(_0x323ab5,_0x11e736){var _0x2cc355={},_0x1f45f6={},_0x4d6b32={'count':0x0,'rows':[]};var _0x14ad8c=_[_0x772b('0x2a')](db[_0x772b('0x2b')][_0x772b('0x2c')],function(_0x3ad5c2){return{'name':_0x3ad5c2[_0x772b('0x2d')],'type':_0x3ad5c2['type'][_0x772b('0x2e')]};});_0x1f45f6[_0x772b('0x2f')]=_[_0x772b('0x2a')](_0x14ad8c,_0x772b('0x28'));_0x1f45f6[_0x772b('0x30')]=_[_0x772b('0x31')](_0x323ab5[_0x772b('0x30')]);_0x1f45f6[_0x772b('0x32')]=_['intersection'](_0x1f45f6['model'],_0x1f45f6[_0x772b('0x30')]);_0x2cc355['attributes']=_['intersection'](_0x1f45f6[_0x772b('0x2f')],qs['fields'](_0x323ab5[_0x772b('0x30')]['fields']));_0x2cc355[_0x772b('0x33')]=_0x2cc355[_0x772b('0x33')][_0x772b('0x34')]?_0x2cc355[_0x772b('0x33')]:_0x1f45f6[_0x772b('0x2f')];if(!_0x323ab5[_0x772b('0x30')][_0x772b('0x35')](_0x772b('0x36'))){_0x2cc355[_0x772b('0x1e')]=qs[_0x772b('0x1e')](_0x323ab5[_0x772b('0x30')][_0x772b('0x1e')]);_0x2cc355[_0x772b('0x1c')]=qs[_0x772b('0x1c')](_0x323ab5['query']['offset']);}_0x2cc355[_0x772b('0x37')]=qs[_0x772b('0x38')](_0x323ab5[_0x772b('0x30')][_0x772b('0x38')]);_0x2cc355['where']=qs[_0x772b('0x32')](_[_0x772b('0x39')](_0x323ab5[_0x772b('0x30')],_0x1f45f6[_0x772b('0x32')]),_0x14ad8c);if(_0x323ab5[_0x772b('0x30')][_0x772b('0x3a')]){_0x2cc355[_0x772b('0x3b')]=_[_0x772b('0x3c')](_0x2cc355[_0x772b('0x3b')],{'$or':_['map'](_0x14ad8c,function(_0x54e733){if(_0x54e733[_0x772b('0x3d')]!=='VIRTUAL'){var _0x229a77={};_0x229a77[_0x54e733['name']]={'$like':'%'+_0x323ab5[_0x772b('0x30')][_0x772b('0x3a')]+'%'};return _0x229a77;}})});}_0x2cc355=_['merge']({},_0x2cc355,_0x323ab5[_0x772b('0x3e')]);var _0x467e78={'where':_0x2cc355[_0x772b('0x3b')]};return db[_0x772b('0x2b')][_0x772b('0x1f')](_0x467e78)[_0x772b('0x25')](function(_0xabcf9c){_0x4d6b32[_0x772b('0x1f')]=_0xabcf9c;if(_0x323ab5[_0x772b('0x30')][_0x772b('0x3f')]){_0x2cc355[_0x772b('0x40')]=[{'all':!![]}];}return db['MailServerOut'][_0x772b('0x41')](_0x2cc355);})[_0x772b('0x25')](function(_0x4bdfae){_0x4d6b32[_0x772b('0x42')]=_0x4bdfae;return _0x4d6b32;})['then'](respondWithFilteredResult(_0x11e736,_0x2cc355))[_0x772b('0x43')](handleError(_0x11e736,null));};exports[_0x772b('0x44')]=function(_0x492f6d,_0x1be109){var _0x12d29b={'raw':!![],'where':{'id':_0x492f6d[_0x772b('0x45')]['id']}},_0x286b70={};_0x286b70['model']=_[_0x772b('0x31')](db['MailServerOut']['rawAttributes']);_0x286b70[_0x772b('0x30')]=_[_0x772b('0x31')](_0x492f6d[_0x772b('0x30')]);_0x286b70[_0x772b('0x32')]=_[_0x772b('0x46')](_0x286b70[_0x772b('0x2f')],_0x286b70[_0x772b('0x30')]);_0x12d29b[_0x772b('0x33')]=_[_0x772b('0x46')](_0x286b70[_0x772b('0x2f')],qs[_0x772b('0x47')](_0x492f6d['query'][_0x772b('0x47')]));_0x12d29b[_0x772b('0x33')]=_0x12d29b[_0x772b('0x33')]['length']?_0x12d29b[_0x772b('0x33')]:_0x286b70[_0x772b('0x2f')];if(_0x492f6d['query']['includeAll']){_0x12d29b[_0x772b('0x40')]=[{'all':!![]}];}_0x12d29b=_[_0x772b('0x3c')]({},_0x12d29b,_0x492f6d[_0x772b('0x3e')]);return db[_0x772b('0x2b')]['find'](_0x12d29b)[_0x772b('0x25')](handleEntityNotFound(_0x1be109,null))['then'](respondWithResult(_0x1be109,null))[_0x772b('0x43')](handleError(_0x1be109,null));};exports['create']=function(_0x34e22e,_0x5afbc0){return db[_0x772b('0x2b')][_0x772b('0x48')](_0x34e22e['body'],{})[_0x772b('0x25')](respondWithResult(_0x5afbc0,0xc9))[_0x772b('0x43')](handleError(_0x5afbc0,null));};exports[_0x772b('0x24')]=function(_0x522f46,_0x383062){if(_0x522f46[_0x772b('0x49')]['id']){delete _0x522f46[_0x772b('0x49')]['id'];}return db[_0x772b('0x2b')][_0x772b('0x4a')]({'where':{'id':_0x522f46[_0x772b('0x45')]['id']}})['then'](handleEntityNotFound(_0x383062,null))['then'](saveUpdates(_0x522f46[_0x772b('0x49')],null))[_0x772b('0x25')](respondWithResult(_0x383062,null))['catch'](handleError(_0x383062,null));};exports[_0x772b('0x4b')]=function(_0x316692,_0x1a2ff4){return db[_0x772b('0x2b')]['find']({'where':{'id':_0x316692[_0x772b('0x45')]['id']}})['then'](handleEntityNotFound(_0x1a2ff4,null))[_0x772b('0x25')](removeEntity(_0x1a2ff4,null))[_0x772b('0x43')](handleError(_0x1a2ff4,null));};
\ No newline at end of file