Built motion from commit (unavailable).|2.5.0
[motion2.git] / server / api / voicePrefix / voicePrefix.controller.js
index bbfbdda..d05c9b5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xad15=['include','findAll','rows','keys','includeAll','find','params','catch','describe','create','transaction','get','VoiceExtension','VoiceExtensionId','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','context','from-sip','app','Voice\x20Prefix\x20Extension','appdata','prefix','NoOp','Voice\x20Prefix','VoicePrefixId','bulkCreate','Extensions\x20creation\x20failed','push','callerIdAll','Set','PREFIX-CALLERIDALL=','No\x20callerid\x20available','goto','${EXTEN:','charAt','body','system-','sequelize','addAgents','ids','spread','emit','isArray','userVoicePrefix:remove','findOne','order','getAgents','hasOwnProperty','eml-format','zip-dir','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','redis','defaults','socket.io-emitter','./voicePrefix.socket','register','end','json','count','offset','limit','status','set','Content-Range','reject','update','then','destroy','VoicePrefixes','UserProfileResource','sendStatus','error','name','send','index','map','VoicePrefix','rawAttributes','fieldName','key','model','query','filters','attributes','intersection','fields','length','nolimit','sort','where','pick','type','filter','merge','options'];(function(_0xac9e9d,_0x768827){var _0x13a727=function(_0x21274c){while(--_0x21274c){_0xac9e9d['push'](_0xac9e9d['shift']());}};_0x13a727(++_0x768827);}(_0xad15,0xab));var _0x5ad1=function(_0x5e515c,_0x3319a7){_0x5e515c=_0x5e515c-0x0;var _0x4f3109=_0xad15[_0x5e515c];return _0x4f3109;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x5ad1('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x5ad1('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5ad1('0x2'));var moment=require(_0x5ad1('0x3'));var BPromise=require(_0x5ad1('0x4'));var Mustache=require(_0x5ad1('0x5'));var util=require(_0x5ad1('0x6'));var path=require('path');var sox=require(_0x5ad1('0x7'));var csv=require(_0x5ad1('0x8'));var ejs=require(_0x5ad1('0x9'));var fs=require('fs');var _=require(_0x5ad1('0xa'));var squel=require(_0x5ad1('0xb'));var crypto=require('crypto');var jsforce=require(_0x5ad1('0xc'));var deskjs=require(_0x5ad1('0xd'));var toCsv=require(_0x5ad1('0x8'));var querystring=require(_0x5ad1('0xe'));var Papa=require('papaparse');var Redis=require(_0x5ad1('0xf'));var authService=require(_0x5ad1('0x10'));var qs=require(_0x5ad1('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x5ad1('0x12'));var logger=require(_0x5ad1('0x13'))('api');var utils=require(_0x5ad1('0x14'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config[_0x5ad1('0x15')]=_[_0x5ad1('0x16')](config[_0x5ad1('0x15')],{'host':'localhost','port':0x18eb});var socket=require(_0x5ad1('0x17'))(new Redis(config[_0x5ad1('0x15')]));require(_0x5ad1('0x18'))[_0x5ad1('0x19')](socket);function respondWithStatusCode(_0x603702,_0x2be03e){_0x2be03e=_0x2be03e||0xcc;return function(_0x3e5da0){if(_0x3e5da0){return _0x603702['sendStatus'](_0x2be03e);}return _0x603702['status'](_0x2be03e)[_0x5ad1('0x1a')]();};}function respondWithResult(_0x729766,_0x54e790){_0x54e790=_0x54e790||0xc8;return function(_0x54b39e){if(_0x54b39e){return _0x729766['status'](_0x54e790)[_0x5ad1('0x1b')](_0x54b39e);}};}function respondWithFilteredResult(_0x90c16,_0x4f42f9){return function(_0x3b4751){if(_0x3b4751){var _0x14eadb=_0x3b4751[_0x5ad1('0x1c')],_0x56a2bd=_0x4f42f9[_0x5ad1('0x1d')],_0xc26a78=_0x4f42f9['offset']+_0x4f42f9[_0x5ad1('0x1e')],_0x10c8be;if(_0xc26a78>=_0x14eadb){_0xc26a78=_0x14eadb;_0x10c8be=0xc8;}else{_0x10c8be=0xce;}_0x90c16[_0x5ad1('0x1f')](_0x10c8be);return _0x90c16[_0x5ad1('0x20')](_0x5ad1('0x21'),_0x56a2bd+'-'+_0xc26a78+'/'+_0x14eadb)['json'](_0x3b4751);}return null;};}function patchUpdates(_0x81db09){return function(_0x3f8abc){try{jsonpatch['apply'](_0x3f8abc,_0x81db09,!![]);}catch(_0xe1d351){return BPromise[_0x5ad1('0x22')](_0xe1d351);}return _0x3f8abc['save']();};}function saveUpdates(_0x479f4e,_0x583c9a){return function(_0x5f4d5c){if(_0x5f4d5c){return _0x5f4d5c[_0x5ad1('0x23')](_0x479f4e)[_0x5ad1('0x24')](function(_0x54cef9){return _0x54cef9;});}return null;};}function removeEntity(_0x1d7b93,_0x3f883a){return function(_0x2c642c){if(_0x2c642c){return _0x2c642c[_0x5ad1('0x25')]()[_0x5ad1('0x24')](function(){var _0x3ba543=_0x2c642c['get']({'plain':!![]});var _0x524e74=_0x5ad1('0x26');return db[_0x5ad1('0x27')][_0x5ad1('0x25')]({'where':{'type':_0x524e74,'resourceId':_0x3ba543['id']}})['then'](function(){return _0x2c642c;});})[_0x5ad1('0x24')](function(){_0x1d7b93['status'](0xcc)[_0x5ad1('0x1a')]();});}};}function handleEntityNotFound(_0x4efe69,_0x567d44){return function(_0x1a67a4){if(!_0x1a67a4){_0x4efe69[_0x5ad1('0x28')](0x194);}return _0x1a67a4;};}function handleError(_0x1890d5,_0x23f022){_0x23f022=_0x23f022||0x1f4;return function(_0x28368a){logger[_0x5ad1('0x29')](_0x28368a['stack']);if(_0x28368a[_0x5ad1('0x2a')]){delete _0x28368a[_0x5ad1('0x2a')];}_0x1890d5[_0x5ad1('0x1f')](_0x23f022)[_0x5ad1('0x2b')](_0x28368a);};}exports[_0x5ad1('0x2c')]=function(_0x35233a,_0xc548b0){var _0x367758={},_0x1e2fce={},_0x562b89={'count':0x0,'rows':[]};var _0x309e9e=_[_0x5ad1('0x2d')](db[_0x5ad1('0x2e')][_0x5ad1('0x2f')],function(_0xb2f9d4){return{'name':_0xb2f9d4[_0x5ad1('0x30')],'type':_0xb2f9d4['type'][_0x5ad1('0x31')]};});_0x1e2fce[_0x5ad1('0x32')]=_[_0x5ad1('0x2d')](_0x309e9e,_0x5ad1('0x2a'));_0x1e2fce[_0x5ad1('0x33')]=_['keys'](_0x35233a[_0x5ad1('0x33')]);_0x1e2fce[_0x5ad1('0x34')]=_['intersection'](_0x1e2fce[_0x5ad1('0x32')],_0x1e2fce[_0x5ad1('0x33')]);_0x367758[_0x5ad1('0x35')]=_[_0x5ad1('0x36')](_0x1e2fce[_0x5ad1('0x32')],qs[_0x5ad1('0x37')](_0x35233a[_0x5ad1('0x33')][_0x5ad1('0x37')]));_0x367758['attributes']=_0x367758[_0x5ad1('0x35')][_0x5ad1('0x38')]?_0x367758['attributes']:_0x1e2fce[_0x5ad1('0x32')];if(!_0x35233a[_0x5ad1('0x33')]['hasOwnProperty'](_0x5ad1('0x39'))){_0x367758[_0x5ad1('0x1e')]=qs[_0x5ad1('0x1e')](_0x35233a[_0x5ad1('0x33')][_0x5ad1('0x1e')]);_0x367758['offset']=qs[_0x5ad1('0x1d')](_0x35233a[_0x5ad1('0x33')][_0x5ad1('0x1d')]);}_0x367758['order']=qs[_0x5ad1('0x3a')](_0x35233a[_0x5ad1('0x33')][_0x5ad1('0x3a')]);_0x367758[_0x5ad1('0x3b')]=qs[_0x5ad1('0x34')](_[_0x5ad1('0x3c')](_0x35233a[_0x5ad1('0x33')],_0x1e2fce['filters']));if(_0x35233a[_0x5ad1('0x33')]['filter']){_0x367758[_0x5ad1('0x3b')]=_['merge'](_0x367758['where'],{'$or':_[_0x5ad1('0x2d')](_0x309e9e,function(_0x361b9e){if(_0x361b9e[_0x5ad1('0x3d')]!=='VIRTUAL'){var _0x45fde8={};_0x45fde8[_0x361b9e[_0x5ad1('0x2a')]]={'$like':'%'+_0x35233a[_0x5ad1('0x33')][_0x5ad1('0x3e')]+'%'};return _0x45fde8;}})});}_0x367758=_[_0x5ad1('0x3f')]({},_0x367758,_0x35233a[_0x5ad1('0x40')]);var _0x589dee={'where':_0x367758[_0x5ad1('0x3b')]};return db[_0x5ad1('0x2e')][_0x5ad1('0x1c')](_0x589dee)[_0x5ad1('0x24')](function(_0x3c5f27){_0x562b89[_0x5ad1('0x1c')]=_0x3c5f27;if(_0x35233a['query']['includeAll']){_0x367758[_0x5ad1('0x41')]=[{'all':!![]}];}return db['VoicePrefix'][_0x5ad1('0x42')](_0x367758);})[_0x5ad1('0x24')](function(_0x50c24c){_0x562b89[_0x5ad1('0x43')]=_0x50c24c;return _0x562b89;})[_0x5ad1('0x24')](respondWithFilteredResult(_0xc548b0,_0x367758))['catch'](handleError(_0xc548b0,null));};exports['show']=function(_0x30ae02,_0x7ef9f9){var _0x5730a4={'raw':![],'where':{'id':_0x30ae02['params']['id']}},_0x164f28={};_0x164f28['model']=_['keys'](db[_0x5ad1('0x2e')][_0x5ad1('0x2f')]);_0x164f28[_0x5ad1('0x33')]=_[_0x5ad1('0x44')](_0x30ae02[_0x5ad1('0x33')]);_0x164f28[_0x5ad1('0x34')]=_[_0x5ad1('0x36')](_0x164f28[_0x5ad1('0x32')],_0x164f28[_0x5ad1('0x33')]);_0x5730a4[_0x5ad1('0x35')]=_[_0x5ad1('0x36')](_0x164f28[_0x5ad1('0x32')],qs[_0x5ad1('0x37')](_0x30ae02[_0x5ad1('0x33')][_0x5ad1('0x37')]));_0x5730a4[_0x5ad1('0x35')]=_0x5730a4[_0x5ad1('0x35')][_0x5ad1('0x38')]?_0x5730a4['attributes']:_0x164f28[_0x5ad1('0x32')];if(_0x30ae02[_0x5ad1('0x33')][_0x5ad1('0x45')]){_0x5730a4['include']=[{'all':!![]}];}_0x5730a4=_[_0x5ad1('0x3f')]({},_0x5730a4,_0x30ae02[_0x5ad1('0x40')]);return db[_0x5ad1('0x2e')][_0x5ad1('0x46')](_0x5730a4)[_0x5ad1('0x24')](handleEntityNotFound(_0x7ef9f9,null))['then'](respondWithResult(_0x7ef9f9,null))['catch'](handleError(_0x7ef9f9,null));};exports[_0x5ad1('0x25')]=function(_0x3676bd,_0x1c6777){return db[_0x5ad1('0x2e')][_0x5ad1('0x46')]({'where':{'id':_0x3676bd[_0x5ad1('0x47')]['id']}})[_0x5ad1('0x24')](handleEntityNotFound(_0x1c6777,null))['then'](removeEntity(_0x1c6777,null))[_0x5ad1('0x48')](handleError(_0x1c6777,null));};exports['describe']=function(_0x668ae2,_0x3b35d7){return db[_0x5ad1('0x2e')][_0x5ad1('0x49')]()[_0x5ad1('0x24')](respondWithResult(_0x3b35d7,null))[_0x5ad1('0x48')](handleError(_0x3b35d7,null));};exports[_0x5ad1('0x4a')]=function(_0x44f6c9,_0x1afdac){var _0x344ade;return db['sequelize'][_0x5ad1('0x4b')](function(_0x3df97e){return db[_0x5ad1('0x2e')][_0x5ad1('0x4a')](_0x44f6c9['body'],{'transaction':_0x3df97e})[_0x5ad1('0x24')](function(_0x57ffbe){_0x344ade=_0x57ffbe[_0x5ad1('0x4c')]({'plain':!![]});return db[_0x5ad1('0x4d')]['find']({'where':{'id':_0x344ade[_0x5ad1('0x4e')]},'raw':!![]})[_0x5ad1('0x24')](function(_0x17f9b1){return createVoicePrefixExtensions(_0x344ade,_0x17f9b1,_0x3df97e);});});})[_0x5ad1('0x24')](function(){var _0x5c65c0=_0x44f6c9['user'][_0x5ad1('0x4c')]({'plain':!![]});if(!_0x5c65c0)throw new Error(_0x5ad1('0x4f'));if(_0x5c65c0[_0x5ad1('0x50')]===_0x5ad1('0x51')){var _0x13dc89=_0x344ade;return db[_0x5ad1('0x52')]['find']({'where':{'name':'VoicePrefixes','userProfileId':_0x5c65c0[_0x5ad1('0x53')]},'raw':!![]})['then'](function(_0x5ea3cc){if(_0x5ea3cc&&_0x5ea3cc[_0x5ad1('0x54')]===0x0){return db[_0x5ad1('0x27')]['create']({'name':_0x13dc89[_0x5ad1('0x2a')],'resourceId':_0x13dc89['id'],'type':_0x5ea3cc[_0x5ad1('0x2a')],'sectionId':_0x5ea3cc['id']},{})[_0x5ad1('0x24')](function(){return _0x344ade;});}else{return _0x344ade;}})['catch'](function(_0x3972fb){logger[_0x5ad1('0x29')](_0x5ad1('0x55'),_0x3972fb);throw _0x3972fb;});}return _0x344ade;})[_0x5ad1('0x24')](respondWithResult(_0x1afdac,null))[_0x5ad1('0x48')](handleError(_0x1afdac,null));};function Extension(_0x309d77,_0x42a2a5,_0x47e87f,_0x5d5ecb){this[_0x5ad1('0x56')]=_0x5ad1('0x57');this['exten']=_0x309d77;this[_0x5ad1('0x58')]=_0x47e87f;this[_0x5ad1('0x3d')]='system';this['description']=_0x5ad1('0x59');this['priority']=_0x42a2a5;this[_0x5ad1('0x5a')]=_0x5d5ecb;}function createVoicePrefixExtensions(_0x2d474b,_0xcc476d,_0x27a1f9){return new BPromise(function(_0x366d8a,_0x3b9352){var _0x275452=new Extension(formatPrefixName(_0x2d474b[_0x5ad1('0x5b')]),0x1,_0x5ad1('0x5c'),_0x5ad1('0x5d'));_0x275452[_0x5ad1('0x5e')]=_0x2d474b['id'];return db['VoiceExtension']['create'](_0x275452,{'transaction':_0x27a1f9})[_0x5ad1('0x24')](function(_0x3bbe13){var _0x31028b=_0x3bbe13[_0x5ad1('0x4c')]({'plain':!![]});var _0x37cebe=_['map'](addVoicePrefixExtensions(_0x2d474b,_0xcc476d),function(_0x57eda4){_0x57eda4[_0x5ad1('0x4e')]=_0x31028b['id'];_0x57eda4[_0x5ad1('0x5e')]=_0x2d474b['id'];return _0x57eda4;});return db[_0x5ad1('0x4d')][_0x5ad1('0x5f')](_0x37cebe,{'transaction':_0x27a1f9})[_0x5ad1('0x24')](function(_0x328df9){if(!_0x328df9){return _0x3b9352(_0x5ad1('0x60'));}else{return _0x366d8a(_0x328df9);}})[_0x5ad1('0x48')](function(_0x222e34){return _0x3b9352(_0x222e34);});});;});};function addVoicePrefixExtensions(_0x2dd135,_0x1aac71){var _0x417def=[];var _0x18e71e=formatPrefixName(_0x2dd135[_0x5ad1('0x5b')]);_0x417def[_0x5ad1('0x61')](new Extension(_0x18e71e,0x2,'Set','CDR(prefix)='+_0x2dd135[_0x5ad1('0x2a')]));if(_0x2dd135[_0x5ad1('0x62')]){_0x417def[_0x5ad1('0x61')](new Extension(_0x18e71e,0x3,_0x5ad1('0x63'),_0x5ad1('0x64')+_0x2dd135[_0x5ad1('0x62')]));}else{_0x417def['push'](new Extension(_0x18e71e,0x3,_0x5ad1('0x5c'),_0x5ad1('0x65')));}_0x417def['push'](new Extension(_0x18e71e,0x4,_0x5ad1('0x66'),_0x1aac71['context']+','+_0x5ad1('0x67')+(0x8+_0x2dd135['name']['length'])+'}'+','+0x1));return _0x417def;}function formatPrefixName(_0x3bd997){var _0x55eac9='_';for(var _0x36e221=0x0;_0x36e221<_0x3bd997['length'];_0x36e221++){if(_0x3bd997[_0x5ad1('0x68')](_0x36e221)=='-'){_0x55eac9+=_0x3bd997[_0x5ad1('0x68')](_0x36e221);}else{_0x55eac9+='['+_0x3bd997[_0x5ad1('0x68')](_0x36e221)+']';}}_0x55eac9+='.';return _0x55eac9;}exports[_0x5ad1('0x23')]=function(_0x7aa67b,_0x390b31,_0x15b883){var _0x163cc0=_0x7aa67b[_0x5ad1('0x69')];_0x163cc0[_0x5ad1('0x5b')]=_0x5ad1('0x6a')+_0x163cc0[_0x5ad1('0x2a')]+'-';return db[_0x5ad1('0x6b')][_0x5ad1('0x4b')](function(_0x2bb08a){return db[_0x5ad1('0x2e')][_0x5ad1('0x23')](_0x163cc0,{'where':{'id':_0x163cc0['id']},'transaction':_0x2bb08a})[_0x5ad1('0x24')](function(){return db['VoiceExtension'][_0x5ad1('0x25')]({'where':{'VoicePrefixId':_0x163cc0['id']},'transaction':_0x2bb08a})[_0x5ad1('0x24')](function(){return db[_0x5ad1('0x4d')]['find']({'where':{'id':_0x163cc0[_0x5ad1('0x4e')]},'raw':!![]})['then'](function(_0x4d5dc7){return createVoicePrefixExtensions(_0x163cc0,_0x4d5dc7,_0x2bb08a);});});});})[_0x5ad1('0x24')](function(){return db[_0x5ad1('0x2e')]['findById'](_0x163cc0['id']);})[_0x5ad1('0x24')](respondWithResult(_0x390b31,null))[_0x5ad1('0x48')](handleError(_0x390b31,null));};exports[_0x5ad1('0x6c')]=function(_0x17bdb2,_0x297c31,_0x4c8b08){return db[_0x5ad1('0x2e')][_0x5ad1('0x46')]({'where':{'id':_0x17bdb2['params']['id']}})[_0x5ad1('0x24')](handleEntityNotFound(_0x297c31,null))[_0x5ad1('0x24')](function(_0x5580de){if(_0x5580de){return _0x5580de['addAgents'](_0x17bdb2[_0x5ad1('0x69')]['ids'],_['omit'](_0x17bdb2[_0x5ad1('0x69')],[_0x5ad1('0x6d'),'id'])||{})[_0x5ad1('0x6e')](function(_0x5ae4c9){for(var _0x1827b5=0x0;_0x1827b5<_0x17bdb2[_0x5ad1('0x69')][_0x5ad1('0x6d')][_0x5ad1('0x38')];_0x1827b5+=0x1){socket[_0x5ad1('0x6f')]('userVoicePrefix:save',{'UserId':_0x17bdb2['body'][_0x5ad1('0x6d')][_0x1827b5],'VoicePrefixId':_0x17bdb2['params']['id']});}return _0x5ae4c9;});}})[_0x5ad1('0x24')](respondWithResult(_0x297c31,null))[_0x5ad1('0x48')](handleError(_0x297c31,null));};exports['removeAgents']=function(_0x1a44eb,_0x1e6454,_0x3399ac){return db[_0x5ad1('0x2e')][_0x5ad1('0x46')]({'where':{'id':_0x1a44eb['params']['id']}})[_0x5ad1('0x24')](handleEntityNotFound(_0x1e6454,null))[_0x5ad1('0x24')](function(_0x389788){if(_0x389788){return _0x389788['removeAgents'](_0x1a44eb['query']['ids'])[_0x5ad1('0x24')](function(){if(_[_0x5ad1('0x70')](_0x1a44eb[_0x5ad1('0x33')]['ids'])){for(var _0x46406c=0x0;_0x46406c<_0x1a44eb[_0x5ad1('0x33')]['ids']['length'];_0x46406c+=0x1){socket[_0x5ad1('0x6f')]('userVoicePrefix:remove',{'UserId':Number(_0x1a44eb['query']['ids'][_0x46406c]),'VoicePrefixId':Number(_0x1a44eb['params']['id'])});}}else{socket[_0x5ad1('0x6f')](_0x5ad1('0x71'),{'UserId':Number(_0x1a44eb[_0x5ad1('0x33')][_0x5ad1('0x6d')]),'VoicePrefixId':Number(_0x1a44eb[_0x5ad1('0x47')]['id'])});}});}})['then'](respondWithStatusCode(_0x1e6454,null))[_0x5ad1('0x48')](handleError(_0x1e6454,null));};exports['getAgents']=function(_0x1c84b8,_0x536cf0,_0x23866f){var _0x3da6ff={};var _0xe304e1={};var _0x1f6d5b;var _0x531509;return db['VoicePrefix'][_0x5ad1('0x72')]({'where':{'id':_0x1c84b8['params']['id']}})[_0x5ad1('0x24')](handleEntityNotFound(_0x536cf0,null))[_0x5ad1('0x24')](function(_0x50bc50){if(_0x50bc50){_0x1f6d5b=_0x50bc50;_0xe304e1[_0x5ad1('0x32')]=_[_0x5ad1('0x44')](db['User'][_0x5ad1('0x2f')]);_0xe304e1[_0x5ad1('0x33')]=_[_0x5ad1('0x44')](_0x1c84b8[_0x5ad1('0x33')]);_0xe304e1[_0x5ad1('0x34')]=_[_0x5ad1('0x36')](_0xe304e1['model'],_0xe304e1['query']);_0x3da6ff['attributes']=_[_0x5ad1('0x36')](_0xe304e1['model'],qs['fields'](_0x1c84b8[_0x5ad1('0x33')][_0x5ad1('0x37')]));_0x3da6ff[_0x5ad1('0x35')]=_0x3da6ff[_0x5ad1('0x35')][_0x5ad1('0x38')]?_0x3da6ff[_0x5ad1('0x35')]:_0xe304e1[_0x5ad1('0x32')];_0x3da6ff[_0x5ad1('0x73')]=qs[_0x5ad1('0x3a')](_0x1c84b8['query']['sort']);_0x3da6ff[_0x5ad1('0x3b')]=qs[_0x5ad1('0x34')](_[_0x5ad1('0x3c')](_0x1c84b8[_0x5ad1('0x33')],_0xe304e1[_0x5ad1('0x34')]));if(_0x1c84b8[_0x5ad1('0x33')][_0x5ad1('0x3e')]){_0x3da6ff[_0x5ad1('0x3b')]=_[_0x5ad1('0x3f')](_0x3da6ff[_0x5ad1('0x3b')],{'$or':_[_0x5ad1('0x2d')](_0x3da6ff[_0x5ad1('0x35')],function(_0x2db5da){var _0x5cf283={};_0x5cf283[_0x2db5da]={'$like':'%'+_0x1c84b8[_0x5ad1('0x33')][_0x5ad1('0x3e')]+'%'};return _0x5cf283;})});}_0x3da6ff=_[_0x5ad1('0x3f')]({},_0x3da6ff,_0x1c84b8['options']);return _0x1f6d5b[_0x5ad1('0x74')](_0x3da6ff);}})[_0x5ad1('0x24')](function(_0x402e67){if(_0x402e67){_0x531509=_0x402e67[_0x5ad1('0x38')];if(!_0x1c84b8[_0x5ad1('0x33')][_0x5ad1('0x75')](_0x5ad1('0x39'))){_0x3da6ff['limit']=qs[_0x5ad1('0x1e')](_0x1c84b8['query']['limit']);_0x3da6ff[_0x5ad1('0x1d')]=qs[_0x5ad1('0x1d')](_0x1c84b8['query'][_0x5ad1('0x1d')]);}return _0x1f6d5b[_0x5ad1('0x74')](_0x3da6ff);}})[_0x5ad1('0x24')](function(_0x2617ac){if(_0x2617ac){return _0x2617ac?{'count':_0x531509,'rows':_0x2617ac}:null;}})[_0x5ad1('0x24')](respondWithResult(_0x536cf0,null))[_0x5ad1('0x48')](handleError(_0x536cf0,null));};
\ No newline at end of file
+var _0xf493=['removeAgents','userVoicePrefix:remove','getAgents','findOne','User','pick','html-pdf','eml-format','zip-dir','fast-json-patch','bluebird','mustache','util','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','redis','defaults','localhost','socket.io-emitter','./voicePrefix.socket','register','status','end','json','count','offset','limit','Content-Range','reject','save','then','destroy','get','UserProfileResource','sendStatus','stack','name','send','index','map','VoicePrefix','rawAttributes','type','key','keys','query','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','filter','where','VIRTUAL','merge','includeAll','include','findAll','rows','catch','show','params','length','options','find','describe','create','transaction','VoiceExtension','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','VoicePrefixes','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','context','from-sip','exten','system','description','priority','appdata','prefix','NoOp','Voice\x20Prefix','VoicePrefixId','VoiceExtensionId','Extensions\x20creation\x20failed','push','Set','CDR(prefix)=','callerIdAll','No\x20callerid\x20available','goto','charAt','update','body','system-','addAgents','ids','spread','emit'];(function(_0x529266,_0x539d07){var _0x23fec2=function(_0x2996ad){while(--_0x2996ad){_0x529266['push'](_0x529266['shift']());}};_0x23fec2(++_0x539d07);}(_0xf493,0x1ea));var _0x3f49=function(_0x3bd82a,_0x5bde5b){_0x3bd82a=_0x3bd82a-0x0;var _0x480b2d=_0xf493[_0x3bd82a];return _0x480b2d;};'use strict';var pdf=require(_0x3f49('0x0'));var emlformat=require(_0x3f49('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x3f49('0x2'));var jsonpatch=require(_0x3f49('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x3f49('0x4'));var Mustache=require(_0x3f49('0x5'));var util=require(_0x3f49('0x6'));var path=require('path');var sox=require(_0x3f49('0x7'));var csv=require(_0x3f49('0x8'));var ejs=require(_0x3f49('0x9'));var fs=require('fs');var _=require(_0x3f49('0xa'));var squel=require('squel');var crypto=require(_0x3f49('0xb'));var jsforce=require(_0x3f49('0xc'));var deskjs=require(_0x3f49('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x3f49('0xe'));var Redis=require(_0x3f49('0xf'));var authService=require(_0x3f49('0x10'));var qs=require(_0x3f49('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x3f49('0x12'));var logger=require(_0x3f49('0x13'))('api');var utils=require(_0x3f49('0x14'));var config=require(_0x3f49('0x15'));var db=require('../../mysqldb')['db'];config[_0x3f49('0x16')]=_[_0x3f49('0x17')](config[_0x3f49('0x16')],{'host':_0x3f49('0x18'),'port':0x18eb});var socket=require(_0x3f49('0x19'))(new Redis(config[_0x3f49('0x16')]));require(_0x3f49('0x1a'))[_0x3f49('0x1b')](socket);function respondWithStatusCode(_0x7b6810,_0x1500f9){_0x1500f9=_0x1500f9||0xcc;return function(_0x38c1c8){if(_0x38c1c8){return _0x7b6810['sendStatus'](_0x1500f9);}return _0x7b6810[_0x3f49('0x1c')](_0x1500f9)[_0x3f49('0x1d')]();};}function respondWithResult(_0x310f30,_0x1e3e93){_0x1e3e93=_0x1e3e93||0xc8;return function(_0x1190d2){if(_0x1190d2){return _0x310f30[_0x3f49('0x1c')](_0x1e3e93)[_0x3f49('0x1e')](_0x1190d2);}};}function respondWithFilteredResult(_0x303d03,_0x514035){return function(_0x294d90){if(_0x294d90){var _0x17b082=_0x294d90[_0x3f49('0x1f')],_0x5f2da4=_0x514035[_0x3f49('0x20')],_0x4f7995=_0x514035['offset']+_0x514035[_0x3f49('0x21')],_0x458233;if(_0x4f7995>=_0x17b082){_0x4f7995=_0x17b082;_0x458233=0xc8;}else{_0x458233=0xce;}_0x303d03['status'](_0x458233);return _0x303d03['set'](_0x3f49('0x22'),_0x5f2da4+'-'+_0x4f7995+'/'+_0x17b082)[_0x3f49('0x1e')](_0x294d90);}return null;};}function patchUpdates(_0x3f2f1c){return function(_0x30c8b1){try{jsonpatch['apply'](_0x30c8b1,_0x3f2f1c,!![]);}catch(_0x109055){return BPromise[_0x3f49('0x23')](_0x109055);}return _0x30c8b1[_0x3f49('0x24')]();};}function saveUpdates(_0x2ee4fe,_0x4d2108){return function(_0x5dd4e3){if(_0x5dd4e3){return _0x5dd4e3['update'](_0x2ee4fe)[_0x3f49('0x25')](function(_0x272ca2){return _0x272ca2;});}return null;};}function removeEntity(_0xa6c725,_0xffa9a6){return function(_0x196ccb){if(_0x196ccb){return _0x196ccb[_0x3f49('0x26')]()['then'](function(){var _0x1c38b1=_0x196ccb[_0x3f49('0x27')]({'plain':!![]});var _0xd8935e='VoicePrefixes';return db[_0x3f49('0x28')][_0x3f49('0x26')]({'where':{'type':_0xd8935e,'resourceId':_0x1c38b1['id']}})['then'](function(){return _0x196ccb;});})[_0x3f49('0x25')](function(){_0xa6c725[_0x3f49('0x1c')](0xcc)[_0x3f49('0x1d')]();});}};}function handleEntityNotFound(_0x103fd1,_0x2dd9ca){return function(_0x3a0bfd){if(!_0x3a0bfd){_0x103fd1[_0x3f49('0x29')](0x194);}return _0x3a0bfd;};}function handleError(_0x26c919,_0x36f4c6){_0x36f4c6=_0x36f4c6||0x1f4;return function(_0x518b16){logger['error'](_0x518b16[_0x3f49('0x2a')]);if(_0x518b16[_0x3f49('0x2b')]){delete _0x518b16[_0x3f49('0x2b')];}_0x26c919[_0x3f49('0x1c')](_0x36f4c6)[_0x3f49('0x2c')](_0x518b16);};}exports[_0x3f49('0x2d')]=function(_0x48c4e0,_0x3b804e){var _0x42084a={},_0x55fcd5={},_0x3184b0={'count':0x0,'rows':[]};var _0x146c91=_[_0x3f49('0x2e')](db[_0x3f49('0x2f')][_0x3f49('0x30')],function(_0x504afc){return{'name':_0x504afc['fieldName'],'type':_0x504afc[_0x3f49('0x31')][_0x3f49('0x32')]};});_0x55fcd5['model']=_[_0x3f49('0x2e')](_0x146c91,_0x3f49('0x2b'));_0x55fcd5['query']=_[_0x3f49('0x33')](_0x48c4e0[_0x3f49('0x34')]);_0x55fcd5[_0x3f49('0x35')]=_[_0x3f49('0x36')](_0x55fcd5[_0x3f49('0x37')],_0x55fcd5['query']);_0x42084a[_0x3f49('0x38')]=_[_0x3f49('0x36')](_0x55fcd5[_0x3f49('0x37')],qs[_0x3f49('0x39')](_0x48c4e0[_0x3f49('0x34')][_0x3f49('0x39')]));_0x42084a[_0x3f49('0x38')]=_0x42084a[_0x3f49('0x38')]['length']?_0x42084a[_0x3f49('0x38')]:_0x55fcd5['model'];if(!_0x48c4e0[_0x3f49('0x34')][_0x3f49('0x3a')](_0x3f49('0x3b'))){_0x42084a[_0x3f49('0x21')]=qs[_0x3f49('0x21')](_0x48c4e0['query']['limit']);_0x42084a[_0x3f49('0x20')]=qs['offset'](_0x48c4e0[_0x3f49('0x34')][_0x3f49('0x20')]);}_0x42084a[_0x3f49('0x3c')]=qs[_0x3f49('0x3d')](_0x48c4e0[_0x3f49('0x34')][_0x3f49('0x3d')]);_0x42084a['where']=qs[_0x3f49('0x35')](_['pick'](_0x48c4e0[_0x3f49('0x34')],_0x55fcd5[_0x3f49('0x35')]),_0x146c91);if(_0x48c4e0[_0x3f49('0x34')][_0x3f49('0x3e')]){_0x42084a[_0x3f49('0x3f')]=_['merge'](_0x42084a['where'],{'$or':_[_0x3f49('0x2e')](_0x146c91,function(_0x356bd7){if(_0x356bd7['type']!==_0x3f49('0x40')){var _0x2dd68f={};_0x2dd68f[_0x356bd7[_0x3f49('0x2b')]]={'$like':'%'+_0x48c4e0[_0x3f49('0x34')][_0x3f49('0x3e')]+'%'};return _0x2dd68f;}})});}_0x42084a=_[_0x3f49('0x41')]({},_0x42084a,_0x48c4e0['options']);var _0x289d66={'where':_0x42084a['where']};return db[_0x3f49('0x2f')][_0x3f49('0x1f')](_0x289d66)[_0x3f49('0x25')](function(_0x488875){_0x3184b0[_0x3f49('0x1f')]=_0x488875;if(_0x48c4e0[_0x3f49('0x34')][_0x3f49('0x42')]){_0x42084a[_0x3f49('0x43')]=[{'all':!![]}];}return db[_0x3f49('0x2f')][_0x3f49('0x44')](_0x42084a);})[_0x3f49('0x25')](function(_0x181b80){_0x3184b0[_0x3f49('0x45')]=_0x181b80;return _0x3184b0;})[_0x3f49('0x25')](respondWithFilteredResult(_0x3b804e,_0x42084a))[_0x3f49('0x46')](handleError(_0x3b804e,null));};exports[_0x3f49('0x47')]=function(_0x4d3d93,_0x532589){var _0x7db6c0={'raw':![],'where':{'id':_0x4d3d93[_0x3f49('0x48')]['id']}},_0x535d98={};_0x535d98[_0x3f49('0x37')]=_['keys'](db['VoicePrefix']['rawAttributes']);_0x535d98['query']=_[_0x3f49('0x33')](_0x4d3d93['query']);_0x535d98[_0x3f49('0x35')]=_[_0x3f49('0x36')](_0x535d98[_0x3f49('0x37')],_0x535d98[_0x3f49('0x34')]);_0x7db6c0[_0x3f49('0x38')]=_[_0x3f49('0x36')](_0x535d98[_0x3f49('0x37')],qs[_0x3f49('0x39')](_0x4d3d93[_0x3f49('0x34')][_0x3f49('0x39')]));_0x7db6c0[_0x3f49('0x38')]=_0x7db6c0[_0x3f49('0x38')][_0x3f49('0x49')]?_0x7db6c0[_0x3f49('0x38')]:_0x535d98[_0x3f49('0x37')];if(_0x4d3d93[_0x3f49('0x34')]['includeAll']){_0x7db6c0[_0x3f49('0x43')]=[{'all':!![]}];}_0x7db6c0=_[_0x3f49('0x41')]({},_0x7db6c0,_0x4d3d93[_0x3f49('0x4a')]);return db['VoicePrefix'][_0x3f49('0x4b')](_0x7db6c0)[_0x3f49('0x25')](handleEntityNotFound(_0x532589,null))[_0x3f49('0x25')](respondWithResult(_0x532589,null))[_0x3f49('0x46')](handleError(_0x532589,null));};exports['destroy']=function(_0x22bf8d,_0x286e49){return db[_0x3f49('0x2f')][_0x3f49('0x4b')]({'where':{'id':_0x22bf8d[_0x3f49('0x48')]['id']}})[_0x3f49('0x25')](handleEntityNotFound(_0x286e49,null))[_0x3f49('0x25')](removeEntity(_0x286e49,null))[_0x3f49('0x46')](handleError(_0x286e49,null));};exports['describe']=function(_0x354d97,_0x1f5486){return db[_0x3f49('0x2f')][_0x3f49('0x4c')]()['then'](respondWithResult(_0x1f5486,null))[_0x3f49('0x46')](handleError(_0x1f5486,null));};exports[_0x3f49('0x4d')]=function(_0x3b7977,_0x35600d){var _0x1a0c32;return db['sequelize'][_0x3f49('0x4e')](function(_0x16010f){return db['VoicePrefix'][_0x3f49('0x4d')](_0x3b7977['body'],{'transaction':_0x16010f})[_0x3f49('0x25')](function(_0x5ab8b2){_0x1a0c32=_0x5ab8b2['get']({'plain':!![]});return db[_0x3f49('0x4f')][_0x3f49('0x4b')]({'where':{'id':_0x1a0c32['VoiceExtensionId']},'raw':!![]})['then'](function(_0x40d187){return createVoicePrefixExtensions(_0x1a0c32,_0x40d187,_0x16010f);});});})[_0x3f49('0x25')](function(){var _0x49e2fc=_0x3b7977[_0x3f49('0x50')]['get']({'plain':!![]});if(!_0x49e2fc)throw new Error(_0x3f49('0x51'));if(_0x49e2fc[_0x3f49('0x52')]===_0x3f49('0x50')){var _0x56b2a=_0x1a0c32;return db[_0x3f49('0x53')][_0x3f49('0x4b')]({'where':{'name':_0x3f49('0x54'),'userProfileId':_0x49e2fc['userProfileId']},'raw':!![]})[_0x3f49('0x25')](function(_0x44fddd){if(_0x44fddd&&_0x44fddd[_0x3f49('0x55')]===0x0){return db[_0x3f49('0x28')][_0x3f49('0x4d')]({'name':_0x56b2a[_0x3f49('0x2b')],'resourceId':_0x56b2a['id'],'type':_0x44fddd[_0x3f49('0x2b')],'sectionId':_0x44fddd['id']},{})[_0x3f49('0x25')](function(){return _0x1a0c32;});}else{return _0x1a0c32;}})['catch'](function(_0x2d491f){logger[_0x3f49('0x56')](_0x3f49('0x57'),_0x2d491f);throw _0x2d491f;});}return _0x1a0c32;})[_0x3f49('0x25')](respondWithResult(_0x35600d,null))[_0x3f49('0x46')](handleError(_0x35600d,null));};function Extension(_0x462f38,_0x56cf16,_0x138047,_0x461275){this[_0x3f49('0x58')]=_0x3f49('0x59');this[_0x3f49('0x5a')]=_0x462f38;this['app']=_0x138047;this[_0x3f49('0x31')]=_0x3f49('0x5b');this[_0x3f49('0x5c')]='Voice\x20Prefix\x20Extension';this[_0x3f49('0x5d')]=_0x56cf16;this[_0x3f49('0x5e')]=_0x461275;}function createVoicePrefixExtensions(_0x3222ad,_0xcd2420,_0x1ae41c){return new BPromise(function(_0x188737,_0x5be99a){var _0x772537=new Extension(formatPrefixName(_0x3222ad[_0x3f49('0x5f')]),0x1,_0x3f49('0x60'),_0x3f49('0x61'));_0x772537[_0x3f49('0x62')]=_0x3222ad['id'];return db[_0x3f49('0x4f')]['create'](_0x772537,{'transaction':_0x1ae41c})[_0x3f49('0x25')](function(_0x42dbed){var _0x38104e=_0x42dbed[_0x3f49('0x27')]({'plain':!![]});var _0x2764b4=_['map'](addVoicePrefixExtensions(_0x3222ad,_0xcd2420),function(_0x1d9057){_0x1d9057[_0x3f49('0x63')]=_0x38104e['id'];_0x1d9057[_0x3f49('0x62')]=_0x3222ad['id'];return _0x1d9057;});return db['VoiceExtension']['bulkCreate'](_0x2764b4,{'transaction':_0x1ae41c})[_0x3f49('0x25')](function(_0x3280cd){if(!_0x3280cd){return _0x5be99a(_0x3f49('0x64'));}else{return _0x188737(_0x3280cd);}})[_0x3f49('0x46')](function(_0x1404ae){return _0x5be99a(_0x1404ae);});});;});};function addVoicePrefixExtensions(_0x5b1d00,_0x27c2c4){var _0x26b6c7=[];var _0x5b24e0=formatPrefixName(_0x5b1d00[_0x3f49('0x5f')]);_0x26b6c7[_0x3f49('0x65')](new Extension(_0x5b24e0,0x2,_0x3f49('0x66'),_0x3f49('0x67')+_0x5b1d00[_0x3f49('0x2b')]));if(_0x5b1d00['callerIdAll']){_0x26b6c7[_0x3f49('0x65')](new Extension(_0x5b24e0,0x3,'Set','PREFIX-CALLERIDALL='+_0x5b1d00[_0x3f49('0x68')]));}else{_0x26b6c7['push'](new Extension(_0x5b24e0,0x3,_0x3f49('0x60'),_0x3f49('0x69')));}_0x26b6c7[_0x3f49('0x65')](new Extension(_0x5b24e0,0x4,_0x3f49('0x6a'),_0x27c2c4[_0x3f49('0x58')]+','+'${EXTEN:'+(0x8+_0x5b1d00[_0x3f49('0x2b')]['length'])+'}'+','+0x1));return _0x26b6c7;}function formatPrefixName(_0x5354e4){var _0x4c1285='_';for(var _0x1d5697=0x0;_0x1d5697<_0x5354e4['length'];_0x1d5697++){if(_0x5354e4[_0x3f49('0x6b')](_0x1d5697)=='-'){_0x4c1285+=_0x5354e4[_0x3f49('0x6b')](_0x1d5697);}else{_0x4c1285+='['+_0x5354e4[_0x3f49('0x6b')](_0x1d5697)+']';}}_0x4c1285+='.';return _0x4c1285;}exports[_0x3f49('0x6c')]=function(_0x31fde4,_0x566fe1,_0x4c5aeb){var _0x2e5490=_0x31fde4[_0x3f49('0x6d')];_0x2e5490['prefix']=_0x3f49('0x6e')+_0x2e5490['name']+'-';return db['sequelize'][_0x3f49('0x4e')](function(_0x59cc1c){return db['VoicePrefix'][_0x3f49('0x6c')](_0x2e5490,{'where':{'id':_0x2e5490['id']},'transaction':_0x59cc1c})['then'](function(){return db['VoiceExtension'][_0x3f49('0x26')]({'where':{'VoicePrefixId':_0x2e5490['id']},'transaction':_0x59cc1c})[_0x3f49('0x25')](function(){return db[_0x3f49('0x4f')][_0x3f49('0x4b')]({'where':{'id':_0x2e5490[_0x3f49('0x63')]},'raw':!![]})[_0x3f49('0x25')](function(_0x288a77){return createVoicePrefixExtensions(_0x2e5490,_0x288a77,_0x59cc1c);});});});})[_0x3f49('0x25')](function(){return db[_0x3f49('0x2f')]['findById'](_0x2e5490['id']);})[_0x3f49('0x25')](respondWithResult(_0x566fe1,null))[_0x3f49('0x46')](handleError(_0x566fe1,null));};exports[_0x3f49('0x6f')]=function(_0x3739cf,_0x24fff8,_0x596969){return db[_0x3f49('0x2f')]['find']({'where':{'id':_0x3739cf[_0x3f49('0x48')]['id']}})[_0x3f49('0x25')](handleEntityNotFound(_0x24fff8,null))[_0x3f49('0x25')](function(_0x5f15c6){if(_0x5f15c6){return _0x5f15c6['addAgents'](_0x3739cf[_0x3f49('0x6d')][_0x3f49('0x70')],_['omit'](_0x3739cf['body'],[_0x3f49('0x70'),'id'])||{})[_0x3f49('0x71')](function(_0x5f3ea5){for(var _0x528f48=0x0;_0x528f48<_0x3739cf['body'][_0x3f49('0x70')][_0x3f49('0x49')];_0x528f48+=0x1){socket[_0x3f49('0x72')]('userVoicePrefix:save',{'UserId':_0x3739cf['body']['ids'][_0x528f48],'VoicePrefixId':_0x3739cf[_0x3f49('0x48')]['id']});}return _0x5f3ea5;});}})['then'](respondWithResult(_0x24fff8,null))[_0x3f49('0x46')](handleError(_0x24fff8,null));};exports[_0x3f49('0x73')]=function(_0x167e7f,_0x5ddcdd,_0x105df1){return db[_0x3f49('0x2f')][_0x3f49('0x4b')]({'where':{'id':_0x167e7f['params']['id']}})[_0x3f49('0x25')](handleEntityNotFound(_0x5ddcdd,null))['then'](function(_0x52cce2){if(_0x52cce2){return _0x52cce2['removeAgents'](_0x167e7f['query']['ids'])[_0x3f49('0x25')](function(){if(_['isArray'](_0x167e7f['query'][_0x3f49('0x70')])){for(var _0x212005=0x0;_0x212005<_0x167e7f[_0x3f49('0x34')][_0x3f49('0x70')][_0x3f49('0x49')];_0x212005+=0x1){socket[_0x3f49('0x72')](_0x3f49('0x74'),{'UserId':Number(_0x167e7f[_0x3f49('0x34')][_0x3f49('0x70')][_0x212005]),'VoicePrefixId':Number(_0x167e7f[_0x3f49('0x48')]['id'])});}}else{socket['emit'](_0x3f49('0x74'),{'UserId':Number(_0x167e7f[_0x3f49('0x34')][_0x3f49('0x70')]),'VoicePrefixId':Number(_0x167e7f[_0x3f49('0x48')]['id'])});}});}})[_0x3f49('0x25')](respondWithStatusCode(_0x5ddcdd,null))[_0x3f49('0x46')](handleError(_0x5ddcdd,null));};exports[_0x3f49('0x75')]=function(_0x4a1b40,_0x1aad3e,_0x1fbc0f){var _0x46c440={};var _0x309310={};var _0x4c9dd9;var _0x455bfd;return db[_0x3f49('0x2f')][_0x3f49('0x76')]({'where':{'id':_0x4a1b40[_0x3f49('0x48')]['id']}})[_0x3f49('0x25')](handleEntityNotFound(_0x1aad3e,null))['then'](function(_0x59a142){if(_0x59a142){_0x4c9dd9=_0x59a142;_0x309310['model']=_[_0x3f49('0x33')](db[_0x3f49('0x77')][_0x3f49('0x30')]);_0x309310[_0x3f49('0x34')]=_[_0x3f49('0x33')](_0x4a1b40['query']);_0x309310['filters']=_[_0x3f49('0x36')](_0x309310[_0x3f49('0x37')],_0x309310[_0x3f49('0x34')]);_0x46c440[_0x3f49('0x38')]=_[_0x3f49('0x36')](_0x309310[_0x3f49('0x37')],qs[_0x3f49('0x39')](_0x4a1b40['query'][_0x3f49('0x39')]));_0x46c440[_0x3f49('0x38')]=_0x46c440[_0x3f49('0x38')][_0x3f49('0x49')]?_0x46c440[_0x3f49('0x38')]:_0x309310[_0x3f49('0x37')];_0x46c440['order']=qs[_0x3f49('0x3d')](_0x4a1b40[_0x3f49('0x34')][_0x3f49('0x3d')]);_0x46c440[_0x3f49('0x3f')]=qs[_0x3f49('0x35')](_[_0x3f49('0x78')](_0x4a1b40[_0x3f49('0x34')],_0x309310[_0x3f49('0x35')]));if(_0x4a1b40[_0x3f49('0x34')][_0x3f49('0x3e')]){_0x46c440[_0x3f49('0x3f')]=_[_0x3f49('0x41')](_0x46c440['where'],{'$or':_[_0x3f49('0x2e')](_0x46c440[_0x3f49('0x38')],function(_0x11feda){var _0x3a501c={};_0x3a501c[_0x11feda]={'$like':'%'+_0x4a1b40[_0x3f49('0x34')]['filter']+'%'};return _0x3a501c;})});}_0x46c440=_[_0x3f49('0x41')]({},_0x46c440,_0x4a1b40[_0x3f49('0x4a')]);return _0x4c9dd9['getAgents'](_0x46c440);}})['then'](function(_0x5494a2){if(_0x5494a2){_0x455bfd=_0x5494a2['length'];if(!_0x4a1b40['query']['hasOwnProperty'](_0x3f49('0x3b'))){_0x46c440[_0x3f49('0x21')]=qs['limit'](_0x4a1b40[_0x3f49('0x34')][_0x3f49('0x21')]);_0x46c440[_0x3f49('0x20')]=qs[_0x3f49('0x20')](_0x4a1b40[_0x3f49('0x34')][_0x3f49('0x20')]);}return _0x4c9dd9[_0x3f49('0x75')](_0x46c440);}})[_0x3f49('0x25')](function(_0xd4299c){if(_0xd4299c){return _0xd4299c?{'count':_0x455bfd,'rows':_0xd4299c}:null;}})[_0x3f49('0x25')](respondWithResult(_0x1aad3e,null))['catch'](handleError(_0x1aad3e,null));};
\ No newline at end of file