Built motion from commit b5996064.|2.6.21
[motion2.git] / server / api / smsApplication / smsApplication.controller.js
index 3d8524a..9b19eae 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2b22=['send','index','SmsApplication','rawAttributes','type','query','keys','intersection','model','fields','attributes','length','hasOwnProperty','limit','order','sort','where','pick','filter','map','VIRTUAL','merge','options','include','findAll','rows','catch','show','params','filters','includeAll','create','body','find','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','mustache','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/license/util','sendStatus','status','end','json','count','offset','Content-Range','reject','save','update','then','destroy','name'];(function(_0x3e81ad,_0x52018e){var _0x504310=function(_0x34bc68){while(--_0x34bc68){_0x3e81ad['push'](_0x3e81ad['shift']());}};_0x504310(++_0x52018e);}(_0x2b22,0xf4));var _0x22b2=function(_0x376150,_0x2f27bd){_0x376150=_0x376150-0x0;var _0x520401=_0x2b22[_0x376150];return _0x520401;};'use strict';var pdf=require(_0x22b2('0x0'));var emlformat=require(_0x22b2('0x1'));var rimraf=require(_0x22b2('0x2'));var zipdir=require(_0x22b2('0x3'));var jsonpatch=require(_0x22b2('0x4'));var rp=require('request-promise');var moment=require(_0x22b2('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x22b2('0x6'));var util=require('util');var path=require(_0x22b2('0x7'));var sox=require(_0x22b2('0x8'));var csv=require(_0x22b2('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x22b2('0xa'));var squel=require(_0x22b2('0xb'));var crypto=require(_0x22b2('0xc'));var jsforce=require(_0x22b2('0xd'));var deskjs=require(_0x22b2('0xe'));var toCsv=require(_0x22b2('0x9'));var querystring=require(_0x22b2('0xf'));var Papa=require(_0x22b2('0x10'));var Redis=require(_0x22b2('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x22b2('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x22b2('0x13'))(_0x22b2('0x14'));var utils=require(_0x22b2('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x22b2('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1ed509,_0x8a90cf){_0x8a90cf=_0x8a90cf||0xcc;return function(_0x50053d){if(_0x50053d){return _0x1ed509[_0x22b2('0x17')](_0x8a90cf);}return _0x1ed509[_0x22b2('0x18')](_0x8a90cf)[_0x22b2('0x19')]();};}function respondWithResult(_0x33ef6d,_0x32988a){_0x32988a=_0x32988a||0xc8;return function(_0x3adbc5){if(_0x3adbc5){return _0x33ef6d['status'](_0x32988a)[_0x22b2('0x1a')](_0x3adbc5);}};}function respondWithFilteredResult(_0x44a5bc,_0x28dcb5){return function(_0x11da6d){if(_0x11da6d){var _0xeda152=_0x11da6d[_0x22b2('0x1b')],_0xe1048e=_0x28dcb5[_0x22b2('0x1c')],_0x4dc4e1=_0x28dcb5[_0x22b2('0x1c')]+_0x28dcb5['limit'],_0x2418e6;if(_0x4dc4e1>=_0xeda152){_0x4dc4e1=_0xeda152;_0x2418e6=0xc8;}else{_0x2418e6=0xce;}_0x44a5bc['status'](_0x2418e6);return _0x44a5bc['set'](_0x22b2('0x1d'),_0xe1048e+'-'+_0x4dc4e1+'/'+_0xeda152)['json'](_0x11da6d);}return null;};}function patchUpdates(_0x2ab955){return function(_0x87f69b){try{jsonpatch['apply'](_0x87f69b,_0x2ab955,!![]);}catch(_0x170344){return BPromise[_0x22b2('0x1e')](_0x170344);}return _0x87f69b[_0x22b2('0x1f')]();};}function saveUpdates(_0x57d092,_0x16948c){return function(_0x20442d){if(_0x20442d){return _0x20442d[_0x22b2('0x20')](_0x57d092)[_0x22b2('0x21')](function(_0x2b0c39){return _0x2b0c39;});}return null;};}function removeEntity(_0x7792da,_0x54beed){return function(_0x1ed45b){if(_0x1ed45b){return _0x1ed45b[_0x22b2('0x22')]()[_0x22b2('0x21')](function(){_0x7792da[_0x22b2('0x18')](0xcc)[_0x22b2('0x19')]();});}};}function handleEntityNotFound(_0x5e34ac,_0x353e5f){return function(_0x831a52){if(!_0x831a52){_0x5e34ac[_0x22b2('0x17')](0x194);}return _0x831a52;};}function handleError(_0x11ff04,_0x39ebe9){_0x39ebe9=_0x39ebe9||0x1f4;return function(_0x102304){logger['error'](_0x102304['stack']);if(_0x102304[_0x22b2('0x23')]){delete _0x102304['name'];}_0x11ff04[_0x22b2('0x18')](_0x39ebe9)[_0x22b2('0x24')](_0x102304);};}exports[_0x22b2('0x25')]=function(_0x3466f5,_0x5ce76f){var _0x3956e8={},_0xcf97a7={},_0x39cb4={'count':0x0,'rows':[]};var _0x686a8f=_['map'](db[_0x22b2('0x26')][_0x22b2('0x27')],function(_0x13af98){return{'name':_0x13af98['fieldName'],'type':_0x13af98[_0x22b2('0x28')]['key']};});_0xcf97a7['model']=_['map'](_0x686a8f,_0x22b2('0x23'));_0xcf97a7[_0x22b2('0x29')]=_[_0x22b2('0x2a')](_0x3466f5[_0x22b2('0x29')]);_0xcf97a7['filters']=_[_0x22b2('0x2b')](_0xcf97a7[_0x22b2('0x2c')],_0xcf97a7['query']);_0x3956e8['attributes']=_[_0x22b2('0x2b')](_0xcf97a7[_0x22b2('0x2c')],qs[_0x22b2('0x2d')](_0x3466f5[_0x22b2('0x29')][_0x22b2('0x2d')]));_0x3956e8[_0x22b2('0x2e')]=_0x3956e8[_0x22b2('0x2e')][_0x22b2('0x2f')]?_0x3956e8['attributes']:_0xcf97a7['model'];if(!_0x3466f5[_0x22b2('0x29')][_0x22b2('0x30')]('nolimit')){_0x3956e8['limit']=qs[_0x22b2('0x31')](_0x3466f5[_0x22b2('0x29')]['limit']);_0x3956e8[_0x22b2('0x1c')]=qs[_0x22b2('0x1c')](_0x3466f5[_0x22b2('0x29')]['offset']);}_0x3956e8[_0x22b2('0x32')]=qs[_0x22b2('0x33')](_0x3466f5[_0x22b2('0x29')][_0x22b2('0x33')]);_0x3956e8[_0x22b2('0x34')]=qs['filters'](_[_0x22b2('0x35')](_0x3466f5[_0x22b2('0x29')],_0xcf97a7['filters']),_0x686a8f);if(_0x3466f5[_0x22b2('0x29')][_0x22b2('0x36')]){_0x3956e8[_0x22b2('0x34')]=_['merge'](_0x3956e8[_0x22b2('0x34')],{'$or':_[_0x22b2('0x37')](_0x686a8f,function(_0x395684){if(_0x395684['type']!==_0x22b2('0x38')){var _0x5ec979={};_0x5ec979[_0x395684['name']]={'$like':'%'+_0x3466f5['query'][_0x22b2('0x36')]+'%'};return _0x5ec979;}})});}_0x3956e8=_[_0x22b2('0x39')]({},_0x3956e8,_0x3466f5[_0x22b2('0x3a')]);var _0x492593={'where':_0x3956e8[_0x22b2('0x34')]};return db[_0x22b2('0x26')][_0x22b2('0x1b')](_0x492593)['then'](function(_0x13d11b){_0x39cb4[_0x22b2('0x1b')]=_0x13d11b;if(_0x3466f5[_0x22b2('0x29')]['includeAll']){_0x3956e8[_0x22b2('0x3b')]=[{'all':!![]}];}return db[_0x22b2('0x26')][_0x22b2('0x3c')](_0x3956e8);})[_0x22b2('0x21')](function(_0x40cc78){_0x39cb4[_0x22b2('0x3d')]=_0x40cc78;return _0x39cb4;})[_0x22b2('0x21')](respondWithFilteredResult(_0x5ce76f,_0x3956e8))[_0x22b2('0x3e')](handleError(_0x5ce76f,null));};exports[_0x22b2('0x3f')]=function(_0x3f422f,_0x594760){var _0x48b94e={'raw':!![],'where':{'id':_0x3f422f[_0x22b2('0x40')]['id']}},_0xc263ca={};_0xc263ca[_0x22b2('0x2c')]=_[_0x22b2('0x2a')](db['SmsApplication'][_0x22b2('0x27')]);_0xc263ca[_0x22b2('0x29')]=_[_0x22b2('0x2a')](_0x3f422f[_0x22b2('0x29')]);_0xc263ca[_0x22b2('0x41')]=_[_0x22b2('0x2b')](_0xc263ca[_0x22b2('0x2c')],_0xc263ca['query']);_0x48b94e['attributes']=_[_0x22b2('0x2b')](_0xc263ca['model'],qs[_0x22b2('0x2d')](_0x3f422f[_0x22b2('0x29')][_0x22b2('0x2d')]));_0x48b94e[_0x22b2('0x2e')]=_0x48b94e[_0x22b2('0x2e')][_0x22b2('0x2f')]?_0x48b94e[_0x22b2('0x2e')]:_0xc263ca[_0x22b2('0x2c')];if(_0x3f422f['query'][_0x22b2('0x42')]){_0x48b94e[_0x22b2('0x3b')]=[{'all':!![]}];}_0x48b94e=_[_0x22b2('0x39')]({},_0x48b94e,_0x3f422f[_0x22b2('0x3a')]);return db[_0x22b2('0x26')]['find'](_0x48b94e)[_0x22b2('0x21')](handleEntityNotFound(_0x594760,null))['then'](respondWithResult(_0x594760,null))[_0x22b2('0x3e')](handleError(_0x594760,null));};exports[_0x22b2('0x43')]=function(_0x1e43ff,_0x21eabd){return db[_0x22b2('0x26')]['create'](_0x1e43ff[_0x22b2('0x44')],{})[_0x22b2('0x21')](respondWithResult(_0x21eabd,0xc9))[_0x22b2('0x3e')](handleError(_0x21eabd,null));};exports[_0x22b2('0x20')]=function(_0x3b829e,_0x54bf73){if(_0x3b829e[_0x22b2('0x44')]['id']){delete _0x3b829e[_0x22b2('0x44')]['id'];}return db['SmsApplication'][_0x22b2('0x45')]({'where':{'id':_0x3b829e['params']['id']}})['then'](handleEntityNotFound(_0x54bf73,null))[_0x22b2('0x21')](saveUpdates(_0x3b829e[_0x22b2('0x44')],null))[_0x22b2('0x21')](respondWithResult(_0x54bf73,null))[_0x22b2('0x3e')](handleError(_0x54bf73,null));};exports[_0x22b2('0x22')]=function(_0x284eb3,_0x2907bd){return db[_0x22b2('0x26')]['find']({'where':{'id':_0x284eb3['params']['id']}})[_0x22b2('0x21')](handleEntityNotFound(_0x2907bd,null))[_0x22b2('0x21')](removeEntity(_0x2907bd,null))[_0x22b2('0x3e')](handleError(_0x2907bd,null));};
\ No newline at end of file
+var _0x8f38=['rimraf','zip-dir','request-promise','moment','mustache','util','path','lodash','squel','crypto','jsforce','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','update','destroy','then','stack','name','index','map','SmsApplication','rawAttributes','type','key','model','query','keys','intersection','attributes','fields','hasOwnProperty','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','include','rows','show','params','length','catch','create','body','find'];(function(_0x451d2a,_0x56d5bd){var _0x1f0b2e=function(_0x57b334){while(--_0x57b334){_0x451d2a['push'](_0x451d2a['shift']());}};_0x1f0b2e(++_0x56d5bd);}(_0x8f38,0x1aa));var _0x88f3=function(_0x7185f7,_0x37065){_0x7185f7=_0x7185f7-0x0;var _0x182e45=_0x8f38[_0x7185f7];return _0x182e45;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x88f3('0x0'));var zipdir=require(_0x88f3('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x88f3('0x2'));var moment=require(_0x88f3('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x88f3('0x4'));var util=require(_0x88f3('0x5'));var path=require(_0x88f3('0x6'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x88f3('0x7'));var squel=require(_0x88f3('0x8'));var crypto=require(_0x88f3('0x9'));var jsforce=require(_0x88f3('0xa'));var deskjs=require('desk.js');var toCsv=require(_0x88f3('0xb'));var querystring=require(_0x88f3('0xc'));var Papa=require(_0x88f3('0xd'));var Redis=require(_0x88f3('0xe'));var authService=require(_0x88f3('0xf'));var qs=require(_0x88f3('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x88f3('0x11'));var logger=require('../../config/logger')(_0x88f3('0x12'));var utils=require(_0x88f3('0x13'));var config=require(_0x88f3('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0x88f3('0x15'))['db'];function respondWithStatusCode(_0x31afa8,_0xf42341){_0xf42341=_0xf42341||0xcc;return function(_0x28a9cd){if(_0x28a9cd){return _0x31afa8[_0x88f3('0x16')](_0xf42341);}return _0x31afa8[_0x88f3('0x17')](_0xf42341)[_0x88f3('0x18')]();};}function respondWithResult(_0x33c811,_0x1f1ce3){_0x1f1ce3=_0x1f1ce3||0xc8;return function(_0x1cee28){if(_0x1cee28){return _0x33c811[_0x88f3('0x17')](_0x1f1ce3)[_0x88f3('0x19')](_0x1cee28);}};}function respondWithFilteredResult(_0xe8b931,_0x1e912d){return function(_0x4107df){if(_0x4107df){var _0x42809e=typeof _0x1e912d[_0x88f3('0x1a')]==='undefined'&&typeof _0x1e912d['limit']===_0x88f3('0x1b');var _0x451778=_0x4107df[_0x88f3('0x1c')];var _0x41aaff=_0x42809e?0x0:_0x1e912d[_0x88f3('0x1a')];var _0x55500a=_0x42809e?_0x4107df[_0x88f3('0x1c')]:_0x1e912d[_0x88f3('0x1a')]+_0x1e912d[_0x88f3('0x1d')];var _0x331218;if(_0x55500a>=_0x451778){_0x55500a=_0x451778;_0x331218=0xc8;}else{_0x331218=0xce;}_0xe8b931['status'](_0x331218);return _0xe8b931[_0x88f3('0x1e')](_0x88f3('0x1f'),_0x41aaff+'-'+_0x55500a+'/'+_0x451778)[_0x88f3('0x19')](_0x4107df);}return null;};}function patchUpdates(_0x49ff92){return function(_0x47c4d4){try{jsonpatch[_0x88f3('0x20')](_0x47c4d4,_0x49ff92,!![]);}catch(_0x27620a){return BPromise[_0x88f3('0x21')](_0x27620a);}return _0x47c4d4['save']();};}function saveUpdates(_0x35f1c8,_0x3c859a){return function(_0x4b5dc9){if(_0x4b5dc9){return _0x4b5dc9[_0x88f3('0x22')](_0x35f1c8)['then'](function(_0x59c34d){return _0x59c34d;});}return null;};}function removeEntity(_0x1015d9,_0x34d966){return function(_0x458fd2){if(_0x458fd2){return _0x458fd2[_0x88f3('0x23')]()[_0x88f3('0x24')](function(){_0x1015d9[_0x88f3('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x147704,_0x115489){return function(_0x4bd98a){if(!_0x4bd98a){_0x147704['sendStatus'](0x194);}return _0x4bd98a;};}function handleError(_0x38b5e9,_0x23a1c3){_0x23a1c3=_0x23a1c3||0x1f4;return function(_0x421454){logger['error'](_0x421454[_0x88f3('0x25')]);if(_0x421454[_0x88f3('0x26')]){delete _0x421454['name'];}_0x38b5e9['status'](_0x23a1c3)['send'](_0x421454);};}exports[_0x88f3('0x27')]=function(_0x55d00a,_0x4776da){var _0x5ab6fd={},_0x57da3e={},_0x1e46f6={'count':0x0,'rows':[]};var _0x1029ae=_[_0x88f3('0x28')](db[_0x88f3('0x29')][_0x88f3('0x2a')],function(_0x4164e3){return{'name':_0x4164e3['fieldName'],'type':_0x4164e3[_0x88f3('0x2b')][_0x88f3('0x2c')]};});_0x57da3e[_0x88f3('0x2d')]=_[_0x88f3('0x28')](_0x1029ae,_0x88f3('0x26'));_0x57da3e[_0x88f3('0x2e')]=_[_0x88f3('0x2f')](_0x55d00a[_0x88f3('0x2e')]);_0x57da3e['filters']=_[_0x88f3('0x30')](_0x57da3e[_0x88f3('0x2d')],_0x57da3e[_0x88f3('0x2e')]);_0x5ab6fd[_0x88f3('0x31')]=_[_0x88f3('0x30')](_0x57da3e[_0x88f3('0x2d')],qs[_0x88f3('0x32')](_0x55d00a[_0x88f3('0x2e')]['fields']));_0x5ab6fd[_0x88f3('0x31')]=_0x5ab6fd['attributes']['length']?_0x5ab6fd[_0x88f3('0x31')]:_0x57da3e[_0x88f3('0x2d')];if(!_0x55d00a[_0x88f3('0x2e')][_0x88f3('0x33')]('nolimit')){_0x5ab6fd[_0x88f3('0x1d')]=qs[_0x88f3('0x1d')](_0x55d00a[_0x88f3('0x2e')]['limit']);_0x5ab6fd[_0x88f3('0x1a')]=qs[_0x88f3('0x1a')](_0x55d00a['query'][_0x88f3('0x1a')]);}_0x5ab6fd[_0x88f3('0x34')]=qs[_0x88f3('0x35')](_0x55d00a['query']['sort']);_0x5ab6fd[_0x88f3('0x36')]=qs[_0x88f3('0x37')](_[_0x88f3('0x38')](_0x55d00a['query'],_0x57da3e[_0x88f3('0x37')]),_0x1029ae);if(_0x55d00a[_0x88f3('0x2e')][_0x88f3('0x39')]){_0x5ab6fd[_0x88f3('0x36')]=_[_0x88f3('0x3a')](_0x5ab6fd[_0x88f3('0x36')],{'$or':_[_0x88f3('0x28')](_0x1029ae,function(_0x5a3036){if(_0x5a3036[_0x88f3('0x2b')]!==_0x88f3('0x3b')){var _0x54c69b={};_0x54c69b[_0x5a3036[_0x88f3('0x26')]]={'$like':'%'+_0x55d00a[_0x88f3('0x2e')][_0x88f3('0x39')]+'%'};return _0x54c69b;}})});}_0x5ab6fd=_[_0x88f3('0x3a')]({},_0x5ab6fd,_0x55d00a[_0x88f3('0x3c')]);var _0x424252={'where':_0x5ab6fd[_0x88f3('0x36')]};return db[_0x88f3('0x29')][_0x88f3('0x1c')](_0x424252)['then'](function(_0x45df1f){_0x1e46f6[_0x88f3('0x1c')]=_0x45df1f;if(_0x55d00a['query'][_0x88f3('0x3d')]){_0x5ab6fd[_0x88f3('0x3e')]=[{'all':!![]}];}return db['SmsApplication']['findAll'](_0x5ab6fd);})[_0x88f3('0x24')](function(_0x19dace){_0x1e46f6[_0x88f3('0x3f')]=_0x19dace;return _0x1e46f6;})['then'](respondWithFilteredResult(_0x4776da,_0x5ab6fd))['catch'](handleError(_0x4776da,null));};exports[_0x88f3('0x40')]=function(_0x84fc85,_0x140934){var _0x129df9={'raw':!![],'where':{'id':_0x84fc85[_0x88f3('0x41')]['id']}},_0x18b5f3={};_0x18b5f3[_0x88f3('0x2d')]=_[_0x88f3('0x2f')](db[_0x88f3('0x29')][_0x88f3('0x2a')]);_0x18b5f3[_0x88f3('0x2e')]=_[_0x88f3('0x2f')](_0x84fc85[_0x88f3('0x2e')]);_0x18b5f3[_0x88f3('0x37')]=_['intersection'](_0x18b5f3[_0x88f3('0x2d')],_0x18b5f3[_0x88f3('0x2e')]);_0x129df9['attributes']=_[_0x88f3('0x30')](_0x18b5f3[_0x88f3('0x2d')],qs[_0x88f3('0x32')](_0x84fc85[_0x88f3('0x2e')][_0x88f3('0x32')]));_0x129df9[_0x88f3('0x31')]=_0x129df9[_0x88f3('0x31')][_0x88f3('0x42')]?_0x129df9['attributes']:_0x18b5f3[_0x88f3('0x2d')];if(_0x84fc85['query'][_0x88f3('0x3d')]){_0x129df9[_0x88f3('0x3e')]=[{'all':!![]}];}_0x129df9=_[_0x88f3('0x3a')]({},_0x129df9,_0x84fc85[_0x88f3('0x3c')]);return db['SmsApplication']['find'](_0x129df9)[_0x88f3('0x24')](handleEntityNotFound(_0x140934,null))['then'](respondWithResult(_0x140934,null))[_0x88f3('0x43')](handleError(_0x140934,null));};exports[_0x88f3('0x44')]=function(_0x55c418,_0x289904){return db[_0x88f3('0x29')][_0x88f3('0x44')](_0x55c418['body'],{})[_0x88f3('0x24')](respondWithResult(_0x289904,0xc9))['catch'](handleError(_0x289904,null));};exports[_0x88f3('0x22')]=function(_0x667b57,_0xd23483){if(_0x667b57[_0x88f3('0x45')]['id']){delete _0x667b57['body']['id'];}return db['SmsApplication'][_0x88f3('0x46')]({'where':{'id':_0x667b57[_0x88f3('0x41')]['id']}})[_0x88f3('0x24')](handleEntityNotFound(_0xd23483,null))[_0x88f3('0x24')](saveUpdates(_0x667b57[_0x88f3('0x45')],null))['then'](respondWithResult(_0xd23483,null))[_0x88f3('0x43')](handleError(_0xd23483,null));};exports[_0x88f3('0x23')]=function(_0x1dd8c5,_0x2289c5){return db[_0x88f3('0x29')][_0x88f3('0x46')]({'where':{'id':_0x1dd8c5[_0x88f3('0x41')]['id']}})['then'](handleEntityNotFound(_0x2289c5,null))[_0x88f3('0x24')](removeEntity(_0x2289c5,null))['catch'](handleError(_0x2289c5,null));};
\ No newline at end of file