Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / smsApplication / smsApplication.controller.js
index 070eedd..bd23bbc 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xacf7=['api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','json','count','offset','limit','set','Content-Range','save','then','destroy','end','sendStatus','error','name','send','index','map','SmsApplication','rawAttributes','fieldName','type','key','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','find','create','body','update','params','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger'];(function(_0x2dadb9,_0x42cfe6){var _0x2f0097=function(_0x21163f){while(--_0x21163f){_0x2dadb9['push'](_0x2dadb9['shift']());}};_0x2f0097(++_0x42cfe6);}(_0xacf7,0x1bd));var _0x7acf=function(_0x42cae2,_0x284ef8){_0x42cae2=_0x42cae2-0x0;var _0x5f256f=_0xacf7[_0x42cae2];return _0x5f256f;};'use strict';var pdf=require(_0x7acf('0x0'));var emlformat=require(_0x7acf('0x1'));var rimraf=require(_0x7acf('0x2'));var zipdir=require(_0x7acf('0x3'));var jsonpatch=require(_0x7acf('0x4'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x7acf('0x5'));var Mustache=require(_0x7acf('0x6'));var util=require(_0x7acf('0x7'));var path=require(_0x7acf('0x8'));var sox=require(_0x7acf('0x9'));var csv=require(_0x7acf('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x7acf('0xb'));var squel=require(_0x7acf('0xc'));var crypto=require(_0x7acf('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x7acf('0xe'));var toCsv=require(_0x7acf('0xa'));var querystring=require(_0x7acf('0xf'));var Papa=require(_0x7acf('0x10'));var Redis=require(_0x7acf('0x11'));var authService=require(_0x7acf('0x12'));var qs=require(_0x7acf('0x13'));var as=require(_0x7acf('0x14'));var hardwareService=require(_0x7acf('0x15'));var logger=require(_0x7acf('0x16'))(_0x7acf('0x17'));var utils=require(_0x7acf('0x18'));var config=require(_0x7acf('0x19'));var licenseUtil=require(_0x7acf('0x1a'));var db=require(_0x7acf('0x1b'))['db'];function respondWithStatusCode(_0x2e4fae,_0x5644f3){_0x5644f3=_0x5644f3||0xcc;return function(_0x1d76bc){if(_0x1d76bc){return _0x2e4fae['sendStatus'](_0x5644f3);}return _0x2e4fae[_0x7acf('0x1c')](_0x5644f3)['end']();};}function respondWithResult(_0xe48928,_0x40dc19){_0x40dc19=_0x40dc19||0xc8;return function(_0x10d29b){if(_0x10d29b){return _0xe48928['status'](_0x40dc19)[_0x7acf('0x1d')](_0x10d29b);}};}function respondWithFilteredResult(_0x1ab1a3,_0x531b60){return function(_0x518a7c){if(_0x518a7c){var _0x41c1ef=_0x518a7c[_0x7acf('0x1e')],_0x482c9f=_0x531b60[_0x7acf('0x1f')],_0x557438=_0x531b60[_0x7acf('0x1f')]+_0x531b60[_0x7acf('0x20')],_0x5bb5ff;if(_0x557438>=_0x41c1ef){_0x557438=_0x41c1ef;_0x5bb5ff=0xc8;}else{_0x5bb5ff=0xce;}_0x1ab1a3[_0x7acf('0x1c')](_0x5bb5ff);return _0x1ab1a3[_0x7acf('0x21')](_0x7acf('0x22'),_0x482c9f+'-'+_0x557438+'/'+_0x41c1ef)[_0x7acf('0x1d')](_0x518a7c);}return null;};}function patchUpdates(_0x588279){return function(_0x1b9a88){try{jsonpatch['apply'](_0x1b9a88,_0x588279,!![]);}catch(_0x52c8a3){return BPromise['reject'](_0x52c8a3);}return _0x1b9a88[_0x7acf('0x23')]();};}function saveUpdates(_0x9a19a9,_0x1ea307){return function(_0x8a439d){if(_0x8a439d){return _0x8a439d['update'](_0x9a19a9)[_0x7acf('0x24')](function(_0x22c41f){return _0x22c41f;});}return null;};}function removeEntity(_0x563ff3,_0x2b0452){return function(_0x3b3521){if(_0x3b3521){return _0x3b3521[_0x7acf('0x25')]()[_0x7acf('0x24')](function(){_0x563ff3['status'](0xcc)[_0x7acf('0x26')]();});}};}function handleEntityNotFound(_0x4e9b20,_0x99d1c7){return function(_0x504ceb){if(!_0x504ceb){_0x4e9b20[_0x7acf('0x27')](0x194);}return _0x504ceb;};}function handleError(_0x4fc93f,_0x4497c0){_0x4497c0=_0x4497c0||0x1f4;return function(_0xf8fe81){logger[_0x7acf('0x28')](_0xf8fe81['stack']);if(_0xf8fe81[_0x7acf('0x29')]){delete _0xf8fe81[_0x7acf('0x29')];}_0x4fc93f[_0x7acf('0x1c')](_0x4497c0)[_0x7acf('0x2a')](_0xf8fe81);};}exports[_0x7acf('0x2b')]=function(_0x103e2d,_0x3d1dd5){var _0xd939e4={},_0x59bf3a={},_0xdeb7f8={'count':0x0,'rows':[]};var _0x378dab=_[_0x7acf('0x2c')](db[_0x7acf('0x2d')][_0x7acf('0x2e')],function(_0x48a9f7){return{'name':_0x48a9f7[_0x7acf('0x2f')],'type':_0x48a9f7[_0x7acf('0x30')][_0x7acf('0x31')]};});_0x59bf3a[_0x7acf('0x32')]=_[_0x7acf('0x2c')](_0x378dab,_0x7acf('0x29'));_0x59bf3a[_0x7acf('0x33')]=_[_0x7acf('0x34')](_0x103e2d[_0x7acf('0x33')]);_0x59bf3a[_0x7acf('0x35')]=_['intersection'](_0x59bf3a[_0x7acf('0x32')],_0x59bf3a['query']);_0xd939e4[_0x7acf('0x36')]=_[_0x7acf('0x37')](_0x59bf3a[_0x7acf('0x32')],qs['fields'](_0x103e2d[_0x7acf('0x33')][_0x7acf('0x38')]));_0xd939e4[_0x7acf('0x36')]=_0xd939e4[_0x7acf('0x36')][_0x7acf('0x39')]?_0xd939e4[_0x7acf('0x36')]:_0x59bf3a[_0x7acf('0x32')];if(!_0x103e2d[_0x7acf('0x33')][_0x7acf('0x3a')](_0x7acf('0x3b'))){_0xd939e4[_0x7acf('0x20')]=qs[_0x7acf('0x20')](_0x103e2d[_0x7acf('0x33')]['limit']);_0xd939e4[_0x7acf('0x1f')]=qs['offset'](_0x103e2d['query'][_0x7acf('0x1f')]);}_0xd939e4['order']=qs[_0x7acf('0x3c')](_0x103e2d[_0x7acf('0x33')][_0x7acf('0x3c')]);_0xd939e4[_0x7acf('0x3d')]=qs[_0x7acf('0x35')](_[_0x7acf('0x3e')](_0x103e2d[_0x7acf('0x33')],_0x59bf3a[_0x7acf('0x35')]),_0x378dab);if(_0x103e2d[_0x7acf('0x33')][_0x7acf('0x3f')]){_0xd939e4[_0x7acf('0x3d')]=_[_0x7acf('0x40')](_0xd939e4['where'],{'$or':_[_0x7acf('0x2c')](_0x378dab,function(_0x417823){if(_0x417823['type']!==_0x7acf('0x41')){var _0x3ae30c={};_0x3ae30c[_0x417823[_0x7acf('0x29')]]={'$like':'%'+_0x103e2d[_0x7acf('0x33')][_0x7acf('0x3f')]+'%'};return _0x3ae30c;}})});}_0xd939e4=_[_0x7acf('0x40')]({},_0xd939e4,_0x103e2d[_0x7acf('0x42')]);var _0x166488={'where':_0xd939e4[_0x7acf('0x3d')]};return db[_0x7acf('0x2d')]['count'](_0x166488)['then'](function(_0x1ca719){_0xdeb7f8[_0x7acf('0x1e')]=_0x1ca719;if(_0x103e2d[_0x7acf('0x33')][_0x7acf('0x43')]){_0xd939e4[_0x7acf('0x44')]=[{'all':!![]}];}return db[_0x7acf('0x2d')][_0x7acf('0x45')](_0xd939e4);})['then'](function(_0x1f5f43){_0xdeb7f8[_0x7acf('0x46')]=_0x1f5f43;return _0xdeb7f8;})[_0x7acf('0x24')](respondWithFilteredResult(_0x3d1dd5,_0xd939e4))[_0x7acf('0x47')](handleError(_0x3d1dd5,null));};exports[_0x7acf('0x48')]=function(_0x1ea5fa,_0x58de08){var _0x5c5256={'raw':!![],'where':{'id':_0x1ea5fa['params']['id']}},_0x5e30f7={};_0x5e30f7[_0x7acf('0x32')]=_[_0x7acf('0x34')](db[_0x7acf('0x2d')][_0x7acf('0x2e')]);_0x5e30f7['query']=_['keys'](_0x1ea5fa[_0x7acf('0x33')]);_0x5e30f7[_0x7acf('0x35')]=_['intersection'](_0x5e30f7[_0x7acf('0x32')],_0x5e30f7[_0x7acf('0x33')]);_0x5c5256[_0x7acf('0x36')]=_[_0x7acf('0x37')](_0x5e30f7['model'],qs[_0x7acf('0x38')](_0x1ea5fa[_0x7acf('0x33')][_0x7acf('0x38')]));_0x5c5256[_0x7acf('0x36')]=_0x5c5256[_0x7acf('0x36')][_0x7acf('0x39')]?_0x5c5256[_0x7acf('0x36')]:_0x5e30f7['model'];if(_0x1ea5fa['query'][_0x7acf('0x43')]){_0x5c5256['include']=[{'all':!![]}];}_0x5c5256=_['merge']({},_0x5c5256,_0x1ea5fa[_0x7acf('0x42')]);return db['SmsApplication'][_0x7acf('0x49')](_0x5c5256)['then'](handleEntityNotFound(_0x58de08,null))[_0x7acf('0x24')](respondWithResult(_0x58de08,null))[_0x7acf('0x47')](handleError(_0x58de08,null));};exports[_0x7acf('0x4a')]=function(_0x2842af,_0x407454){return db[_0x7acf('0x2d')][_0x7acf('0x4a')](_0x2842af[_0x7acf('0x4b')],{})['then'](respondWithResult(_0x407454,0xc9))[_0x7acf('0x47')](handleError(_0x407454,null));};exports[_0x7acf('0x4c')]=function(_0x5cdc00,_0x4021f8){if(_0x5cdc00[_0x7acf('0x4b')]['id']){delete _0x5cdc00[_0x7acf('0x4b')]['id'];}return db[_0x7acf('0x2d')][_0x7acf('0x49')]({'where':{'id':_0x5cdc00[_0x7acf('0x4d')]['id']}})[_0x7acf('0x24')](handleEntityNotFound(_0x4021f8,null))[_0x7acf('0x24')](saveUpdates(_0x5cdc00['body'],null))['then'](respondWithResult(_0x4021f8,null))[_0x7acf('0x47')](handleError(_0x4021f8,null));};exports['destroy']=function(_0x407f27,_0xcd8055){return db[_0x7acf('0x2d')][_0x7acf('0x49')]({'where':{'id':_0x407f27[_0x7acf('0x4d')]['id']}})[_0x7acf('0x24')](handleEntityNotFound(_0xcd8055,null))[_0x7acf('0x24')](removeEntity(_0xcd8055,null))[_0x7acf('0x47')](handleError(_0xcd8055,null));};
\ No newline at end of file
+var _0x41e8=['api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','destroy','error','stack','name','send','map','SmsApplication','key','model','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','pick','filter','type','VIRTUAL','options','include','rows','catch','show','params','rawAttributes','keys','length','find','create','update','body','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','sox','fs-extra','lodash','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x41e8,0x189));var _0x841e=function(_0x31e29a,_0x349c9b){_0x31e29a=_0x31e29a-0x0;var _0x32d892=_0x41e8[_0x31e29a];return _0x32d892;};'use strict';var emlformat=require(_0x841e('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x841e('0x1'));var jsonpatch=require(_0x841e('0x2'));var rp=require(_0x841e('0x3'));var moment=require('moment');var BPromise=require(_0x841e('0x4'));var Mustache=require(_0x841e('0x5'));var util=require('util');var path=require('path');var sox=require(_0x841e('0x6'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x841e('0x7'));var _=require(_0x841e('0x8'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x841e('0x9'));var deskjs=require(_0x841e('0xa'));var toCsv=require('to-csv');var querystring=require(_0x841e('0xb'));var Papa=require('papaparse');var Redis=require(_0x841e('0xc'));var authService=require(_0x841e('0xd'));var qs=require(_0x841e('0xe'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x841e('0xf'));var utils=require(_0x841e('0x10'));var config=require('../../config/environment');var licenseUtil=require(_0x841e('0x11'));var db=require(_0x841e('0x12'))['db'];function respondWithStatusCode(_0x58e5e0,_0x5ded8f){_0x5ded8f=_0x5ded8f||0xcc;return function(_0x328b62){if(_0x328b62){return _0x58e5e0[_0x841e('0x13')](_0x5ded8f);}return _0x58e5e0[_0x841e('0x14')](_0x5ded8f)[_0x841e('0x15')]();};}function respondWithResult(_0x3da528,_0x3eeb10){_0x3eeb10=_0x3eeb10||0xc8;return function(_0x105cc9){if(_0x105cc9){return _0x3da528[_0x841e('0x14')](_0x3eeb10)[_0x841e('0x16')](_0x105cc9);}};}function respondWithFilteredResult(_0x5cfb0f,_0xe73124){return function(_0x269465){if(_0x269465){var _0xdede9c=typeof _0xe73124[_0x841e('0x17')]===_0x841e('0x18')&&typeof _0xe73124[_0x841e('0x19')]==='undefined';var _0x2b3514=_0x269465[_0x841e('0x1a')];var _0x5d95f8=_0xdede9c?0x0:_0xe73124[_0x841e('0x17')];var _0x2d6bcf=_0xdede9c?_0x269465['count']:_0xe73124[_0x841e('0x17')]+_0xe73124[_0x841e('0x19')];var _0x5515ed;if(_0x2d6bcf>=_0x2b3514){_0x2d6bcf=_0x2b3514;_0x5515ed=0xc8;}else{_0x5515ed=0xce;}_0x5cfb0f[_0x841e('0x14')](_0x5515ed);return _0x5cfb0f[_0x841e('0x1b')](_0x841e('0x1c'),_0x5d95f8+'-'+_0x2d6bcf+'/'+_0x2b3514)['json'](_0x269465);}return null;};}function patchUpdates(_0x43970f){return function(_0x1d0192){try{jsonpatch[_0x841e('0x1d')](_0x1d0192,_0x43970f,!![]);}catch(_0x5c4491){return BPromise[_0x841e('0x1e')](_0x5c4491);}return _0x1d0192[_0x841e('0x1f')]();};}function saveUpdates(_0x3eaf35,_0x5b4fc4){return function(_0x48ddc5){if(_0x48ddc5){return _0x48ddc5['update'](_0x3eaf35)[_0x841e('0x20')](function(_0x6c88c){return _0x6c88c;});}return null;};}function removeEntity(_0x157e6f,_0x4563a6){return function(_0xcfbb4b){if(_0xcfbb4b){return _0xcfbb4b[_0x841e('0x21')]()['then'](function(){_0x157e6f['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x2be749,_0x1e52f0){return function(_0x2ecc16){if(!_0x2ecc16){_0x2be749[_0x841e('0x13')](0x194);}return _0x2ecc16;};}function handleError(_0x27976e,_0x37ccb4){_0x37ccb4=_0x37ccb4||0x1f4;return function(_0x38b714){logger[_0x841e('0x22')](_0x38b714[_0x841e('0x23')]);if(_0x38b714[_0x841e('0x24')]){delete _0x38b714[_0x841e('0x24')];}_0x27976e['status'](_0x37ccb4)[_0x841e('0x25')](_0x38b714);};}exports['index']=function(_0x2d7093,_0x5103f5){var _0x54b7e2={},_0x2d3bc1={},_0x4ad8a8={'count':0x0,'rows':[]};var _0x2ba3b6=_[_0x841e('0x26')](db[_0x841e('0x27')]['rawAttributes'],function(_0xeb0ba8){return{'name':_0xeb0ba8['fieldName'],'type':_0xeb0ba8['type'][_0x841e('0x28')]};});_0x2d3bc1[_0x841e('0x29')]=_[_0x841e('0x26')](_0x2ba3b6,_0x841e('0x24'));_0x2d3bc1['query']=_['keys'](_0x2d7093[_0x841e('0x2a')]);_0x2d3bc1[_0x841e('0x2b')]=_[_0x841e('0x2c')](_0x2d3bc1[_0x841e('0x29')],_0x2d3bc1[_0x841e('0x2a')]);_0x54b7e2[_0x841e('0x2d')]=_[_0x841e('0x2c')](_0x2d3bc1[_0x841e('0x29')],qs[_0x841e('0x2e')](_0x2d7093[_0x841e('0x2a')]['fields']));_0x54b7e2[_0x841e('0x2d')]=_0x54b7e2[_0x841e('0x2d')]['length']?_0x54b7e2[_0x841e('0x2d')]:_0x2d3bc1['model'];if(!_0x2d7093[_0x841e('0x2a')][_0x841e('0x2f')](_0x841e('0x30'))){_0x54b7e2[_0x841e('0x19')]=qs[_0x841e('0x19')](_0x2d7093[_0x841e('0x2a')]['limit']);_0x54b7e2['offset']=qs['offset'](_0x2d7093['query'][_0x841e('0x17')]);}_0x54b7e2['order']=qs[_0x841e('0x31')](_0x2d7093[_0x841e('0x2a')]['sort']);_0x54b7e2[_0x841e('0x32')]=qs['filters'](_[_0x841e('0x33')](_0x2d7093[_0x841e('0x2a')],_0x2d3bc1[_0x841e('0x2b')]),_0x2ba3b6);if(_0x2d7093[_0x841e('0x2a')][_0x841e('0x34')]){_0x54b7e2['where']=_['merge'](_0x54b7e2[_0x841e('0x32')],{'$or':_[_0x841e('0x26')](_0x2ba3b6,function(_0x1d3695){if(_0x1d3695[_0x841e('0x35')]!==_0x841e('0x36')){var _0x572588={};_0x572588[_0x1d3695[_0x841e('0x24')]]={'$like':'%'+_0x2d7093[_0x841e('0x2a')]['filter']+'%'};return _0x572588;}})});}_0x54b7e2=_['merge']({},_0x54b7e2,_0x2d7093[_0x841e('0x37')]);var _0x4e8557={'where':_0x54b7e2[_0x841e('0x32')]};return db[_0x841e('0x27')][_0x841e('0x1a')](_0x4e8557)[_0x841e('0x20')](function(_0x517dba){_0x4ad8a8[_0x841e('0x1a')]=_0x517dba;if(_0x2d7093[_0x841e('0x2a')]['includeAll']){_0x54b7e2[_0x841e('0x38')]=[{'all':!![]}];}return db[_0x841e('0x27')]['findAll'](_0x54b7e2);})['then'](function(_0x43fd58){_0x4ad8a8[_0x841e('0x39')]=_0x43fd58;return _0x4ad8a8;})[_0x841e('0x20')](respondWithFilteredResult(_0x5103f5,_0x54b7e2))[_0x841e('0x3a')](handleError(_0x5103f5,null));};exports[_0x841e('0x3b')]=function(_0x3e1646,_0x57ae57){var _0x1326ae={'raw':!![],'where':{'id':_0x3e1646[_0x841e('0x3c')]['id']}},_0x37ca5a={};_0x37ca5a[_0x841e('0x29')]=_['keys'](db['SmsApplication'][_0x841e('0x3d')]);_0x37ca5a[_0x841e('0x2a')]=_[_0x841e('0x3e')](_0x3e1646[_0x841e('0x2a')]);_0x37ca5a[_0x841e('0x2b')]=_['intersection'](_0x37ca5a[_0x841e('0x29')],_0x37ca5a[_0x841e('0x2a')]);_0x1326ae[_0x841e('0x2d')]=_[_0x841e('0x2c')](_0x37ca5a[_0x841e('0x29')],qs[_0x841e('0x2e')](_0x3e1646['query']['fields']));_0x1326ae[_0x841e('0x2d')]=_0x1326ae['attributes'][_0x841e('0x3f')]?_0x1326ae[_0x841e('0x2d')]:_0x37ca5a[_0x841e('0x29')];if(_0x3e1646[_0x841e('0x2a')]['includeAll']){_0x1326ae['include']=[{'all':!![]}];}_0x1326ae=_['merge']({},_0x1326ae,_0x3e1646[_0x841e('0x37')]);return db['SmsApplication'][_0x841e('0x40')](_0x1326ae)['then'](handleEntityNotFound(_0x57ae57,null))[_0x841e('0x20')](respondWithResult(_0x57ae57,null))[_0x841e('0x3a')](handleError(_0x57ae57,null));};exports[_0x841e('0x41')]=function(_0x1939e2,_0x36a455){return db['SmsApplication'][_0x841e('0x41')](_0x1939e2['body'],{})[_0x841e('0x20')](respondWithResult(_0x36a455,0xc9))[_0x841e('0x3a')](handleError(_0x36a455,null));};exports[_0x841e('0x42')]=function(_0x1d3ec4,_0x4edd9){if(_0x1d3ec4['body']['id']){delete _0x1d3ec4[_0x841e('0x43')]['id'];}return db[_0x841e('0x27')]['find']({'where':{'id':_0x1d3ec4[_0x841e('0x3c')]['id']}})[_0x841e('0x20')](handleEntityNotFound(_0x4edd9,null))[_0x841e('0x20')](saveUpdates(_0x1d3ec4[_0x841e('0x43')],null))['then'](respondWithResult(_0x4edd9,null))[_0x841e('0x3a')](handleError(_0x4edd9,null));};exports[_0x841e('0x21')]=function(_0x23e684,_0x2fc0ae){return db[_0x841e('0x27')][_0x841e('0x40')]({'where':{'id':_0x23e684[_0x841e('0x3c')]['id']}})[_0x841e('0x20')](handleEntityNotFound(_0x2fc0ae,null))[_0x841e('0x20')](removeEntity(_0x2fc0ae,null))[_0x841e('0x3a')](handleError(_0x2fc0ae,null));};
\ No newline at end of file