Built motion from commit efa66e19.|2.6.22
[motion2.git] / server / api / mailServerOut / mailServerOut.controller.js
index b8e5616..a2c93a8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb011=['show','includeAll','find','create','body','params','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','util','path','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','limit','undefined','count','set','Content-Range','json','reject','save','then','destroy','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','keys','intersection','query','fields','attributes','length','hasOwnProperty','nolimit','sort','where','filters','pick','VIRTUAL','filter','merge','options','include','MailServerOut','catch'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xb011,0x9a));var _0x1b01=function(_0x2f1ef6,_0x343c1f){_0x2f1ef6=_0x2f1ef6-0x0;var _0x4ab777=_0xb011[_0x2f1ef6];return _0x4ab777;};'use strict';var emlformat=require(_0x1b01('0x0'));var rimraf=require(_0x1b01('0x1'));var zipdir=require(_0x1b01('0x2'));var jsonpatch=require(_0x1b01('0x3'));var rp=require(_0x1b01('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x1b01('0x5'));var util=require(_0x1b01('0x6'));var path=require(_0x1b01('0x7'));var sox=require('sox');var csv=require(_0x1b01('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x1b01('0x9'));var _=require(_0x1b01('0xa'));var squel=require(_0x1b01('0xb'));var crypto=require(_0x1b01('0xc'));var jsforce=require(_0x1b01('0xd'));var deskjs=require(_0x1b01('0xe'));var toCsv=require('to-csv');var querystring=require(_0x1b01('0xf'));var Papa=require(_0x1b01('0x10'));var Redis=require(_0x1b01('0x11'));var authService=require(_0x1b01('0x12'));var qs=require(_0x1b01('0x13'));var as=require(_0x1b01('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0x1b01('0x15'));var config=require(_0x1b01('0x16'));var licenseUtil=require(_0x1b01('0x17'));var db=require(_0x1b01('0x18'))['db'];function respondWithStatusCode(_0x45c375,_0x568d9b){_0x568d9b=_0x568d9b||0xcc;return function(_0x25cd34){if(_0x25cd34){return _0x45c375[_0x1b01('0x19')](_0x568d9b);}return _0x45c375[_0x1b01('0x1a')](_0x568d9b)[_0x1b01('0x1b')]();};}function respondWithResult(_0xbcf5b1,_0x1dfef7){_0x1dfef7=_0x1dfef7||0xc8;return function(_0x122f10){if(_0x122f10){return _0xbcf5b1[_0x1b01('0x1a')](_0x1dfef7)['json'](_0x122f10);}};}function respondWithFilteredResult(_0x46c9cd,_0x3d56db){return function(_0xe74e98){if(_0xe74e98){var _0xccd7fa=typeof _0x3d56db[_0x1b01('0x1c')]==='undefined'&&typeof _0x3d56db[_0x1b01('0x1d')]===_0x1b01('0x1e');var _0x3a31b0=_0xe74e98[_0x1b01('0x1f')];var _0xf6eb9c=_0xccd7fa?0x0:_0x3d56db['offset'];var _0x3409ae=_0xccd7fa?_0xe74e98[_0x1b01('0x1f')]:_0x3d56db[_0x1b01('0x1c')]+_0x3d56db[_0x1b01('0x1d')];var _0x495623;if(_0x3409ae>=_0x3a31b0){_0x3409ae=_0x3a31b0;_0x495623=0xc8;}else{_0x495623=0xce;}_0x46c9cd['status'](_0x495623);return _0x46c9cd[_0x1b01('0x20')](_0x1b01('0x21'),_0xf6eb9c+'-'+_0x3409ae+'/'+_0x3a31b0)[_0x1b01('0x22')](_0xe74e98);}return null;};}function patchUpdates(_0x2495d6){return function(_0x446b32){try{jsonpatch['apply'](_0x446b32,_0x2495d6,!![]);}catch(_0x4a6cbe){return BPromise[_0x1b01('0x23')](_0x4a6cbe);}return _0x446b32[_0x1b01('0x24')]();};}function saveUpdates(_0x350ddb,_0x5866bf){return function(_0x3974da){if(_0x3974da){return _0x3974da['update'](_0x350ddb)[_0x1b01('0x25')](function(_0x182b7f){return _0x182b7f;});}return null;};}function removeEntity(_0x49632b,_0x48e3a1){return function(_0x58586b){if(_0x58586b){return _0x58586b[_0x1b01('0x26')]()[_0x1b01('0x25')](function(){_0x49632b['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x23ed69,_0x3a7f84){return function(_0x529b63){if(!_0x529b63){_0x23ed69[_0x1b01('0x19')](0x194);}return _0x529b63;};}function handleError(_0x310b38,_0x2aa3ed){_0x2aa3ed=_0x2aa3ed||0x1f4;return function(_0x37cb0e){logger['error'](_0x37cb0e[_0x1b01('0x27')]);if(_0x37cb0e[_0x1b01('0x28')]){delete _0x37cb0e['name'];}_0x310b38['status'](_0x2aa3ed)[_0x1b01('0x29')](_0x37cb0e);};}exports[_0x1b01('0x2a')]=function(_0x4cc2bc,_0x49ad84){var _0x23aa18={},_0x1517ad={},_0xf527e8={'count':0x0,'rows':[]};var _0x7f249=_[_0x1b01('0x2b')](db['MailServerOut'][_0x1b01('0x2c')],function(_0x2d91fd){return{'name':_0x2d91fd[_0x1b01('0x2d')],'type':_0x2d91fd[_0x1b01('0x2e')][_0x1b01('0x2f')]};});_0x1517ad[_0x1b01('0x30')]=_[_0x1b01('0x2b')](_0x7f249,_0x1b01('0x28'));_0x1517ad['query']=_[_0x1b01('0x31')](_0x4cc2bc['query']);_0x1517ad['filters']=_[_0x1b01('0x32')](_0x1517ad[_0x1b01('0x30')],_0x1517ad[_0x1b01('0x33')]);_0x23aa18['attributes']=_[_0x1b01('0x32')](_0x1517ad[_0x1b01('0x30')],qs[_0x1b01('0x34')](_0x4cc2bc[_0x1b01('0x33')][_0x1b01('0x34')]));_0x23aa18[_0x1b01('0x35')]=_0x23aa18[_0x1b01('0x35')][_0x1b01('0x36')]?_0x23aa18[_0x1b01('0x35')]:_0x1517ad['model'];if(!_0x4cc2bc[_0x1b01('0x33')][_0x1b01('0x37')](_0x1b01('0x38'))){_0x23aa18[_0x1b01('0x1d')]=qs[_0x1b01('0x1d')](_0x4cc2bc[_0x1b01('0x33')][_0x1b01('0x1d')]);_0x23aa18[_0x1b01('0x1c')]=qs['offset'](_0x4cc2bc['query'][_0x1b01('0x1c')]);}_0x23aa18['order']=qs[_0x1b01('0x39')](_0x4cc2bc[_0x1b01('0x33')]['sort']);_0x23aa18[_0x1b01('0x3a')]=qs[_0x1b01('0x3b')](_[_0x1b01('0x3c')](_0x4cc2bc['query'],_0x1517ad[_0x1b01('0x3b')]),_0x7f249);if(_0x4cc2bc[_0x1b01('0x33')]['filter']){_0x23aa18[_0x1b01('0x3a')]=_['merge'](_0x23aa18['where'],{'$or':_[_0x1b01('0x2b')](_0x7f249,function(_0x38ab8e){if(_0x38ab8e[_0x1b01('0x2e')]!==_0x1b01('0x3d')){var _0x26f19a={};_0x26f19a[_0x38ab8e[_0x1b01('0x28')]]={'$like':'%'+_0x4cc2bc[_0x1b01('0x33')][_0x1b01('0x3e')]+'%'};return _0x26f19a;}})});}_0x23aa18=_[_0x1b01('0x3f')]({},_0x23aa18,_0x4cc2bc[_0x1b01('0x40')]);var _0x23315b={'where':_0x23aa18[_0x1b01('0x3a')]};return db['MailServerOut'][_0x1b01('0x1f')](_0x23315b)[_0x1b01('0x25')](function(_0x129a16){_0xf527e8[_0x1b01('0x1f')]=_0x129a16;if(_0x4cc2bc['query']['includeAll']){_0x23aa18[_0x1b01('0x41')]=[{'all':!![]}];}return db[_0x1b01('0x42')]['findAll'](_0x23aa18);})[_0x1b01('0x25')](function(_0x43d877){_0xf527e8['rows']=_0x43d877;return _0xf527e8;})[_0x1b01('0x25')](respondWithFilteredResult(_0x49ad84,_0x23aa18))[_0x1b01('0x43')](handleError(_0x49ad84,null));};exports[_0x1b01('0x44')]=function(_0x3b4ee5,_0x38996b){var _0x34063f={'raw':!![],'where':{'id':_0x3b4ee5['params']['id']}},_0x5952b3={};_0x5952b3[_0x1b01('0x30')]=_[_0x1b01('0x31')](db['MailServerOut'][_0x1b01('0x2c')]);_0x5952b3['query']=_[_0x1b01('0x31')](_0x3b4ee5[_0x1b01('0x33')]);_0x5952b3[_0x1b01('0x3b')]=_['intersection'](_0x5952b3[_0x1b01('0x30')],_0x5952b3[_0x1b01('0x33')]);_0x34063f[_0x1b01('0x35')]=_[_0x1b01('0x32')](_0x5952b3[_0x1b01('0x30')],qs['fields'](_0x3b4ee5[_0x1b01('0x33')][_0x1b01('0x34')]));_0x34063f[_0x1b01('0x35')]=_0x34063f['attributes']['length']?_0x34063f[_0x1b01('0x35')]:_0x5952b3['model'];if(_0x3b4ee5[_0x1b01('0x33')][_0x1b01('0x45')]){_0x34063f[_0x1b01('0x41')]=[{'all':!![]}];}_0x34063f=_[_0x1b01('0x3f')]({},_0x34063f,_0x3b4ee5['options']);return db[_0x1b01('0x42')][_0x1b01('0x46')](_0x34063f)[_0x1b01('0x25')](handleEntityNotFound(_0x38996b,null))[_0x1b01('0x25')](respondWithResult(_0x38996b,null))['catch'](handleError(_0x38996b,null));};exports[_0x1b01('0x47')]=function(_0x101ca8,_0x33c9cd){return db[_0x1b01('0x42')][_0x1b01('0x47')](_0x101ca8[_0x1b01('0x48')],{})[_0x1b01('0x25')](respondWithResult(_0x33c9cd,0xc9))[_0x1b01('0x43')](handleError(_0x33c9cd,null));};exports['update']=function(_0x4d59d5,_0x22c77c){if(_0x4d59d5[_0x1b01('0x48')]['id']){delete _0x4d59d5[_0x1b01('0x48')]['id'];}return db[_0x1b01('0x42')][_0x1b01('0x46')]({'where':{'id':_0x4d59d5[_0x1b01('0x49')]['id']}})[_0x1b01('0x25')](handleEntityNotFound(_0x22c77c,null))[_0x1b01('0x25')](saveUpdates(_0x4d59d5[_0x1b01('0x48')],null))[_0x1b01('0x25')](respondWithResult(_0x22c77c,null))[_0x1b01('0x43')](handleError(_0x22c77c,null));};exports['destroy']=function(_0x215544,_0x2ef649){return db[_0x1b01('0x42')][_0x1b01('0x46')]({'where':{'id':_0x215544['params']['id']}})[_0x1b01('0x25')](handleEntityNotFound(_0x2ef649,null))[_0x1b01('0x25')](removeEntity(_0x2ef649,null))['catch'](handleError(_0x2ef649,null));};
\ No newline at end of file
+var _0x49f9=['VIRTUAL','options','includeAll','include','then','rows','catch','show','params','create','body','find','eml-format','rimraf','zip-dir','moment','bluebird','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/environment','../../mysqldb','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply','update','destroy','end','error','stack','name','index','map','MailServerOut','rawAttributes','type','key','model','keys','query','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filters','filter','merge'];(function(_0x53bea,_0x197d23){var _0x1d7a94=function(_0x1ca209){while(--_0x1ca209){_0x53bea['push'](_0x53bea['shift']());}};_0x1d7a94(++_0x197d23);}(_0x49f9,0x174));var _0x949f=function(_0x374954,_0x18dc36){_0x374954=_0x374954-0x0;var _0x42073e=_0x49f9[_0x374954];return _0x42073e;};'use strict';var emlformat=require(_0x949f('0x0'));var rimraf=require(_0x949f('0x1'));var zipdir=require(_0x949f('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x949f('0x3'));var BPromise=require(_0x949f('0x4'));var Mustache=require('mustache');var util=require(_0x949f('0x5'));var path=require(_0x949f('0x6'));var sox=require(_0x949f('0x7'));var csv=require(_0x949f('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x949f('0x9'));var _=require(_0x949f('0xa'));var squel=require(_0x949f('0xb'));var crypto=require(_0x949f('0xc'));var jsforce=require(_0x949f('0xd'));var deskjs=require(_0x949f('0xe'));var toCsv=require(_0x949f('0x8'));var querystring=require(_0x949f('0xf'));var Papa=require(_0x949f('0x10'));var Redis=require(_0x949f('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x949f('0x12'));var as=require(_0x949f('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x949f('0x14'));var utils=require('../../config/utils');var config=require(_0x949f('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0x949f('0x16'))['db'];function respondWithStatusCode(_0x215bd6,_0x298407){_0x298407=_0x298407||0xcc;return function(_0x5ae9a9){if(_0x5ae9a9){return _0x215bd6[_0x949f('0x17')](_0x298407);}return _0x215bd6[_0x949f('0x18')](_0x298407)['end']();};}function respondWithResult(_0x25f6f1,_0x4b70f8){_0x4b70f8=_0x4b70f8||0xc8;return function(_0x3aa427){if(_0x3aa427){return _0x25f6f1[_0x949f('0x18')](_0x4b70f8)[_0x949f('0x19')](_0x3aa427);}};}function respondWithFilteredResult(_0x3981ce,_0x103a43){return function(_0x2611c9){if(_0x2611c9){var _0x1fed6d=typeof _0x103a43[_0x949f('0x1a')]===_0x949f('0x1b')&&typeof _0x103a43[_0x949f('0x1c')]===_0x949f('0x1b');var _0x52076b=_0x2611c9[_0x949f('0x1d')];var _0x4995f1=_0x1fed6d?0x0:_0x103a43[_0x949f('0x1a')];var _0x231383=_0x1fed6d?_0x2611c9[_0x949f('0x1d')]:_0x103a43[_0x949f('0x1a')]+_0x103a43[_0x949f('0x1c')];var _0x342802;if(_0x231383>=_0x52076b){_0x231383=_0x52076b;_0x342802=0xc8;}else{_0x342802=0xce;}_0x3981ce['status'](_0x342802);return _0x3981ce[_0x949f('0x1e')](_0x949f('0x1f'),_0x4995f1+'-'+_0x231383+'/'+_0x52076b)[_0x949f('0x19')](_0x2611c9);}return null;};}function patchUpdates(_0x436766){return function(_0x2fa14b){try{jsonpatch[_0x949f('0x20')](_0x2fa14b,_0x436766,!![]);}catch(_0x5f432f){return BPromise['reject'](_0x5f432f);}return _0x2fa14b['save']();};}function saveUpdates(_0x552388,_0xcdfbb){return function(_0x25a4f1){if(_0x25a4f1){return _0x25a4f1[_0x949f('0x21')](_0x552388)['then'](function(_0x331bb8){return _0x331bb8;});}return null;};}function removeEntity(_0x60f5a8,_0x1d2414){return function(_0x328080){if(_0x328080){return _0x328080[_0x949f('0x22')]()['then'](function(){_0x60f5a8[_0x949f('0x18')](0xcc)[_0x949f('0x23')]();});}};}function handleEntityNotFound(_0x5512bb,_0x4c30fc){return function(_0x391455){if(!_0x391455){_0x5512bb[_0x949f('0x17')](0x194);}return _0x391455;};}function handleError(_0x2b8009,_0x5167b6){_0x5167b6=_0x5167b6||0x1f4;return function(_0x584321){logger[_0x949f('0x24')](_0x584321[_0x949f('0x25')]);if(_0x584321['name']){delete _0x584321[_0x949f('0x26')];}_0x2b8009['status'](_0x5167b6)['send'](_0x584321);};}exports[_0x949f('0x27')]=function(_0x1e5df0,_0x333e56){var _0x26e64d={},_0x3073ef={},_0x35ba99={'count':0x0,'rows':[]};var _0x21f8ff=_[_0x949f('0x28')](db[_0x949f('0x29')][_0x949f('0x2a')],function(_0x3d3a8a){return{'name':_0x3d3a8a['fieldName'],'type':_0x3d3a8a[_0x949f('0x2b')][_0x949f('0x2c')]};});_0x3073ef[_0x949f('0x2d')]=_[_0x949f('0x28')](_0x21f8ff,_0x949f('0x26'));_0x3073ef['query']=_[_0x949f('0x2e')](_0x1e5df0[_0x949f('0x2f')]);_0x3073ef['filters']=_[_0x949f('0x30')](_0x3073ef[_0x949f('0x2d')],_0x3073ef[_0x949f('0x2f')]);_0x26e64d[_0x949f('0x31')]=_[_0x949f('0x30')](_0x3073ef[_0x949f('0x2d')],qs[_0x949f('0x32')](_0x1e5df0[_0x949f('0x2f')][_0x949f('0x32')]));_0x26e64d[_0x949f('0x31')]=_0x26e64d[_0x949f('0x31')][_0x949f('0x33')]?_0x26e64d[_0x949f('0x31')]:_0x3073ef[_0x949f('0x2d')];if(!_0x1e5df0[_0x949f('0x2f')]['hasOwnProperty'](_0x949f('0x34'))){_0x26e64d['limit']=qs[_0x949f('0x1c')](_0x1e5df0[_0x949f('0x2f')][_0x949f('0x1c')]);_0x26e64d[_0x949f('0x1a')]=qs[_0x949f('0x1a')](_0x1e5df0[_0x949f('0x2f')][_0x949f('0x1a')]);}_0x26e64d[_0x949f('0x35')]=qs[_0x949f('0x36')](_0x1e5df0[_0x949f('0x2f')][_0x949f('0x36')]);_0x26e64d[_0x949f('0x37')]=qs['filters'](_[_0x949f('0x38')](_0x1e5df0[_0x949f('0x2f')],_0x3073ef[_0x949f('0x39')]),_0x21f8ff);if(_0x1e5df0[_0x949f('0x2f')][_0x949f('0x3a')]){_0x26e64d['where']=_[_0x949f('0x3b')](_0x26e64d['where'],{'$or':_['map'](_0x21f8ff,function(_0x3b32bb){if(_0x3b32bb[_0x949f('0x2b')]!==_0x949f('0x3c')){var _0x4f9426={};_0x4f9426[_0x3b32bb[_0x949f('0x26')]]={'$like':'%'+_0x1e5df0[_0x949f('0x2f')][_0x949f('0x3a')]+'%'};return _0x4f9426;}})});}_0x26e64d=_[_0x949f('0x3b')]({},_0x26e64d,_0x1e5df0[_0x949f('0x3d')]);var _0x30f8c1={'where':_0x26e64d['where']};return db['MailServerOut']['count'](_0x30f8c1)['then'](function(_0x4180c3){_0x35ba99[_0x949f('0x1d')]=_0x4180c3;if(_0x1e5df0[_0x949f('0x2f')][_0x949f('0x3e')]){_0x26e64d[_0x949f('0x3f')]=[{'all':!![]}];}return db['MailServerOut']['findAll'](_0x26e64d);})[_0x949f('0x40')](function(_0x4cb6b7){_0x35ba99[_0x949f('0x41')]=_0x4cb6b7;return _0x35ba99;})[_0x949f('0x40')](respondWithFilteredResult(_0x333e56,_0x26e64d))[_0x949f('0x42')](handleError(_0x333e56,null));};exports[_0x949f('0x43')]=function(_0x9f8ae5,_0x220e40){var _0x2db851={'raw':!![],'where':{'id':_0x9f8ae5[_0x949f('0x44')]['id']}},_0x1a2f38={};_0x1a2f38[_0x949f('0x2d')]=_[_0x949f('0x2e')](db['MailServerOut'][_0x949f('0x2a')]);_0x1a2f38['query']=_[_0x949f('0x2e')](_0x9f8ae5[_0x949f('0x2f')]);_0x1a2f38['filters']=_['intersection'](_0x1a2f38['model'],_0x1a2f38[_0x949f('0x2f')]);_0x2db851[_0x949f('0x31')]=_['intersection'](_0x1a2f38[_0x949f('0x2d')],qs[_0x949f('0x32')](_0x9f8ae5[_0x949f('0x2f')][_0x949f('0x32')]));_0x2db851[_0x949f('0x31')]=_0x2db851[_0x949f('0x31')][_0x949f('0x33')]?_0x2db851['attributes']:_0x1a2f38[_0x949f('0x2d')];if(_0x9f8ae5['query']['includeAll']){_0x2db851[_0x949f('0x3f')]=[{'all':!![]}];}_0x2db851=_['merge']({},_0x2db851,_0x9f8ae5['options']);return db['MailServerOut']['find'](_0x2db851)[_0x949f('0x40')](handleEntityNotFound(_0x220e40,null))[_0x949f('0x40')](respondWithResult(_0x220e40,null))[_0x949f('0x42')](handleError(_0x220e40,null));};exports['create']=function(_0x41bbc3,_0x3f1e82){return db['MailServerOut'][_0x949f('0x45')](_0x41bbc3[_0x949f('0x46')],{})['then'](respondWithResult(_0x3f1e82,0xc9))[_0x949f('0x42')](handleError(_0x3f1e82,null));};exports['update']=function(_0x5db8a1,_0x2da0d0){if(_0x5db8a1['body']['id']){delete _0x5db8a1[_0x949f('0x46')]['id'];}return db[_0x949f('0x29')][_0x949f('0x47')]({'where':{'id':_0x5db8a1[_0x949f('0x44')]['id']}})['then'](handleEntityNotFound(_0x2da0d0,null))[_0x949f('0x40')](saveUpdates(_0x5db8a1[_0x949f('0x46')],null))[_0x949f('0x40')](respondWithResult(_0x2da0d0,null))['catch'](handleError(_0x2da0d0,null));};exports[_0x949f('0x22')]=function(_0x489032,_0x2c59db){return db['MailServerOut'][_0x949f('0x47')]({'where':{'id':_0x489032[_0x949f('0x44')]['id']}})[_0x949f('0x40')](handleEntityNotFound(_0x2c59db,null))[_0x949f('0x40')](removeEntity(_0x2c59db,null))[_0x949f('0x42')](handleError(_0x2c59db,null));};
\ No newline at end of file