Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / voicePrefix / voicePrefix.controller.js
index 8b9e88d..4fd8247 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf1c6=['transaction','findById','addAgents','ids','omit','userVoicePrefix:remove','getAgents','User','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','lodash','squel','crypto','jsforce','desk.js','to-csv','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','./voicePrefix.socket','sendStatus','status','end','json','count','offset','limit','Content-Range','apply','save','then','destroy','get','VoicePrefixes','UserProfileResource','stack','name','index','map','rawAttributes','fieldName','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','includeAll','include','VoicePrefix','findAll','catch','show','params','options','find','describe','create','sequelize','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','error','context','from-sip','exten','app','system','Voice\x20Prefix\x20Extension','appdata','prefix','Voice\x20Prefix','VoicePrefixId','VoiceExtension','VoiceExtensionId','bulkCreate','Extensions\x20creation\x20failed','CDR(prefix)=','callerIdAll','push','Set','NoOp','goto','charAt','update'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xf1c6,0xf4));var _0x6f1c=function(_0xfe00bd,_0x4c9578){_0xfe00bd=_0xfe00bd-0x0;var _0x50e3ee=_0xf1c6[_0xfe00bd];return _0x50e3ee;};'use strict';var pdf=require(_0x6f1c('0x0'));var emlformat=require(_0x6f1c('0x1'));var rimraf=require(_0x6f1c('0x2'));var zipdir=require(_0x6f1c('0x3'));var jsonpatch=require(_0x6f1c('0x4'));var rp=require(_0x6f1c('0x5'));var moment=require(_0x6f1c('0x6'));var BPromise=require('bluebird');var Mustache=require(_0x6f1c('0x7'));var util=require(_0x6f1c('0x8'));var path=require(_0x6f1c('0x9'));var sox=require(_0x6f1c('0xa'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x6f1c('0xb'));var squel=require(_0x6f1c('0xc'));var crypto=require(_0x6f1c('0xd'));var jsforce=require(_0x6f1c('0xe'));var deskjs=require(_0x6f1c('0xf'));var toCsv=require(_0x6f1c('0x10'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x6f1c('0x11'));var authService=require(_0x6f1c('0x12'));var qs=require(_0x6f1c('0x13'));var as=require(_0x6f1c('0x14'));var hardwareService=require(_0x6f1c('0x15'));var logger=require(_0x6f1c('0x16'))('api');var utils=require(_0x6f1c('0x17'));var config=require(_0x6f1c('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0x6f1c('0x19'))['db'];config['redis']=_['defaults'](config[_0x6f1c('0x1a')],{'host':_0x6f1c('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x6f1c('0x1c'))['register'](socket);function respondWithStatusCode(_0x206ed5,_0xb36b41){_0xb36b41=_0xb36b41||0xcc;return function(_0x14c412){if(_0x14c412){return _0x206ed5[_0x6f1c('0x1d')](_0xb36b41);}return _0x206ed5[_0x6f1c('0x1e')](_0xb36b41)[_0x6f1c('0x1f')]();};}function respondWithResult(_0xbac2ee,_0x5e953f){_0x5e953f=_0x5e953f||0xc8;return function(_0x2ca612){if(_0x2ca612){return _0xbac2ee['status'](_0x5e953f)[_0x6f1c('0x20')](_0x2ca612);}};}function respondWithFilteredResult(_0x5a0a2d,_0x1d968f){return function(_0x66103a){if(_0x66103a){var _0x5b11ea=_0x66103a[_0x6f1c('0x21')],_0x5475d6=_0x1d968f['offset'],_0x317686=_0x1d968f[_0x6f1c('0x22')]+_0x1d968f[_0x6f1c('0x23')],_0x842773;if(_0x317686>=_0x5b11ea){_0x317686=_0x5b11ea;_0x842773=0xc8;}else{_0x842773=0xce;}_0x5a0a2d[_0x6f1c('0x1e')](_0x842773);return _0x5a0a2d['set'](_0x6f1c('0x24'),_0x5475d6+'-'+_0x317686+'/'+_0x5b11ea)[_0x6f1c('0x20')](_0x66103a);}return null;};}function patchUpdates(_0x27a351){return function(_0x539d59){try{jsonpatch[_0x6f1c('0x25')](_0x539d59,_0x27a351,!![]);}catch(_0xebf430){return BPromise['reject'](_0xebf430);}return _0x539d59[_0x6f1c('0x26')]();};}function saveUpdates(_0x1f7ac2,_0x3fe23a){return function(_0x25e460){if(_0x25e460){return _0x25e460['update'](_0x1f7ac2)[_0x6f1c('0x27')](function(_0xd19a62){return _0xd19a62;});}return null;};}function removeEntity(_0x235773,_0x241ee7){return function(_0xa9c80d){if(_0xa9c80d){return _0xa9c80d[_0x6f1c('0x28')]()['then'](function(){var _0x1ac41=_0xa9c80d[_0x6f1c('0x29')]({'plain':!![]});var _0x2d4236=_0x6f1c('0x2a');return db[_0x6f1c('0x2b')]['destroy']({'where':{'type':_0x2d4236,'resourceId':_0x1ac41['id']}})[_0x6f1c('0x27')](function(){return _0xa9c80d;});})[_0x6f1c('0x27')](function(){_0x235773[_0x6f1c('0x1e')](0xcc)[_0x6f1c('0x1f')]();});}};}function handleEntityNotFound(_0x31e829,_0x145ae9){return function(_0x4d120d){if(!_0x4d120d){_0x31e829['sendStatus'](0x194);}return _0x4d120d;};}function handleError(_0x30ba57,_0x2b3732){_0x2b3732=_0x2b3732||0x1f4;return function(_0x1b5c9a){logger['error'](_0x1b5c9a[_0x6f1c('0x2c')]);if(_0x1b5c9a[_0x6f1c('0x2d')]){delete _0x1b5c9a[_0x6f1c('0x2d')];}_0x30ba57[_0x6f1c('0x1e')](_0x2b3732)['send'](_0x1b5c9a);};}exports[_0x6f1c('0x2e')]=function(_0x11f1f6,_0x5c09ba){var _0x11ac4b={},_0x346c4a={},_0x182f99={'count':0x0,'rows':[]};var _0x5a25ec=_[_0x6f1c('0x2f')](db['VoicePrefix'][_0x6f1c('0x30')],function(_0x2ee3e7){return{'name':_0x2ee3e7[_0x6f1c('0x31')],'type':_0x2ee3e7['type']['key']};});_0x346c4a[_0x6f1c('0x32')]=_[_0x6f1c('0x2f')](_0x5a25ec,_0x6f1c('0x2d'));_0x346c4a[_0x6f1c('0x33')]=_[_0x6f1c('0x34')](_0x11f1f6[_0x6f1c('0x33')]);_0x346c4a[_0x6f1c('0x35')]=_[_0x6f1c('0x36')](_0x346c4a[_0x6f1c('0x32')],_0x346c4a[_0x6f1c('0x33')]);_0x11ac4b[_0x6f1c('0x37')]=_[_0x6f1c('0x36')](_0x346c4a[_0x6f1c('0x32')],qs[_0x6f1c('0x38')](_0x11f1f6[_0x6f1c('0x33')]['fields']));_0x11ac4b[_0x6f1c('0x37')]=_0x11ac4b[_0x6f1c('0x37')][_0x6f1c('0x39')]?_0x11ac4b[_0x6f1c('0x37')]:_0x346c4a['model'];if(!_0x11f1f6[_0x6f1c('0x33')][_0x6f1c('0x3a')](_0x6f1c('0x3b'))){_0x11ac4b[_0x6f1c('0x23')]=qs[_0x6f1c('0x23')](_0x11f1f6[_0x6f1c('0x33')][_0x6f1c('0x23')]);_0x11ac4b['offset']=qs[_0x6f1c('0x22')](_0x11f1f6[_0x6f1c('0x33')][_0x6f1c('0x22')]);}_0x11ac4b[_0x6f1c('0x3c')]=qs[_0x6f1c('0x3d')](_0x11f1f6[_0x6f1c('0x33')][_0x6f1c('0x3d')]);_0x11ac4b[_0x6f1c('0x3e')]=qs[_0x6f1c('0x35')](_[_0x6f1c('0x3f')](_0x11f1f6['query'],_0x346c4a[_0x6f1c('0x35')]),_0x5a25ec);if(_0x11f1f6[_0x6f1c('0x33')][_0x6f1c('0x40')]){_0x11ac4b[_0x6f1c('0x3e')]=_[_0x6f1c('0x41')](_0x11ac4b[_0x6f1c('0x3e')],{'$or':_[_0x6f1c('0x2f')](_0x5a25ec,function(_0x248fc4){if(_0x248fc4[_0x6f1c('0x42')]!==_0x6f1c('0x43')){var _0xcd112e={};_0xcd112e[_0x248fc4['name']]={'$like':'%'+_0x11f1f6[_0x6f1c('0x33')][_0x6f1c('0x40')]+'%'};return _0xcd112e;}})});}_0x11ac4b=_[_0x6f1c('0x41')]({},_0x11ac4b,_0x11f1f6['options']);var _0x4e2754={'where':_0x11ac4b[_0x6f1c('0x3e')]};return db['VoicePrefix']['count'](_0x4e2754)[_0x6f1c('0x27')](function(_0x4f58a7){_0x182f99[_0x6f1c('0x21')]=_0x4f58a7;if(_0x11f1f6['query'][_0x6f1c('0x44')]){_0x11ac4b[_0x6f1c('0x45')]=[{'all':!![]}];}return db[_0x6f1c('0x46')][_0x6f1c('0x47')](_0x11ac4b);})[_0x6f1c('0x27')](function(_0x35203e){_0x182f99['rows']=_0x35203e;return _0x182f99;})[_0x6f1c('0x27')](respondWithFilteredResult(_0x5c09ba,_0x11ac4b))[_0x6f1c('0x48')](handleError(_0x5c09ba,null));};exports[_0x6f1c('0x49')]=function(_0x234d79,_0x1a506b){var _0x307e7e={'raw':![],'where':{'id':_0x234d79[_0x6f1c('0x4a')]['id']}},_0xd61e73={};_0xd61e73[_0x6f1c('0x32')]=_[_0x6f1c('0x34')](db[_0x6f1c('0x46')][_0x6f1c('0x30')]);_0xd61e73['query']=_['keys'](_0x234d79[_0x6f1c('0x33')]);_0xd61e73['filters']=_[_0x6f1c('0x36')](_0xd61e73[_0x6f1c('0x32')],_0xd61e73['query']);_0x307e7e[_0x6f1c('0x37')]=_[_0x6f1c('0x36')](_0xd61e73[_0x6f1c('0x32')],qs['fields'](_0x234d79['query'][_0x6f1c('0x38')]));_0x307e7e[_0x6f1c('0x37')]=_0x307e7e[_0x6f1c('0x37')][_0x6f1c('0x39')]?_0x307e7e['attributes']:_0xd61e73[_0x6f1c('0x32')];if(_0x234d79[_0x6f1c('0x33')][_0x6f1c('0x44')]){_0x307e7e[_0x6f1c('0x45')]=[{'all':!![]}];}_0x307e7e=_[_0x6f1c('0x41')]({},_0x307e7e,_0x234d79[_0x6f1c('0x4b')]);return db['VoicePrefix'][_0x6f1c('0x4c')](_0x307e7e)['then'](handleEntityNotFound(_0x1a506b,null))['then'](respondWithResult(_0x1a506b,null))[_0x6f1c('0x48')](handleError(_0x1a506b,null));};exports['destroy']=function(_0x256ca1,_0x79498){return db[_0x6f1c('0x46')][_0x6f1c('0x4c')]({'where':{'id':_0x256ca1[_0x6f1c('0x4a')]['id']}})[_0x6f1c('0x27')](handleEntityNotFound(_0x79498,null))[_0x6f1c('0x27')](removeEntity(_0x79498,null))[_0x6f1c('0x48')](handleError(_0x79498,null));};exports[_0x6f1c('0x4d')]=function(_0x374bf6,_0x530b9f){return db['VoicePrefix'][_0x6f1c('0x4d')]()[_0x6f1c('0x27')](respondWithResult(_0x530b9f,null))[_0x6f1c('0x48')](handleError(_0x530b9f,null));};exports[_0x6f1c('0x4e')]=function(_0xe29b0c,_0x70c654){var _0x353b50;return db[_0x6f1c('0x4f')]['transaction'](function(_0x2878e7){return db['VoicePrefix']['create'](_0xe29b0c[_0x6f1c('0x50')],{'transaction':_0x2878e7})[_0x6f1c('0x27')](function(_0x4a7244){_0x353b50=_0x4a7244[_0x6f1c('0x29')]({'plain':!![]});return db['VoiceExtension'][_0x6f1c('0x4c')]({'where':{'id':_0x353b50['VoiceExtensionId']},'raw':!![]})[_0x6f1c('0x27')](function(_0x546f05){return createVoicePrefixExtensions(_0x353b50,_0x546f05,_0x2878e7);});});})[_0x6f1c('0x27')](function(){var _0x40c1a7=_0xe29b0c[_0x6f1c('0x51')][_0x6f1c('0x29')]({'plain':!![]});if(!_0x40c1a7)throw new Error(_0x6f1c('0x52'));if(_0x40c1a7[_0x6f1c('0x53')]===_0x6f1c('0x51')){var _0x2397c2=_0x353b50;return db[_0x6f1c('0x54')][_0x6f1c('0x4c')]({'where':{'name':_0x6f1c('0x2a'),'userProfileId':_0x40c1a7[_0x6f1c('0x55')]},'raw':!![]})[_0x6f1c('0x27')](function(_0x567d50){if(_0x567d50&&_0x567d50[_0x6f1c('0x56')]===0x0){return db[_0x6f1c('0x2b')][_0x6f1c('0x4e')]({'name':_0x2397c2[_0x6f1c('0x2d')],'resourceId':_0x2397c2['id'],'type':_0x567d50['name'],'sectionId':_0x567d50['id']},{})[_0x6f1c('0x27')](function(){return _0x353b50;});}else{return _0x353b50;}})['catch'](function(_0x199aad){logger[_0x6f1c('0x57')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x199aad);throw _0x199aad;});}return _0x353b50;})[_0x6f1c('0x27')](respondWithResult(_0x70c654,null))['catch'](handleError(_0x70c654,null));};function Extension(_0xd9e2a2,_0x43b6c1,_0x5ce94a,_0x12d3c9){this[_0x6f1c('0x58')]=_0x6f1c('0x59');this[_0x6f1c('0x5a')]=_0xd9e2a2;this[_0x6f1c('0x5b')]=_0x5ce94a;this['type']=_0x6f1c('0x5c');this['description']=_0x6f1c('0x5d');this['priority']=_0x43b6c1;this[_0x6f1c('0x5e')]=_0x12d3c9;}function createVoicePrefixExtensions(_0x8c47e0,_0x4556a6,_0x2ef7ce){return new BPromise(function(_0x471664,_0x712a6b){var _0x57ebea=new Extension(formatPrefixName(_0x8c47e0[_0x6f1c('0x5f')]),0x1,'NoOp',_0x6f1c('0x60'));_0x57ebea[_0x6f1c('0x61')]=_0x8c47e0['id'];return db[_0x6f1c('0x62')][_0x6f1c('0x4e')](_0x57ebea,{'transaction':_0x2ef7ce})[_0x6f1c('0x27')](function(_0x7baff3){var _0x4694f3=_0x7baff3[_0x6f1c('0x29')]({'plain':!![]});var _0x518bbc=_[_0x6f1c('0x2f')](addVoicePrefixExtensions(_0x8c47e0,_0x4556a6),function(_0x291a3f){_0x291a3f[_0x6f1c('0x63')]=_0x4694f3['id'];_0x291a3f[_0x6f1c('0x61')]=_0x8c47e0['id'];return _0x291a3f;});return db[_0x6f1c('0x62')][_0x6f1c('0x64')](_0x518bbc,{'transaction':_0x2ef7ce})[_0x6f1c('0x27')](function(_0x3f2cea){if(!_0x3f2cea){return _0x712a6b(_0x6f1c('0x65'));}else{return _0x471664(_0x3f2cea);}})[_0x6f1c('0x48')](function(_0x4ee324){return _0x712a6b(_0x4ee324);});});;});};function addVoicePrefixExtensions(_0x49c6ad,_0x23e0e5){var _0x3ed2f0=[];var _0xd36d97=formatPrefixName(_0x49c6ad[_0x6f1c('0x5f')]);_0x3ed2f0['push'](new Extension(_0xd36d97,0x2,'Set',_0x6f1c('0x66')+_0x49c6ad['name']));if(_0x49c6ad[_0x6f1c('0x67')]){_0x3ed2f0[_0x6f1c('0x68')](new Extension(_0xd36d97,0x3,_0x6f1c('0x69'),'PREFIX-CALLERIDALL='+_0x49c6ad[_0x6f1c('0x67')]));}else{_0x3ed2f0[_0x6f1c('0x68')](new Extension(_0xd36d97,0x3,_0x6f1c('0x6a'),'No\x20callerid\x20available'));}_0x3ed2f0['push'](new Extension(_0xd36d97,0x4,_0x6f1c('0x6b'),_0x23e0e5[_0x6f1c('0x58')]+','+'${EXTEN:'+(0x8+_0x49c6ad[_0x6f1c('0x2d')][_0x6f1c('0x39')])+'}'+','+0x1));return _0x3ed2f0;}function formatPrefixName(_0x515374){var _0x5f219a='_';for(var _0x24d863=0x0;_0x24d863<_0x515374[_0x6f1c('0x39')];_0x24d863++){if(_0x515374[_0x6f1c('0x6c')](_0x24d863)=='-'){_0x5f219a+=_0x515374[_0x6f1c('0x6c')](_0x24d863);}else{_0x5f219a+='['+_0x515374[_0x6f1c('0x6c')](_0x24d863)+']';}}_0x5f219a+='.';return _0x5f219a;}exports[_0x6f1c('0x6d')]=function(_0x27490c,_0x2c6752,_0x68c121){var _0x2e4743=_0x27490c[_0x6f1c('0x50')];_0x2e4743[_0x6f1c('0x5f')]='system-'+_0x2e4743[_0x6f1c('0x2d')]+'-';return db['sequelize'][_0x6f1c('0x6e')](function(_0x46bbc3){return db[_0x6f1c('0x46')][_0x6f1c('0x6d')](_0x2e4743,{'where':{'id':_0x2e4743['id']},'transaction':_0x46bbc3})[_0x6f1c('0x27')](function(){return db['VoiceExtension'][_0x6f1c('0x28')]({'where':{'VoicePrefixId':_0x2e4743['id']},'transaction':_0x46bbc3})[_0x6f1c('0x27')](function(){return db[_0x6f1c('0x62')][_0x6f1c('0x4c')]({'where':{'id':_0x2e4743[_0x6f1c('0x63')]},'raw':!![]})['then'](function(_0x5324e4){return createVoicePrefixExtensions(_0x2e4743,_0x5324e4,_0x46bbc3);});});});})[_0x6f1c('0x27')](function(){return db[_0x6f1c('0x46')][_0x6f1c('0x6f')](_0x2e4743['id']);})[_0x6f1c('0x27')](respondWithResult(_0x2c6752,null))[_0x6f1c('0x48')](handleError(_0x2c6752,null));};exports['addAgents']=function(_0x251baf,_0x32aa2f,_0x220d83){return db[_0x6f1c('0x46')]['find']({'where':{'id':_0x251baf[_0x6f1c('0x4a')]['id']}})[_0x6f1c('0x27')](handleEntityNotFound(_0x32aa2f,null))[_0x6f1c('0x27')](function(_0xe4ea3c){if(_0xe4ea3c){return _0xe4ea3c[_0x6f1c('0x70')](_0x251baf['body'][_0x6f1c('0x71')],_[_0x6f1c('0x72')](_0x251baf[_0x6f1c('0x50')],[_0x6f1c('0x71'),'id'])||{})['spread'](function(_0x565708){for(var _0xf82c2f=0x0;_0xf82c2f<_0x251baf['body'][_0x6f1c('0x71')][_0x6f1c('0x39')];_0xf82c2f+=0x1){socket['emit']('userVoicePrefix:save',{'UserId':_0x251baf[_0x6f1c('0x50')][_0x6f1c('0x71')][_0xf82c2f],'VoicePrefixId':_0x251baf[_0x6f1c('0x4a')]['id']});}return _0x565708;});}})[_0x6f1c('0x27')](respondWithResult(_0x32aa2f,null))[_0x6f1c('0x48')](handleError(_0x32aa2f,null));};exports['removeAgents']=function(_0x34927a,_0x4e666a,_0x2391d7){return db['VoicePrefix']['find']({'where':{'id':_0x34927a[_0x6f1c('0x4a')]['id']}})[_0x6f1c('0x27')](handleEntityNotFound(_0x4e666a,null))['then'](function(_0x4770f0){if(_0x4770f0){return _0x4770f0['removeAgents'](_0x34927a['query']['ids'])[_0x6f1c('0x27')](function(){if(_['isArray'](_0x34927a[_0x6f1c('0x33')][_0x6f1c('0x71')])){for(var _0x256bab=0x0;_0x256bab<_0x34927a[_0x6f1c('0x33')][_0x6f1c('0x71')][_0x6f1c('0x39')];_0x256bab+=0x1){socket['emit'](_0x6f1c('0x73'),{'UserId':Number(_0x34927a[_0x6f1c('0x33')]['ids'][_0x256bab]),'VoicePrefixId':Number(_0x34927a[_0x6f1c('0x4a')]['id'])});}}else{socket['emit'](_0x6f1c('0x73'),{'UserId':Number(_0x34927a[_0x6f1c('0x33')][_0x6f1c('0x71')]),'VoicePrefixId':Number(_0x34927a[_0x6f1c('0x4a')]['id'])});}});}})[_0x6f1c('0x27')](respondWithStatusCode(_0x4e666a,null))[_0x6f1c('0x48')](handleError(_0x4e666a,null));};exports[_0x6f1c('0x74')]=function(_0x281c4d,_0x2907cb,_0x2195ea){var _0x5d54ec={};var _0x4f4161={};var _0x12f48b;var _0x5d6858;return db['VoicePrefix']['findOne']({'where':{'id':_0x281c4d[_0x6f1c('0x4a')]['id']}})[_0x6f1c('0x27')](handleEntityNotFound(_0x2907cb,null))[_0x6f1c('0x27')](function(_0x37ccb3){if(_0x37ccb3){_0x12f48b=_0x37ccb3;_0x4f4161['model']=_[_0x6f1c('0x34')](db[_0x6f1c('0x75')]['rawAttributes']);_0x4f4161[_0x6f1c('0x33')]=_[_0x6f1c('0x34')](_0x281c4d[_0x6f1c('0x33')]);_0x4f4161[_0x6f1c('0x35')]=_[_0x6f1c('0x36')](_0x4f4161[_0x6f1c('0x32')],_0x4f4161[_0x6f1c('0x33')]);_0x5d54ec[_0x6f1c('0x37')]=_[_0x6f1c('0x36')](_0x4f4161['model'],qs[_0x6f1c('0x38')](_0x281c4d['query']['fields']));_0x5d54ec[_0x6f1c('0x37')]=_0x5d54ec[_0x6f1c('0x37')][_0x6f1c('0x39')]?_0x5d54ec[_0x6f1c('0x37')]:_0x4f4161[_0x6f1c('0x32')];_0x5d54ec[_0x6f1c('0x3c')]=qs[_0x6f1c('0x3d')](_0x281c4d['query']['sort']);_0x5d54ec[_0x6f1c('0x3e')]=qs[_0x6f1c('0x35')](_[_0x6f1c('0x3f')](_0x281c4d[_0x6f1c('0x33')],_0x4f4161['filters']));if(_0x281c4d[_0x6f1c('0x33')][_0x6f1c('0x40')]){_0x5d54ec[_0x6f1c('0x3e')]=_[_0x6f1c('0x41')](_0x5d54ec['where'],{'$or':_['map'](_0x5d54ec[_0x6f1c('0x37')],function(_0x282d6b){var _0x3695d9={};_0x3695d9[_0x282d6b]={'$like':'%'+_0x281c4d[_0x6f1c('0x33')]['filter']+'%'};return _0x3695d9;})});}_0x5d54ec=_[_0x6f1c('0x41')]({},_0x5d54ec,_0x281c4d[_0x6f1c('0x4b')]);return _0x12f48b['getAgents'](_0x5d54ec);}})['then'](function(_0x2deebb){if(_0x2deebb){_0x5d6858=_0x2deebb[_0x6f1c('0x39')];if(!_0x281c4d[_0x6f1c('0x33')][_0x6f1c('0x3a')](_0x6f1c('0x3b'))){_0x5d54ec['limit']=qs[_0x6f1c('0x23')](_0x281c4d['query']['limit']);_0x5d54ec[_0x6f1c('0x22')]=qs[_0x6f1c('0x22')](_0x281c4d[_0x6f1c('0x33')]['offset']);}return _0x12f48b[_0x6f1c('0x74')](_0x5d54ec);}})['then'](function(_0x39939b){if(_0x39939b){return _0x39939b?{'count':_0x5d6858,'rows':_0x39939b}:null;}})['then'](respondWithResult(_0x2907cb,null))[_0x6f1c('0x48')](handleError(_0x2907cb,null));};
\ No newline at end of file
+var _0x5204=['Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','context','from-sip','exten','system','description','Voice\x20Prefix\x20Extension','appdata','prefix','NoOp','VoicePrefixId','Extensions\x20creation\x20failed','push','Set','CDR(prefix)=','callerIdAll','PREFIX-CALLERIDALL=','goto','${EXTEN:','system-','findById','addAgents','ids','spread','emit','userVoicePrefix:save','removeAgents','userVoicePrefix:remove','getAgents','User','filter','findOne','Team','getTeams','Agents','online','voicePause','interface','flatMap','addTeams','TeamVoicePrefix','each','UserVoicePrefix','findOrCreate','forEach','field','tq.TeamId','from','team_has_voice_prefixes','join','user_has_teams','VoicePrefixId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','includes','all','union','compact','value','removeTeams','isEmpty','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./voicePrefix.socket','register','sendStatus','status','end','json','offset','undefined','limit','set','reject','save','update','then','destroy','get','VoicePrefixes','UserProfileResource','error','name','index','map','VoicePrefix','rawAttributes','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','type','VIRTUAL','merge','options','count','includeAll','findAll','rows','catch','show','params','length','include','find','describe','create','sequelize','transaction','body','VoiceExtension','VoiceExtensionId','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId'];(function(_0x518c2e,_0x4afdb2){var _0x40e45f=function(_0x357da4){while(--_0x357da4){_0x518c2e['push'](_0x518c2e['shift']());}};_0x40e45f(++_0x4afdb2);}(_0x5204,0xdf));var _0x4520=function(_0x352d28,_0x444033){_0x352d28=_0x352d28-0x0;var _0x387d7e=_0x5204[_0x352d28];return _0x387d7e;};'use strict';var emlformat=require(_0x4520('0x0'));var rimraf=require(_0x4520('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x4520('0x2'));var rp=require(_0x4520('0x3'));var moment=require(_0x4520('0x4'));var BPromise=require(_0x4520('0x5'));var Mustache=require(_0x4520('0x6'));var util=require('util');var path=require(_0x4520('0x7'));var sox=require('sox');var csv=require(_0x4520('0x8'));var ejs=require(_0x4520('0x9'));var fs=require('fs');var fs_extra=require(_0x4520('0xa'));var _=require(_0x4520('0xb'));var squel=require(_0x4520('0xc'));var crypto=require(_0x4520('0xd'));var jsforce=require(_0x4520('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x4520('0x8'));var querystring=require('querystring');var Papa=require(_0x4520('0xf'));var Redis=require(_0x4520('0x10'));var authService=require(_0x4520('0x11'));var qs=require(_0x4520('0x12'));var as=require(_0x4520('0x13'));var hardwareService=require(_0x4520('0x14'));var logger=require(_0x4520('0x15'))(_0x4520('0x16'));var utils=require(_0x4520('0x17'));var config=require(_0x4520('0x18'));var licenseUtil=require(_0x4520('0x19'));var db=require(_0x4520('0x1a'))['db'];config[_0x4520('0x1b')]=_[_0x4520('0x1c')](config[_0x4520('0x1b')],{'host':_0x4520('0x1d'),'port':0x18eb});var socket=require(_0x4520('0x1e'))(new Redis(config[_0x4520('0x1b')]));require(_0x4520('0x1f'))[_0x4520('0x20')](socket);function respondWithStatusCode(_0x32950a,_0x48b3e7){_0x48b3e7=_0x48b3e7||0xcc;return function(_0x3e53e5){if(_0x3e53e5){return _0x32950a[_0x4520('0x21')](_0x48b3e7);}return _0x32950a[_0x4520('0x22')](_0x48b3e7)[_0x4520('0x23')]();};}function respondWithResult(_0x32d8aa,_0x51d85f){_0x51d85f=_0x51d85f||0xc8;return function(_0x2c1805){if(_0x2c1805){return _0x32d8aa[_0x4520('0x22')](_0x51d85f)[_0x4520('0x24')](_0x2c1805);}};}function respondWithFilteredResult(_0x283ad4,_0x1b8b0f){return function(_0x2e00f4){if(_0x2e00f4){var _0x1dcf51=typeof _0x1b8b0f[_0x4520('0x25')]===_0x4520('0x26')&&typeof _0x1b8b0f[_0x4520('0x27')]===_0x4520('0x26');var _0x460521=_0x2e00f4['count'];var _0xc016a3=_0x1dcf51?0x0:_0x1b8b0f['offset'];var _0x5ceff6=_0x1dcf51?_0x2e00f4['count']:_0x1b8b0f[_0x4520('0x25')]+_0x1b8b0f['limit'];var _0x39e196;if(_0x5ceff6>=_0x460521){_0x5ceff6=_0x460521;_0x39e196=0xc8;}else{_0x39e196=0xce;}_0x283ad4[_0x4520('0x22')](_0x39e196);return _0x283ad4[_0x4520('0x28')]('Content-Range',_0xc016a3+'-'+_0x5ceff6+'/'+_0x460521)[_0x4520('0x24')](_0x2e00f4);}return null;};}function patchUpdates(_0x4000d4){return function(_0x3b2ede){try{jsonpatch['apply'](_0x3b2ede,_0x4000d4,!![]);}catch(_0x198c34){return BPromise[_0x4520('0x29')](_0x198c34);}return _0x3b2ede[_0x4520('0x2a')]();};}function saveUpdates(_0x3a4680,_0x2a8528){return function(_0x552da1){if(_0x552da1){return _0x552da1[_0x4520('0x2b')](_0x3a4680)[_0x4520('0x2c')](function(_0x3532aa){return _0x3532aa;});}return null;};}function removeEntity(_0x3e2906,_0x57306b){return function(_0x336c63){if(_0x336c63){return _0x336c63[_0x4520('0x2d')]()[_0x4520('0x2c')](function(){var _0x21e1f3=_0x336c63[_0x4520('0x2e')]({'plain':!![]});var _0x2c95ea=_0x4520('0x2f');return db[_0x4520('0x30')][_0x4520('0x2d')]({'where':{'type':_0x2c95ea,'resourceId':_0x21e1f3['id']}})[_0x4520('0x2c')](function(){return _0x336c63;});})['then'](function(){_0x3e2906[_0x4520('0x22')](0xcc)['end']();});}};}function handleEntityNotFound(_0x7ce8d2,_0x14778a){return function(_0x43b4a2){if(!_0x43b4a2){_0x7ce8d2[_0x4520('0x21')](0x194);}return _0x43b4a2;};}function handleError(_0x1da740,_0x4751d1){_0x4751d1=_0x4751d1||0x1f4;return function(_0x5bb163){logger[_0x4520('0x31')](_0x5bb163['stack']);if(_0x5bb163[_0x4520('0x32')]){delete _0x5bb163['name'];}_0x1da740[_0x4520('0x22')](_0x4751d1)['send'](_0x5bb163);};}exports[_0x4520('0x33')]=function(_0x4e6a5f,_0x5087dc){var _0x18d6e9={},_0x14cbb5={},_0x24d5b9={'count':0x0,'rows':[]};var _0x4af381=_[_0x4520('0x34')](db[_0x4520('0x35')][_0x4520('0x36')],function(_0x2ad47f){return{'name':_0x2ad47f['fieldName'],'type':_0x2ad47f['type'][_0x4520('0x37')]};});_0x14cbb5[_0x4520('0x38')]=_['map'](_0x4af381,_0x4520('0x32'));_0x14cbb5[_0x4520('0x39')]=_[_0x4520('0x3a')](_0x4e6a5f[_0x4520('0x39')]);_0x14cbb5[_0x4520('0x3b')]=_[_0x4520('0x3c')](_0x14cbb5['model'],_0x14cbb5[_0x4520('0x39')]);_0x18d6e9[_0x4520('0x3d')]=_['intersection'](_0x14cbb5[_0x4520('0x38')],qs['fields'](_0x4e6a5f[_0x4520('0x39')][_0x4520('0x3e')]));_0x18d6e9['attributes']=_0x18d6e9['attributes']['length']?_0x18d6e9[_0x4520('0x3d')]:_0x14cbb5[_0x4520('0x38')];if(!_0x4e6a5f[_0x4520('0x39')][_0x4520('0x3f')](_0x4520('0x40'))){_0x18d6e9[_0x4520('0x27')]=qs[_0x4520('0x27')](_0x4e6a5f['query'][_0x4520('0x27')]);_0x18d6e9[_0x4520('0x25')]=qs[_0x4520('0x25')](_0x4e6a5f['query'][_0x4520('0x25')]);}_0x18d6e9[_0x4520('0x41')]=qs['sort'](_0x4e6a5f['query'][_0x4520('0x42')]);_0x18d6e9[_0x4520('0x43')]=qs[_0x4520('0x3b')](_[_0x4520('0x44')](_0x4e6a5f[_0x4520('0x39')],_0x14cbb5['filters']),_0x4af381);if(_0x4e6a5f['query']['filter']){_0x18d6e9[_0x4520('0x43')]=_['merge'](_0x18d6e9[_0x4520('0x43')],{'$or':_['map'](_0x4af381,function(_0x517fcb){if(_0x517fcb[_0x4520('0x45')]!==_0x4520('0x46')){var _0x2e005d={};_0x2e005d[_0x517fcb[_0x4520('0x32')]]={'$like':'%'+_0x4e6a5f[_0x4520('0x39')]['filter']+'%'};return _0x2e005d;}})});}_0x18d6e9=_[_0x4520('0x47')]({},_0x18d6e9,_0x4e6a5f[_0x4520('0x48')]);var _0x4a39d4={'where':_0x18d6e9['where']};return db[_0x4520('0x35')][_0x4520('0x49')](_0x4a39d4)['then'](function(_0x2978d5){_0x24d5b9[_0x4520('0x49')]=_0x2978d5;if(_0x4e6a5f[_0x4520('0x39')][_0x4520('0x4a')]){_0x18d6e9['include']=[{'all':!![]}];}return db[_0x4520('0x35')][_0x4520('0x4b')](_0x18d6e9);})[_0x4520('0x2c')](function(_0xb92e25){_0x24d5b9[_0x4520('0x4c')]=_0xb92e25;return _0x24d5b9;})[_0x4520('0x2c')](respondWithFilteredResult(_0x5087dc,_0x18d6e9))[_0x4520('0x4d')](handleError(_0x5087dc,null));};exports[_0x4520('0x4e')]=function(_0x3a2b55,_0x6c07fe){var _0x1e6ac0={'raw':![],'where':{'id':_0x3a2b55[_0x4520('0x4f')]['id']}},_0x199565={};_0x199565[_0x4520('0x38')]=_[_0x4520('0x3a')](db[_0x4520('0x35')][_0x4520('0x36')]);_0x199565['query']=_[_0x4520('0x3a')](_0x3a2b55[_0x4520('0x39')]);_0x199565['filters']=_['intersection'](_0x199565['model'],_0x199565['query']);_0x1e6ac0[_0x4520('0x3d')]=_['intersection'](_0x199565[_0x4520('0x38')],qs[_0x4520('0x3e')](_0x3a2b55[_0x4520('0x39')][_0x4520('0x3e')]));_0x1e6ac0[_0x4520('0x3d')]=_0x1e6ac0[_0x4520('0x3d')][_0x4520('0x50')]?_0x1e6ac0[_0x4520('0x3d')]:_0x199565[_0x4520('0x38')];if(_0x3a2b55[_0x4520('0x39')][_0x4520('0x4a')]){_0x1e6ac0[_0x4520('0x51')]=[{'all':!![]}];}_0x1e6ac0=_[_0x4520('0x47')]({},_0x1e6ac0,_0x3a2b55[_0x4520('0x48')]);return db[_0x4520('0x35')][_0x4520('0x52')](_0x1e6ac0)[_0x4520('0x2c')](handleEntityNotFound(_0x6c07fe,null))[_0x4520('0x2c')](respondWithResult(_0x6c07fe,null))['catch'](handleError(_0x6c07fe,null));};exports['destroy']=function(_0x2f14c1,_0x29e14c){return db[_0x4520('0x35')]['find']({'where':{'id':_0x2f14c1[_0x4520('0x4f')]['id']}})[_0x4520('0x2c')](handleEntityNotFound(_0x29e14c,null))[_0x4520('0x2c')](removeEntity(_0x29e14c,null))['catch'](handleError(_0x29e14c,null));};exports[_0x4520('0x53')]=function(_0x2eb8c2,_0x32d950){return db['VoicePrefix']['describe']()[_0x4520('0x2c')](respondWithResult(_0x32d950,null))[_0x4520('0x4d')](handleError(_0x32d950,null));};exports[_0x4520('0x54')]=function(_0x379da4,_0x2d37ed){var _0x1549cc;return db[_0x4520('0x55')][_0x4520('0x56')](function(_0x4d30d3){return db[_0x4520('0x35')][_0x4520('0x54')](_0x379da4[_0x4520('0x57')],{'transaction':_0x4d30d3})[_0x4520('0x2c')](function(_0xff7d4b){_0x1549cc=_0xff7d4b[_0x4520('0x2e')]({'plain':!![]});return db[_0x4520('0x58')][_0x4520('0x52')]({'where':{'id':_0x1549cc[_0x4520('0x59')]},'raw':!![]})[_0x4520('0x2c')](function(_0x381e0b){return createVoicePrefixExtensions(_0x1549cc,_0x381e0b,_0x4d30d3);});});})[_0x4520('0x2c')](function(){var _0x2f11d9=_0x379da4[_0x4520('0x5a')][_0x4520('0x2e')]({'plain':!![]});if(!_0x2f11d9)throw new Error(_0x4520('0x5b'));if(_0x2f11d9[_0x4520('0x5c')]==='user'){var _0x52bb6c=_0x1549cc;return db[_0x4520('0x5d')][_0x4520('0x52')]({'where':{'name':_0x4520('0x2f'),'userProfileId':_0x2f11d9[_0x4520('0x5e')]},'raw':!![]})[_0x4520('0x2c')](function(_0x2f071e){if(_0x2f071e&&_0x2f071e['autoAssociation']===0x0){return db[_0x4520('0x30')][_0x4520('0x54')]({'name':_0x52bb6c['name'],'resourceId':_0x52bb6c['id'],'type':_0x2f071e[_0x4520('0x32')],'sectionId':_0x2f071e['id']},{})[_0x4520('0x2c')](function(){return _0x1549cc;});}else{return _0x1549cc;}})[_0x4520('0x4d')](function(_0x325edb){logger['error'](_0x4520('0x5f'),_0x325edb);throw _0x325edb;});}return _0x1549cc;})[_0x4520('0x2c')](respondWithResult(_0x2d37ed,null))['catch'](handleError(_0x2d37ed,null));};function Extension(_0x4c7172,_0x347130,_0x83cac1,_0xe07bd0){this[_0x4520('0x60')]=_0x4520('0x61');this[_0x4520('0x62')]=_0x4c7172;this['app']=_0x83cac1;this[_0x4520('0x45')]=_0x4520('0x63');this[_0x4520('0x64')]=_0x4520('0x65');this['priority']=_0x347130;this[_0x4520('0x66')]=_0xe07bd0;}function createVoicePrefixExtensions(_0x26f172,_0x4c9108,_0x20a517){return new BPromise(function(_0x5a55d6,_0x7215a3){var _0xadedd0=new Extension(formatPrefixName(_0x26f172[_0x4520('0x67')]),0x1,_0x4520('0x68'),'Voice\x20Prefix');_0xadedd0[_0x4520('0x69')]=_0x26f172['id'];return db[_0x4520('0x58')][_0x4520('0x54')](_0xadedd0,{'transaction':_0x20a517})[_0x4520('0x2c')](function(_0x4b6f71){var _0x28a0fd=_0x4b6f71[_0x4520('0x2e')]({'plain':!![]});var _0x3c7b9e=_[_0x4520('0x34')](addVoicePrefixExtensions(_0x26f172,_0x4c9108),function(_0x196763){_0x196763[_0x4520('0x59')]=_0x28a0fd['id'];_0x196763['VoicePrefixId']=_0x26f172['id'];return _0x196763;});return db[_0x4520('0x58')]['bulkCreate'](_0x3c7b9e,{'transaction':_0x20a517})[_0x4520('0x2c')](function(_0x22e363){if(!_0x22e363){return _0x7215a3(_0x4520('0x6a'));}else{return _0x5a55d6(_0x22e363);}})[_0x4520('0x4d')](function(_0x393da3){return _0x7215a3(_0x393da3);});});;});};function addVoicePrefixExtensions(_0x41a204,_0x5d100c){var _0x4d5085=[];var _0xa7461b=formatPrefixName(_0x41a204['prefix']);_0x4d5085[_0x4520('0x6b')](new Extension(_0xa7461b,0x2,_0x4520('0x6c'),_0x4520('0x6d')+_0x41a204[_0x4520('0x32')]));if(_0x41a204[_0x4520('0x6e')]){_0x4d5085[_0x4520('0x6b')](new Extension(_0xa7461b,0x3,_0x4520('0x6c'),_0x4520('0x6f')+_0x41a204[_0x4520('0x6e')]));}else{_0x4d5085['push'](new Extension(_0xa7461b,0x3,_0x4520('0x68'),'No\x20callerid\x20available'));}_0x4d5085[_0x4520('0x6b')](new Extension(_0xa7461b,0x4,_0x4520('0x70'),_0x5d100c[_0x4520('0x60')]+','+_0x4520('0x71')+(0x8+_0x41a204[_0x4520('0x32')]['length'])+'}'+','+0x1));return _0x4d5085;}function formatPrefixName(_0x1f7ccb){var _0x375f5d='_';for(var _0x3892fa=0x0;_0x3892fa<_0x1f7ccb[_0x4520('0x50')];_0x3892fa++){if(_0x1f7ccb['charAt'](_0x3892fa)=='-'){_0x375f5d+=_0x1f7ccb['charAt'](_0x3892fa);}else{_0x375f5d+='['+_0x1f7ccb['charAt'](_0x3892fa)+']';}}_0x375f5d+='.';return _0x375f5d;}exports[_0x4520('0x2b')]=function(_0x14bd13,_0x390835,_0x5cf8b9){var _0x2842dc=_0x14bd13[_0x4520('0x57')];_0x2842dc[_0x4520('0x67')]=_0x4520('0x72')+_0x2842dc[_0x4520('0x32')]+'-';return db['sequelize'][_0x4520('0x56')](function(_0x3fa1ac){return db[_0x4520('0x35')]['update'](_0x2842dc,{'where':{'id':_0x2842dc['id']},'transaction':_0x3fa1ac})[_0x4520('0x2c')](function(){return db[_0x4520('0x58')][_0x4520('0x2d')]({'where':{'VoicePrefixId':_0x2842dc['id']},'transaction':_0x3fa1ac})[_0x4520('0x2c')](function(){return db[_0x4520('0x58')][_0x4520('0x52')]({'where':{'id':_0x2842dc[_0x4520('0x59')]},'raw':!![]})[_0x4520('0x2c')](function(_0x524942){return createVoicePrefixExtensions(_0x2842dc,_0x524942,_0x3fa1ac);});});});})['then'](function(){return db[_0x4520('0x35')][_0x4520('0x73')](_0x2842dc['id']);})['then'](respondWithResult(_0x390835,null))[_0x4520('0x4d')](handleError(_0x390835,null));};exports['addAgents']=function(_0x2d2f31,_0x231843,_0x536e21){return db[_0x4520('0x35')][_0x4520('0x52')]({'where':{'id':_0x2d2f31['params']['id']}})[_0x4520('0x2c')](handleEntityNotFound(_0x231843,null))[_0x4520('0x2c')](function(_0x5330cf){if(_0x5330cf){return _0x5330cf[_0x4520('0x74')](_0x2d2f31[_0x4520('0x57')][_0x4520('0x75')],_['omit'](_0x2d2f31[_0x4520('0x57')],[_0x4520('0x75'),'id'])||{})[_0x4520('0x76')](function(_0x17d595){for(var _0x2d21e9=0x0;_0x2d21e9<_0x2d2f31[_0x4520('0x57')][_0x4520('0x75')][_0x4520('0x50')];_0x2d21e9+=0x1){socket[_0x4520('0x77')](_0x4520('0x78'),{'UserId':Number(_0x2d2f31[_0x4520('0x57')][_0x4520('0x75')][_0x2d21e9]),'VoicePrefixId':Number(_0x2d2f31['params']['id'])});}return _0x17d595;});}})['then'](respondWithResult(_0x231843,null))[_0x4520('0x4d')](handleError(_0x231843,null));};exports['removeAgents']=function(_0x15b5ae,_0x15fb9c,_0x17c779){return db[_0x4520('0x35')][_0x4520('0x52')]({'where':{'id':_0x15b5ae['params']['id']}})['then'](handleEntityNotFound(_0x15fb9c,null))[_0x4520('0x2c')](function(_0x2f4226){if(_0x2f4226){return _0x2f4226[_0x4520('0x79')](_0x15b5ae[_0x4520('0x39')][_0x4520('0x75')])[_0x4520('0x2c')](function(){if(_['isArray'](_0x15b5ae[_0x4520('0x39')][_0x4520('0x75')])){for(var _0x55f3ab=0x0;_0x55f3ab<_0x15b5ae[_0x4520('0x39')]['ids']['length'];_0x55f3ab+=0x1){socket['emit'](_0x4520('0x7a'),{'UserId':Number(_0x15b5ae[_0x4520('0x39')][_0x4520('0x75')][_0x55f3ab]),'VoicePrefixId':Number(_0x15b5ae[_0x4520('0x4f')]['id'])});}}else{socket[_0x4520('0x77')]('userVoicePrefix:remove',{'UserId':Number(_0x15b5ae[_0x4520('0x39')][_0x4520('0x75')]),'VoicePrefixId':Number(_0x15b5ae['params']['id'])});}});}})['then'](respondWithStatusCode(_0x15fb9c,null))[_0x4520('0x4d')](handleError(_0x15fb9c,null));};exports[_0x4520('0x7b')]=function(_0x34b640,_0x539644,_0xc9bc2){var _0x341b55={};var _0x1df90c={};var _0x4866b5;var _0x80496a;return db[_0x4520('0x35')]['findOne']({'where':{'id':_0x34b640[_0x4520('0x4f')]['id']}})['then'](handleEntityNotFound(_0x539644,null))[_0x4520('0x2c')](function(_0x388177){if(_0x388177){_0x4866b5=_0x388177;_0x1df90c[_0x4520('0x38')]=_[_0x4520('0x3a')](db[_0x4520('0x7c')][_0x4520('0x36')]);_0x1df90c[_0x4520('0x39')]=_['keys'](_0x34b640[_0x4520('0x39')]);_0x1df90c['filters']=_[_0x4520('0x3c')](_0x1df90c[_0x4520('0x38')],_0x1df90c['query']);_0x341b55[_0x4520('0x3d')]=_[_0x4520('0x3c')](_0x1df90c[_0x4520('0x38')],qs[_0x4520('0x3e')](_0x34b640[_0x4520('0x39')][_0x4520('0x3e')]));_0x341b55[_0x4520('0x3d')]=_0x341b55[_0x4520('0x3d')][_0x4520('0x50')]?_0x341b55[_0x4520('0x3d')]:_0x1df90c[_0x4520('0x38')];_0x341b55['order']=qs['sort'](_0x34b640['query']['sort']);_0x341b55['where']=qs[_0x4520('0x3b')](_[_0x4520('0x44')](_0x34b640[_0x4520('0x39')],_0x1df90c[_0x4520('0x3b')]));if(_0x34b640['query'][_0x4520('0x7d')]){_0x341b55['where']=_[_0x4520('0x47')](_0x341b55['where'],{'$or':_[_0x4520('0x34')](_0x341b55['attributes'],function(_0x2b334a){var _0x2e08ab={};_0x2e08ab[_0x2b334a]={'$like':'%'+_0x34b640[_0x4520('0x39')][_0x4520('0x7d')]+'%'};return _0x2e08ab;})});}_0x341b55=_['merge']({},_0x341b55,_0x34b640[_0x4520('0x48')]);return _0x4866b5['getAgents'](_0x341b55);}})[_0x4520('0x2c')](function(_0x322d47){if(_0x322d47){_0x80496a=_0x322d47[_0x4520('0x50')];if(!_0x34b640[_0x4520('0x39')][_0x4520('0x3f')]('nolimit')){_0x341b55[_0x4520('0x27')]=qs[_0x4520('0x27')](_0x34b640['query'][_0x4520('0x27')]);_0x341b55[_0x4520('0x25')]=qs['offset'](_0x34b640[_0x4520('0x39')]['offset']);}return _0x4866b5['getAgents'](_0x341b55);}})[_0x4520('0x2c')](function(_0x39af12){if(_0x39af12){return _0x39af12?{'count':_0x80496a,'rows':_0x39af12}:null;}})['then'](respondWithResult(_0x539644,null))[_0x4520('0x4d')](handleError(_0x539644,null));};exports['getTeams']=function(_0x2739c5,_0x3b29de,_0x41b2d7){var _0x1ea71c={};var _0x47273c={};var _0x1c5bf5;var _0x1079e1;return db[_0x4520('0x35')][_0x4520('0x7e')]({'where':{'id':_0x2739c5[_0x4520('0x4f')]['id']}})[_0x4520('0x2c')](handleEntityNotFound(_0x3b29de,null))[_0x4520('0x2c')](function(_0x42a394){if(_0x42a394){_0x1c5bf5=_0x42a394;_0x47273c[_0x4520('0x38')]=_['keys'](db[_0x4520('0x7f')][_0x4520('0x36')]);_0x47273c['query']=_[_0x4520('0x3a')](_0x2739c5[_0x4520('0x39')]);_0x47273c['filters']=_[_0x4520('0x3c')](_0x47273c[_0x4520('0x38')],_0x47273c[_0x4520('0x39')]);_0x1ea71c[_0x4520('0x3d')]=_[_0x4520('0x3c')](_0x47273c[_0x4520('0x38')],qs['fields'](_0x2739c5[_0x4520('0x39')][_0x4520('0x3e')]));_0x1ea71c[_0x4520('0x3d')]=_0x1ea71c[_0x4520('0x3d')][_0x4520('0x50')]?_0x1ea71c['attributes']:_0x47273c['model'];_0x1ea71c[_0x4520('0x41')]=qs[_0x4520('0x42')](_0x2739c5[_0x4520('0x39')][_0x4520('0x42')]);_0x1ea71c[_0x4520('0x43')]=qs[_0x4520('0x3b')](_[_0x4520('0x44')](_0x2739c5[_0x4520('0x39')],_0x47273c[_0x4520('0x3b')]));if(_0x2739c5[_0x4520('0x39')]['filter']){_0x1ea71c[_0x4520('0x43')]=_[_0x4520('0x47')](_0x1ea71c['where'],{'$or':_[_0x4520('0x34')](_0x1ea71c[_0x4520('0x3d')],function(_0x54d969){var _0x14724f={};_0x14724f[_0x54d969]={'$like':'%'+_0x2739c5[_0x4520('0x39')]['filter']+'%'};return _0x14724f;})});}_0x1ea71c=_['merge']({},_0x1ea71c,_0x2739c5[_0x4520('0x48')]);return _0x1c5bf5[_0x4520('0x80')](_0x1ea71c);}})[_0x4520('0x2c')](function(_0xf3ef3f){if(_0xf3ef3f){_0x1079e1=_0xf3ef3f['length'];if(!_0x2739c5[_0x4520('0x39')][_0x4520('0x3f')](_0x4520('0x40'))){_0x1ea71c[_0x4520('0x27')]=qs[_0x4520('0x27')](_0x2739c5[_0x4520('0x39')][_0x4520('0x27')]);_0x1ea71c[_0x4520('0x25')]=qs[_0x4520('0x25')](_0x2739c5['query'][_0x4520('0x25')]);}return _0x1c5bf5[_0x4520('0x80')](_0x1ea71c);}})[_0x4520('0x2c')](function(_0x5e273e){if(_0x5e273e){return _0x5e273e?{'count':_0x1079e1,'rows':_0x5e273e}:null;}})['then'](respondWithResult(_0x3b29de,null))[_0x4520('0x4d')](handleError(_0x3b29de,null));};exports['addTeams']=function(_0x770d66,_0xe8aa53,_0xd57838){var _0x12b063=_0x770d66[_0x4520('0x57')][_0x4520('0x75')];var _0x1b2c01;return db[_0x4520('0x7f')][_0x4520('0x4b')]({'where':{'id':_0x12b063},'attributes':['id'],'include':[{'model':db['User'],'as':_0x4520('0x81'),'attributes':['id',_0x4520('0x32'),_0x4520('0x82'),_0x4520('0x83'),_0x4520('0x84')],'raw':!![]}]})[_0x4520('0x2c')](function(_0x3d21a1){if(_0x3d21a1){_0x1b2c01=_0x3d21a1;var _0x53acec=_[_0x4520('0x85')](_0x3d21a1,function(_0x249502){var _0x3780ad=_0x249502[_0x4520('0x2e')]({'plain':!![]});return _0x3780ad[_0x4520('0x81')];});return db['VoicePrefix']['find']({'where':{'id':_0x770d66[_0x4520('0x4f')]['id']}})[_0x4520('0x2c')](function(_0x36b481){return db['sequelize']['transaction'](function(_0x321c4b){return _0x36b481[_0x4520('0x86')](_0x12b063,{'transaction':_0x321c4b})[_0x4520('0x2c')](function(){return BPromise['each'](_0x1b2c01,function(_0x509de6){return db[_0x4520('0x87')]['upsert']({'TeamId':_0x509de6['id'],'VoicePrefixId':_0x770d66[_0x4520('0x4f')]['id']},{'transaction':_0x321c4b});});})[_0x4520('0x2c')](function(){return BPromise[_0x4520('0x88')](_0x53acec,function(_0x3c5501){return db[_0x4520('0x89')][_0x4520('0x8a')]({'where':{'UserId':_0x3c5501['id'],'VoicePrefixId':_0x770d66[_0x4520('0x4f')]['id']},'transaction':_0x321c4b});});})[_0x4520('0x2c')](function(){_0x53acec[_0x4520('0x8b')](function(_0x3eb1fd){socket['emit'](_0x4520('0x78'),{'UserId':_0x3eb1fd['id'],'VoicePrefixId':_0x36b481['id']});});});});});}})['then'](respondWithStatusCode(_0xe8aa53,null))[_0x4520('0x4d')](handleError(_0xe8aa53,null));};exports['removeTeams']=function(_0x3262ef,_0x31ab69,_0x245180){return db[_0x4520('0x7f')]['findAll']({'where':{'id':_0x3262ef[_0x4520('0x39')][_0x4520('0x75')]},'attributes':['id'],'include':[{'model':db[_0x4520('0x7c')],'as':_0x4520('0x81'),'attributes':['id'],'raw':!![]}]})[_0x4520('0x2c')](handleEntityNotFound(_0x31ab69,null))[_0x4520('0x2c')](function(_0x22a5cd){var _0x4d108f=_[_0x4520('0x34')](_0x22a5cd,'id');var _0x56f398=[];var _0x4ab423=[];var _0x320603=squel['select']();_0x320603[_0x4520('0x8c')](_0x4520('0x8d'))[_0x4520('0x8e')](_0x4520('0x8f'),'tq')[_0x4520('0x90')](_0x4520('0x91'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x4520('0x43')](_0x4520('0x92'),_0x3262ef[_0x4520('0x4f')]['id']);for(var _0x353b3e=0x0;_0x353b3e<_0x22a5cd['length'];_0x353b3e+=0x1){let _0x21bb01=_0x22a5cd[_0x353b3e];for(var _0x4e7421=0x0;_0x4e7421<_0x21bb01[_0x4520('0x81')][_0x4520('0x50')];_0x4e7421+=0x1){let _0x490a08=_0x21bb01[_0x4520('0x81')][_0x4e7421];var _0x1872d2=_0x320603[_0x4520('0x93')]();_0x1872d2['where'](_0x4520('0x94'),_0x490a08['id']);_0x4ab423[_0x4520('0x6b')](db['sequelize'][_0x4520('0x39')](_0x1872d2[_0x4520('0x95')](),{'type':db[_0x4520('0x55')][_0x4520('0x96')][_0x4520('0x97')]})['then'](function(_0x7058b0){if(_0x7058b0[_0x4520('0x50')]===0x1){return _0x490a08['id'];}else{var _0x3398e2=_['every'](_[_0x4520('0x34')](_0x7058b0,'TeamId'),function(_0x408dff){return _[_0x4520('0x98')](_0x4d108f,_0x408dff);});if(_0x3398e2){return _0x490a08['id'];}}}));}}return BPromise[_0x4520('0x99')](_0x4ab423)[_0x4520('0x2c')](function(_0x2f0c56){_0x56f398=_(_0x56f398)[_0x4520('0x9a')](_0x2f0c56)[_0x4520('0x9b')]()[_0x4520('0x9c')]();return db[_0x4520('0x35')]['find']({'where':{'id':_0x3262ef[_0x4520('0x4f')]['id']}})[_0x4520('0x2c')](function(_0x4b7ffd){return db['sequelize'][_0x4520('0x56')](function(_0x11709d){return _0x4b7ffd[_0x4520('0x9d')](_0x3262ef[_0x4520('0x39')][_0x4520('0x75')],{'transaction':_0x11709d})[_0x4520('0x2c')](function(){if(!_[_0x4520('0x9e')](_0x56f398)){return _0x4b7ffd[_0x4520('0x79')](_0x56f398,{'transaction':_0x11709d});}})[_0x4520('0x2c')](function(){_0x56f398[_0x4520('0x8b')](function(_0x43e7c7){socket['emit'](_0x4520('0x7a'),{'UserId':_0x43e7c7,'VoicePrefixId':_0x4b7ffd['id']});});});});});});})[_0x4520('0x2c')](respondWithStatusCode(_0x31ab69,null))[_0x4520('0x4d')](handleError(_0x31ab69,null));};
\ No newline at end of file