Built motion from commit b5996064.|2.6.21
[motion2.git] / server / api / smsApplication / smsApplication.controller.js
index 6beccaf..9b19eae 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x729f=['end','json','offset','undefined','limit','count','Content-Range','reject','save','then','error','stack','name','send','SmsApplication','rawAttributes','fieldName','type','key','model','map','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filters','merge','where','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','find','create','destroy','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','squel','crypto','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status'];(function(_0x2e8fe5,_0x2ceea0){var _0x19eca6=function(_0x1cc3e4){while(--_0x1cc3e4){_0x2e8fe5['push'](_0x2e8fe5['shift']());}};_0x19eca6(++_0x2ceea0);}(_0x729f,0xc2));var _0xf729=function(_0x5bdbfd,_0x3aaf24){_0x5bdbfd=_0x5bdbfd-0x0;var _0x5711c0=_0x729f[_0x5bdbfd];return _0x5711c0;};'use strict';var emlformat=require(_0xf729('0x0'));var rimraf=require(_0xf729('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf729('0x2'));var rp=require(_0xf729('0x3'));var moment=require(_0xf729('0x4'));var BPromise=require(_0xf729('0x5'));var Mustache=require(_0xf729('0x6'));var util=require(_0xf729('0x7'));var path=require(_0xf729('0x8'));var sox=require('sox');var csv=require(_0xf729('0x9'));var ejs=require(_0xf729('0xa'));var fs=require('fs');var fs_extra=require(_0xf729('0xb'));var _=require('lodash');var squel=require(_0xf729('0xc'));var crypto=require(_0xf729('0xd'));var jsforce=require(_0xf729('0xe'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xf729('0xf'));var Papa=require(_0xf729('0x10'));var Redis=require('ioredis');var authService=require(_0xf729('0x11'));var qs=require(_0xf729('0x12'));var as=require(_0xf729('0x13'));var hardwareService=require(_0xf729('0x14'));var logger=require(_0xf729('0x15'))('api');var utils=require(_0xf729('0x16'));var config=require(_0xf729('0x17'));var licenseUtil=require(_0xf729('0x18'));var db=require(_0xf729('0x19'))['db'];function respondWithStatusCode(_0x4da316,_0x4b9c3d){_0x4b9c3d=_0x4b9c3d||0xcc;return function(_0x330a7a){if(_0x330a7a){return _0x4da316[_0xf729('0x1a')](_0x4b9c3d);}return _0x4da316[_0xf729('0x1b')](_0x4b9c3d)[_0xf729('0x1c')]();};}function respondWithResult(_0x20fd16,_0x51eb03){_0x51eb03=_0x51eb03||0xc8;return function(_0x2f4d4e){if(_0x2f4d4e){return _0x20fd16[_0xf729('0x1b')](_0x51eb03)[_0xf729('0x1d')](_0x2f4d4e);}};}function respondWithFilteredResult(_0x1662bb,_0x58b42f){return function(_0x1dca21){if(_0x1dca21){var _0x3021e=typeof _0x58b42f[_0xf729('0x1e')]===_0xf729('0x1f')&&typeof _0x58b42f[_0xf729('0x20')]==='undefined';var _0x324d5a=_0x1dca21[_0xf729('0x21')];var _0x5ab2ab=_0x3021e?0x0:_0x58b42f[_0xf729('0x1e')];var _0x502c90=_0x3021e?_0x1dca21[_0xf729('0x21')]:_0x58b42f[_0xf729('0x1e')]+_0x58b42f[_0xf729('0x20')];var _0x1b7642;if(_0x502c90>=_0x324d5a){_0x502c90=_0x324d5a;_0x1b7642=0xc8;}else{_0x1b7642=0xce;}_0x1662bb[_0xf729('0x1b')](_0x1b7642);return _0x1662bb['set'](_0xf729('0x22'),_0x5ab2ab+'-'+_0x502c90+'/'+_0x324d5a)[_0xf729('0x1d')](_0x1dca21);}return null;};}function patchUpdates(_0x24f773){return function(_0x3be2fe){try{jsonpatch['apply'](_0x3be2fe,_0x24f773,!![]);}catch(_0x22f002){return BPromise[_0xf729('0x23')](_0x22f002);}return _0x3be2fe[_0xf729('0x24')]();};}function saveUpdates(_0x78f50,_0x25ba53){return function(_0x3d7888){if(_0x3d7888){return _0x3d7888['update'](_0x78f50)['then'](function(_0x6531a){return _0x6531a;});}return null;};}function removeEntity(_0x4fb573,_0x4b2eb0){return function(_0x128c33){if(_0x128c33){return _0x128c33['destroy']()[_0xf729('0x25')](function(){_0x4fb573['status'](0xcc)[_0xf729('0x1c')]();});}};}function handleEntityNotFound(_0x38a9fa,_0x4372fe){return function(_0x38d6e9){if(!_0x38d6e9){_0x38a9fa[_0xf729('0x1a')](0x194);}return _0x38d6e9;};}function handleError(_0x100e8f,_0x12e6b0){_0x12e6b0=_0x12e6b0||0x1f4;return function(_0x34f5ea){logger[_0xf729('0x26')](_0x34f5ea[_0xf729('0x27')]);if(_0x34f5ea[_0xf729('0x28')]){delete _0x34f5ea['name'];}_0x100e8f[_0xf729('0x1b')](_0x12e6b0)[_0xf729('0x29')](_0x34f5ea);};}exports['index']=function(_0x43c04b,_0x255501){var _0x3351b0={},_0x5a2d05={},_0x38bda7={'count':0x0,'rows':[]};var _0x4dcf0f=_['map'](db[_0xf729('0x2a')][_0xf729('0x2b')],function(_0x1b9d98){return{'name':_0x1b9d98[_0xf729('0x2c')],'type':_0x1b9d98[_0xf729('0x2d')][_0xf729('0x2e')]};});_0x5a2d05[_0xf729('0x2f')]=_[_0xf729('0x30')](_0x4dcf0f,_0xf729('0x28'));_0x5a2d05[_0xf729('0x31')]=_[_0xf729('0x32')](_0x43c04b[_0xf729('0x31')]);_0x5a2d05['filters']=_[_0xf729('0x33')](_0x5a2d05[_0xf729('0x2f')],_0x5a2d05[_0xf729('0x31')]);_0x3351b0[_0xf729('0x34')]=_[_0xf729('0x33')](_0x5a2d05['model'],qs[_0xf729('0x35')](_0x43c04b[_0xf729('0x31')]['fields']));_0x3351b0['attributes']=_0x3351b0[_0xf729('0x34')][_0xf729('0x36')]?_0x3351b0[_0xf729('0x34')]:_0x5a2d05[_0xf729('0x2f')];if(!_0x43c04b[_0xf729('0x31')][_0xf729('0x37')](_0xf729('0x38'))){_0x3351b0[_0xf729('0x20')]=qs[_0xf729('0x20')](_0x43c04b[_0xf729('0x31')][_0xf729('0x20')]);_0x3351b0[_0xf729('0x1e')]=qs[_0xf729('0x1e')](_0x43c04b['query']['offset']);}_0x3351b0[_0xf729('0x39')]=qs['sort'](_0x43c04b[_0xf729('0x31')][_0xf729('0x3a')]);_0x3351b0['where']=qs['filters'](_['pick'](_0x43c04b[_0xf729('0x31')],_0x5a2d05[_0xf729('0x3b')]),_0x4dcf0f);if(_0x43c04b[_0xf729('0x31')]['filter']){_0x3351b0['where']=_[_0xf729('0x3c')](_0x3351b0[_0xf729('0x3d')],{'$or':_[_0xf729('0x30')](_0x4dcf0f,function(_0x1b637f){if(_0x1b637f[_0xf729('0x2d')]!==_0xf729('0x3e')){var _0x3af3ca={};_0x3af3ca[_0x1b637f['name']]={'$like':'%'+_0x43c04b[_0xf729('0x31')]['filter']+'%'};return _0x3af3ca;}})});}_0x3351b0=_[_0xf729('0x3c')]({},_0x3351b0,_0x43c04b[_0xf729('0x3f')]);var _0x36e097={'where':_0x3351b0[_0xf729('0x3d')]};return db['SmsApplication'][_0xf729('0x21')](_0x36e097)['then'](function(_0x10dc80){_0x38bda7[_0xf729('0x21')]=_0x10dc80;if(_0x43c04b[_0xf729('0x31')][_0xf729('0x40')]){_0x3351b0[_0xf729('0x41')]=[{'all':!![]}];}return db[_0xf729('0x2a')][_0xf729('0x42')](_0x3351b0);})['then'](function(_0x16980c){_0x38bda7[_0xf729('0x43')]=_0x16980c;return _0x38bda7;})['then'](respondWithFilteredResult(_0x255501,_0x3351b0))[_0xf729('0x44')](handleError(_0x255501,null));};exports[_0xf729('0x45')]=function(_0x1cd298,_0x58246b){var _0x1665e3={'raw':!![],'where':{'id':_0x1cd298[_0xf729('0x46')]['id']}},_0x567a58={};_0x567a58[_0xf729('0x2f')]=_[_0xf729('0x32')](db['SmsApplication'][_0xf729('0x2b')]);_0x567a58[_0xf729('0x31')]=_[_0xf729('0x32')](_0x1cd298[_0xf729('0x31')]);_0x567a58[_0xf729('0x3b')]=_[_0xf729('0x33')](_0x567a58['model'],_0x567a58[_0xf729('0x31')]);_0x1665e3[_0xf729('0x34')]=_['intersection'](_0x567a58[_0xf729('0x2f')],qs[_0xf729('0x35')](_0x1cd298[_0xf729('0x31')][_0xf729('0x35')]));_0x1665e3[_0xf729('0x34')]=_0x1665e3['attributes'][_0xf729('0x36')]?_0x1665e3[_0xf729('0x34')]:_0x567a58[_0xf729('0x2f')];if(_0x1cd298[_0xf729('0x31')][_0xf729('0x40')]){_0x1665e3[_0xf729('0x41')]=[{'all':!![]}];}_0x1665e3=_[_0xf729('0x3c')]({},_0x1665e3,_0x1cd298[_0xf729('0x3f')]);return db[_0xf729('0x2a')][_0xf729('0x47')](_0x1665e3)[_0xf729('0x25')](handleEntityNotFound(_0x58246b,null))[_0xf729('0x25')](respondWithResult(_0x58246b,null))['catch'](handleError(_0x58246b,null));};exports[_0xf729('0x48')]=function(_0x511738,_0x418cbf){return db['SmsApplication'][_0xf729('0x48')](_0x511738['body'],{})[_0xf729('0x25')](respondWithResult(_0x418cbf,0xc9))['catch'](handleError(_0x418cbf,null));};exports['update']=function(_0x1fc1f0,_0x5d96d7){if(_0x1fc1f0['body']['id']){delete _0x1fc1f0['body']['id'];}return db['SmsApplication'][_0xf729('0x47')]({'where':{'id':_0x1fc1f0[_0xf729('0x46')]['id']}})[_0xf729('0x25')](handleEntityNotFound(_0x5d96d7,null))[_0xf729('0x25')](saveUpdates(_0x1fc1f0['body'],null))['then'](respondWithResult(_0x5d96d7,null))[_0xf729('0x44')](handleError(_0x5d96d7,null));};exports[_0xf729('0x49')]=function(_0x4d9817,_0x3a7e35){return db[_0xf729('0x2a')]['find']({'where':{'id':_0x4d9817[_0xf729('0x46')]['id']}})[_0xf729('0x25')](handleEntityNotFound(_0x3a7e35,null))['then'](removeEntity(_0x3a7e35,null))[_0xf729('0x44')](handleError(_0x3a7e35,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