Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / voiceContext / voiceContext.controller.js
index bd66c67..0ba9dba 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 _0x10f6=['ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','request','then','info','VoiceContext,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','sendStatus','status','end','json','offset','undefined','count','set','apply','reject','destroy','get','Contexts','UserProfileResource','name','index','rawAttributes','fieldName','type','key','model','keys','query','filters','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','map','VIRTUAL','merge','options','VoiceContext','includeAll','include','findAll','rows','show','params','intersection','find','create','body','readFileSync','join','root','server/files/templates/context.ejs','utf8','render','writeFileSync','Reload','chan_sip.so','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','/etc/asterisk/extensions_xcally_contexts.conf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse'];(function(_0x39e84d,_0x11931d){var _0x1991bc=function(_0xc81e32){while(--_0xc81e32){_0x39e84d['push'](_0x39e84d['shift']());}};_0x1991bc(++_0x11931d);}(_0x10f6,0xc7));var _0x610f=function(_0x2b9202,_0x2a8edb){_0x2b9202=_0x2b9202-0x0;var _0x85f119=_0x10f6[_0x2b9202];return _0x85f119;};'use strict';var emlformat=require(_0x610f('0x0'));var rimraf=require(_0x610f('0x1'));var zipdir=require(_0x610f('0x2'));var jsonpatch=require(_0x610f('0x3'));var rp=require(_0x610f('0x4'));var moment=require(_0x610f('0x5'));var BPromise=require(_0x610f('0x6'));var Mustache=require(_0x610f('0x7'));var util=require('util');var path=require(_0x610f('0x8'));var sox=require(_0x610f('0x9'));var csv=require(_0x610f('0xa'));var ejs=require(_0x610f('0xb'));var fs=require('fs');var fs_extra=require(_0x610f('0xc'));var _=require(_0x610f('0xd'));var squel=require(_0x610f('0xe'));var crypto=require(_0x610f('0xf'));var jsforce=require(_0x610f('0x10'));var deskjs=require('desk.js');var toCsv=require(_0x610f('0xa'));var querystring=require(_0x610f('0x11'));var Papa=require(_0x610f('0x12'));var Redis=require(_0x610f('0x13'));var authService=require(_0x610f('0x14'));var qs=require(_0x610f('0x15'));var as=require(_0x610f('0x16'));var hardwareService=require(_0x610f('0x17'));var logger=require('../../config/logger')(_0x610f('0x18'));var utils=require('../../config/utils');var config=require(_0x610f('0x19'));var licenseUtil=require(_0x610f('0x1a'));var db=require(_0x610f('0x1b'))['db'];var jayson=require(_0x610f('0x1c'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x14b78e,_0x432216,_0x22773b,_0x23b8dc){return new BPromise(function(_0x11ae46,_0xee6ea3){var _0x4938a2=_0x23b8dc||client;return _0x4938a2[_0x610f('0x1d')](_0x14b78e,_0x22773b)[_0x610f('0x1e')](function(_0x2748db){logger[_0x610f('0x1f')](_0x610f('0x20'),_0x432216,_0x610f('0x21'));logger[_0x610f('0x22')]('VoiceContext,\x20%s,\x20%s,\x20%s',_0x432216,_0x610f('0x21'),JSON[_0x610f('0x23')](_0x2748db));if(_0x2748db[_0x610f('0x24')]){if(_0x2748db[_0x610f('0x24')][_0x610f('0x25')]===0x1f4){logger['error'](_0x610f('0x20'),_0x432216,_0x2748db[_0x610f('0x24')]['message']);return _0xee6ea3(_0x2748db[_0x610f('0x24')][_0x610f('0x26')]);}logger[_0x610f('0x24')]('VoiceContext,\x20%s,\x20%s',_0x432216,_0x2748db[_0x610f('0x24')][_0x610f('0x26')]);return _0x11ae46(_0x2748db[_0x610f('0x24')][_0x610f('0x26')]);}else{logger[_0x610f('0x1f')](_0x610f('0x20'),_0x432216,_0x610f('0x21'));_0x11ae46(_0x2748db[_0x610f('0x27')][_0x610f('0x26')]);}})[_0x610f('0x28')](function(_0x5ed720){logger[_0x610f('0x24')](_0x610f('0x20'),_0x432216,_0x5ed720);_0xee6ea3(_0x5ed720);});});}function respondWithStatusCode(_0x412142,_0x5edf30){_0x5edf30=_0x5edf30||0xcc;return function(_0x577845){if(_0x577845){return _0x412142[_0x610f('0x29')](_0x5edf30);}return _0x412142[_0x610f('0x2a')](_0x5edf30)[_0x610f('0x2b')]();};}function respondWithResult(_0x5d0f59,_0xa5d7c0){_0xa5d7c0=_0xa5d7c0||0xc8;return function(_0x47c07e){if(_0x47c07e){return _0x5d0f59['status'](_0xa5d7c0)[_0x610f('0x2c')](_0x47c07e);}};}function respondWithFilteredResult(_0x1744bb,_0x3175ff){return function(_0x5c7d86){if(_0x5c7d86){var _0x38b348=typeof _0x3175ff[_0x610f('0x2d')]===_0x610f('0x2e')&&typeof _0x3175ff['limit']===_0x610f('0x2e');var _0x2c81de=_0x5c7d86['count'];var _0x43c83d=_0x38b348?0x0:_0x3175ff[_0x610f('0x2d')];var _0x1fd7d1=_0x38b348?_0x5c7d86[_0x610f('0x2f')]:_0x3175ff[_0x610f('0x2d')]+_0x3175ff['limit'];var _0x4a0e16;if(_0x1fd7d1>=_0x2c81de){_0x1fd7d1=_0x2c81de;_0x4a0e16=0xc8;}else{_0x4a0e16=0xce;}_0x1744bb[_0x610f('0x2a')](_0x4a0e16);return _0x1744bb[_0x610f('0x30')]('Content-Range',_0x43c83d+'-'+_0x1fd7d1+'/'+_0x2c81de)['json'](_0x5c7d86);}return null;};}function patchUpdates(_0x2c537c){return function(_0x2e2bd2){try{jsonpatch[_0x610f('0x31')](_0x2e2bd2,_0x2c537c,!![]);}catch(_0x1d2100){return BPromise[_0x610f('0x32')](_0x1d2100);}return _0x2e2bd2['save']();};}function saveUpdates(_0x556611,_0x104fce){return function(_0x1dbb34){if(_0x1dbb34){return _0x1dbb34['update'](_0x556611)[_0x610f('0x1e')](function(_0xae571e){return _0xae571e;});}return null;};}function removeEntity(_0x3837ea,_0x220325){return function(_0x304022){if(_0x304022){return _0x304022[_0x610f('0x33')]()[_0x610f('0x1e')](function(){var _0x16a57d=_0x304022[_0x610f('0x34')]({'plain':!![]});var _0x394431=_0x610f('0x35');return db[_0x610f('0x36')]['destroy']({'where':{'type':_0x394431,'resourceId':_0x16a57d['id']}})[_0x610f('0x1e')](function(){return _0x304022;});})[_0x610f('0x1e')](function(){_0x3837ea['status'](0xcc)[_0x610f('0x2b')]();});}};}function handleEntityNotFound(_0x43d878,_0x3baf9e){return function(_0x1c36a7){if(!_0x1c36a7){_0x43d878[_0x610f('0x29')](0x194);}return _0x1c36a7;};}function handleError(_0x2fc77c,_0x18a4d0){_0x18a4d0=_0x18a4d0||0x1f4;return function(_0x16e2df){logger[_0x610f('0x24')](_0x16e2df['stack']);if(_0x16e2df[_0x610f('0x37')]){delete _0x16e2df[_0x610f('0x37')];}_0x2fc77c[_0x610f('0x2a')](_0x18a4d0)['send'](_0x16e2df);};}exports[_0x610f('0x38')]=function(_0x4d18e9,_0x1b5631){var _0x162e68={},_0xf48fa={},_0x55cc99={'count':0x0,'rows':[]};var _0x4e036b=_['map'](db['VoiceContext'][_0x610f('0x39')],function(_0x5430b1){return{'name':_0x5430b1[_0x610f('0x3a')],'type':_0x5430b1[_0x610f('0x3b')][_0x610f('0x3c')]};});_0xf48fa[_0x610f('0x3d')]=_['map'](_0x4e036b,_0x610f('0x37'));_0xf48fa['query']=_[_0x610f('0x3e')](_0x4d18e9[_0x610f('0x3f')]);_0xf48fa[_0x610f('0x40')]=_['intersection'](_0xf48fa[_0x610f('0x3d')],_0xf48fa[_0x610f('0x3f')]);_0x162e68[_0x610f('0x41')]=_['intersection'](_0xf48fa[_0x610f('0x3d')],qs['fields'](_0x4d18e9['query'][_0x610f('0x42')]));_0x162e68[_0x610f('0x41')]=_0x162e68['attributes'][_0x610f('0x43')]?_0x162e68[_0x610f('0x41')]:_0xf48fa[_0x610f('0x3d')];if(!_0x4d18e9['query'][_0x610f('0x44')](_0x610f('0x45'))){_0x162e68[_0x610f('0x46')]=qs[_0x610f('0x46')](_0x4d18e9[_0x610f('0x3f')][_0x610f('0x46')]);_0x162e68[_0x610f('0x2d')]=qs[_0x610f('0x2d')](_0x4d18e9[_0x610f('0x3f')][_0x610f('0x2d')]);}_0x162e68[_0x610f('0x47')]=qs[_0x610f('0x48')](_0x4d18e9[_0x610f('0x3f')][_0x610f('0x48')]);_0x162e68[_0x610f('0x49')]=qs[_0x610f('0x40')](_[_0x610f('0x4a')](_0x4d18e9[_0x610f('0x3f')],_0xf48fa[_0x610f('0x40')]),_0x4e036b);if(_0x4d18e9[_0x610f('0x3f')][_0x610f('0x4b')]){_0x162e68[_0x610f('0x49')]=_['merge'](_0x162e68[_0x610f('0x49')],{'$or':_[_0x610f('0x4c')](_0x4e036b,function(_0x2f1d41){if(_0x2f1d41[_0x610f('0x3b')]!==_0x610f('0x4d')){var _0x59e7d2={};_0x59e7d2[_0x2f1d41[_0x610f('0x37')]]={'$like':'%'+_0x4d18e9[_0x610f('0x3f')][_0x610f('0x4b')]+'%'};return _0x59e7d2;}})});}_0x162e68=_[_0x610f('0x4e')]({},_0x162e68,_0x4d18e9[_0x610f('0x4f')]);var _0x8264e={'where':_0x162e68[_0x610f('0x49')]};return db[_0x610f('0x50')][_0x610f('0x2f')](_0x8264e)[_0x610f('0x1e')](function(_0x473016){_0x55cc99[_0x610f('0x2f')]=_0x473016;if(_0x4d18e9[_0x610f('0x3f')][_0x610f('0x51')]){_0x162e68[_0x610f('0x52')]=[{'all':!![]}];}return db[_0x610f('0x50')][_0x610f('0x53')](_0x162e68);})[_0x610f('0x1e')](function(_0x93fa86){_0x55cc99[_0x610f('0x54')]=_0x93fa86;return _0x55cc99;})[_0x610f('0x1e')](respondWithFilteredResult(_0x1b5631,_0x162e68))[_0x610f('0x28')](handleError(_0x1b5631,null));};exports[_0x610f('0x55')]=function(_0x7be4e1,_0x24bc85){var _0x57b62f={'raw':![],'where':{'id':_0x7be4e1[_0x610f('0x56')]['id']}},_0x3b92c9={};_0x3b92c9[_0x610f('0x3d')]=_['keys'](db[_0x610f('0x50')][_0x610f('0x39')]);_0x3b92c9[_0x610f('0x3f')]=_[_0x610f('0x3e')](_0x7be4e1['query']);_0x3b92c9[_0x610f('0x40')]=_[_0x610f('0x57')](_0x3b92c9[_0x610f('0x3d')],_0x3b92c9['query']);_0x57b62f[_0x610f('0x41')]=_['intersection'](_0x3b92c9['model'],qs[_0x610f('0x42')](_0x7be4e1[_0x610f('0x3f')][_0x610f('0x42')]));_0x57b62f[_0x610f('0x41')]=_0x57b62f[_0x610f('0x41')][_0x610f('0x43')]?_0x57b62f[_0x610f('0x41')]:_0x3b92c9[_0x610f('0x3d')];if(_0x7be4e1[_0x610f('0x3f')]['includeAll']){_0x57b62f[_0x610f('0x52')]=[{'all':!![]}];}_0x57b62f=_['merge']({},_0x57b62f,_0x7be4e1[_0x610f('0x4f')]);return db[_0x610f('0x50')][_0x610f('0x58')](_0x57b62f)[_0x610f('0x1e')](handleEntityNotFound(_0x24bc85,null))[_0x610f('0x1e')](respondWithResult(_0x24bc85,null))[_0x610f('0x28')](handleError(_0x24bc85,null));};exports[_0x610f('0x59')]=function(_0x4d1d78,_0x1583f3,_0x5a464a){var _0x556a00;return db[_0x610f('0x50')][_0x610f('0x59')](_0x4d1d78[_0x610f('0x5a')],{'raw':!![]})[_0x610f('0x1e')](function(_0x4fb904){_0x556a00=_0x4fb904;return db[_0x610f('0x50')][_0x610f('0x53')]({'raw':!![]});})[_0x610f('0x1e')](function(_0x4aa682){var _0x35b122=fs[_0x610f('0x5b')](path[_0x610f('0x5c')](config[_0x610f('0x5d')],_0x610f('0x5e')),_0x610f('0x5f'));var _0x5b418f=ejs[_0x610f('0x60')](_0x35b122,{'contexts':_0x4aa682||[]});fs[_0x610f('0x61')]('/etc/asterisk/extensions_xcally_contexts.conf',_0x5b418f);})[_0x610f('0x1e')](function(){return respondWithRpcPromise(_0x610f('0x62'),'create',{'module':_0x610f('0x63')});})[_0x610f('0x1e')](function(){var _0x453c0f=_0x4d1d78[_0x610f('0x64')][_0x610f('0x34')]({'plain':!![]});if(!_0x453c0f)throw new Error(_0x610f('0x65'));if(_0x453c0f[_0x610f('0x66')]==='user'){var _0x3ccfac=_0x556a00[_0x610f('0x34')]({'plain':!![]});return db[_0x610f('0x67')][_0x610f('0x58')]({'where':{'name':_0x610f('0x35'),'userProfileId':_0x453c0f[_0x610f('0x68')]},'raw':!![]})['then'](function(_0x2d3750){if(_0x2d3750&&_0x2d3750[_0x610f('0x69')]===0x0){return db['UserProfileResource'][_0x610f('0x59')]({'name':_0x3ccfac[_0x610f('0x37')],'resourceId':_0x3ccfac['id'],'type':_0x2d3750[_0x610f('0x37')],'sectionId':_0x2d3750['id']},{})['then'](function(){return _0x556a00;});}else{return _0x556a00;}})['catch'](function(_0x1cd568){logger['error'](_0x610f('0x6a'),_0x1cd568);throw _0x1cd568;});}return _0x556a00;})[_0x610f('0x1e')](respondWithResult(_0x1583f3,0xc9))['catch'](handleError(_0x1583f3,null));};exports[_0x610f('0x6b')]=function(_0x62c8a,_0x5ccaf0,_0x3aefa8){var _0x924f03;return db['VoiceContext'][_0x610f('0x58')]({'where':{'id':_0x62c8a['params']['id']}})[_0x610f('0x1e')](handleEntityNotFound(_0x5ccaf0,null))['then'](saveUpdates(_0x62c8a['body'],null))[_0x610f('0x1e')](function(_0x5abce5){if(_0x5abce5){_0x924f03=_0x5abce5;return db[_0x610f('0x50')][_0x610f('0x53')]({'raw':!![]});}})[_0x610f('0x1e')](function(_0x555ab4){var _0x22389b=fs['readFileSync'](path[_0x610f('0x5c')](config['root'],_0x610f('0x5e')),'utf8');var _0x2474f0=ejs['render'](_0x22389b,{'contexts':_0x555ab4||[]});fs['writeFileSync'](_0x610f('0x6c'),_0x2474f0);})['then'](function(){return respondWithRpcPromise(_0x610f('0x62'),_0x610f('0x6b'),{'module':'chan_sip.so'});})[_0x610f('0x1e')](function(){return _0x924f03;})[_0x610f('0x1e')](respondWithResult(_0x5ccaf0,null))[_0x610f('0x28')](handleError(_0x5ccaf0,null));};exports[_0x610f('0x33')]=function(_0x161d17,_0x41f150,_0x2b9e39){var _0x400dbe;return db['VoiceContext']['find']({'where':{'id':_0x161d17[_0x610f('0x56')]['id']}})[_0x610f('0x1e')](handleEntityNotFound(_0x41f150,null))['then'](removeEntity(_0x41f150,null))['then'](function(){return db['VoiceContext'][_0x610f('0x53')]({'raw':!![]});})['then'](function(_0x192ce5){var _0x1269e1=fs[_0x610f('0x5b')](path[_0x610f('0x5c')](config[_0x610f('0x5d')],'server/files/templates/context.ejs'),_0x610f('0x5f'));var _0x553b44=ejs[_0x610f('0x60')](_0x1269e1,{'contexts':_0x192ce5});fs[_0x610f('0x61')](_0x610f('0x6c'),_0x553b44);return respondWithRpcPromise(_0x610f('0x62'),_0x610f('0x33'),{'module':_0x610f('0x63')});})[_0x610f('0x28')](handleError(_0x41f150,null));};
\ No newline at end of file