Built motion from commit efa66e19.|2.6.22
[motion2.git] / server / api / voiceContext / voiceContext.controller.js
index bd66c67..9a84851 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 _0xbcf0=['client','http','info','request\x20sent','debug','VoiceContext,\x20%s,\x20%s,\x20%s','error','code','VoiceContext,\x20%s,\x20%s','message','result','catch','sendStatus','status','end','count','offset','limit','Content-Range','apply','reject','update','then','destroy','get','Contexts','UserProfileResource','stack','name','index','VoiceContext','rawAttributes','fieldName','key','model','map','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','type','filter','options','includeAll','include','findAll','rows','show','params','find','create','readFileSync','join','root','server/files/templates/context.ejs','utf8','render','writeFileSync','Reload','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','/etc/asterisk/extensions_xcally_contexts.conf','chan_sip.so','eml-format','rimraf','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise'];(function(_0x38ded6,_0x260e8c){var _0x404a50=function(_0x316b34){while(--_0x316b34){_0x38ded6['push'](_0x38ded6['shift']());}};_0x404a50(++_0x260e8c);}(_0xbcf0,0xb7));var _0x0bcf=function(_0x173441,_0x26b0d9){_0x173441=_0x173441-0x0;var _0x2423a8=_0xbcf0[_0x173441];return _0x2423a8;};'use strict';var emlformat=require(_0x0bcf('0x0'));var rimraf=require(_0x0bcf('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x0bcf('0x2'));var moment=require(_0x0bcf('0x3'));var BPromise=require(_0x0bcf('0x4'));var Mustache=require(_0x0bcf('0x5'));var util=require(_0x0bcf('0x6'));var path=require(_0x0bcf('0x7'));var sox=require(_0x0bcf('0x8'));var csv=require('to-csv');var ejs=require(_0x0bcf('0x9'));var fs=require('fs');var fs_extra=require(_0x0bcf('0xa'));var _=require(_0x0bcf('0xb'));var squel=require(_0x0bcf('0xc'));var crypto=require(_0x0bcf('0xd'));var jsforce=require(_0x0bcf('0xe'));var deskjs=require(_0x0bcf('0xf'));var toCsv=require(_0x0bcf('0x10'));var querystring=require(_0x0bcf('0x11'));var Papa=require('papaparse');var Redis=require(_0x0bcf('0x12'));var authService=require(_0x0bcf('0x13'));var qs=require(_0x0bcf('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0bcf('0x15'));var logger=require(_0x0bcf('0x16'))(_0x0bcf('0x17'));var utils=require(_0x0bcf('0x18'));var config=require(_0x0bcf('0x19'));var licenseUtil=require(_0x0bcf('0x1a'));var db=require(_0x0bcf('0x1b'))['db'];var jayson=require(_0x0bcf('0x1c'));var client=jayson[_0x0bcf('0x1d')][_0x0bcf('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x376ba4,_0x1d2795,_0x2d0f65,_0x1e3221){return new BPromise(function(_0x2cbaae,_0x1c3210){var _0x4ca8ea=_0x1e3221||client;return _0x4ca8ea['request'](_0x376ba4,_0x2d0f65)['then'](function(_0x39363f){logger[_0x0bcf('0x1f')]('VoiceContext,\x20%s,\x20%s',_0x1d2795,_0x0bcf('0x20'));logger[_0x0bcf('0x21')](_0x0bcf('0x22'),_0x1d2795,_0x0bcf('0x20'),JSON['stringify'](_0x39363f));if(_0x39363f['error']){if(_0x39363f[_0x0bcf('0x23')][_0x0bcf('0x24')]===0x1f4){logger[_0x0bcf('0x23')](_0x0bcf('0x25'),_0x1d2795,_0x39363f[_0x0bcf('0x23')][_0x0bcf('0x26')]);return _0x1c3210(_0x39363f[_0x0bcf('0x23')][_0x0bcf('0x26')]);}logger[_0x0bcf('0x23')]('VoiceContext,\x20%s,\x20%s',_0x1d2795,_0x39363f['error']['message']);return _0x2cbaae(_0x39363f['error'][_0x0bcf('0x26')]);}else{logger[_0x0bcf('0x1f')](_0x0bcf('0x25'),_0x1d2795,'request\x20sent');_0x2cbaae(_0x39363f[_0x0bcf('0x27')][_0x0bcf('0x26')]);}})[_0x0bcf('0x28')](function(_0x2fc280){logger['error'](_0x0bcf('0x25'),_0x1d2795,_0x2fc280);_0x1c3210(_0x2fc280);});});}function respondWithStatusCode(_0x4f1ec9,_0x45b98e){_0x45b98e=_0x45b98e||0xcc;return function(_0x3f97ce){if(_0x3f97ce){return _0x4f1ec9[_0x0bcf('0x29')](_0x45b98e);}return _0x4f1ec9[_0x0bcf('0x2a')](_0x45b98e)[_0x0bcf('0x2b')]();};}function respondWithResult(_0x48bb85,_0x3a527d){_0x3a527d=_0x3a527d||0xc8;return function(_0xf8cdcd){if(_0xf8cdcd){return _0x48bb85['status'](_0x3a527d)['json'](_0xf8cdcd);}};}function respondWithFilteredResult(_0x380f86,_0x5a2b97){return function(_0x2ccc6f){if(_0x2ccc6f){var _0x3fd9c0=typeof _0x5a2b97['offset']==='undefined'&&typeof _0x5a2b97['limit']==='undefined';var _0xc18cc7=_0x2ccc6f[_0x0bcf('0x2c')];var _0x8ff78b=_0x3fd9c0?0x0:_0x5a2b97[_0x0bcf('0x2d')];var _0x8a95c1=_0x3fd9c0?_0x2ccc6f[_0x0bcf('0x2c')]:_0x5a2b97['offset']+_0x5a2b97[_0x0bcf('0x2e')];var _0xea2870;if(_0x8a95c1>=_0xc18cc7){_0x8a95c1=_0xc18cc7;_0xea2870=0xc8;}else{_0xea2870=0xce;}_0x380f86[_0x0bcf('0x2a')](_0xea2870);return _0x380f86['set'](_0x0bcf('0x2f'),_0x8ff78b+'-'+_0x8a95c1+'/'+_0xc18cc7)['json'](_0x2ccc6f);}return null;};}function patchUpdates(_0x3a603f){return function(_0x2464b1){try{jsonpatch[_0x0bcf('0x30')](_0x2464b1,_0x3a603f,!![]);}catch(_0x14a8f0){return BPromise[_0x0bcf('0x31')](_0x14a8f0);}return _0x2464b1['save']();};}function saveUpdates(_0x10bf15,_0x3dac6f){return function(_0x6e3a93){if(_0x6e3a93){return _0x6e3a93[_0x0bcf('0x32')](_0x10bf15)[_0x0bcf('0x33')](function(_0x5ad303){return _0x5ad303;});}return null;};}function removeEntity(_0xb8543e,_0x5f21e2){return function(_0x1a29a2){if(_0x1a29a2){return _0x1a29a2[_0x0bcf('0x34')]()['then'](function(){var _0x190c49=_0x1a29a2[_0x0bcf('0x35')]({'plain':!![]});var _0x417d8d=_0x0bcf('0x36');return db[_0x0bcf('0x37')][_0x0bcf('0x34')]({'where':{'type':_0x417d8d,'resourceId':_0x190c49['id']}})[_0x0bcf('0x33')](function(){return _0x1a29a2;});})[_0x0bcf('0x33')](function(){_0xb8543e[_0x0bcf('0x2a')](0xcc)[_0x0bcf('0x2b')]();});}};}function handleEntityNotFound(_0x1597b3,_0x376072){return function(_0x41290c){if(!_0x41290c){_0x1597b3[_0x0bcf('0x29')](0x194);}return _0x41290c;};}function handleError(_0x46fdf5,_0x459865){_0x459865=_0x459865||0x1f4;return function(_0x38251b){logger[_0x0bcf('0x23')](_0x38251b[_0x0bcf('0x38')]);if(_0x38251b[_0x0bcf('0x39')]){delete _0x38251b['name'];}_0x46fdf5[_0x0bcf('0x2a')](_0x459865)['send'](_0x38251b);};}exports[_0x0bcf('0x3a')]=function(_0x118e02,_0x5e26ee){var _0x72ec5c={},_0x51ed19={},_0x253c59={'count':0x0,'rows':[]};var _0x115d27=_['map'](db[_0x0bcf('0x3b')][_0x0bcf('0x3c')],function(_0x24ee28){return{'name':_0x24ee28[_0x0bcf('0x3d')],'type':_0x24ee28['type'][_0x0bcf('0x3e')]};});_0x51ed19[_0x0bcf('0x3f')]=_[_0x0bcf('0x40')](_0x115d27,'name');_0x51ed19['query']=_[_0x0bcf('0x41')](_0x118e02[_0x0bcf('0x42')]);_0x51ed19[_0x0bcf('0x43')]=_['intersection'](_0x51ed19[_0x0bcf('0x3f')],_0x51ed19['query']);_0x72ec5c[_0x0bcf('0x44')]=_[_0x0bcf('0x45')](_0x51ed19['model'],qs[_0x0bcf('0x46')](_0x118e02[_0x0bcf('0x42')][_0x0bcf('0x46')]));_0x72ec5c[_0x0bcf('0x44')]=_0x72ec5c['attributes'][_0x0bcf('0x47')]?_0x72ec5c[_0x0bcf('0x44')]:_0x51ed19[_0x0bcf('0x3f')];if(!_0x118e02[_0x0bcf('0x42')][_0x0bcf('0x48')](_0x0bcf('0x49'))){_0x72ec5c[_0x0bcf('0x2e')]=qs[_0x0bcf('0x2e')](_0x118e02[_0x0bcf('0x42')][_0x0bcf('0x2e')]);_0x72ec5c[_0x0bcf('0x2d')]=qs['offset'](_0x118e02[_0x0bcf('0x42')][_0x0bcf('0x2d')]);}_0x72ec5c[_0x0bcf('0x4a')]=qs[_0x0bcf('0x4b')](_0x118e02[_0x0bcf('0x42')]['sort']);_0x72ec5c[_0x0bcf('0x4c')]=qs['filters'](_[_0x0bcf('0x4d')](_0x118e02[_0x0bcf('0x42')],_0x51ed19[_0x0bcf('0x43')]),_0x115d27);if(_0x118e02['query']['filter']){_0x72ec5c[_0x0bcf('0x4c')]=_[_0x0bcf('0x4e')](_0x72ec5c[_0x0bcf('0x4c')],{'$or':_['map'](_0x115d27,function(_0x1efa28){if(_0x1efa28[_0x0bcf('0x4f')]!=='VIRTUAL'){var _0x3e3f14={};_0x3e3f14[_0x1efa28['name']]={'$like':'%'+_0x118e02[_0x0bcf('0x42')][_0x0bcf('0x50')]+'%'};return _0x3e3f14;}})});}_0x72ec5c=_['merge']({},_0x72ec5c,_0x118e02[_0x0bcf('0x51')]);var _0x4245c0={'where':_0x72ec5c[_0x0bcf('0x4c')]};return db[_0x0bcf('0x3b')][_0x0bcf('0x2c')](_0x4245c0)['then'](function(_0x58d89d){_0x253c59[_0x0bcf('0x2c')]=_0x58d89d;if(_0x118e02['query'][_0x0bcf('0x52')]){_0x72ec5c[_0x0bcf('0x53')]=[{'all':!![]}];}return db['VoiceContext'][_0x0bcf('0x54')](_0x72ec5c);})['then'](function(_0xd59162){_0x253c59[_0x0bcf('0x55')]=_0xd59162;return _0x253c59;})['then'](respondWithFilteredResult(_0x5e26ee,_0x72ec5c))[_0x0bcf('0x28')](handleError(_0x5e26ee,null));};exports[_0x0bcf('0x56')]=function(_0x75609b,_0x42f768){var _0xb6109b={'raw':![],'where':{'id':_0x75609b[_0x0bcf('0x57')]['id']}},_0x5cf517={};_0x5cf517[_0x0bcf('0x3f')]=_[_0x0bcf('0x41')](db['VoiceContext'][_0x0bcf('0x3c')]);_0x5cf517[_0x0bcf('0x42')]=_['keys'](_0x75609b[_0x0bcf('0x42')]);_0x5cf517['filters']=_[_0x0bcf('0x45')](_0x5cf517['model'],_0x5cf517[_0x0bcf('0x42')]);_0xb6109b['attributes']=_[_0x0bcf('0x45')](_0x5cf517[_0x0bcf('0x3f')],qs[_0x0bcf('0x46')](_0x75609b['query'][_0x0bcf('0x46')]));_0xb6109b[_0x0bcf('0x44')]=_0xb6109b[_0x0bcf('0x44')]['length']?_0xb6109b[_0x0bcf('0x44')]:_0x5cf517['model'];if(_0x75609b['query'][_0x0bcf('0x52')]){_0xb6109b[_0x0bcf('0x53')]=[{'all':!![]}];}_0xb6109b=_[_0x0bcf('0x4e')]({},_0xb6109b,_0x75609b[_0x0bcf('0x51')]);return db['VoiceContext'][_0x0bcf('0x58')](_0xb6109b)[_0x0bcf('0x33')](handleEntityNotFound(_0x42f768,null))[_0x0bcf('0x33')](respondWithResult(_0x42f768,null))[_0x0bcf('0x28')](handleError(_0x42f768,null));};exports[_0x0bcf('0x59')]=function(_0x485754,_0x1bf0dd,_0x329e1f){var _0x21d1e2;return db['VoiceContext'][_0x0bcf('0x59')](_0x485754['body'],{'raw':!![]})[_0x0bcf('0x33')](function(_0x9f7fd8){_0x21d1e2=_0x9f7fd8;return db['VoiceContext'][_0x0bcf('0x54')]({'raw':!![]});})[_0x0bcf('0x33')](function(_0xf31bb){var _0x6e5bbc=fs[_0x0bcf('0x5a')](path[_0x0bcf('0x5b')](config[_0x0bcf('0x5c')],_0x0bcf('0x5d')),_0x0bcf('0x5e'));var _0x55c3cb=ejs[_0x0bcf('0x5f')](_0x6e5bbc,{'contexts':_0xf31bb||[]});fs[_0x0bcf('0x60')]('/etc/asterisk/extensions_xcally_contexts.conf',_0x55c3cb);})[_0x0bcf('0x33')](function(){return respondWithRpcPromise(_0x0bcf('0x61'),'create',{'module':'chan_sip.so'});})[_0x0bcf('0x33')](function(){var _0x3609dd=_0x485754['user'][_0x0bcf('0x35')]({'plain':!![]});if(!_0x3609dd)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3609dd[_0x0bcf('0x62')]==='user'){var _0x2aeed8=_0x21d1e2[_0x0bcf('0x35')]({'plain':!![]});return db[_0x0bcf('0x63')]['find']({'where':{'name':_0x0bcf('0x36'),'userProfileId':_0x3609dd[_0x0bcf('0x64')]},'raw':!![]})[_0x0bcf('0x33')](function(_0x1a7f6b){if(_0x1a7f6b&&_0x1a7f6b[_0x0bcf('0x65')]===0x0){return db['UserProfileResource'][_0x0bcf('0x59')]({'name':_0x2aeed8[_0x0bcf('0x39')],'resourceId':_0x2aeed8['id'],'type':_0x1a7f6b['name'],'sectionId':_0x1a7f6b['id']},{})[_0x0bcf('0x33')](function(){return _0x21d1e2;});}else{return _0x21d1e2;}})[_0x0bcf('0x28')](function(_0x48321f){logger[_0x0bcf('0x23')](_0x0bcf('0x66'),_0x48321f);throw _0x48321f;});}return _0x21d1e2;})[_0x0bcf('0x33')](respondWithResult(_0x1bf0dd,0xc9))['catch'](handleError(_0x1bf0dd,null));};exports[_0x0bcf('0x32')]=function(_0x107755,_0xbe4bc1,_0x5a0c99){var _0x35c6e1;return db['VoiceContext'][_0x0bcf('0x58')]({'where':{'id':_0x107755[_0x0bcf('0x57')]['id']}})[_0x0bcf('0x33')](handleEntityNotFound(_0xbe4bc1,null))[_0x0bcf('0x33')](saveUpdates(_0x107755[_0x0bcf('0x67')],null))[_0x0bcf('0x33')](function(_0x1a56ca){if(_0x1a56ca){_0x35c6e1=_0x1a56ca;return db[_0x0bcf('0x3b')][_0x0bcf('0x54')]({'raw':!![]});}})['then'](function(_0xef4981){var _0x3c68f9=fs[_0x0bcf('0x5a')](path[_0x0bcf('0x5b')](config[_0x0bcf('0x5c')],_0x0bcf('0x5d')),_0x0bcf('0x5e'));var _0x230eac=ejs[_0x0bcf('0x5f')](_0x3c68f9,{'contexts':_0xef4981||[]});fs[_0x0bcf('0x60')](_0x0bcf('0x68'),_0x230eac);})['then'](function(){return respondWithRpcPromise(_0x0bcf('0x61'),_0x0bcf('0x32'),{'module':_0x0bcf('0x69')});})[_0x0bcf('0x33')](function(){return _0x35c6e1;})[_0x0bcf('0x33')](respondWithResult(_0xbe4bc1,null))[_0x0bcf('0x28')](handleError(_0xbe4bc1,null));};exports['destroy']=function(_0x5da3d6,_0x35d579,_0x51ea28){var _0x7778ce;return db[_0x0bcf('0x3b')]['find']({'where':{'id':_0x5da3d6['params']['id']}})[_0x0bcf('0x33')](handleEntityNotFound(_0x35d579,null))[_0x0bcf('0x33')](removeEntity(_0x35d579,null))[_0x0bcf('0x33')](function(){return db['VoiceContext']['findAll']({'raw':!![]});})[_0x0bcf('0x33')](function(_0x326274){var _0x33f1be=fs[_0x0bcf('0x5a')](path[_0x0bcf('0x5b')](config[_0x0bcf('0x5c')],_0x0bcf('0x5d')),_0x0bcf('0x5e'));var _0x19ce08=ejs[_0x0bcf('0x5f')](_0x33f1be,{'contexts':_0x326274});fs['writeFileSync'](_0x0bcf('0x68'),_0x19ce08);return respondWithRpcPromise('Reload','destroy',{'module':_0x0bcf('0x69')});})[_0x0bcf('0x28')](handleError(_0x35d579,null));};
\ No newline at end of file