Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / voicePrefix / voicePrefix.controller.js
index 680871a..c0090ed 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbaf0=['querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','redis','defaults','localhost','register','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','update','then','destroy','get','VoicePrefixes','UserProfileResource','end','error','stack','name','send','index','map','VoicePrefix','rawAttributes','fieldName','type','model','query','keys','intersection','attributes','fields','hasOwnProperty','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','length','find','catch','describe','create','sequelize','VoiceExtensionId','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','context','from-sip','exten','app','description','Voice\x20Prefix\x20Extension','priority','appdata','NoOp','VoiceExtension','VoicePrefixId','bulkCreate','push','Set','CDR(prefix)=','callerIdAll','PREFIX-CALLERIDALL=','No\x20callerid\x20available','${EXTEN:','charAt','body','prefix','system-','ids','omit','spread','userVoicePrefix:save','params','removeAgents','emit','userVoicePrefix:remove','getAgents','findOne','User','nolimit','getTeams','Team','addTeams','Agents','online','voicePause','interface','flatMap','transaction','each','TeamVoicePrefix','upsert','UserVoicePrefix','findOrCreate','forEach','removeTeams','select','field','tq.TeamId','from','team_has_voice_prefixes','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','QueryTypes','SELECT','TeamId','includes','compact','isEmpty','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js'];(function(_0x3d83cd,_0x34b54a){var _0x51e93c=function(_0x403b46){while(--_0x403b46){_0x3d83cd['push'](_0x3d83cd['shift']());}};_0x51e93c(++_0x34b54a);}(_0xbaf0,0x12a));var _0x0baf=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0xbaf0[_0x14add3];return _0x4a174f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x0baf('0x0'));var zipdir=require(_0x0baf('0x1'));var jsonpatch=require(_0x0baf('0x2'));var rp=require(_0x0baf('0x3'));var moment=require(_0x0baf('0x4'));var BPromise=require(_0x0baf('0x5'));var Mustache=require('mustache');var util=require(_0x0baf('0x6'));var path=require(_0x0baf('0x7'));var sox=require(_0x0baf('0x8'));var csv=require(_0x0baf('0x9'));var ejs=require(_0x0baf('0xa'));var fs=require('fs');var fs_extra=require(_0x0baf('0xb'));var _=require(_0x0baf('0xc'));var squel=require(_0x0baf('0xd'));var crypto=require(_0x0baf('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x0baf('0xf'));var toCsv=require('to-csv');var querystring=require(_0x0baf('0x10'));var Papa=require(_0x0baf('0x11'));var Redis=require(_0x0baf('0x12'));var authService=require(_0x0baf('0x13'));var qs=require(_0x0baf('0x14'));var as=require(_0x0baf('0x15'));var hardwareService=require(_0x0baf('0x16'));var logger=require(_0x0baf('0x17'))(_0x0baf('0x18'));var utils=require(_0x0baf('0x19'));var config=require(_0x0baf('0x1a'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0x0baf('0x1b')]=_[_0x0baf('0x1c')](config[_0x0baf('0x1b')],{'host':_0x0baf('0x1d'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x0baf('0x1b')]));require('./voicePrefix.socket')[_0x0baf('0x1e')](socket);function respondWithStatusCode(_0x1f50c3,_0x7fbf67){_0x7fbf67=_0x7fbf67||0xcc;return function(_0x2bc381){if(_0x2bc381){return _0x1f50c3[_0x0baf('0x1f')](_0x7fbf67);}return _0x1f50c3[_0x0baf('0x20')](_0x7fbf67)['end']();};}function respondWithResult(_0x4cd79d,_0x2312c7){_0x2312c7=_0x2312c7||0xc8;return function(_0x38395b){if(_0x38395b){return _0x4cd79d[_0x0baf('0x20')](_0x2312c7)[_0x0baf('0x21')](_0x38395b);}};}function respondWithFilteredResult(_0x2cf7da,_0x288a98){return function(_0x53c338){if(_0x53c338){var _0x63c820=typeof _0x288a98[_0x0baf('0x22')]===_0x0baf('0x23')&&typeof _0x288a98[_0x0baf('0x24')]===_0x0baf('0x23');var _0x42b7f2=_0x53c338['count'];var _0x5cff5d=_0x63c820?0x0:_0x288a98[_0x0baf('0x22')];var _0x154f48=_0x63c820?_0x53c338[_0x0baf('0x25')]:_0x288a98[_0x0baf('0x22')]+_0x288a98[_0x0baf('0x24')];var _0x3e3e20;if(_0x154f48>=_0x42b7f2){_0x154f48=_0x42b7f2;_0x3e3e20=0xc8;}else{_0x3e3e20=0xce;}_0x2cf7da[_0x0baf('0x20')](_0x3e3e20);return _0x2cf7da[_0x0baf('0x26')](_0x0baf('0x27'),_0x5cff5d+'-'+_0x154f48+'/'+_0x42b7f2)[_0x0baf('0x21')](_0x53c338);}return null;};}function patchUpdates(_0x54f2fa){return function(_0x334bd6){try{jsonpatch['apply'](_0x334bd6,_0x54f2fa,!![]);}catch(_0xf6c158){return BPromise['reject'](_0xf6c158);}return _0x334bd6['save']();};}function saveUpdates(_0x2ef0aa,_0x48a0e9){return function(_0x4be1b9){if(_0x4be1b9){return _0x4be1b9[_0x0baf('0x28')](_0x2ef0aa)[_0x0baf('0x29')](function(_0x34e264){return _0x34e264;});}return null;};}function removeEntity(_0x19d9fd,_0x3a1ba1){return function(_0x56b299){if(_0x56b299){return _0x56b299[_0x0baf('0x2a')]()[_0x0baf('0x29')](function(){var _0x1ca35a=_0x56b299[_0x0baf('0x2b')]({'plain':!![]});var _0x3843b8=_0x0baf('0x2c');return db[_0x0baf('0x2d')]['destroy']({'where':{'type':_0x3843b8,'resourceId':_0x1ca35a['id']}})[_0x0baf('0x29')](function(){return _0x56b299;});})[_0x0baf('0x29')](function(){_0x19d9fd[_0x0baf('0x20')](0xcc)[_0x0baf('0x2e')]();});}};}function handleEntityNotFound(_0x55c715,_0x29dbdf){return function(_0x34a58a){if(!_0x34a58a){_0x55c715['sendStatus'](0x194);}return _0x34a58a;};}function handleError(_0x44ec31,_0x32e4fb){_0x32e4fb=_0x32e4fb||0x1f4;return function(_0x478ce8){logger[_0x0baf('0x2f')](_0x478ce8[_0x0baf('0x30')]);if(_0x478ce8[_0x0baf('0x31')]){delete _0x478ce8[_0x0baf('0x31')];}_0x44ec31['status'](_0x32e4fb)[_0x0baf('0x32')](_0x478ce8);};}exports[_0x0baf('0x33')]=function(_0x37be4e,_0x3ed995){var _0x24ecee={},_0x275ea1={},_0x2fc983={'count':0x0,'rows':[]};var _0x2f0a45=_[_0x0baf('0x34')](db[_0x0baf('0x35')][_0x0baf('0x36')],function(_0x165d14){return{'name':_0x165d14[_0x0baf('0x37')],'type':_0x165d14[_0x0baf('0x38')]['key']};});_0x275ea1[_0x0baf('0x39')]=_['map'](_0x2f0a45,_0x0baf('0x31'));_0x275ea1[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x37be4e[_0x0baf('0x3a')]);_0x275ea1['filters']=_[_0x0baf('0x3c')](_0x275ea1[_0x0baf('0x39')],_0x275ea1['query']);_0x24ecee[_0x0baf('0x3d')]=_[_0x0baf('0x3c')](_0x275ea1[_0x0baf('0x39')],qs[_0x0baf('0x3e')](_0x37be4e[_0x0baf('0x3a')][_0x0baf('0x3e')]));_0x24ecee[_0x0baf('0x3d')]=_0x24ecee[_0x0baf('0x3d')]['length']?_0x24ecee[_0x0baf('0x3d')]:_0x275ea1[_0x0baf('0x39')];if(!_0x37be4e['query'][_0x0baf('0x3f')]('nolimit')){_0x24ecee['limit']=qs[_0x0baf('0x24')](_0x37be4e[_0x0baf('0x3a')]['limit']);_0x24ecee['offset']=qs[_0x0baf('0x22')](_0x37be4e[_0x0baf('0x3a')][_0x0baf('0x22')]);}_0x24ecee[_0x0baf('0x40')]=qs[_0x0baf('0x41')](_0x37be4e[_0x0baf('0x3a')][_0x0baf('0x41')]);_0x24ecee[_0x0baf('0x42')]=qs[_0x0baf('0x43')](_[_0x0baf('0x44')](_0x37be4e[_0x0baf('0x3a')],_0x275ea1[_0x0baf('0x43')]),_0x2f0a45);if(_0x37be4e[_0x0baf('0x3a')][_0x0baf('0x45')]){_0x24ecee['where']=_[_0x0baf('0x46')](_0x24ecee[_0x0baf('0x42')],{'$or':_['map'](_0x2f0a45,function(_0x38006a){if(_0x38006a[_0x0baf('0x38')]!==_0x0baf('0x47')){var _0x299f93={};_0x299f93[_0x38006a[_0x0baf('0x31')]]={'$like':'%'+_0x37be4e[_0x0baf('0x3a')]['filter']+'%'};return _0x299f93;}})});}_0x24ecee=_[_0x0baf('0x46')]({},_0x24ecee,_0x37be4e[_0x0baf('0x48')]);var _0x540c41={'where':_0x24ecee[_0x0baf('0x42')]};return db[_0x0baf('0x35')][_0x0baf('0x25')](_0x540c41)[_0x0baf('0x29')](function(_0x504031){_0x2fc983[_0x0baf('0x25')]=_0x504031;if(_0x37be4e[_0x0baf('0x3a')][_0x0baf('0x49')]){_0x24ecee[_0x0baf('0x4a')]=[{'all':!![]}];}return db[_0x0baf('0x35')][_0x0baf('0x4b')](_0x24ecee);})[_0x0baf('0x29')](function(_0x1fa237){_0x2fc983[_0x0baf('0x4c')]=_0x1fa237;return _0x2fc983;})[_0x0baf('0x29')](respondWithFilteredResult(_0x3ed995,_0x24ecee))['catch'](handleError(_0x3ed995,null));};exports[_0x0baf('0x4d')]=function(_0x2bc755,_0x1daf1d){var _0x339aff={'raw':![],'where':{'id':_0x2bc755['params']['id']}},_0x22207a={};_0x22207a[_0x0baf('0x39')]=_[_0x0baf('0x3b')](db[_0x0baf('0x35')][_0x0baf('0x36')]);_0x22207a[_0x0baf('0x3a')]=_['keys'](_0x2bc755[_0x0baf('0x3a')]);_0x22207a[_0x0baf('0x43')]=_[_0x0baf('0x3c')](_0x22207a[_0x0baf('0x39')],_0x22207a[_0x0baf('0x3a')]);_0x339aff[_0x0baf('0x3d')]=_[_0x0baf('0x3c')](_0x22207a['model'],qs[_0x0baf('0x3e')](_0x2bc755[_0x0baf('0x3a')][_0x0baf('0x3e')]));_0x339aff['attributes']=_0x339aff[_0x0baf('0x3d')][_0x0baf('0x4e')]?_0x339aff[_0x0baf('0x3d')]:_0x22207a[_0x0baf('0x39')];if(_0x2bc755[_0x0baf('0x3a')][_0x0baf('0x49')]){_0x339aff[_0x0baf('0x4a')]=[{'all':!![]}];}_0x339aff=_['merge']({},_0x339aff,_0x2bc755[_0x0baf('0x48')]);return db[_0x0baf('0x35')][_0x0baf('0x4f')](_0x339aff)[_0x0baf('0x29')](handleEntityNotFound(_0x1daf1d,null))[_0x0baf('0x29')](respondWithResult(_0x1daf1d,null))[_0x0baf('0x50')](handleError(_0x1daf1d,null));};exports[_0x0baf('0x2a')]=function(_0x1af4aa,_0x2be7fe){return db[_0x0baf('0x35')][_0x0baf('0x4f')]({'where':{'id':_0x1af4aa['params']['id']}})['then'](handleEntityNotFound(_0x2be7fe,null))[_0x0baf('0x29')](removeEntity(_0x2be7fe,null))[_0x0baf('0x50')](handleError(_0x2be7fe,null));};exports[_0x0baf('0x51')]=function(_0xb8fa28,_0x21b108){return db[_0x0baf('0x35')][_0x0baf('0x51')]()['then'](respondWithResult(_0x21b108,null))[_0x0baf('0x50')](handleError(_0x21b108,null));};exports[_0x0baf('0x52')]=function(_0xf2424,_0x16d9fb){var _0x3fdb41;return db[_0x0baf('0x53')]['transaction'](function(_0x3eebe5){return db['VoicePrefix'][_0x0baf('0x52')](_0xf2424['body'],{'transaction':_0x3eebe5})[_0x0baf('0x29')](function(_0x5eaeb2){_0x3fdb41=_0x5eaeb2[_0x0baf('0x2b')]({'plain':!![]});return db['VoiceExtension'][_0x0baf('0x4f')]({'where':{'id':_0x3fdb41[_0x0baf('0x54')]},'raw':!![]})[_0x0baf('0x29')](function(_0x4520d1){return createVoicePrefixExtensions(_0x3fdb41,_0x4520d1,_0x3eebe5);});});})[_0x0baf('0x29')](function(){var _0x576475=_0xf2424[_0x0baf('0x55')][_0x0baf('0x2b')]({'plain':!![]});if(!_0x576475)throw new Error(_0x0baf('0x56'));if(_0x576475[_0x0baf('0x57')]===_0x0baf('0x55')){var _0xa19b21=_0x3fdb41;return db['UserProfileSection'][_0x0baf('0x4f')]({'where':{'name':_0x0baf('0x2c'),'userProfileId':_0x576475[_0x0baf('0x58')]},'raw':!![]})[_0x0baf('0x29')](function(_0xbc7cc2){if(_0xbc7cc2&&_0xbc7cc2[_0x0baf('0x59')]===0x0){return db[_0x0baf('0x2d')]['create']({'name':_0xa19b21['name'],'resourceId':_0xa19b21['id'],'type':_0xbc7cc2[_0x0baf('0x31')],'sectionId':_0xbc7cc2['id']},{})[_0x0baf('0x29')](function(){return _0x3fdb41;});}else{return _0x3fdb41;}})[_0x0baf('0x50')](function(_0x337d94){logger[_0x0baf('0x2f')](_0x0baf('0x5a'),_0x337d94);throw _0x337d94;});}return _0x3fdb41;})[_0x0baf('0x29')](respondWithResult(_0x16d9fb,null))[_0x0baf('0x50')](handleError(_0x16d9fb,null));};function Extension(_0x3d9a32,_0x585969,_0x3238f9,_0x268be8){this[_0x0baf('0x5b')]=_0x0baf('0x5c');this[_0x0baf('0x5d')]=_0x3d9a32;this[_0x0baf('0x5e')]=_0x3238f9;this[_0x0baf('0x38')]='system';this[_0x0baf('0x5f')]=_0x0baf('0x60');this[_0x0baf('0x61')]=_0x585969;this[_0x0baf('0x62')]=_0x268be8;}function createVoicePrefixExtensions(_0x1c7d88,_0x1a6d22,_0x14e6d0){return new BPromise(function(_0x12543e,_0x498405){var _0x178495=new Extension(formatPrefixName(_0x1c7d88['prefix']),0x1,_0x0baf('0x63'),'Voice\x20Prefix');_0x178495['VoicePrefixId']=_0x1c7d88['id'];return db[_0x0baf('0x64')]['create'](_0x178495,{'transaction':_0x14e6d0})[_0x0baf('0x29')](function(_0x2b17f8){var _0x49d713=_0x2b17f8[_0x0baf('0x2b')]({'plain':!![]});var _0xfb6708=_[_0x0baf('0x34')](addVoicePrefixExtensions(_0x1c7d88,_0x1a6d22),function(_0x5b3c1d){_0x5b3c1d['VoiceExtensionId']=_0x49d713['id'];_0x5b3c1d[_0x0baf('0x65')]=_0x1c7d88['id'];return _0x5b3c1d;});return db[_0x0baf('0x64')][_0x0baf('0x66')](_0xfb6708,{'transaction':_0x14e6d0})[_0x0baf('0x29')](function(_0x784e1a){if(!_0x784e1a){return _0x498405('Extensions\x20creation\x20failed');}else{return _0x12543e(_0x784e1a);}})[_0x0baf('0x50')](function(_0x4c02ca){return _0x498405(_0x4c02ca);});});;});};function addVoicePrefixExtensions(_0x5d5751,_0x59a0b2){var _0x427ed1=[];var _0x58a366=formatPrefixName(_0x5d5751['prefix']);_0x427ed1[_0x0baf('0x67')](new Extension(_0x58a366,0x2,_0x0baf('0x68'),_0x0baf('0x69')+_0x5d5751[_0x0baf('0x31')]));if(_0x5d5751[_0x0baf('0x6a')]){_0x427ed1[_0x0baf('0x67')](new Extension(_0x58a366,0x3,'Set',_0x0baf('0x6b')+_0x5d5751[_0x0baf('0x6a')]));}else{_0x427ed1[_0x0baf('0x67')](new Extension(_0x58a366,0x3,_0x0baf('0x63'),_0x0baf('0x6c')));}_0x427ed1[_0x0baf('0x67')](new Extension(_0x58a366,0x4,'goto',_0x59a0b2[_0x0baf('0x5b')]+','+_0x0baf('0x6d')+(0x8+_0x5d5751[_0x0baf('0x31')]['length'])+'}'+','+0x1));return _0x427ed1;}function formatPrefixName(_0x89484d){var _0x1e474f='_';for(var _0x3d333d=0x0;_0x3d333d<_0x89484d[_0x0baf('0x4e')];_0x3d333d++){if(_0x89484d[_0x0baf('0x6e')](_0x3d333d)=='-'){_0x1e474f+=_0x89484d[_0x0baf('0x6e')](_0x3d333d);}else{_0x1e474f+='['+_0x89484d[_0x0baf('0x6e')](_0x3d333d)+']';}}_0x1e474f+='.';return _0x1e474f;}exports['update']=function(_0x54353a,_0x4b7caa,_0x6ce83c){var _0x89bec7=_0x54353a[_0x0baf('0x6f')];_0x89bec7[_0x0baf('0x70')]=_0x0baf('0x71')+_0x89bec7[_0x0baf('0x31')]+'-';return db['sequelize']['transaction'](function(_0x34c1f4){return db['VoicePrefix'][_0x0baf('0x28')](_0x89bec7,{'where':{'id':_0x89bec7['id']},'transaction':_0x34c1f4})[_0x0baf('0x29')](function(){return db['VoiceExtension'][_0x0baf('0x2a')]({'where':{'VoicePrefixId':_0x89bec7['id']},'transaction':_0x34c1f4})[_0x0baf('0x29')](function(){return db[_0x0baf('0x64')][_0x0baf('0x4f')]({'where':{'id':_0x89bec7[_0x0baf('0x54')]},'raw':!![]})[_0x0baf('0x29')](function(_0x1b6b73){return createVoicePrefixExtensions(_0x89bec7,_0x1b6b73,_0x34c1f4);});});});})[_0x0baf('0x29')](function(){return db[_0x0baf('0x35')]['findById'](_0x89bec7['id']);})['then'](respondWithResult(_0x4b7caa,null))['catch'](handleError(_0x4b7caa,null));};exports['addAgents']=function(_0x5361a5,_0x418c45,_0x18963f){return db[_0x0baf('0x35')][_0x0baf('0x4f')]({'where':{'id':_0x5361a5['params']['id']}})[_0x0baf('0x29')](handleEntityNotFound(_0x418c45,null))[_0x0baf('0x29')](function(_0x58caee){if(_0x58caee){return _0x58caee['addAgents'](_0x5361a5[_0x0baf('0x6f')][_0x0baf('0x72')],_[_0x0baf('0x73')](_0x5361a5[_0x0baf('0x6f')],[_0x0baf('0x72'),'id'])||{})[_0x0baf('0x74')](function(_0x3ce111){for(var _0x399f40=0x0;_0x399f40<_0x5361a5['body'][_0x0baf('0x72')][_0x0baf('0x4e')];_0x399f40+=0x1){socket['emit'](_0x0baf('0x75'),{'UserId':Number(_0x5361a5[_0x0baf('0x6f')]['ids'][_0x399f40]),'VoicePrefixId':Number(_0x5361a5[_0x0baf('0x76')]['id'])});}return _0x3ce111;});}})[_0x0baf('0x29')](respondWithResult(_0x418c45,null))[_0x0baf('0x50')](handleError(_0x418c45,null));};exports[_0x0baf('0x77')]=function(_0x167977,_0x4fc5af,_0x4807fc){return db[_0x0baf('0x35')][_0x0baf('0x4f')]({'where':{'id':_0x167977['params']['id']}})[_0x0baf('0x29')](handleEntityNotFound(_0x4fc5af,null))[_0x0baf('0x29')](function(_0x21ad25){if(_0x21ad25){return _0x21ad25['removeAgents'](_0x167977[_0x0baf('0x3a')][_0x0baf('0x72')])[_0x0baf('0x29')](function(){if(_['isArray'](_0x167977[_0x0baf('0x3a')]['ids'])){for(var _0x316397=0x0;_0x316397<_0x167977[_0x0baf('0x3a')][_0x0baf('0x72')][_0x0baf('0x4e')];_0x316397+=0x1){socket[_0x0baf('0x78')]('userVoicePrefix:remove',{'UserId':Number(_0x167977[_0x0baf('0x3a')][_0x0baf('0x72')][_0x316397]),'VoicePrefixId':Number(_0x167977['params']['id'])});}}else{socket[_0x0baf('0x78')](_0x0baf('0x79'),{'UserId':Number(_0x167977[_0x0baf('0x3a')][_0x0baf('0x72')]),'VoicePrefixId':Number(_0x167977[_0x0baf('0x76')]['id'])});}});}})[_0x0baf('0x29')](respondWithStatusCode(_0x4fc5af,null))[_0x0baf('0x50')](handleError(_0x4fc5af,null));};exports[_0x0baf('0x7a')]=function(_0x44ef57,_0x1ca3a6,_0x3b7abf){var _0x2c2f09={};var _0x5985f9={};var _0x599ac0;var _0x29a036;return db[_0x0baf('0x35')][_0x0baf('0x7b')]({'where':{'id':_0x44ef57['params']['id']}})['then'](handleEntityNotFound(_0x1ca3a6,null))[_0x0baf('0x29')](function(_0x368e23){if(_0x368e23){_0x599ac0=_0x368e23;_0x5985f9[_0x0baf('0x39')]=_[_0x0baf('0x3b')](db[_0x0baf('0x7c')][_0x0baf('0x36')]);_0x5985f9[_0x0baf('0x3a')]=_[_0x0baf('0x3b')](_0x44ef57[_0x0baf('0x3a')]);_0x5985f9['filters']=_[_0x0baf('0x3c')](_0x5985f9[_0x0baf('0x39')],_0x5985f9[_0x0baf('0x3a')]);_0x2c2f09[_0x0baf('0x3d')]=_['intersection'](_0x5985f9['model'],qs['fields'](_0x44ef57[_0x0baf('0x3a')][_0x0baf('0x3e')]));_0x2c2f09['attributes']=_0x2c2f09['attributes'][_0x0baf('0x4e')]?_0x2c2f09[_0x0baf('0x3d')]:_0x5985f9['model'];_0x2c2f09[_0x0baf('0x40')]=qs[_0x0baf('0x41')](_0x44ef57[_0x0baf('0x3a')][_0x0baf('0x41')]);_0x2c2f09[_0x0baf('0x42')]=qs[_0x0baf('0x43')](_[_0x0baf('0x44')](_0x44ef57[_0x0baf('0x3a')],_0x5985f9[_0x0baf('0x43')]));if(_0x44ef57[_0x0baf('0x3a')][_0x0baf('0x45')]){_0x2c2f09[_0x0baf('0x42')]=_['merge'](_0x2c2f09[_0x0baf('0x42')],{'$or':_[_0x0baf('0x34')](_0x2c2f09[_0x0baf('0x3d')],function(_0x3bd15b){var _0x3c37b4={};_0x3c37b4[_0x3bd15b]={'$like':'%'+_0x44ef57[_0x0baf('0x3a')]['filter']+'%'};return _0x3c37b4;})});}_0x2c2f09=_[_0x0baf('0x46')]({},_0x2c2f09,_0x44ef57[_0x0baf('0x48')]);return _0x599ac0[_0x0baf('0x7a')](_0x2c2f09);}})[_0x0baf('0x29')](function(_0x4376a1){if(_0x4376a1){_0x29a036=_0x4376a1['length'];if(!_0x44ef57[_0x0baf('0x3a')][_0x0baf('0x3f')](_0x0baf('0x7d'))){_0x2c2f09[_0x0baf('0x24')]=qs[_0x0baf('0x24')](_0x44ef57['query']['limit']);_0x2c2f09[_0x0baf('0x22')]=qs['offset'](_0x44ef57[_0x0baf('0x3a')]['offset']);}return _0x599ac0[_0x0baf('0x7a')](_0x2c2f09);}})[_0x0baf('0x29')](function(_0x1ce7bb){if(_0x1ce7bb){return _0x1ce7bb?{'count':_0x29a036,'rows':_0x1ce7bb}:null;}})[_0x0baf('0x29')](respondWithResult(_0x1ca3a6,null))['catch'](handleError(_0x1ca3a6,null));};exports[_0x0baf('0x7e')]=function(_0x106ffa,_0xf7a9d0,_0x551df3){var _0x487aec={};var _0x591cc2={};var _0x4d4884;var _0x427638;return db[_0x0baf('0x35')][_0x0baf('0x7b')]({'where':{'id':_0x106ffa[_0x0baf('0x76')]['id']}})['then'](handleEntityNotFound(_0xf7a9d0,null))[_0x0baf('0x29')](function(_0x37594e){if(_0x37594e){_0x4d4884=_0x37594e;_0x591cc2[_0x0baf('0x39')]=_['keys'](db[_0x0baf('0x7f')][_0x0baf('0x36')]);_0x591cc2['query']=_[_0x0baf('0x3b')](_0x106ffa['query']);_0x591cc2[_0x0baf('0x43')]=_[_0x0baf('0x3c')](_0x591cc2[_0x0baf('0x39')],_0x591cc2[_0x0baf('0x3a')]);_0x487aec['attributes']=_['intersection'](_0x591cc2[_0x0baf('0x39')],qs['fields'](_0x106ffa[_0x0baf('0x3a')][_0x0baf('0x3e')]));_0x487aec[_0x0baf('0x3d')]=_0x487aec[_0x0baf('0x3d')][_0x0baf('0x4e')]?_0x487aec['attributes']:_0x591cc2[_0x0baf('0x39')];_0x487aec['order']=qs[_0x0baf('0x41')](_0x106ffa['query'][_0x0baf('0x41')]);_0x487aec['where']=qs[_0x0baf('0x43')](_[_0x0baf('0x44')](_0x106ffa[_0x0baf('0x3a')],_0x591cc2['filters']));if(_0x106ffa['query'][_0x0baf('0x45')]){_0x487aec[_0x0baf('0x42')]=_[_0x0baf('0x46')](_0x487aec[_0x0baf('0x42')],{'$or':_[_0x0baf('0x34')](_0x487aec[_0x0baf('0x3d')],function(_0x4e6059){var _0xd4170d={};_0xd4170d[_0x4e6059]={'$like':'%'+_0x106ffa['query'][_0x0baf('0x45')]+'%'};return _0xd4170d;})});}_0x487aec=_['merge']({},_0x487aec,_0x106ffa[_0x0baf('0x48')]);return _0x4d4884[_0x0baf('0x7e')](_0x487aec);}})[_0x0baf('0x29')](function(_0x557a38){if(_0x557a38){_0x427638=_0x557a38[_0x0baf('0x4e')];if(!_0x106ffa[_0x0baf('0x3a')]['hasOwnProperty']('nolimit')){_0x487aec[_0x0baf('0x24')]=qs[_0x0baf('0x24')](_0x106ffa[_0x0baf('0x3a')][_0x0baf('0x24')]);_0x487aec['offset']=qs['offset'](_0x106ffa[_0x0baf('0x3a')][_0x0baf('0x22')]);}return _0x4d4884[_0x0baf('0x7e')](_0x487aec);}})[_0x0baf('0x29')](function(_0xfc91ce){if(_0xfc91ce){return _0xfc91ce?{'count':_0x427638,'rows':_0xfc91ce}:null;}})[_0x0baf('0x29')](respondWithResult(_0xf7a9d0,null))[_0x0baf('0x50')](handleError(_0xf7a9d0,null));};exports[_0x0baf('0x80')]=function(_0x205de6,_0x2369f0,_0x58f95c){var _0xdb96c0=_0x205de6['body'][_0x0baf('0x72')];var _0x42abcf;return db[_0x0baf('0x7f')][_0x0baf('0x4b')]({'where':{'id':_0xdb96c0},'attributes':['id'],'include':[{'model':db['User'],'as':_0x0baf('0x81'),'attributes':['id',_0x0baf('0x31'),_0x0baf('0x82'),_0x0baf('0x83'),_0x0baf('0x84')],'raw':!![]}]})[_0x0baf('0x29')](function(_0x3b9101){if(_0x3b9101){_0x42abcf=_0x3b9101;var _0x205075=_[_0x0baf('0x85')](_0x3b9101,function(_0x4b6cd5){var _0x8d1bae=_0x4b6cd5[_0x0baf('0x2b')]({'plain':!![]});return _0x8d1bae['Agents'];});return db[_0x0baf('0x35')][_0x0baf('0x4f')]({'where':{'id':_0x205de6[_0x0baf('0x76')]['id']}})[_0x0baf('0x29')](function(_0x97f5d6){return db[_0x0baf('0x53')][_0x0baf('0x86')](function(_0x8c1dc2){return _0x97f5d6[_0x0baf('0x80')](_0xdb96c0,{'transaction':_0x8c1dc2})['then'](function(){return BPromise[_0x0baf('0x87')](_0x42abcf,function(_0x218fc5){return db[_0x0baf('0x88')][_0x0baf('0x89')]({'TeamId':_0x218fc5['id'],'VoicePrefixId':_0x205de6[_0x0baf('0x76')]['id']},{'transaction':_0x8c1dc2});});})[_0x0baf('0x29')](function(){return BPromise['each'](_0x205075,function(_0x121718){return db[_0x0baf('0x8a')][_0x0baf('0x8b')]({'where':{'UserId':_0x121718['id'],'VoicePrefixId':_0x205de6['params']['id']},'transaction':_0x8c1dc2});});})['then'](function(){_0x205075[_0x0baf('0x8c')](function(_0x1adb84){socket[_0x0baf('0x78')]('userVoicePrefix:save',{'UserId':_0x1adb84['id'],'VoicePrefixId':_0x97f5d6['id']});});});});});}})[_0x0baf('0x29')](respondWithStatusCode(_0x2369f0,null))['catch'](handleError(_0x2369f0,null));};exports[_0x0baf('0x8d')]=function(_0x5f09be,_0x41b216,_0x3f2838){return db['Team'][_0x0baf('0x4b')]({'where':{'id':_0x5f09be[_0x0baf('0x3a')][_0x0baf('0x72')]},'attributes':['id'],'include':[{'model':db[_0x0baf('0x7c')],'as':_0x0baf('0x81'),'attributes':['id'],'raw':!![]}]})[_0x0baf('0x29')](handleEntityNotFound(_0x41b216,null))[_0x0baf('0x29')](function(_0x5508db){var _0x727cad=_[_0x0baf('0x34')](_0x5508db,'id');var _0x2766fb=[];var _0x2e1629=[];var _0x275cc4=squel[_0x0baf('0x8e')]();_0x275cc4[_0x0baf('0x8f')](_0x0baf('0x90'))[_0x0baf('0x91')](_0x0baf('0x92'),'tq')[_0x0baf('0x93')](_0x0baf('0x94'),'ut',_0x0baf('0x95'))[_0x0baf('0x42')]('VoicePrefixId\x20=\x20?',_0x5f09be['params']['id']);for(var _0x1cd215=0x0;_0x1cd215<_0x5508db[_0x0baf('0x4e')];_0x1cd215+=0x1){let _0x3b9429=_0x5508db[_0x1cd215];for(var _0x41d397=0x0;_0x41d397<_0x3b9429['Agents'][_0x0baf('0x4e')];_0x41d397+=0x1){let _0xc6c049=_0x3b9429[_0x0baf('0x81')][_0x41d397];var _0x2fb267=_0x275cc4[_0x0baf('0x96')]();_0x2fb267[_0x0baf('0x42')]('ut.UserId\x20=\x20?',_0xc6c049['id']);_0x2e1629[_0x0baf('0x67')](db[_0x0baf('0x53')][_0x0baf('0x3a')](_0x2fb267['toString'](),{'type':db[_0x0baf('0x53')][_0x0baf('0x97')][_0x0baf('0x98')]})['then'](function(_0x4f7145){if(_0x4f7145['length']===0x1){return _0xc6c049['id'];}else{var _0x11a85a=_['every'](_[_0x0baf('0x34')](_0x4f7145,_0x0baf('0x99')),function(_0x55124b){return _[_0x0baf('0x9a')](_0x727cad,_0x55124b);});if(_0x11a85a){return _0xc6c049['id'];}}}));}}return BPromise['all'](_0x2e1629)['then'](function(_0x21516f){_0x2766fb=_(_0x2766fb)['union'](_0x21516f)[_0x0baf('0x9b')]()['value']();return db['VoicePrefix']['find']({'where':{'id':_0x5f09be[_0x0baf('0x76')]['id']}})[_0x0baf('0x29')](function(_0x3d1f80){return db[_0x0baf('0x53')][_0x0baf('0x86')](function(_0x4f9904){return _0x3d1f80[_0x0baf('0x8d')](_0x5f09be['query'][_0x0baf('0x72')],{'transaction':_0x4f9904})[_0x0baf('0x29')](function(){if(!_[_0x0baf('0x9c')](_0x2766fb)){return _0x3d1f80['removeAgents'](_0x2766fb,{'transaction':_0x4f9904});}})[_0x0baf('0x29')](function(){_0x2766fb[_0x0baf('0x8c')](function(_0x12311d){socket['emit'](_0x0baf('0x79'),{'UserId':_0x12311d,'VoicePrefixId':_0x3d1f80['id']});});});});});});})['then'](respondWithStatusCode(_0x41b216,null))[_0x0baf('0x50')](handleError(_0x41b216,null));};
\ No newline at end of file
+var _0xef0f=['sequelize','transaction','addAgents','ids','omit','emit','userVoicePrefix:save','removeAgents','isArray','userVoicePrefix:remove','getAgents','User','order','where','filter','getTeams','findOne','Team','online','interface','Agents','addTeams','each','TeamVoicePrefix','upsert','UserVoicePrefix','findOrCreate','forEach','removeTeams','select','field','tq.TeamId','from','team_has_voice_prefixes','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','VoicePrefixId\x20=\x20?','clone','toString','SELECT','every','TeamId','includes','all','compact','isEmpty','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','querystring','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','defaults','redis','localhost','socket.io-emitter','./voicePrefix.socket','register','end','status','json','offset','undefined','limit','count','set','reject','save','destroy','then','get','UserProfileResource','sendStatus','error','name','type','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','pick','merge','VIRTUAL','options','VoicePrefix','includeAll','include','findAll','catch','show','params','rawAttributes','find','describe','create','body','VoiceExtension','VoiceExtensionId','user','role','UserProfileSection','VoicePrefixes','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','from-sip','exten','app','system','Voice\x20Prefix\x20Extension','appdata','prefix','NoOp','Voice\x20Prefix','VoicePrefixId','map','bulkCreate','Extensions\x20creation\x20failed','Set','CDR(prefix)=','callerIdAll','push','PREFIX-CALLERIDALL=','No\x20callerid\x20available','context','${EXTEN:','charAt','update','system-'];(function(_0x25dcbd,_0x1d2baf){var _0x5af92f=function(_0x286f4b){while(--_0x286f4b){_0x25dcbd['push'](_0x25dcbd['shift']());}};_0x5af92f(++_0x1d2baf);}(_0xef0f,0x168));var _0xfef0=function(_0x446eac,_0x29f115){_0x446eac=_0x446eac-0x0;var _0x2d0614=_0xef0f[_0x446eac];return _0x2d0614;};'use strict';var emlformat=require(_0xfef0('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xfef0('0x1'));var jsonpatch=require(_0xfef0('0x2'));var rp=require(_0xfef0('0x3'));var moment=require('moment');var BPromise=require(_0xfef0('0x4'));var Mustache=require(_0xfef0('0x5'));var util=require(_0xfef0('0x6'));var path=require('path');var sox=require(_0xfef0('0x7'));var csv=require(_0xfef0('0x8'));var ejs=require(_0xfef0('0x9'));var fs=require('fs');var fs_extra=require(_0xfef0('0xa'));var _=require(_0xfef0('0xb'));var squel=require(_0xfef0('0xc'));var crypto=require('crypto');var jsforce=require(_0xfef0('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xfef0('0x8'));var querystring=require(_0xfef0('0xe'));var Papa=require(_0xfef0('0xf'));var Redis=require(_0xfef0('0x10'));var authService=require(_0xfef0('0x11'));var qs=require(_0xfef0('0x12'));var as=require(_0xfef0('0x13'));var hardwareService=require(_0xfef0('0x14'));var logger=require(_0xfef0('0x15'))(_0xfef0('0x16'));var utils=require(_0xfef0('0x17'));var config=require(_0xfef0('0x18'));var licenseUtil=require(_0xfef0('0x19'));var db=require(_0xfef0('0x1a'))['db'];config['redis']=_[_0xfef0('0x1b')](config[_0xfef0('0x1c')],{'host':_0xfef0('0x1d'),'port':0x18eb});var socket=require(_0xfef0('0x1e'))(new Redis(config[_0xfef0('0x1c')]));require(_0xfef0('0x1f'))[_0xfef0('0x20')](socket);function respondWithStatusCode(_0x573ae7,_0x3d1f02){_0x3d1f02=_0x3d1f02||0xcc;return function(_0x554aaa){if(_0x554aaa){return _0x573ae7['sendStatus'](_0x3d1f02);}return _0x573ae7['status'](_0x3d1f02)[_0xfef0('0x21')]();};}function respondWithResult(_0x284b6d,_0x3510a7){_0x3510a7=_0x3510a7||0xc8;return function(_0x1bce2f){if(_0x1bce2f){return _0x284b6d[_0xfef0('0x22')](_0x3510a7)[_0xfef0('0x23')](_0x1bce2f);}};}function respondWithFilteredResult(_0x155833,_0x2887e6){return function(_0x581459){if(_0x581459){var _0xd60678=typeof _0x2887e6[_0xfef0('0x24')]===_0xfef0('0x25')&&typeof _0x2887e6[_0xfef0('0x26')]===_0xfef0('0x25');var _0x55912f=_0x581459[_0xfef0('0x27')];var _0x4e24de=_0xd60678?0x0:_0x2887e6[_0xfef0('0x24')];var _0x1a0aa0=_0xd60678?_0x581459[_0xfef0('0x27')]:_0x2887e6['offset']+_0x2887e6[_0xfef0('0x26')];var _0x4c304d;if(_0x1a0aa0>=_0x55912f){_0x1a0aa0=_0x55912f;_0x4c304d=0xc8;}else{_0x4c304d=0xce;}_0x155833[_0xfef0('0x22')](_0x4c304d);return _0x155833[_0xfef0('0x28')]('Content-Range',_0x4e24de+'-'+_0x1a0aa0+'/'+_0x55912f)['json'](_0x581459);}return null;};}function patchUpdates(_0x4b8b22){return function(_0x19fde8){try{jsonpatch['apply'](_0x19fde8,_0x4b8b22,!![]);}catch(_0x1f9970){return BPromise[_0xfef0('0x29')](_0x1f9970);}return _0x19fde8[_0xfef0('0x2a')]();};}function saveUpdates(_0x4483f2,_0x249fe4){return function(_0xd687ed){if(_0xd687ed){return _0xd687ed['update'](_0x4483f2)['then'](function(_0x316e20){return _0x316e20;});}return null;};}function removeEntity(_0x1ffaa4,_0x924f6e){return function(_0x34ca65){if(_0x34ca65){return _0x34ca65[_0xfef0('0x2b')]()[_0xfef0('0x2c')](function(){var _0x5df04f=_0x34ca65[_0xfef0('0x2d')]({'plain':!![]});var _0x391279='VoicePrefixes';return db[_0xfef0('0x2e')][_0xfef0('0x2b')]({'where':{'type':_0x391279,'resourceId':_0x5df04f['id']}})[_0xfef0('0x2c')](function(){return _0x34ca65;});})[_0xfef0('0x2c')](function(){_0x1ffaa4[_0xfef0('0x22')](0xcc)[_0xfef0('0x21')]();});}};}function handleEntityNotFound(_0x3e3c4c,_0x3e026a){return function(_0x26cb9a){if(!_0x26cb9a){_0x3e3c4c[_0xfef0('0x2f')](0x194);}return _0x26cb9a;};}function handleError(_0x3ee42f,_0x3ffea0){_0x3ffea0=_0x3ffea0||0x1f4;return function(_0x51af0f){logger[_0xfef0('0x30')](_0x51af0f['stack']);if(_0x51af0f['name']){delete _0x51af0f[_0xfef0('0x31')];}_0x3ee42f[_0xfef0('0x22')](_0x3ffea0)['send'](_0x51af0f);};}exports['index']=function(_0x5cf518,_0x4f65cd){var _0x4cce8a={},_0x417535={},_0x172d94={'count':0x0,'rows':[]};var _0x2fffae=_['map'](db['VoicePrefix']['rawAttributes'],function(_0x1f8110){return{'name':_0x1f8110['fieldName'],'type':_0x1f8110[_0xfef0('0x32')][_0xfef0('0x33')]};});_0x417535[_0xfef0('0x34')]=_['map'](_0x2fffae,_0xfef0('0x31'));_0x417535['query']=_[_0xfef0('0x35')](_0x5cf518[_0xfef0('0x36')]);_0x417535[_0xfef0('0x37')]=_[_0xfef0('0x38')](_0x417535[_0xfef0('0x34')],_0x417535[_0xfef0('0x36')]);_0x4cce8a[_0xfef0('0x39')]=_[_0xfef0('0x38')](_0x417535['model'],qs[_0xfef0('0x3a')](_0x5cf518[_0xfef0('0x36')][_0xfef0('0x3a')]));_0x4cce8a[_0xfef0('0x39')]=_0x4cce8a[_0xfef0('0x39')][_0xfef0('0x3b')]?_0x4cce8a[_0xfef0('0x39')]:_0x417535[_0xfef0('0x34')];if(!_0x5cf518[_0xfef0('0x36')][_0xfef0('0x3c')](_0xfef0('0x3d'))){_0x4cce8a[_0xfef0('0x26')]=qs[_0xfef0('0x26')](_0x5cf518['query'][_0xfef0('0x26')]);_0x4cce8a['offset']=qs[_0xfef0('0x24')](_0x5cf518[_0xfef0('0x36')][_0xfef0('0x24')]);}_0x4cce8a['order']=qs[_0xfef0('0x3e')](_0x5cf518[_0xfef0('0x36')][_0xfef0('0x3e')]);_0x4cce8a['where']=qs[_0xfef0('0x37')](_[_0xfef0('0x3f')](_0x5cf518[_0xfef0('0x36')],_0x417535['filters']),_0x2fffae);if(_0x5cf518[_0xfef0('0x36')]['filter']){_0x4cce8a['where']=_[_0xfef0('0x40')](_0x4cce8a['where'],{'$or':_['map'](_0x2fffae,function(_0xbf6ddd){if(_0xbf6ddd[_0xfef0('0x32')]!==_0xfef0('0x41')){var _0x1a6593={};_0x1a6593[_0xbf6ddd[_0xfef0('0x31')]]={'$like':'%'+_0x5cf518[_0xfef0('0x36')]['filter']+'%'};return _0x1a6593;}})});}_0x4cce8a=_[_0xfef0('0x40')]({},_0x4cce8a,_0x5cf518[_0xfef0('0x42')]);var _0x5a9ed3={'where':_0x4cce8a['where']};return db[_0xfef0('0x43')]['count'](_0x5a9ed3)[_0xfef0('0x2c')](function(_0x22c940){_0x172d94[_0xfef0('0x27')]=_0x22c940;if(_0x5cf518[_0xfef0('0x36')][_0xfef0('0x44')]){_0x4cce8a[_0xfef0('0x45')]=[{'all':!![]}];}return db[_0xfef0('0x43')][_0xfef0('0x46')](_0x4cce8a);})['then'](function(_0x1813dc){_0x172d94['rows']=_0x1813dc;return _0x172d94;})['then'](respondWithFilteredResult(_0x4f65cd,_0x4cce8a))[_0xfef0('0x47')](handleError(_0x4f65cd,null));};exports[_0xfef0('0x48')]=function(_0x5bf416,_0x2af79f){var _0x5587a9={'raw':![],'where':{'id':_0x5bf416[_0xfef0('0x49')]['id']}},_0x39df7c={};_0x39df7c[_0xfef0('0x34')]=_[_0xfef0('0x35')](db['VoicePrefix'][_0xfef0('0x4a')]);_0x39df7c[_0xfef0('0x36')]=_['keys'](_0x5bf416['query']);_0x39df7c[_0xfef0('0x37')]=_['intersection'](_0x39df7c[_0xfef0('0x34')],_0x39df7c[_0xfef0('0x36')]);_0x5587a9[_0xfef0('0x39')]=_[_0xfef0('0x38')](_0x39df7c[_0xfef0('0x34')],qs[_0xfef0('0x3a')](_0x5bf416['query'][_0xfef0('0x3a')]));_0x5587a9['attributes']=_0x5587a9['attributes'][_0xfef0('0x3b')]?_0x5587a9[_0xfef0('0x39')]:_0x39df7c[_0xfef0('0x34')];if(_0x5bf416['query'][_0xfef0('0x44')]){_0x5587a9['include']=[{'all':!![]}];}_0x5587a9=_['merge']({},_0x5587a9,_0x5bf416['options']);return db[_0xfef0('0x43')][_0xfef0('0x4b')](_0x5587a9)[_0xfef0('0x2c')](handleEntityNotFound(_0x2af79f,null))[_0xfef0('0x2c')](respondWithResult(_0x2af79f,null))[_0xfef0('0x47')](handleError(_0x2af79f,null));};exports[_0xfef0('0x2b')]=function(_0x1b78af,_0x3853bb){return db[_0xfef0('0x43')]['find']({'where':{'id':_0x1b78af['params']['id']}})[_0xfef0('0x2c')](handleEntityNotFound(_0x3853bb,null))[_0xfef0('0x2c')](removeEntity(_0x3853bb,null))[_0xfef0('0x47')](handleError(_0x3853bb,null));};exports[_0xfef0('0x4c')]=function(_0x393fee,_0x1e1458){return db[_0xfef0('0x43')][_0xfef0('0x4c')]()['then'](respondWithResult(_0x1e1458,null))[_0xfef0('0x47')](handleError(_0x1e1458,null));};exports[_0xfef0('0x4d')]=function(_0x247caf,_0x10378e){var _0x6591d4;return db['sequelize']['transaction'](function(_0x523763){return db[_0xfef0('0x43')][_0xfef0('0x4d')](_0x247caf[_0xfef0('0x4e')],{'transaction':_0x523763})[_0xfef0('0x2c')](function(_0x4e959e){_0x6591d4=_0x4e959e[_0xfef0('0x2d')]({'plain':!![]});return db[_0xfef0('0x4f')][_0xfef0('0x4b')]({'where':{'id':_0x6591d4[_0xfef0('0x50')]},'raw':!![]})[_0xfef0('0x2c')](function(_0x2f94c4){return createVoicePrefixExtensions(_0x6591d4,_0x2f94c4,_0x523763);});});})[_0xfef0('0x2c')](function(){var _0x4cd0fd=_0x247caf[_0xfef0('0x51')][_0xfef0('0x2d')]({'plain':!![]});if(!_0x4cd0fd)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x4cd0fd[_0xfef0('0x52')]==='user'){var _0x175e97=_0x6591d4;return db[_0xfef0('0x53')]['find']({'where':{'name':_0xfef0('0x54'),'userProfileId':_0x4cd0fd['userProfileId']},'raw':!![]})['then'](function(_0x4812c7){if(_0x4812c7&&_0x4812c7[_0xfef0('0x55')]===0x0){return db[_0xfef0('0x2e')][_0xfef0('0x4d')]({'name':_0x175e97[_0xfef0('0x31')],'resourceId':_0x175e97['id'],'type':_0x4812c7[_0xfef0('0x31')],'sectionId':_0x4812c7['id']},{})[_0xfef0('0x2c')](function(){return _0x6591d4;});}else{return _0x6591d4;}})['catch'](function(_0xa365e5){logger[_0xfef0('0x30')](_0xfef0('0x56'),_0xa365e5);throw _0xa365e5;});}return _0x6591d4;})[_0xfef0('0x2c')](respondWithResult(_0x10378e,null))[_0xfef0('0x47')](handleError(_0x10378e,null));};function Extension(_0x58d95e,_0x59d1b6,_0x4aef94,_0x135653){this['context']=_0xfef0('0x57');this[_0xfef0('0x58')]=_0x58d95e;this[_0xfef0('0x59')]=_0x4aef94;this[_0xfef0('0x32')]=_0xfef0('0x5a');this['description']=_0xfef0('0x5b');this['priority']=_0x59d1b6;this[_0xfef0('0x5c')]=_0x135653;}function createVoicePrefixExtensions(_0x4a1316,_0x4a4d36,_0x3a12c5){return new BPromise(function(_0x3c5640,_0xd6de4d){var _0x35a486=new Extension(formatPrefixName(_0x4a1316[_0xfef0('0x5d')]),0x1,_0xfef0('0x5e'),_0xfef0('0x5f'));_0x35a486[_0xfef0('0x60')]=_0x4a1316['id'];return db[_0xfef0('0x4f')][_0xfef0('0x4d')](_0x35a486,{'transaction':_0x3a12c5})[_0xfef0('0x2c')](function(_0x46d0bb){var _0x5df358=_0x46d0bb[_0xfef0('0x2d')]({'plain':!![]});var _0x3b660c=_[_0xfef0('0x61')](addVoicePrefixExtensions(_0x4a1316,_0x4a4d36),function(_0x312dcf){_0x312dcf[_0xfef0('0x50')]=_0x5df358['id'];_0x312dcf['VoicePrefixId']=_0x4a1316['id'];return _0x312dcf;});return db[_0xfef0('0x4f')][_0xfef0('0x62')](_0x3b660c,{'transaction':_0x3a12c5})[_0xfef0('0x2c')](function(_0x3c6bb8){if(!_0x3c6bb8){return _0xd6de4d(_0xfef0('0x63'));}else{return _0x3c5640(_0x3c6bb8);}})[_0xfef0('0x47')](function(_0xb9693b){return _0xd6de4d(_0xb9693b);});});;});};function addVoicePrefixExtensions(_0x103ca3,_0x14d53d){var _0x3f26d9=[];var _0x4f7ad3=formatPrefixName(_0x103ca3[_0xfef0('0x5d')]);_0x3f26d9['push'](new Extension(_0x4f7ad3,0x2,_0xfef0('0x64'),_0xfef0('0x65')+_0x103ca3['name']));if(_0x103ca3[_0xfef0('0x66')]){_0x3f26d9[_0xfef0('0x67')](new Extension(_0x4f7ad3,0x3,_0xfef0('0x64'),_0xfef0('0x68')+_0x103ca3[_0xfef0('0x66')]));}else{_0x3f26d9['push'](new Extension(_0x4f7ad3,0x3,_0xfef0('0x5e'),_0xfef0('0x69')));}_0x3f26d9[_0xfef0('0x67')](new Extension(_0x4f7ad3,0x4,'goto',_0x14d53d[_0xfef0('0x6a')]+','+_0xfef0('0x6b')+(0x8+_0x103ca3[_0xfef0('0x31')][_0xfef0('0x3b')])+'}'+','+0x1));return _0x3f26d9;}function formatPrefixName(_0x7186c8){var _0x3cfe32='_';for(var _0x45ba65=0x0;_0x45ba65<_0x7186c8['length'];_0x45ba65++){if(_0x7186c8[_0xfef0('0x6c')](_0x45ba65)=='-'){_0x3cfe32+=_0x7186c8[_0xfef0('0x6c')](_0x45ba65);}else{_0x3cfe32+='['+_0x7186c8[_0xfef0('0x6c')](_0x45ba65)+']';}}_0x3cfe32+='.';return _0x3cfe32;}exports[_0xfef0('0x6d')]=function(_0x317eda,_0x2dde67,_0x488db4){var _0x340517=_0x317eda[_0xfef0('0x4e')];_0x340517[_0xfef0('0x5d')]=_0xfef0('0x6e')+_0x340517['name']+'-';return db[_0xfef0('0x6f')][_0xfef0('0x70')](function(_0x5a33a1){return db[_0xfef0('0x43')][_0xfef0('0x6d')](_0x340517,{'where':{'id':_0x340517['id']},'transaction':_0x5a33a1})[_0xfef0('0x2c')](function(){return db[_0xfef0('0x4f')][_0xfef0('0x2b')]({'where':{'VoicePrefixId':_0x340517['id']},'transaction':_0x5a33a1})['then'](function(){return db['VoiceExtension']['find']({'where':{'id':_0x340517[_0xfef0('0x50')]},'raw':!![]})[_0xfef0('0x2c')](function(_0x2474b2){return createVoicePrefixExtensions(_0x340517,_0x2474b2,_0x5a33a1);});});});})['then'](function(){return db[_0xfef0('0x43')]['findById'](_0x340517['id']);})['then'](respondWithResult(_0x2dde67,null))['catch'](handleError(_0x2dde67,null));};exports[_0xfef0('0x71')]=function(_0x1cf182,_0x50cd7a,_0x166aab){return db[_0xfef0('0x43')][_0xfef0('0x4b')]({'where':{'id':_0x1cf182['params']['id']}})[_0xfef0('0x2c')](handleEntityNotFound(_0x50cd7a,null))['then'](function(_0x5ee0c0){if(_0x5ee0c0){return _0x5ee0c0[_0xfef0('0x71')](_0x1cf182[_0xfef0('0x4e')][_0xfef0('0x72')],_[_0xfef0('0x73')](_0x1cf182['body'],['ids','id'])||{})['spread'](function(_0xd973d3){for(var _0x546455=0x0;_0x546455<_0x1cf182[_0xfef0('0x4e')][_0xfef0('0x72')][_0xfef0('0x3b')];_0x546455+=0x1){socket[_0xfef0('0x74')](_0xfef0('0x75'),{'UserId':Number(_0x1cf182['body'][_0xfef0('0x72')][_0x546455]),'VoicePrefixId':Number(_0x1cf182['params']['id'])});}return _0xd973d3;});}})['then'](respondWithResult(_0x50cd7a,null))[_0xfef0('0x47')](handleError(_0x50cd7a,null));};exports[_0xfef0('0x76')]=function(_0xc30175,_0x3bfe3f,_0x5a17a9){return db['VoicePrefix'][_0xfef0('0x4b')]({'where':{'id':_0xc30175[_0xfef0('0x49')]['id']}})['then'](handleEntityNotFound(_0x3bfe3f,null))[_0xfef0('0x2c')](function(_0x3bbb7e){if(_0x3bbb7e){return _0x3bbb7e[_0xfef0('0x76')](_0xc30175[_0xfef0('0x36')][_0xfef0('0x72')])[_0xfef0('0x2c')](function(){if(_[_0xfef0('0x77')](_0xc30175[_0xfef0('0x36')][_0xfef0('0x72')])){for(var _0x52fe45=0x0;_0x52fe45<_0xc30175[_0xfef0('0x36')][_0xfef0('0x72')][_0xfef0('0x3b')];_0x52fe45+=0x1){socket[_0xfef0('0x74')](_0xfef0('0x78'),{'UserId':Number(_0xc30175[_0xfef0('0x36')][_0xfef0('0x72')][_0x52fe45]),'VoicePrefixId':Number(_0xc30175['params']['id'])});}}else{socket[_0xfef0('0x74')](_0xfef0('0x78'),{'UserId':Number(_0xc30175[_0xfef0('0x36')][_0xfef0('0x72')]),'VoicePrefixId':Number(_0xc30175[_0xfef0('0x49')]['id'])});}});}})[_0xfef0('0x2c')](respondWithStatusCode(_0x3bfe3f,null))[_0xfef0('0x47')](handleError(_0x3bfe3f,null));};exports[_0xfef0('0x79')]=function(_0x32944e,_0x39c591,_0x1f2413){var _0x17c350={};var _0x283d5a={};var _0x5630a6;var _0x32aab6;return db['VoicePrefix']['findOne']({'where':{'id':_0x32944e[_0xfef0('0x49')]['id']}})[_0xfef0('0x2c')](handleEntityNotFound(_0x39c591,null))['then'](function(_0x299116){if(_0x299116){_0x5630a6=_0x299116;_0x283d5a['model']=_['keys'](db[_0xfef0('0x7a')][_0xfef0('0x4a')]);_0x283d5a[_0xfef0('0x36')]=_[_0xfef0('0x35')](_0x32944e['query']);_0x283d5a[_0xfef0('0x37')]=_[_0xfef0('0x38')](_0x283d5a['model'],_0x283d5a[_0xfef0('0x36')]);_0x17c350[_0xfef0('0x39')]=_[_0xfef0('0x38')](_0x283d5a['model'],qs['fields'](_0x32944e[_0xfef0('0x36')]['fields']));_0x17c350['attributes']=_0x17c350[_0xfef0('0x39')]['length']?_0x17c350[_0xfef0('0x39')]:_0x283d5a[_0xfef0('0x34')];_0x17c350[_0xfef0('0x7b')]=qs[_0xfef0('0x3e')](_0x32944e[_0xfef0('0x36')][_0xfef0('0x3e')]);_0x17c350[_0xfef0('0x7c')]=qs[_0xfef0('0x37')](_[_0xfef0('0x3f')](_0x32944e[_0xfef0('0x36')],_0x283d5a['filters']));if(_0x32944e[_0xfef0('0x36')]['filter']){_0x17c350['where']=_[_0xfef0('0x40')](_0x17c350['where'],{'$or':_[_0xfef0('0x61')](_0x17c350[_0xfef0('0x39')],function(_0x2e7268){var _0x34b802={};_0x34b802[_0x2e7268]={'$like':'%'+_0x32944e[_0xfef0('0x36')][_0xfef0('0x7d')]+'%'};return _0x34b802;})});}_0x17c350=_['merge']({},_0x17c350,_0x32944e[_0xfef0('0x42')]);return _0x5630a6[_0xfef0('0x79')](_0x17c350);}})[_0xfef0('0x2c')](function(_0x17a514){if(_0x17a514){_0x32aab6=_0x17a514[_0xfef0('0x3b')];if(!_0x32944e[_0xfef0('0x36')][_0xfef0('0x3c')](_0xfef0('0x3d'))){_0x17c350['limit']=qs[_0xfef0('0x26')](_0x32944e[_0xfef0('0x36')]['limit']);_0x17c350[_0xfef0('0x24')]=qs[_0xfef0('0x24')](_0x32944e[_0xfef0('0x36')]['offset']);}return _0x5630a6[_0xfef0('0x79')](_0x17c350);}})['then'](function(_0x1cb952){if(_0x1cb952){return _0x1cb952?{'count':_0x32aab6,'rows':_0x1cb952}:null;}})[_0xfef0('0x2c')](respondWithResult(_0x39c591,null))['catch'](handleError(_0x39c591,null));};exports[_0xfef0('0x7e')]=function(_0x51f79b,_0x1fa881,_0x8c4979){var _0x1b8ee7={};var _0x3eff14={};var _0x14d871;var _0x306319;return db[_0xfef0('0x43')][_0xfef0('0x7f')]({'where':{'id':_0x51f79b[_0xfef0('0x49')]['id']}})[_0xfef0('0x2c')](handleEntityNotFound(_0x1fa881,null))[_0xfef0('0x2c')](function(_0x5b7ffa){if(_0x5b7ffa){_0x14d871=_0x5b7ffa;_0x3eff14[_0xfef0('0x34')]=_['keys'](db['Team'][_0xfef0('0x4a')]);_0x3eff14['query']=_[_0xfef0('0x35')](_0x51f79b['query']);_0x3eff14['filters']=_[_0xfef0('0x38')](_0x3eff14['model'],_0x3eff14['query']);_0x1b8ee7['attributes']=_[_0xfef0('0x38')](_0x3eff14[_0xfef0('0x34')],qs[_0xfef0('0x3a')](_0x51f79b[_0xfef0('0x36')]['fields']));_0x1b8ee7[_0xfef0('0x39')]=_0x1b8ee7[_0xfef0('0x39')][_0xfef0('0x3b')]?_0x1b8ee7[_0xfef0('0x39')]:_0x3eff14[_0xfef0('0x34')];_0x1b8ee7['order']=qs['sort'](_0x51f79b[_0xfef0('0x36')][_0xfef0('0x3e')]);_0x1b8ee7['where']=qs[_0xfef0('0x37')](_[_0xfef0('0x3f')](_0x51f79b[_0xfef0('0x36')],_0x3eff14[_0xfef0('0x37')]));if(_0x51f79b[_0xfef0('0x36')][_0xfef0('0x7d')]){_0x1b8ee7[_0xfef0('0x7c')]=_[_0xfef0('0x40')](_0x1b8ee7['where'],{'$or':_['map'](_0x1b8ee7[_0xfef0('0x39')],function(_0x4135b0){var _0x14fc20={};_0x14fc20[_0x4135b0]={'$like':'%'+_0x51f79b[_0xfef0('0x36')][_0xfef0('0x7d')]+'%'};return _0x14fc20;})});}_0x1b8ee7=_[_0xfef0('0x40')]({},_0x1b8ee7,_0x51f79b[_0xfef0('0x42')]);return _0x14d871[_0xfef0('0x7e')](_0x1b8ee7);}})['then'](function(_0x5d7df9){if(_0x5d7df9){_0x306319=_0x5d7df9[_0xfef0('0x3b')];if(!_0x51f79b[_0xfef0('0x36')][_0xfef0('0x3c')](_0xfef0('0x3d'))){_0x1b8ee7[_0xfef0('0x26')]=qs[_0xfef0('0x26')](_0x51f79b['query'][_0xfef0('0x26')]);_0x1b8ee7[_0xfef0('0x24')]=qs['offset'](_0x51f79b[_0xfef0('0x36')][_0xfef0('0x24')]);}return _0x14d871[_0xfef0('0x7e')](_0x1b8ee7);}})[_0xfef0('0x2c')](function(_0x3b8b10){if(_0x3b8b10){return _0x3b8b10?{'count':_0x306319,'rows':_0x3b8b10}:null;}})[_0xfef0('0x2c')](respondWithResult(_0x1fa881,null))['catch'](handleError(_0x1fa881,null));};exports['addTeams']=function(_0x1084b9,_0xd7c5b,_0xd2c0be){var _0x15eefc=_0x1084b9[_0xfef0('0x4e')][_0xfef0('0x72')];var _0x4df302;return db[_0xfef0('0x80')]['findAll']({'where':{'id':_0x15eefc},'attributes':['id'],'include':[{'model':db[_0xfef0('0x7a')],'as':'Agents','attributes':['id',_0xfef0('0x31'),_0xfef0('0x81'),'voicePause',_0xfef0('0x82')],'raw':!![]}]})[_0xfef0('0x2c')](function(_0xc91fea){if(_0xc91fea){_0x4df302=_0xc91fea;var _0x4d56e5=_['flatMap'](_0xc91fea,function(_0x57083a){var _0x3a28b2=_0x57083a['get']({'plain':!![]});return _0x3a28b2[_0xfef0('0x83')];});return db[_0xfef0('0x43')]['find']({'where':{'id':_0x1084b9[_0xfef0('0x49')]['id']}})['then'](function(_0x43ee5f){return db[_0xfef0('0x6f')][_0xfef0('0x70')](function(_0x1a9ed3){return _0x43ee5f[_0xfef0('0x84')](_0x15eefc,{'transaction':_0x1a9ed3})[_0xfef0('0x2c')](function(){return BPromise[_0xfef0('0x85')](_0x4df302,function(_0x53ecba){return db[_0xfef0('0x86')][_0xfef0('0x87')]({'TeamId':_0x53ecba['id'],'VoicePrefixId':_0x1084b9[_0xfef0('0x49')]['id']},{'transaction':_0x1a9ed3});});})[_0xfef0('0x2c')](function(){return BPromise[_0xfef0('0x85')](_0x4d56e5,function(_0x110ef9){return db[_0xfef0('0x88')][_0xfef0('0x89')]({'where':{'UserId':_0x110ef9['id'],'VoicePrefixId':_0x1084b9[_0xfef0('0x49')]['id']},'transaction':_0x1a9ed3});});})[_0xfef0('0x2c')](function(){_0x4d56e5[_0xfef0('0x8a')](function(_0x34f1db){socket[_0xfef0('0x74')](_0xfef0('0x75'),{'UserId':_0x34f1db['id'],'VoicePrefixId':_0x43ee5f['id']});});});});});}})['then'](respondWithStatusCode(_0xd7c5b,null))[_0xfef0('0x47')](handleError(_0xd7c5b,null));};exports[_0xfef0('0x8b')]=function(_0x29ad24,_0x1ee5ad,_0xeea2ff){return db[_0xfef0('0x80')][_0xfef0('0x46')]({'where':{'id':_0x29ad24[_0xfef0('0x36')][_0xfef0('0x72')]},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0xfef0('0x2c')](handleEntityNotFound(_0x1ee5ad,null))['then'](function(_0x63704){var _0x3d85ec=_[_0xfef0('0x61')](_0x63704,'id');var _0x17ab00=[];var _0xd9c290=[];var _0x365938=squel[_0xfef0('0x8c')]();_0x365938[_0xfef0('0x8d')](_0xfef0('0x8e'))[_0xfef0('0x8f')](_0xfef0('0x90'),'tq')['join'](_0xfef0('0x91'),'ut',_0xfef0('0x92'))['where'](_0xfef0('0x93'),_0x29ad24[_0xfef0('0x49')]['id']);for(var _0x524db7=0x0;_0x524db7<_0x63704[_0xfef0('0x3b')];_0x524db7+=0x1){let _0x591f01=_0x63704[_0x524db7];for(var _0x6ccbf8=0x0;_0x6ccbf8<_0x591f01[_0xfef0('0x83')][_0xfef0('0x3b')];_0x6ccbf8+=0x1){let _0xdf3db9=_0x591f01[_0xfef0('0x83')][_0x6ccbf8];var _0x520ff3=_0x365938[_0xfef0('0x94')]();_0x520ff3[_0xfef0('0x7c')]('ut.UserId\x20=\x20?',_0xdf3db9['id']);_0xd9c290[_0xfef0('0x67')](db['sequelize'][_0xfef0('0x36')](_0x520ff3[_0xfef0('0x95')](),{'type':db[_0xfef0('0x6f')]['QueryTypes'][_0xfef0('0x96')]})['then'](function(_0x5dde37){if(_0x5dde37[_0xfef0('0x3b')]===0x1){return _0xdf3db9['id'];}else{var _0x57b2b4=_[_0xfef0('0x97')](_[_0xfef0('0x61')](_0x5dde37,_0xfef0('0x98')),function(_0x11c5f0){return _[_0xfef0('0x99')](_0x3d85ec,_0x11c5f0);});if(_0x57b2b4){return _0xdf3db9['id'];}}}));}}return BPromise[_0xfef0('0x9a')](_0xd9c290)[_0xfef0('0x2c')](function(_0x547b4d){_0x17ab00=_(_0x17ab00)['union'](_0x547b4d)[_0xfef0('0x9b')]()['value']();return db[_0xfef0('0x43')][_0xfef0('0x4b')]({'where':{'id':_0x29ad24[_0xfef0('0x49')]['id']}})[_0xfef0('0x2c')](function(_0x3f9588){return db[_0xfef0('0x6f')][_0xfef0('0x70')](function(_0x326c85){return _0x3f9588['removeTeams'](_0x29ad24['query'][_0xfef0('0x72')],{'transaction':_0x326c85})[_0xfef0('0x2c')](function(){if(!_[_0xfef0('0x9c')](_0x17ab00)){return _0x3f9588[_0xfef0('0x76')](_0x17ab00,{'transaction':_0x326c85});}})[_0xfef0('0x2c')](function(){_0x17ab00['forEach'](function(_0x54d98e){socket['emit'](_0xfef0('0x78'),{'UserId':_0x54d98e,'VoicePrefixId':_0x3f9588['id']});});});});});});})[_0xfef0('0x2c')](respondWithStatusCode(_0x1ee5ad,null))['catch'](handleError(_0x1ee5ad,null));};
\ No newline at end of file