Built motion from commit (unavailable).|2.5.15
[motion2.git] / server / api / voiceContext / voiceContext.controller.js
index bd66c67..99556a7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd52a=['userProfileId','create','server/files/templates/context.ejs','Reload','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','lodash','crypto','desk.js','to-csv','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../mysqldb','jayson/promise','client','http','request','then','info','VoiceContext,\x20%s,\x20%s','request\x20sent','debug','VoiceContext,\x20%s,\x20%s,\x20%s','error','code','message','result','sendStatus','status','count','offset','limit','set','Content-Range','apply','reject','update','destroy','get','Contexts','UserProfileResource','end','stack','name','send','index','map','VoiceContext','rawAttributes','fieldName','type','key','model','keys','filters','intersection','query','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','rows','params','includeAll','find','catch','body','findAll','join','root','utf8','render','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','chan_sip.so','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection'];(function(_0x432724,_0x1b6237){var _0x1a47ef=function(_0x474cf7){while(--_0x474cf7){_0x432724['push'](_0x432724['shift']());}};_0x1a47ef(++_0x1b6237);}(_0xd52a,0xca));var _0xad52=function(_0x538516,_0x4e4006){_0x538516=_0x538516-0x0;var _0x330d8e=_0xd52a[_0x538516];return _0x330d8e;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xad52('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xad52('0x1'));var jsonpatch=require(_0xad52('0x2'));var rp=require(_0xad52('0x3'));var moment=require('moment');var BPromise=require(_0xad52('0x4'));var Mustache=require(_0xad52('0x5'));var util=require(_0xad52('0x6'));var path=require(_0xad52('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0xad52('0x8'));var squel=require('squel');var crypto=require(_0xad52('0x9'));var jsforce=require('jsforce');var deskjs=require(_0xad52('0xa'));var toCsv=require(_0xad52('0xb'));var querystring=require('querystring');var Papa=require(_0xad52('0xc'));var Redis=require('ioredis');var authService=require(_0xad52('0xd'));var qs=require('../../components/parsers/qs');var as=require(_0xad52('0xe'));var hardwareService=require(_0xad52('0xf'));var logger=require(_0xad52('0x10'))(_0xad52('0x11'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xad52('0x12'))['db'];var jayson=require(_0xad52('0x13'));var client=jayson[_0xad52('0x14')][_0xad52('0x15')]({'port':0x232a});function respondWithRpcPromise(_0x11127c,_0x230eaa,_0x16e0f7,_0xd04cde){return new BPromise(function(_0x3d2df6,_0x5727a2){var _0x330794=_0xd04cde||client;return _0x330794[_0xad52('0x16')](_0x11127c,_0x16e0f7)[_0xad52('0x17')](function(_0x42eb20){logger[_0xad52('0x18')](_0xad52('0x19'),_0x230eaa,_0xad52('0x1a'));logger[_0xad52('0x1b')](_0xad52('0x1c'),_0x230eaa,'request\x20sent',JSON['stringify'](_0x42eb20));if(_0x42eb20[_0xad52('0x1d')]){if(_0x42eb20[_0xad52('0x1d')][_0xad52('0x1e')]===0x1f4){logger[_0xad52('0x1d')](_0xad52('0x19'),_0x230eaa,_0x42eb20['error'][_0xad52('0x1f')]);return _0x5727a2(_0x42eb20['error'][_0xad52('0x1f')]);}logger[_0xad52('0x1d')](_0xad52('0x19'),_0x230eaa,_0x42eb20['error'][_0xad52('0x1f')]);return _0x3d2df6(_0x42eb20['error'][_0xad52('0x1f')]);}else{logger[_0xad52('0x18')](_0xad52('0x19'),_0x230eaa,_0xad52('0x1a'));_0x3d2df6(_0x42eb20[_0xad52('0x20')][_0xad52('0x1f')]);}})['catch'](function(_0x7de59d){logger['error'](_0xad52('0x19'),_0x230eaa,_0x7de59d);_0x5727a2(_0x7de59d);});});}function respondWithStatusCode(_0x2acbb4,_0x2fa90c){_0x2fa90c=_0x2fa90c||0xcc;return function(_0x5bce67){if(_0x5bce67){return _0x2acbb4[_0xad52('0x21')](_0x2fa90c);}return _0x2acbb4['status'](_0x2fa90c)['end']();};}function respondWithResult(_0x2809f7,_0x583999){_0x583999=_0x583999||0xc8;return function(_0x477b47){if(_0x477b47){return _0x2809f7[_0xad52('0x22')](_0x583999)['json'](_0x477b47);}};}function respondWithFilteredResult(_0x58adf5,_0xb526bf){return function(_0x31b5e0){if(_0x31b5e0){var _0x42db69=_0x31b5e0[_0xad52('0x23')],_0x50431e=_0xb526bf[_0xad52('0x24')],_0x132e94=_0xb526bf[_0xad52('0x24')]+_0xb526bf[_0xad52('0x25')],_0x5771ce;if(_0x132e94>=_0x42db69){_0x132e94=_0x42db69;_0x5771ce=0xc8;}else{_0x5771ce=0xce;}_0x58adf5['status'](_0x5771ce);return _0x58adf5[_0xad52('0x26')](_0xad52('0x27'),_0x50431e+'-'+_0x132e94+'/'+_0x42db69)['json'](_0x31b5e0);}return null;};}function patchUpdates(_0x3f5757){return function(_0x3a0fd6){try{jsonpatch[_0xad52('0x28')](_0x3a0fd6,_0x3f5757,!![]);}catch(_0x75dfb6){return BPromise[_0xad52('0x29')](_0x75dfb6);}return _0x3a0fd6['save']();};}function saveUpdates(_0x5ccd33,_0x4c389e){return function(_0xc2553d){if(_0xc2553d){return _0xc2553d[_0xad52('0x2a')](_0x5ccd33)[_0xad52('0x17')](function(_0x548d04){return _0x548d04;});}return null;};}function removeEntity(_0x52e3cc,_0x2e77fe){return function(_0x1af23e){if(_0x1af23e){return _0x1af23e[_0xad52('0x2b')]()[_0xad52('0x17')](function(){var _0x919c28=_0x1af23e[_0xad52('0x2c')]({'plain':!![]});var _0x504d75=_0xad52('0x2d');return db[_0xad52('0x2e')][_0xad52('0x2b')]({'where':{'type':_0x504d75,'resourceId':_0x919c28['id']}})[_0xad52('0x17')](function(){return _0x1af23e;});})[_0xad52('0x17')](function(){_0x52e3cc[_0xad52('0x22')](0xcc)[_0xad52('0x2f')]();});}};}function handleEntityNotFound(_0x123f30,_0x3d863d){return function(_0x434762){if(!_0x434762){_0x123f30[_0xad52('0x21')](0x194);}return _0x434762;};}function handleError(_0x5027c1,_0x1745e0){_0x1745e0=_0x1745e0||0x1f4;return function(_0x2c3676){logger[_0xad52('0x1d')](_0x2c3676[_0xad52('0x30')]);if(_0x2c3676[_0xad52('0x31')]){delete _0x2c3676[_0xad52('0x31')];}_0x5027c1['status'](_0x1745e0)[_0xad52('0x32')](_0x2c3676);};}exports[_0xad52('0x33')]=function(_0xc9461d,_0x596a3a){var _0x2ff49c={},_0x1d16b4={},_0x268353={'count':0x0,'rows':[]};var _0x4ad21c=_[_0xad52('0x34')](db[_0xad52('0x35')][_0xad52('0x36')],function(_0x49260f){return{'name':_0x49260f[_0xad52('0x37')],'type':_0x49260f[_0xad52('0x38')][_0xad52('0x39')]};});_0x1d16b4[_0xad52('0x3a')]=_[_0xad52('0x34')](_0x4ad21c,_0xad52('0x31'));_0x1d16b4['query']=_[_0xad52('0x3b')](_0xc9461d['query']);_0x1d16b4[_0xad52('0x3c')]=_[_0xad52('0x3d')](_0x1d16b4[_0xad52('0x3a')],_0x1d16b4[_0xad52('0x3e')]);_0x2ff49c[_0xad52('0x3f')]=_['intersection'](_0x1d16b4[_0xad52('0x3a')],qs[_0xad52('0x40')](_0xc9461d[_0xad52('0x3e')]['fields']));_0x2ff49c[_0xad52('0x3f')]=_0x2ff49c[_0xad52('0x3f')][_0xad52('0x41')]?_0x2ff49c['attributes']:_0x1d16b4[_0xad52('0x3a')];if(!_0xc9461d['query'][_0xad52('0x42')](_0xad52('0x43'))){_0x2ff49c[_0xad52('0x25')]=qs[_0xad52('0x25')](_0xc9461d['query'][_0xad52('0x25')]);_0x2ff49c[_0xad52('0x24')]=qs[_0xad52('0x24')](_0xc9461d[_0xad52('0x3e')][_0xad52('0x24')]);}_0x2ff49c[_0xad52('0x44')]=qs[_0xad52('0x45')](_0xc9461d[_0xad52('0x3e')]['sort']);_0x2ff49c[_0xad52('0x46')]=qs['filters'](_[_0xad52('0x47')](_0xc9461d[_0xad52('0x3e')],_0x1d16b4[_0xad52('0x3c')]),_0x4ad21c);if(_0xc9461d[_0xad52('0x3e')][_0xad52('0x48')]){_0x2ff49c[_0xad52('0x46')]=_[_0xad52('0x49')](_0x2ff49c[_0xad52('0x46')],{'$or':_[_0xad52('0x34')](_0x4ad21c,function(_0x24b970){if(_0x24b970[_0xad52('0x38')]!==_0xad52('0x4a')){var _0x4411eb={};_0x4411eb[_0x24b970[_0xad52('0x31')]]={'$like':'%'+_0xc9461d[_0xad52('0x3e')][_0xad52('0x48')]+'%'};return _0x4411eb;}})});}_0x2ff49c=_[_0xad52('0x49')]({},_0x2ff49c,_0xc9461d[_0xad52('0x4b')]);var _0x711cc6={'where':_0x2ff49c[_0xad52('0x46')]};return db['VoiceContext'][_0xad52('0x23')](_0x711cc6)[_0xad52('0x17')](function(_0x14b87b){_0x268353['count']=_0x14b87b;if(_0xc9461d[_0xad52('0x3e')]['includeAll']){_0x2ff49c[_0xad52('0x4c')]=[{'all':!![]}];}return db['VoiceContext']['findAll'](_0x2ff49c);})[_0xad52('0x17')](function(_0x1746b0){_0x268353[_0xad52('0x4d')]=_0x1746b0;return _0x268353;})[_0xad52('0x17')](respondWithFilteredResult(_0x596a3a,_0x2ff49c))['catch'](handleError(_0x596a3a,null));};exports['show']=function(_0x254416,_0x5dede4){var _0x207096={'raw':![],'where':{'id':_0x254416[_0xad52('0x4e')]['id']}},_0x581f41={};_0x581f41[_0xad52('0x3a')]=_[_0xad52('0x3b')](db[_0xad52('0x35')][_0xad52('0x36')]);_0x581f41[_0xad52('0x3e')]=_['keys'](_0x254416[_0xad52('0x3e')]);_0x581f41[_0xad52('0x3c')]=_[_0xad52('0x3d')](_0x581f41[_0xad52('0x3a')],_0x581f41['query']);_0x207096[_0xad52('0x3f')]=_[_0xad52('0x3d')](_0x581f41[_0xad52('0x3a')],qs['fields'](_0x254416[_0xad52('0x3e')][_0xad52('0x40')]));_0x207096[_0xad52('0x3f')]=_0x207096[_0xad52('0x3f')]['length']?_0x207096[_0xad52('0x3f')]:_0x581f41[_0xad52('0x3a')];if(_0x254416[_0xad52('0x3e')][_0xad52('0x4f')]){_0x207096[_0xad52('0x4c')]=[{'all':!![]}];}_0x207096=_['merge']({},_0x207096,_0x254416['options']);return db[_0xad52('0x35')][_0xad52('0x50')](_0x207096)[_0xad52('0x17')](handleEntityNotFound(_0x5dede4,null))[_0xad52('0x17')](respondWithResult(_0x5dede4,null))[_0xad52('0x51')](handleError(_0x5dede4,null));};exports['create']=function(_0x21f850,_0x4ccf7b,_0x5fe34c){var _0xa72c7;return db[_0xad52('0x35')]['create'](_0x21f850[_0xad52('0x52')],{'raw':!![]})['then'](function(_0x3784b5){_0xa72c7=_0x3784b5;return db[_0xad52('0x35')][_0xad52('0x53')]({'raw':!![]});})['then'](function(_0x490866){var _0xf0fc0d=fs['readFileSync'](path[_0xad52('0x54')](config[_0xad52('0x55')],'server/files/templates/context.ejs'),_0xad52('0x56'));var _0x4b51fd=ejs[_0xad52('0x57')](_0xf0fc0d,{'contexts':_0x490866||[]});fs[_0xad52('0x58')](_0xad52('0x59'),_0x4b51fd);})[_0xad52('0x17')](function(){return respondWithRpcPromise('Reload','create',{'module':_0xad52('0x5a')});})[_0xad52('0x17')](function(){var _0x541fd3=_0x21f850[_0xad52('0x5b')][_0xad52('0x2c')]({'plain':!![]});if(!_0x541fd3)throw new Error(_0xad52('0x5c'));if(_0x541fd3[_0xad52('0x5d')]==='user'){var _0xba9665=_0xa72c7[_0xad52('0x2c')]({'plain':!![]});return db[_0xad52('0x5e')][_0xad52('0x50')]({'where':{'name':_0xad52('0x2d'),'userProfileId':_0x541fd3[_0xad52('0x5f')]},'raw':!![]})[_0xad52('0x17')](function(_0x16807a){if(_0x16807a&&_0x16807a['autoAssociation']===0x0){return db['UserProfileResource'][_0xad52('0x60')]({'name':_0xba9665[_0xad52('0x31')],'resourceId':_0xba9665['id'],'type':_0x16807a[_0xad52('0x31')],'sectionId':_0x16807a['id']},{})['then'](function(){return _0xa72c7;});}else{return _0xa72c7;}})[_0xad52('0x51')](function(_0x805bc3){logger[_0xad52('0x1d')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x805bc3);throw _0x805bc3;});}return _0xa72c7;})[_0xad52('0x17')](respondWithResult(_0x4ccf7b,0xc9))['catch'](handleError(_0x4ccf7b,null));};exports[_0xad52('0x2a')]=function(_0x56fca3,_0x538c7b,_0x3db9d6){var _0x2c6c48;return db['VoiceContext']['find']({'where':{'id':_0x56fca3['params']['id']}})[_0xad52('0x17')](handleEntityNotFound(_0x538c7b,null))[_0xad52('0x17')](saveUpdates(_0x56fca3['body'],null))[_0xad52('0x17')](function(_0x352302){if(_0x352302){_0x2c6c48=_0x352302;return db[_0xad52('0x35')]['findAll']({'raw':!![]});}})[_0xad52('0x17')](function(_0x2622a4){var _0x26935e=fs['readFileSync'](path['join'](config[_0xad52('0x55')],_0xad52('0x61')),_0xad52('0x56'));var _0xe22d76=ejs['render'](_0x26935e,{'contexts':_0x2622a4||[]});fs[_0xad52('0x58')]('/etc/asterisk/extensions_xcally_contexts.conf',_0xe22d76);})[_0xad52('0x17')](function(){return respondWithRpcPromise('Reload',_0xad52('0x2a'),{'module':_0xad52('0x5a')});})[_0xad52('0x17')](function(){return _0x2c6c48;})[_0xad52('0x17')](respondWithResult(_0x538c7b,null))[_0xad52('0x51')](handleError(_0x538c7b,null));};exports[_0xad52('0x2b')]=function(_0xa4097c,_0x15f49d,_0x41b710){var _0x2b71e2;return db[_0xad52('0x35')]['find']({'where':{'id':_0xa4097c['params']['id']}})[_0xad52('0x17')](handleEntityNotFound(_0x15f49d,null))['then'](removeEntity(_0x15f49d,null))[_0xad52('0x17')](function(){return db[_0xad52('0x35')][_0xad52('0x53')]({'raw':!![]});})['then'](function(_0x3b865f){var _0x55b17b=fs['readFileSync'](path[_0xad52('0x54')](config[_0xad52('0x55')],_0xad52('0x61')),_0xad52('0x56'));var _0x72f326=ejs['render'](_0x55b17b,{'contexts':_0x3b865f});fs[_0xad52('0x58')]('/etc/asterisk/extensions_xcally_contexts.conf',_0x72f326);return respondWithRpcPromise(_0xad52('0x62'),_0xad52('0x2b'),{'module':'chan_sip.so'});})[_0xad52('0x51')](handleError(_0x15f49d,null));};
\ No newline at end of file
+var _0x340c=['find','create','readFileSync','root','utf8','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','Reload','chan_sip.so','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','join','server/files/templates/context.ejs','render','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','then','info','VoiceContext,\x20%s,\x20%s','debug','VoiceContext,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','status','json','offset','limit','set','Content-Range','apply','reject','save','update','destroy','get','Contexts','UserProfileResource','end','stack','name','index','VoiceContext','rawAttributes','fieldName','type','key','map','query','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','count','include','findAll','params','keys','includeAll'];(function(_0x44268d,_0xad8443){var _0x4be92d=function(_0x8a57ff){while(--_0x8a57ff){_0x44268d['push'](_0x44268d['shift']());}};_0x4be92d(++_0xad8443);}(_0x340c,0xe5));var _0xc340=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x340c[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0xc340('0x0'));var emlformat=require(_0xc340('0x1'));var rimraf=require(_0xc340('0x2'));var zipdir=require(_0xc340('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0xc340('0x4'));var moment=require(_0xc340('0x5'));var BPromise=require(_0xc340('0x6'));var Mustache=require(_0xc340('0x7'));var util=require('util');var path=require(_0xc340('0x8'));var sox=require(_0xc340('0x9'));var csv=require(_0xc340('0xa'));var ejs=require(_0xc340('0xb'));var fs=require('fs');var _=require(_0xc340('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xc340('0xd'));var toCsv=require(_0xc340('0xa'));var querystring=require('querystring');var Papa=require(_0xc340('0xe'));var Redis=require(_0xc340('0xf'));var authService=require(_0xc340('0x10'));var qs=require(_0xc340('0x11'));var as=require(_0xc340('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xc340('0x13'))(_0xc340('0x14'));var utils=require(_0xc340('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xc340('0x16'));var db=require(_0xc340('0x17'))['db'];var jayson=require(_0xc340('0x18'));var client=jayson[_0xc340('0x19')][_0xc340('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0x50365c,_0x13c360,_0x7c70c8,_0x340563){return new BPromise(function(_0x10b317,_0x2f257b){var _0x4abaa9=_0x340563||client;return _0x4abaa9[_0xc340('0x1b')](_0x50365c,_0x7c70c8)[_0xc340('0x1c')](function(_0x2609b2){logger[_0xc340('0x1d')](_0xc340('0x1e'),_0x13c360,'request\x20sent');logger[_0xc340('0x1f')](_0xc340('0x20'),_0x13c360,_0xc340('0x21'),JSON[_0xc340('0x22')](_0x2609b2));if(_0x2609b2[_0xc340('0x23')]){if(_0x2609b2['error'][_0xc340('0x24')]===0x1f4){logger[_0xc340('0x23')](_0xc340('0x1e'),_0x13c360,_0x2609b2['error']['message']);return _0x2f257b(_0x2609b2[_0xc340('0x23')][_0xc340('0x25')]);}logger[_0xc340('0x23')]('VoiceContext,\x20%s,\x20%s',_0x13c360,_0x2609b2['error'][_0xc340('0x25')]);return _0x10b317(_0x2609b2['error'][_0xc340('0x25')]);}else{logger[_0xc340('0x1d')](_0xc340('0x1e'),_0x13c360,_0xc340('0x21'));_0x10b317(_0x2609b2[_0xc340('0x26')][_0xc340('0x25')]);}})[_0xc340('0x27')](function(_0xb6e946){logger[_0xc340('0x23')](_0xc340('0x1e'),_0x13c360,_0xb6e946);_0x2f257b(_0xb6e946);});});}function respondWithStatusCode(_0x5ac403,_0x10543e){_0x10543e=_0x10543e||0xcc;return function(_0x250dbd){if(_0x250dbd){return _0x5ac403['sendStatus'](_0x10543e);}return _0x5ac403[_0xc340('0x28')](_0x10543e)['end']();};}function respondWithResult(_0x334744,_0x7852b1){_0x7852b1=_0x7852b1||0xc8;return function(_0x36ea03){if(_0x36ea03){return _0x334744['status'](_0x7852b1)[_0xc340('0x29')](_0x36ea03);}};}function respondWithFilteredResult(_0x1f0359,_0x33b1b5){return function(_0x183bfa){if(_0x183bfa){var _0xd9e330=_0x183bfa['count'],_0xedbb6f=_0x33b1b5[_0xc340('0x2a')],_0x3397ef=_0x33b1b5[_0xc340('0x2a')]+_0x33b1b5[_0xc340('0x2b')],_0x4bbddf;if(_0x3397ef>=_0xd9e330){_0x3397ef=_0xd9e330;_0x4bbddf=0xc8;}else{_0x4bbddf=0xce;}_0x1f0359[_0xc340('0x28')](_0x4bbddf);return _0x1f0359[_0xc340('0x2c')](_0xc340('0x2d'),_0xedbb6f+'-'+_0x3397ef+'/'+_0xd9e330)['json'](_0x183bfa);}return null;};}function patchUpdates(_0x160c38){return function(_0x1b6b00){try{jsonpatch[_0xc340('0x2e')](_0x1b6b00,_0x160c38,!![]);}catch(_0x197510){return BPromise[_0xc340('0x2f')](_0x197510);}return _0x1b6b00[_0xc340('0x30')]();};}function saveUpdates(_0x1f632d,_0x5e46e1){return function(_0x5d84e2){if(_0x5d84e2){return _0x5d84e2[_0xc340('0x31')](_0x1f632d)[_0xc340('0x1c')](function(_0x28cade){return _0x28cade;});}return null;};}function removeEntity(_0x9c8c7,_0x42ea78){return function(_0x3d34a4){if(_0x3d34a4){return _0x3d34a4[_0xc340('0x32')]()['then'](function(){var _0x20a8ed=_0x3d34a4[_0xc340('0x33')]({'plain':!![]});var _0x59b435=_0xc340('0x34');return db[_0xc340('0x35')][_0xc340('0x32')]({'where':{'type':_0x59b435,'resourceId':_0x20a8ed['id']}})['then'](function(){return _0x3d34a4;});})[_0xc340('0x1c')](function(){_0x9c8c7[_0xc340('0x28')](0xcc)[_0xc340('0x36')]();});}};}function handleEntityNotFound(_0x58b6b3,_0x17bd9b){return function(_0x2ece6f){if(!_0x2ece6f){_0x58b6b3['sendStatus'](0x194);}return _0x2ece6f;};}function handleError(_0x430b1b,_0x560ecb){_0x560ecb=_0x560ecb||0x1f4;return function(_0x309f2d){logger[_0xc340('0x23')](_0x309f2d[_0xc340('0x37')]);if(_0x309f2d['name']){delete _0x309f2d[_0xc340('0x38')];}_0x430b1b[_0xc340('0x28')](_0x560ecb)['send'](_0x309f2d);};}exports[_0xc340('0x39')]=function(_0x1407da,_0x317e5d){var _0x1eefc3={},_0xdb363c={},_0x3ed2aa={'count':0x0,'rows':[]};var _0x1c37bb=_['map'](db[_0xc340('0x3a')][_0xc340('0x3b')],function(_0x5443d5){return{'name':_0x5443d5[_0xc340('0x3c')],'type':_0x5443d5[_0xc340('0x3d')][_0xc340('0x3e')]};});_0xdb363c['model']=_[_0xc340('0x3f')](_0x1c37bb,_0xc340('0x38'));_0xdb363c[_0xc340('0x40')]=_['keys'](_0x1407da[_0xc340('0x40')]);_0xdb363c['filters']=_['intersection'](_0xdb363c['model'],_0xdb363c[_0xc340('0x40')]);_0x1eefc3['attributes']=_[_0xc340('0x41')](_0xdb363c[_0xc340('0x42')],qs['fields'](_0x1407da[_0xc340('0x40')][_0xc340('0x43')]));_0x1eefc3[_0xc340('0x44')]=_0x1eefc3['attributes'][_0xc340('0x45')]?_0x1eefc3['attributes']:_0xdb363c[_0xc340('0x42')];if(!_0x1407da[_0xc340('0x40')][_0xc340('0x46')](_0xc340('0x47'))){_0x1eefc3[_0xc340('0x2b')]=qs[_0xc340('0x2b')](_0x1407da[_0xc340('0x40')][_0xc340('0x2b')]);_0x1eefc3[_0xc340('0x2a')]=qs['offset'](_0x1407da['query'][_0xc340('0x2a')]);}_0x1eefc3[_0xc340('0x48')]=qs[_0xc340('0x49')](_0x1407da['query']['sort']);_0x1eefc3[_0xc340('0x4a')]=qs[_0xc340('0x4b')](_[_0xc340('0x4c')](_0x1407da[_0xc340('0x40')],_0xdb363c[_0xc340('0x4b')]),_0x1c37bb);if(_0x1407da[_0xc340('0x40')][_0xc340('0x4d')]){_0x1eefc3[_0xc340('0x4a')]=_[_0xc340('0x4e')](_0x1eefc3[_0xc340('0x4a')],{'$or':_[_0xc340('0x3f')](_0x1c37bb,function(_0x4df518){if(_0x4df518[_0xc340('0x3d')]!==_0xc340('0x4f')){var _0x46b838={};_0x46b838[_0x4df518[_0xc340('0x38')]]={'$like':'%'+_0x1407da[_0xc340('0x40')][_0xc340('0x4d')]+'%'};return _0x46b838;}})});}_0x1eefc3=_[_0xc340('0x4e')]({},_0x1eefc3,_0x1407da['options']);var _0x45a595={'where':_0x1eefc3[_0xc340('0x4a')]};return db[_0xc340('0x3a')][_0xc340('0x50')](_0x45a595)[_0xc340('0x1c')](function(_0x12bd52){_0x3ed2aa[_0xc340('0x50')]=_0x12bd52;if(_0x1407da['query']['includeAll']){_0x1eefc3[_0xc340('0x51')]=[{'all':!![]}];}return db[_0xc340('0x3a')][_0xc340('0x52')](_0x1eefc3);})[_0xc340('0x1c')](function(_0x17b842){_0x3ed2aa['rows']=_0x17b842;return _0x3ed2aa;})['then'](respondWithFilteredResult(_0x317e5d,_0x1eefc3))[_0xc340('0x27')](handleError(_0x317e5d,null));};exports['show']=function(_0x47d860,_0x4ad5c8){var _0x29d5ad={'raw':![],'where':{'id':_0x47d860[_0xc340('0x53')]['id']}},_0x44314c={};_0x44314c[_0xc340('0x42')]=_[_0xc340('0x54')](db[_0xc340('0x3a')][_0xc340('0x3b')]);_0x44314c[_0xc340('0x40')]=_[_0xc340('0x54')](_0x47d860[_0xc340('0x40')]);_0x44314c[_0xc340('0x4b')]=_[_0xc340('0x41')](_0x44314c['model'],_0x44314c['query']);_0x29d5ad[_0xc340('0x44')]=_[_0xc340('0x41')](_0x44314c[_0xc340('0x42')],qs[_0xc340('0x43')](_0x47d860['query']['fields']));_0x29d5ad[_0xc340('0x44')]=_0x29d5ad['attributes'][_0xc340('0x45')]?_0x29d5ad['attributes']:_0x44314c['model'];if(_0x47d860[_0xc340('0x40')][_0xc340('0x55')]){_0x29d5ad[_0xc340('0x51')]=[{'all':!![]}];}_0x29d5ad=_[_0xc340('0x4e')]({},_0x29d5ad,_0x47d860['options']);return db['VoiceContext'][_0xc340('0x56')](_0x29d5ad)['then'](handleEntityNotFound(_0x4ad5c8,null))['then'](respondWithResult(_0x4ad5c8,null))[_0xc340('0x27')](handleError(_0x4ad5c8,null));};exports[_0xc340('0x57')]=function(_0x5945ba,_0xbfc132,_0x178c5e){var _0x4a2357;return db['VoiceContext']['create'](_0x5945ba['body'],{'raw':!![]})[_0xc340('0x1c')](function(_0x46a366){_0x4a2357=_0x46a366;return db[_0xc340('0x3a')][_0xc340('0x52')]({'raw':!![]});})[_0xc340('0x1c')](function(_0x5178f1){var _0x328e89=fs[_0xc340('0x58')](path['join'](config[_0xc340('0x59')],'server/files/templates/context.ejs'),_0xc340('0x5a'));var _0x436415=ejs['render'](_0x328e89,{'contexts':_0x5178f1||[]});fs[_0xc340('0x5b')](_0xc340('0x5c'),_0x436415);})[_0xc340('0x1c')](function(){return respondWithRpcPromise(_0xc340('0x5d'),_0xc340('0x57'),{'module':_0xc340('0x5e')});})[_0xc340('0x1c')](function(){var _0x34d8e7=_0x5945ba['user'][_0xc340('0x33')]({'plain':!![]});if(!_0x34d8e7)throw new Error(_0xc340('0x5f'));if(_0x34d8e7['role']===_0xc340('0x60')){var _0x163ae8=_0x4a2357[_0xc340('0x33')]({'plain':!![]});return db[_0xc340('0x61')][_0xc340('0x56')]({'where':{'name':'Contexts','userProfileId':_0x34d8e7[_0xc340('0x62')]},'raw':!![]})[_0xc340('0x1c')](function(_0x38f855){if(_0x38f855&&_0x38f855[_0xc340('0x63')]===0x0){return db[_0xc340('0x35')][_0xc340('0x57')]({'name':_0x163ae8[_0xc340('0x38')],'resourceId':_0x163ae8['id'],'type':_0x38f855[_0xc340('0x38')],'sectionId':_0x38f855['id']},{})[_0xc340('0x1c')](function(){return _0x4a2357;});}else{return _0x4a2357;}})[_0xc340('0x27')](function(_0x14c5d5){logger[_0xc340('0x23')](_0xc340('0x64'),_0x14c5d5);throw _0x14c5d5;});}return _0x4a2357;})['then'](respondWithResult(_0xbfc132,0xc9))['catch'](handleError(_0xbfc132,null));};exports[_0xc340('0x31')]=function(_0x154e52,_0x2e7396,_0x5687af){var _0x545796;return db['VoiceContext'][_0xc340('0x56')]({'where':{'id':_0x154e52[_0xc340('0x53')]['id']}})[_0xc340('0x1c')](handleEntityNotFound(_0x2e7396,null))['then'](saveUpdates(_0x154e52[_0xc340('0x65')],null))[_0xc340('0x1c')](function(_0x3fe579){if(_0x3fe579){_0x545796=_0x3fe579;return db[_0xc340('0x3a')][_0xc340('0x52')]({'raw':!![]});}})[_0xc340('0x1c')](function(_0x59880b){var _0x1285ec=fs[_0xc340('0x58')](path[_0xc340('0x66')](config['root'],_0xc340('0x67')),_0xc340('0x5a'));var _0x1f4a35=ejs[_0xc340('0x68')](_0x1285ec,{'contexts':_0x59880b||[]});fs[_0xc340('0x5b')]('/etc/asterisk/extensions_xcally_contexts.conf',_0x1f4a35);})[_0xc340('0x1c')](function(){return respondWithRpcPromise('Reload',_0xc340('0x31'),{'module':_0xc340('0x5e')});})['then'](function(){return _0x545796;})[_0xc340('0x1c')](respondWithResult(_0x2e7396,null))[_0xc340('0x27')](handleError(_0x2e7396,null));};exports[_0xc340('0x32')]=function(_0x1dd168,_0x3a70e9,_0x39af16){var _0x58b8d8;return db[_0xc340('0x3a')][_0xc340('0x56')]({'where':{'id':_0x1dd168[_0xc340('0x53')]['id']}})[_0xc340('0x1c')](handleEntityNotFound(_0x3a70e9,null))[_0xc340('0x1c')](removeEntity(_0x3a70e9,null))[_0xc340('0x1c')](function(){return db[_0xc340('0x3a')]['findAll']({'raw':!![]});})[_0xc340('0x1c')](function(_0x524702){var _0x246fe2=fs[_0xc340('0x58')](path[_0xc340('0x66')](config[_0xc340('0x59')],_0xc340('0x67')),_0xc340('0x5a'));var _0x443963=ejs[_0xc340('0x68')](_0x246fe2,{'contexts':_0x524702});fs[_0xc340('0x5b')](_0xc340('0x5c'),_0x443963);return respondWithRpcPromise(_0xc340('0x5d'),_0xc340('0x32'),{'module':'chan_sip.so'});})[_0xc340('0x27')](handleError(_0x3a70e9,null));};
\ No newline at end of file