Built motion from commit (unavailable).|2.5.7
[motion2.git] / server / api / voiceContext / voiceContext.controller.js
index a111601..d7ed287 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0f97=['rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/environment','../../mysqldb','jayson/promise','http','test','ValidationError','request','then','info','request\x20sent','debug','VoiceContext,\x20%s,\x20%s,\x20%s','stringify','error','code','message','VoiceContext,\x20%s,\x20%s','result','status','count','set','json','apply','reject','save','update','get','Contexts','UserProfileResource','destroy','end','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','query','keys','filters','fields','attributes','hasOwnProperty','nolimit','limit','offset','order','sort','where','pick','filter','merge','VIRTUAL','VoiceContext','includeAll','include','findAll','rows','catch','show','params','intersection','length','find','create','body','join','root','render','/etc/asterisk/extensions_xcally_contexts.conf','chan_sip.so','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','readFileSync','server/files/templates/context.ejs','utf8','Reload','html-pdf'];(function(_0x18cd5b,_0x10240b){var _0x5eaa52=function(_0x2bccad){while(--_0x2bccad){_0x18cd5b['push'](_0x18cd5b['shift']());}};_0x5eaa52(++_0x10240b);}(_0x0f97,0x6a));var _0x70f9=function(_0x3fbe46,_0x12a0d1){_0x3fbe46=_0x3fbe46-0x0;var _0x27c406=_0x0f97[_0x3fbe46];return _0x27c406;};'use strict';var pdf=require(_0x70f9('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x70f9('0x1'));var zipdir=require(_0x70f9('0x2'));var jsonpatch=require(_0x70f9('0x3'));var rp=require(_0x70f9('0x4'));var moment=require(_0x70f9('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x70f9('0x6'));var util=require(_0x70f9('0x7'));var path=require(_0x70f9('0x8'));var sox=require(_0x70f9('0x9'));var csv=require(_0x70f9('0xa'));var ejs=require(_0x70f9('0xb'));var fs=require('fs');var _=require(_0x70f9('0xc'));var squel=require(_0x70f9('0xd'));var crypto=require('crypto');var jsforce=require(_0x70f9('0xe'));var deskjs=require(_0x70f9('0xf'));var toCsv=require(_0x70f9('0xa'));var querystring=require(_0x70f9('0x10'));var Papa=require(_0x70f9('0x11'));var Redis=require(_0x70f9('0x12'));var authService=require(_0x70f9('0x13'));var qs=require(_0x70f9('0x14'));var as=require(_0x70f9('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x70f9('0x16'));var utils=require('../../config/utils');var config=require(_0x70f9('0x17'));var db=require(_0x70f9('0x18'))['db'];var jayson=require(_0x70f9('0x19'));var client=jayson['client'][_0x70f9('0x1a')]({'port':0x232a});function checkPasswordPattern(_0x3a0a5f,_0x58eff5,_0xebb4f0){if(_0xebb4f0){var _0xfba195=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0xfba195[_0x70f9('0x1b')](_0x58eff5)){return _0x3a0a5f;}else{throw new db['Sequelize'][(_0x70f9('0x1c'))]('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x3a0a5f;}}function respondWithRpcPromise(_0x491383,_0xa77b20,_0x2478b3,_0x332757){return new BPromise(function(_0xf34036,_0x32bf45){var _0x55473d=_0x332757||client;return _0x55473d[_0x70f9('0x1d')](_0x491383,_0x2478b3)[_0x70f9('0x1e')](function(_0xea1d11){logger[_0x70f9('0x1f')]('VoiceContext,\x20%s,\x20%s',_0xa77b20,_0x70f9('0x20'));logger[_0x70f9('0x21')](_0x70f9('0x22'),_0xa77b20,_0x70f9('0x20'),JSON[_0x70f9('0x23')](_0xea1d11));if(_0xea1d11[_0x70f9('0x24')]){if(_0xea1d11[_0x70f9('0x24')][_0x70f9('0x25')]===0x1f4){logger[_0x70f9('0x24')]('VoiceContext,\x20%s,\x20%s',_0xa77b20,_0xea1d11[_0x70f9('0x24')][_0x70f9('0x26')]);return _0x32bf45(_0xea1d11['error'][_0x70f9('0x26')]);}logger[_0x70f9('0x24')](_0x70f9('0x27'),_0xa77b20,_0xea1d11[_0x70f9('0x24')][_0x70f9('0x26')]);return _0xf34036(_0xea1d11[_0x70f9('0x24')]['message']);}else{logger['info'](_0x70f9('0x27'),_0xa77b20,_0x70f9('0x20'));_0xf34036(_0xea1d11[_0x70f9('0x28')][_0x70f9('0x26')]);}})['catch'](function(_0x7df16e){logger[_0x70f9('0x24')](_0x70f9('0x27'),_0xa77b20,_0x7df16e);_0x32bf45(_0x7df16e);});});}function respondWithStatusCode(_0x1e8224,_0x560329){_0x560329=_0x560329||0xcc;return function(_0x21b709){if(_0x21b709){return _0x1e8224['sendStatus'](_0x560329);}return _0x1e8224[_0x70f9('0x29')](_0x560329)['end']();};}function respondWithResult(_0x223e9f,_0x357f51){_0x357f51=_0x357f51||0xc8;return function(_0x4cfd78){if(_0x4cfd78){return _0x223e9f['status'](_0x357f51)['json'](_0x4cfd78);}};}function respondWithFilteredResult(_0x18ae05,_0x1cbac3){return function(_0x350aa9){if(_0x350aa9){var _0xafaec3=_0x350aa9[_0x70f9('0x2a')],_0x43dba4=_0x1cbac3['offset'],_0x1b6dea=_0x1cbac3['offset']+_0x1cbac3['limit'],_0x431b57;if(_0x1b6dea>=_0xafaec3){_0x1b6dea=_0xafaec3;_0x431b57=0xc8;}else{_0x431b57=0xce;}_0x18ae05[_0x70f9('0x29')](_0x431b57);return _0x18ae05[_0x70f9('0x2b')]('Content-Range',_0x43dba4+'-'+_0x1b6dea+'/'+_0xafaec3)[_0x70f9('0x2c')](_0x350aa9);}return null;};}function patchUpdates(_0x385d0e){return function(_0x4e7fa2){try{jsonpatch[_0x70f9('0x2d')](_0x4e7fa2,_0x385d0e,!![]);}catch(_0x2e1e49){return BPromise[_0x70f9('0x2e')](_0x2e1e49);}return _0x4e7fa2[_0x70f9('0x2f')]();};}function saveUpdates(_0x509f61,_0x2a0fe2){return function(_0x5d8e76){if(_0x5d8e76){return _0x5d8e76[_0x70f9('0x30')](_0x509f61)['then'](function(_0x554305){return _0x554305;});}return null;};}function removeEntity(_0x272ebe,_0x37a593){return function(_0x45a190){if(_0x45a190){return _0x45a190['destroy']()['then'](function(){var _0x1ce443=_0x45a190[_0x70f9('0x31')]({'plain':!![]});var _0x1ba543=_0x70f9('0x32');return db[_0x70f9('0x33')][_0x70f9('0x34')]({'where':{'type':_0x1ba543,'resourceId':_0x1ce443['id']}})[_0x70f9('0x1e')](function(){return _0x45a190;});})[_0x70f9('0x1e')](function(){_0x272ebe[_0x70f9('0x29')](0xcc)[_0x70f9('0x35')]();});}};}function handleEntityNotFound(_0x2a16c9,_0x42db3f){return function(_0x3f2217){if(!_0x3f2217){_0x2a16c9['sendStatus'](0x194);}return _0x3f2217;};}function handleError(_0x4bc4ce,_0x497ca1){_0x497ca1=_0x497ca1||0x1f4;return function(_0x23b6ec){logger['error'](_0x23b6ec[_0x70f9('0x36')]);if(_0x23b6ec[_0x70f9('0x37')]){delete _0x23b6ec[_0x70f9('0x37')];}_0x4bc4ce[_0x70f9('0x29')](_0x497ca1)[_0x70f9('0x38')](_0x23b6ec);};}exports[_0x70f9('0x39')]=function(_0x5259a3,_0x401d4c){var _0x17f618={},_0x56aa66={},_0x589e09={'count':0x0,'rows':[]};var _0x483cde=_[_0x70f9('0x3a')](db['VoiceContext'][_0x70f9('0x3b')],function(_0x371b62){return{'name':_0x371b62[_0x70f9('0x3c')],'type':_0x371b62[_0x70f9('0x3d')][_0x70f9('0x3e')]};});_0x56aa66[_0x70f9('0x3f')]=_[_0x70f9('0x3a')](_0x483cde,_0x70f9('0x37'));_0x56aa66[_0x70f9('0x40')]=_[_0x70f9('0x41')](_0x5259a3[_0x70f9('0x40')]);_0x56aa66[_0x70f9('0x42')]=_['intersection'](_0x56aa66[_0x70f9('0x3f')],_0x56aa66[_0x70f9('0x40')]);_0x17f618['attributes']=_['intersection'](_0x56aa66['model'],qs[_0x70f9('0x43')](_0x5259a3[_0x70f9('0x40')][_0x70f9('0x43')]));_0x17f618[_0x70f9('0x44')]=_0x17f618[_0x70f9('0x44')]['length']?_0x17f618[_0x70f9('0x44')]:_0x56aa66[_0x70f9('0x3f')];if(!_0x5259a3[_0x70f9('0x40')][_0x70f9('0x45')](_0x70f9('0x46'))){_0x17f618[_0x70f9('0x47')]=qs[_0x70f9('0x47')](_0x5259a3[_0x70f9('0x40')][_0x70f9('0x47')]);_0x17f618[_0x70f9('0x48')]=qs[_0x70f9('0x48')](_0x5259a3[_0x70f9('0x40')]['offset']);}_0x17f618[_0x70f9('0x49')]=qs[_0x70f9('0x4a')](_0x5259a3['query'][_0x70f9('0x4a')]);_0x17f618[_0x70f9('0x4b')]=qs[_0x70f9('0x42')](_[_0x70f9('0x4c')](_0x5259a3[_0x70f9('0x40')],_0x56aa66[_0x70f9('0x42')]));if(_0x5259a3['query'][_0x70f9('0x4d')]){_0x17f618[_0x70f9('0x4b')]=_[_0x70f9('0x4e')](_0x17f618[_0x70f9('0x4b')],{'$or':_['map'](_0x483cde,function(_0x11ea78){if(_0x11ea78['type']!==_0x70f9('0x4f')){var _0x5543dc={};_0x5543dc[_0x11ea78['name']]={'$like':'%'+_0x5259a3['query']['filter']+'%'};return _0x5543dc;}})});}_0x17f618=_[_0x70f9('0x4e')]({},_0x17f618,_0x5259a3['options']);var _0x412d38={'where':_0x17f618[_0x70f9('0x4b')]};return db[_0x70f9('0x50')][_0x70f9('0x2a')](_0x412d38)[_0x70f9('0x1e')](function(_0x3fdb97){_0x589e09[_0x70f9('0x2a')]=_0x3fdb97;if(_0x5259a3[_0x70f9('0x40')][_0x70f9('0x51')]){_0x17f618[_0x70f9('0x52')]=[{'all':!![]}];}return db[_0x70f9('0x50')][_0x70f9('0x53')](_0x17f618);})[_0x70f9('0x1e')](function(_0x13a889){_0x589e09[_0x70f9('0x54')]=_0x13a889;return _0x589e09;})['then'](respondWithFilteredResult(_0x401d4c,_0x17f618))[_0x70f9('0x55')](handleError(_0x401d4c,null));};exports[_0x70f9('0x56')]=function(_0x5da974,_0x597f23){var _0x1ca704={'raw':![],'where':{'id':_0x5da974[_0x70f9('0x57')]['id']}},_0x49550f={};_0x49550f[_0x70f9('0x3f')]=_['keys'](db['VoiceContext'][_0x70f9('0x3b')]);_0x49550f[_0x70f9('0x40')]=_[_0x70f9('0x41')](_0x5da974[_0x70f9('0x40')]);_0x49550f[_0x70f9('0x42')]=_['intersection'](_0x49550f[_0x70f9('0x3f')],_0x49550f[_0x70f9('0x40')]);_0x1ca704[_0x70f9('0x44')]=_[_0x70f9('0x58')](_0x49550f[_0x70f9('0x3f')],qs[_0x70f9('0x43')](_0x5da974[_0x70f9('0x40')][_0x70f9('0x43')]));_0x1ca704[_0x70f9('0x44')]=_0x1ca704[_0x70f9('0x44')][_0x70f9('0x59')]?_0x1ca704[_0x70f9('0x44')]:_0x49550f[_0x70f9('0x3f')];if(_0x5da974[_0x70f9('0x40')][_0x70f9('0x51')]){_0x1ca704[_0x70f9('0x52')]=[{'all':!![]}];}_0x1ca704=_[_0x70f9('0x4e')]({},_0x1ca704,_0x5da974['options']);return db[_0x70f9('0x50')][_0x70f9('0x5a')](_0x1ca704)[_0x70f9('0x1e')](handleEntityNotFound(_0x597f23,null))['then'](respondWithResult(_0x597f23,null))['catch'](handleError(_0x597f23,null));};exports[_0x70f9('0x5b')]=function(_0x49fb20,_0x24579c,_0x459fcb){var _0x3cd582;return db[_0x70f9('0x50')]['create'](_0x49fb20[_0x70f9('0x5c')],{'raw':!![]})[_0x70f9('0x1e')](function(_0x54a8c5){_0x3cd582=_0x54a8c5;return db[_0x70f9('0x50')][_0x70f9('0x53')]({'raw':!![]});})[_0x70f9('0x1e')](function(_0x3764ac){var _0x54635a=fs['readFileSync'](path[_0x70f9('0x5d')](config[_0x70f9('0x5e')],'server/files/templates/context.ejs'),'utf8');var _0x5b3972=ejs[_0x70f9('0x5f')](_0x54635a,{'contexts':_0x3764ac||[]});fs['writeFileSync'](_0x70f9('0x60'),_0x5b3972);})[_0x70f9('0x1e')](function(){return respondWithRpcPromise('Reload',_0x70f9('0x5b'),{'module':_0x70f9('0x61')});})['then'](function(){var _0x418604=_0x49fb20[_0x70f9('0x62')]['get']({'plain':!![]});if(!_0x418604)throw new Error(_0x70f9('0x63'));if(_0x418604[_0x70f9('0x64')]==='user'){var _0xd80947=_0x3cd582[_0x70f9('0x31')]({'plain':!![]});return db['UserProfileSection'][_0x70f9('0x5a')]({'where':{'name':'Contexts','userProfileId':_0x418604[_0x70f9('0x65')]},'raw':!![]})[_0x70f9('0x1e')](function(_0x12ce16){if(_0x12ce16&&_0x12ce16[_0x70f9('0x66')]===0x0){return db['UserProfileResource']['create']({'name':_0xd80947[_0x70f9('0x37')],'resourceId':_0xd80947['id'],'type':_0x12ce16[_0x70f9('0x37')],'sectionId':_0x12ce16['id']},{})[_0x70f9('0x1e')](function(){return _0x3cd582;});}else{return _0x3cd582;}})[_0x70f9('0x55')](function(_0x52813c){logger[_0x70f9('0x24')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x52813c);throw _0x52813c;});}return _0x3cd582;})[_0x70f9('0x1e')](respondWithResult(_0x24579c,0xc9))[_0x70f9('0x55')](handleError(_0x24579c,null));};exports['update']=function(_0x2ab1db,_0x4576a1,_0x357b84){var _0x5a4bcf;return db[_0x70f9('0x50')][_0x70f9('0x5a')]({'where':{'id':_0x2ab1db[_0x70f9('0x57')]['id']}})[_0x70f9('0x1e')](handleEntityNotFound(_0x4576a1,null))[_0x70f9('0x1e')](saveUpdates(_0x2ab1db[_0x70f9('0x5c')],null))[_0x70f9('0x1e')](function(_0x5c1b51){if(_0x5c1b51){_0x5a4bcf=_0x5c1b51;return db[_0x70f9('0x50')][_0x70f9('0x53')]({'raw':!![]});}})[_0x70f9('0x1e')](function(_0x1f25eb){var _0x3c91a9=fs[_0x70f9('0x67')](path['join'](config[_0x70f9('0x5e')],_0x70f9('0x68')),_0x70f9('0x69'));var _0x4b151c=ejs[_0x70f9('0x5f')](_0x3c91a9,{'contexts':_0x1f25eb||[]});fs['writeFileSync']('/etc/asterisk/extensions_xcally_contexts.conf',_0x4b151c);})[_0x70f9('0x1e')](function(){return respondWithRpcPromise(_0x70f9('0x6a'),_0x70f9('0x30'),{'module':_0x70f9('0x61')});})[_0x70f9('0x1e')](function(){return _0x5a4bcf;})['then'](respondWithResult(_0x4576a1,null))[_0x70f9('0x55')](handleError(_0x4576a1,null));};exports[_0x70f9('0x34')]=function(_0x227c39,_0x172e94,_0x1302be){var _0x149e5b;return db[_0x70f9('0x50')][_0x70f9('0x5a')]({'where':{'id':_0x227c39[_0x70f9('0x57')]['id']}})[_0x70f9('0x1e')](handleEntityNotFound(_0x172e94,null))[_0x70f9('0x1e')](removeEntity(_0x172e94,null))[_0x70f9('0x1e')](function(){return db['VoiceContext'][_0x70f9('0x53')]({'raw':!![]});})[_0x70f9('0x1e')](function(_0x3cb24b){var _0x422bed=fs[_0x70f9('0x67')](path[_0x70f9('0x5d')](config['root'],_0x70f9('0x68')),_0x70f9('0x69'));var _0x18b5cc=ejs['render'](_0x422bed,{'contexts':_0x3cb24b});fs['writeFileSync'](_0x70f9('0x60'),_0x18b5cc);return respondWithRpcPromise('Reload',_0x70f9('0x34'),{'module':_0x70f9('0x61')});})[_0x70f9('0x55')](handleError(_0x172e94,null));};
\ No newline at end of file
+var _0x6b61=['save','update','then','destroy','get','Contexts','UserProfileResource','end','stack','name','send','index','map','VoiceContext','fieldName','key','model','query','intersection','attributes','fields','length','nolimit','order','sort','where','filters','pick','merge','type','filter','options','count','includeAll','include','findAll','rows','show','keys','rawAttributes','find','create','body','readFileSync','join','root','server/files/templates/context.ejs','utf8','render','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','Reload','chan_sip.so','user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','lodash','squel','jsforce','desk.js','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','client','http','debug','error','code','VoiceContext,\x20%s,\x20%s','message','info','request\x20sent','result','catch','sendStatus','status','json','offset','limit','set','Content-Range','reject'];(function(_0x3132e8,_0x499a0e){var _0x43eb8c=function(_0x2321e1){while(--_0x2321e1){_0x3132e8['push'](_0x3132e8['shift']());}};_0x43eb8c(++_0x499a0e);}(_0x6b61,0x16a));var _0x16b6=function(_0x4eec9b,_0x4aea09){_0x4eec9b=_0x4eec9b-0x0;var _0x2e3849=_0x6b61[_0x4eec9b];return _0x2e3849;};'use strict';var pdf=require(_0x16b6('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x16b6('0x1'));var zipdir=require(_0x16b6('0x2'));var jsonpatch=require(_0x16b6('0x3'));var rp=require(_0x16b6('0x4'));var moment=require(_0x16b6('0x5'));var BPromise=require(_0x16b6('0x6'));var Mustache=require(_0x16b6('0x7'));var util=require(_0x16b6('0x8'));var path=require('path');var sox=require(_0x16b6('0x9'));var csv=require(_0x16b6('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x16b6('0xb'));var squel=require(_0x16b6('0xc'));var crypto=require('crypto');var jsforce=require(_0x16b6('0xd'));var deskjs=require(_0x16b6('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x16b6('0xf'));var authService=require('../../components/auth/service');var qs=require(_0x16b6('0x10'));var as=require(_0x16b6('0x11'));var hardwareService=require(_0x16b6('0x12'));var logger=require(_0x16b6('0x13'))(_0x16b6('0x14'));var utils=require(_0x16b6('0x15'));var config=require(_0x16b6('0x16'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var jayson=require('jayson/promise');var client=jayson[_0x16b6('0x17')][_0x16b6('0x18')]({'port':0x232a});function respondWithRpcPromise(_0x22cfba,_0x250b7b,_0x132d71,_0x13158a){return new BPromise(function(_0x37e479,_0x5434c8){var _0x43600e=_0x13158a||client;return _0x43600e['request'](_0x22cfba,_0x132d71)['then'](function(_0x4f8a1e){logger['info']('VoiceContext,\x20%s,\x20%s',_0x250b7b,'request\x20sent');logger[_0x16b6('0x19')]('VoiceContext,\x20%s,\x20%s,\x20%s',_0x250b7b,'request\x20sent',JSON['stringify'](_0x4f8a1e));if(_0x4f8a1e[_0x16b6('0x1a')]){if(_0x4f8a1e[_0x16b6('0x1a')][_0x16b6('0x1b')]===0x1f4){logger[_0x16b6('0x1a')](_0x16b6('0x1c'),_0x250b7b,_0x4f8a1e[_0x16b6('0x1a')][_0x16b6('0x1d')]);return _0x5434c8(_0x4f8a1e[_0x16b6('0x1a')][_0x16b6('0x1d')]);}logger['error'](_0x16b6('0x1c'),_0x250b7b,_0x4f8a1e['error'][_0x16b6('0x1d')]);return _0x37e479(_0x4f8a1e['error']['message']);}else{logger[_0x16b6('0x1e')](_0x16b6('0x1c'),_0x250b7b,_0x16b6('0x1f'));_0x37e479(_0x4f8a1e[_0x16b6('0x20')][_0x16b6('0x1d')]);}})[_0x16b6('0x21')](function(_0x293a67){logger[_0x16b6('0x1a')]('VoiceContext,\x20%s,\x20%s',_0x250b7b,_0x293a67);_0x5434c8(_0x293a67);});});}function respondWithStatusCode(_0x20a807,_0xb56485){_0xb56485=_0xb56485||0xcc;return function(_0x47fcf0){if(_0x47fcf0){return _0x20a807[_0x16b6('0x22')](_0xb56485);}return _0x20a807[_0x16b6('0x23')](_0xb56485)['end']();};}function respondWithResult(_0x35c00e,_0x20995e){_0x20995e=_0x20995e||0xc8;return function(_0x4bb1b1){if(_0x4bb1b1){return _0x35c00e[_0x16b6('0x23')](_0x20995e)[_0x16b6('0x24')](_0x4bb1b1);}};}function respondWithFilteredResult(_0x4be96d,_0x4394e9){return function(_0x2c12aa){if(_0x2c12aa){var _0x4451a1=_0x2c12aa['count'],_0x35b127=_0x4394e9[_0x16b6('0x25')],_0x599aa0=_0x4394e9['offset']+_0x4394e9[_0x16b6('0x26')],_0x44fa79;if(_0x599aa0>=_0x4451a1){_0x599aa0=_0x4451a1;_0x44fa79=0xc8;}else{_0x44fa79=0xce;}_0x4be96d['status'](_0x44fa79);return _0x4be96d[_0x16b6('0x27')](_0x16b6('0x28'),_0x35b127+'-'+_0x599aa0+'/'+_0x4451a1)[_0x16b6('0x24')](_0x2c12aa);}return null;};}function patchUpdates(_0x2c1e63){return function(_0x4e3191){try{jsonpatch['apply'](_0x4e3191,_0x2c1e63,!![]);}catch(_0x278a8c){return BPromise[_0x16b6('0x29')](_0x278a8c);}return _0x4e3191[_0x16b6('0x2a')]();};}function saveUpdates(_0x2314bb,_0x2f1be8){return function(_0x3d6957){if(_0x3d6957){return _0x3d6957[_0x16b6('0x2b')](_0x2314bb)[_0x16b6('0x2c')](function(_0x1c870e){return _0x1c870e;});}return null;};}function removeEntity(_0x4fa98e,_0x2149a3){return function(_0x279047){if(_0x279047){return _0x279047[_0x16b6('0x2d')]()[_0x16b6('0x2c')](function(){var _0x3519cc=_0x279047[_0x16b6('0x2e')]({'plain':!![]});var _0x49ac87=_0x16b6('0x2f');return db[_0x16b6('0x30')]['destroy']({'where':{'type':_0x49ac87,'resourceId':_0x3519cc['id']}})[_0x16b6('0x2c')](function(){return _0x279047;});})['then'](function(){_0x4fa98e[_0x16b6('0x23')](0xcc)[_0x16b6('0x31')]();});}};}function handleEntityNotFound(_0x2b7e36,_0x13af30){return function(_0x197a5b){if(!_0x197a5b){_0x2b7e36[_0x16b6('0x22')](0x194);}return _0x197a5b;};}function handleError(_0x3950ed,_0x1de239){_0x1de239=_0x1de239||0x1f4;return function(_0x163b49){logger[_0x16b6('0x1a')](_0x163b49[_0x16b6('0x32')]);if(_0x163b49[_0x16b6('0x33')]){delete _0x163b49[_0x16b6('0x33')];}_0x3950ed[_0x16b6('0x23')](_0x1de239)[_0x16b6('0x34')](_0x163b49);};}exports[_0x16b6('0x35')]=function(_0x2460fb,_0x34ade4){var _0x5a8be3={},_0x540d28={},_0x71e904={'count':0x0,'rows':[]};var _0x14c640=_[_0x16b6('0x36')](db[_0x16b6('0x37')]['rawAttributes'],function(_0x5af29e){return{'name':_0x5af29e[_0x16b6('0x38')],'type':_0x5af29e['type'][_0x16b6('0x39')]};});_0x540d28[_0x16b6('0x3a')]=_[_0x16b6('0x36')](_0x14c640,'name');_0x540d28[_0x16b6('0x3b')]=_['keys'](_0x2460fb[_0x16b6('0x3b')]);_0x540d28['filters']=_[_0x16b6('0x3c')](_0x540d28[_0x16b6('0x3a')],_0x540d28[_0x16b6('0x3b')]);_0x5a8be3[_0x16b6('0x3d')]=_['intersection'](_0x540d28['model'],qs[_0x16b6('0x3e')](_0x2460fb[_0x16b6('0x3b')]['fields']));_0x5a8be3[_0x16b6('0x3d')]=_0x5a8be3['attributes'][_0x16b6('0x3f')]?_0x5a8be3['attributes']:_0x540d28['model'];if(!_0x2460fb[_0x16b6('0x3b')]['hasOwnProperty'](_0x16b6('0x40'))){_0x5a8be3[_0x16b6('0x26')]=qs[_0x16b6('0x26')](_0x2460fb[_0x16b6('0x3b')][_0x16b6('0x26')]);_0x5a8be3[_0x16b6('0x25')]=qs[_0x16b6('0x25')](_0x2460fb[_0x16b6('0x3b')][_0x16b6('0x25')]);}_0x5a8be3[_0x16b6('0x41')]=qs[_0x16b6('0x42')](_0x2460fb[_0x16b6('0x3b')][_0x16b6('0x42')]);_0x5a8be3[_0x16b6('0x43')]=qs[_0x16b6('0x44')](_[_0x16b6('0x45')](_0x2460fb[_0x16b6('0x3b')],_0x540d28[_0x16b6('0x44')]),_0x14c640);if(_0x2460fb['query']['filter']){_0x5a8be3['where']=_[_0x16b6('0x46')](_0x5a8be3['where'],{'$or':_['map'](_0x14c640,function(_0x33c5b7){if(_0x33c5b7[_0x16b6('0x47')]!=='VIRTUAL'){var _0xea7112={};_0xea7112[_0x33c5b7[_0x16b6('0x33')]]={'$like':'%'+_0x2460fb['query'][_0x16b6('0x48')]+'%'};return _0xea7112;}})});}_0x5a8be3=_[_0x16b6('0x46')]({},_0x5a8be3,_0x2460fb[_0x16b6('0x49')]);var _0x58ee76={'where':_0x5a8be3[_0x16b6('0x43')]};return db[_0x16b6('0x37')][_0x16b6('0x4a')](_0x58ee76)['then'](function(_0x269f94){_0x71e904['count']=_0x269f94;if(_0x2460fb[_0x16b6('0x3b')][_0x16b6('0x4b')]){_0x5a8be3[_0x16b6('0x4c')]=[{'all':!![]}];}return db[_0x16b6('0x37')][_0x16b6('0x4d')](_0x5a8be3);})['then'](function(_0x3fa71b){_0x71e904[_0x16b6('0x4e')]=_0x3fa71b;return _0x71e904;})[_0x16b6('0x2c')](respondWithFilteredResult(_0x34ade4,_0x5a8be3))['catch'](handleError(_0x34ade4,null));};exports[_0x16b6('0x4f')]=function(_0x24b9f3,_0x53d2ca){var _0x445877={'raw':![],'where':{'id':_0x24b9f3['params']['id']}},_0x37b4fb={};_0x37b4fb['model']=_[_0x16b6('0x50')](db[_0x16b6('0x37')][_0x16b6('0x51')]);_0x37b4fb[_0x16b6('0x3b')]=_[_0x16b6('0x50')](_0x24b9f3[_0x16b6('0x3b')]);_0x37b4fb[_0x16b6('0x44')]=_['intersection'](_0x37b4fb[_0x16b6('0x3a')],_0x37b4fb[_0x16b6('0x3b')]);_0x445877['attributes']=_[_0x16b6('0x3c')](_0x37b4fb[_0x16b6('0x3a')],qs[_0x16b6('0x3e')](_0x24b9f3[_0x16b6('0x3b')]['fields']));_0x445877['attributes']=_0x445877[_0x16b6('0x3d')][_0x16b6('0x3f')]?_0x445877[_0x16b6('0x3d')]:_0x37b4fb[_0x16b6('0x3a')];if(_0x24b9f3[_0x16b6('0x3b')][_0x16b6('0x4b')]){_0x445877[_0x16b6('0x4c')]=[{'all':!![]}];}_0x445877=_[_0x16b6('0x46')]({},_0x445877,_0x24b9f3[_0x16b6('0x49')]);return db['VoiceContext'][_0x16b6('0x52')](_0x445877)[_0x16b6('0x2c')](handleEntityNotFound(_0x53d2ca,null))[_0x16b6('0x2c')](respondWithResult(_0x53d2ca,null))[_0x16b6('0x21')](handleError(_0x53d2ca,null));};exports[_0x16b6('0x53')]=function(_0x4b7ad4,_0x141fe9,_0x47f8e5){var _0x199285;return db[_0x16b6('0x37')][_0x16b6('0x53')](_0x4b7ad4[_0x16b6('0x54')],{'raw':!![]})[_0x16b6('0x2c')](function(_0x5c49bc){_0x199285=_0x5c49bc;return db[_0x16b6('0x37')][_0x16b6('0x4d')]({'raw':!![]});})[_0x16b6('0x2c')](function(_0x2d9b2f){var _0x39d621=fs[_0x16b6('0x55')](path[_0x16b6('0x56')](config[_0x16b6('0x57')],_0x16b6('0x58')),_0x16b6('0x59'));var _0x110a2e=ejs[_0x16b6('0x5a')](_0x39d621,{'contexts':_0x2d9b2f||[]});fs[_0x16b6('0x5b')](_0x16b6('0x5c'),_0x110a2e);})[_0x16b6('0x2c')](function(){return respondWithRpcPromise(_0x16b6('0x5d'),_0x16b6('0x53'),{'module':_0x16b6('0x5e')});})[_0x16b6('0x2c')](function(){var _0x4e61d8=_0x4b7ad4[_0x16b6('0x5f')][_0x16b6('0x2e')]({'plain':!![]});if(!_0x4e61d8)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x4e61d8[_0x16b6('0x60')]===_0x16b6('0x5f')){var _0x47d5ba=_0x199285[_0x16b6('0x2e')]({'plain':!![]});return db[_0x16b6('0x61')][_0x16b6('0x52')]({'where':{'name':_0x16b6('0x2f'),'userProfileId':_0x4e61d8['userProfileId']},'raw':!![]})[_0x16b6('0x2c')](function(_0x314699){if(_0x314699&&_0x314699[_0x16b6('0x62')]===0x0){return db[_0x16b6('0x30')][_0x16b6('0x53')]({'name':_0x47d5ba[_0x16b6('0x33')],'resourceId':_0x47d5ba['id'],'type':_0x314699['name'],'sectionId':_0x314699['id']},{})[_0x16b6('0x2c')](function(){return _0x199285;});}else{return _0x199285;}})[_0x16b6('0x21')](function(_0x3f26a0){logger[_0x16b6('0x1a')](_0x16b6('0x63'),_0x3f26a0);throw _0x3f26a0;});}return _0x199285;})[_0x16b6('0x2c')](respondWithResult(_0x141fe9,0xc9))[_0x16b6('0x21')](handleError(_0x141fe9,null));};exports[_0x16b6('0x2b')]=function(_0x496e34,_0x12f658,_0x84022){var _0x477ae5;return db[_0x16b6('0x37')][_0x16b6('0x52')]({'where':{'id':_0x496e34[_0x16b6('0x64')]['id']}})['then'](handleEntityNotFound(_0x12f658,null))['then'](saveUpdates(_0x496e34[_0x16b6('0x54')],null))['then'](function(_0x150607){if(_0x150607){_0x477ae5=_0x150607;return db[_0x16b6('0x37')][_0x16b6('0x4d')]({'raw':!![]});}})[_0x16b6('0x2c')](function(_0x2bf2da){var _0x348fa8=fs[_0x16b6('0x55')](path[_0x16b6('0x56')](config[_0x16b6('0x57')],_0x16b6('0x58')),_0x16b6('0x59'));var _0x3e099a=ejs[_0x16b6('0x5a')](_0x348fa8,{'contexts':_0x2bf2da||[]});fs['writeFileSync']('/etc/asterisk/extensions_xcally_contexts.conf',_0x3e099a);})['then'](function(){return respondWithRpcPromise('Reload','update',{'module':_0x16b6('0x5e')});})[_0x16b6('0x2c')](function(){return _0x477ae5;})['then'](respondWithResult(_0x12f658,null))[_0x16b6('0x21')](handleError(_0x12f658,null));};exports['destroy']=function(_0x580c26,_0x23803a,_0x39d2c9){var _0x1535ad;return db[_0x16b6('0x37')][_0x16b6('0x52')]({'where':{'id':_0x580c26[_0x16b6('0x64')]['id']}})[_0x16b6('0x2c')](handleEntityNotFound(_0x23803a,null))[_0x16b6('0x2c')](removeEntity(_0x23803a,null))['then'](function(){return db[_0x16b6('0x37')][_0x16b6('0x4d')]({'raw':!![]});})[_0x16b6('0x2c')](function(_0x541a5c){var _0x398e6f=fs[_0x16b6('0x55')](path[_0x16b6('0x56')](config['root'],'server/files/templates/context.ejs'),_0x16b6('0x59'));var _0x18193f=ejs[_0x16b6('0x5a')](_0x398e6f,{'contexts':_0x541a5c});fs[_0x16b6('0x5b')](_0x16b6('0x5c'),_0x18193f);return respondWithRpcPromise(_0x16b6('0x5d'),'destroy',{'module':_0x16b6('0x5e')});})[_0x16b6('0x21')](handleError(_0x23803a,null));};
\ No newline at end of file