Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / api / voiceContext / voiceContext.controller.js
index 83ff15c..75849d7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x18e0=['message','result','sendStatus','status','end','json','count','offset','limit','Content-Range','apply','save','update','then','destroy','get','Contexts','UserProfileResource','stack','name','send','index','map','VoiceContext','rawAttributes','fieldName','key','query','keys','filters','intersection','attributes','model','fields','length','hasOwnProperty','sort','where','pick','merge','type','filter','options','include','findAll','params','includeAll','catch','create','body','readFileSync','join','root','server/files/templates/context.ejs','utf8','render','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','Reload','chan_sip.so','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','path','sox','to-csv','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','info','VoiceContext,\x20%s,\x20%s','request\x20sent','VoiceContext,\x20%s,\x20%s,\x20%s','error','code'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x18e0,0xa2));var _0x018e=function(_0xe73080,_0x24c56d){_0xe73080=_0xe73080-0x0;var _0x12cbc4=_0x18e0[_0xe73080];return _0x12cbc4;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x018e('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x018e('0x1'));var jsonpatch=require(_0x018e('0x2'));var rp=require(_0x018e('0x3'));var moment=require('moment');var BPromise=require(_0x018e('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0x018e('0x5'));var sox=require(_0x018e('0x6'));var csv=require(_0x018e('0x7'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x018e('0x8'));var crypto=require(_0x018e('0x9'));var jsforce=require('jsforce');var deskjs=require(_0x018e('0xa'));var toCsv=require(_0x018e('0x7'));var querystring=require(_0x018e('0xb'));var Papa=require(_0x018e('0xc'));var Redis=require(_0x018e('0xd'));var authService=require(_0x018e('0xe'));var qs=require('../../components/parsers/qs');var as=require(_0x018e('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0x018e('0x10'));var config=require(_0x018e('0x11'));var licenseUtil=require(_0x018e('0x12'));var db=require(_0x018e('0x13'))['db'];var jayson=require(_0x018e('0x14'));var client=jayson[_0x018e('0x15')][_0x018e('0x16')]({'port':0x232a});function respondWithRpcPromise(_0x23d2e7,_0x39898a,_0x52e2fd,_0xec531a){return new BPromise(function(_0x3b1e5e,_0x2d6aa0){var _0x423f58=_0xec531a||client;return _0x423f58[_0x018e('0x17')](_0x23d2e7,_0x52e2fd)['then'](function(_0x275c21){logger[_0x018e('0x18')](_0x018e('0x19'),_0x39898a,_0x018e('0x1a'));logger['debug'](_0x018e('0x1b'),_0x39898a,_0x018e('0x1a'),JSON['stringify'](_0x275c21));if(_0x275c21[_0x018e('0x1c')]){if(_0x275c21[_0x018e('0x1c')][_0x018e('0x1d')]===0x1f4){logger[_0x018e('0x1c')](_0x018e('0x19'),_0x39898a,_0x275c21['error'][_0x018e('0x1e')]);return _0x2d6aa0(_0x275c21[_0x018e('0x1c')][_0x018e('0x1e')]);}logger[_0x018e('0x1c')](_0x018e('0x19'),_0x39898a,_0x275c21[_0x018e('0x1c')][_0x018e('0x1e')]);return _0x3b1e5e(_0x275c21['error'][_0x018e('0x1e')]);}else{logger[_0x018e('0x18')](_0x018e('0x19'),_0x39898a,_0x018e('0x1a'));_0x3b1e5e(_0x275c21[_0x018e('0x1f')]['message']);}})['catch'](function(_0x74dd70){logger[_0x018e('0x1c')](_0x018e('0x19'),_0x39898a,_0x74dd70);_0x2d6aa0(_0x74dd70);});});}function respondWithStatusCode(_0x1e3106,_0x2ef801){_0x2ef801=_0x2ef801||0xcc;return function(_0x198b0b){if(_0x198b0b){return _0x1e3106[_0x018e('0x20')](_0x2ef801);}return _0x1e3106[_0x018e('0x21')](_0x2ef801)[_0x018e('0x22')]();};}function respondWithResult(_0x1d0baa,_0x35f9a3){_0x35f9a3=_0x35f9a3||0xc8;return function(_0x7596f4){if(_0x7596f4){return _0x1d0baa['status'](_0x35f9a3)[_0x018e('0x23')](_0x7596f4);}};}function respondWithFilteredResult(_0x289931,_0x176822){return function(_0x344e2b){if(_0x344e2b){var _0x2167e6=_0x344e2b[_0x018e('0x24')],_0x184990=_0x176822[_0x018e('0x25')],_0x407fda=_0x176822['offset']+_0x176822[_0x018e('0x26')],_0x3724ed;if(_0x407fda>=_0x2167e6){_0x407fda=_0x2167e6;_0x3724ed=0xc8;}else{_0x3724ed=0xce;}_0x289931[_0x018e('0x21')](_0x3724ed);return _0x289931['set'](_0x018e('0x27'),_0x184990+'-'+_0x407fda+'/'+_0x2167e6)[_0x018e('0x23')](_0x344e2b);}return null;};}function patchUpdates(_0x471e30){return function(_0x2836b1){try{jsonpatch[_0x018e('0x28')](_0x2836b1,_0x471e30,!![]);}catch(_0x42da91){return BPromise['reject'](_0x42da91);}return _0x2836b1[_0x018e('0x29')]();};}function saveUpdates(_0x1e35d9,_0x5903d6){return function(_0x12a7e5){if(_0x12a7e5){return _0x12a7e5[_0x018e('0x2a')](_0x1e35d9)[_0x018e('0x2b')](function(_0xfc64dd){return _0xfc64dd;});}return null;};}function removeEntity(_0x2e160d,_0x4e23ef){return function(_0xafd399){if(_0xafd399){return _0xafd399[_0x018e('0x2c')]()[_0x018e('0x2b')](function(){var _0x502763=_0xafd399[_0x018e('0x2d')]({'plain':!![]});var _0x4d0ed8=_0x018e('0x2e');return db[_0x018e('0x2f')]['destroy']({'where':{'type':_0x4d0ed8,'resourceId':_0x502763['id']}})['then'](function(){return _0xafd399;});})[_0x018e('0x2b')](function(){_0x2e160d[_0x018e('0x21')](0xcc)[_0x018e('0x22')]();});}};}function handleEntityNotFound(_0x37f8f6,_0x3b52f7){return function(_0x4a5cca){if(!_0x4a5cca){_0x37f8f6[_0x018e('0x20')](0x194);}return _0x4a5cca;};}function handleError(_0x39d210,_0x450ba5){_0x450ba5=_0x450ba5||0x1f4;return function(_0x55dbda){logger['error'](_0x55dbda[_0x018e('0x30')]);if(_0x55dbda[_0x018e('0x31')]){delete _0x55dbda[_0x018e('0x31')];}_0x39d210[_0x018e('0x21')](_0x450ba5)[_0x018e('0x32')](_0x55dbda);};}exports[_0x018e('0x33')]=function(_0x581a9e,_0x158f8d){var _0x1f3e7e={},_0x4fd059={},_0x4cb785={'count':0x0,'rows':[]};var _0x5c34c9=_[_0x018e('0x34')](db[_0x018e('0x35')][_0x018e('0x36')],function(_0x1705b7){return{'name':_0x1705b7[_0x018e('0x37')],'type':_0x1705b7['type'][_0x018e('0x38')]};});_0x4fd059['model']=_[_0x018e('0x34')](_0x5c34c9,_0x018e('0x31'));_0x4fd059[_0x018e('0x39')]=_[_0x018e('0x3a')](_0x581a9e['query']);_0x4fd059[_0x018e('0x3b')]=_[_0x018e('0x3c')](_0x4fd059['model'],_0x4fd059['query']);_0x1f3e7e[_0x018e('0x3d')]=_['intersection'](_0x4fd059[_0x018e('0x3e')],qs[_0x018e('0x3f')](_0x581a9e['query'][_0x018e('0x3f')]));_0x1f3e7e[_0x018e('0x3d')]=_0x1f3e7e[_0x018e('0x3d')][_0x018e('0x40')]?_0x1f3e7e[_0x018e('0x3d')]:_0x4fd059[_0x018e('0x3e')];if(!_0x581a9e[_0x018e('0x39')][_0x018e('0x41')]('nolimit')){_0x1f3e7e[_0x018e('0x26')]=qs[_0x018e('0x26')](_0x581a9e['query'][_0x018e('0x26')]);_0x1f3e7e[_0x018e('0x25')]=qs[_0x018e('0x25')](_0x581a9e[_0x018e('0x39')][_0x018e('0x25')]);}_0x1f3e7e['order']=qs[_0x018e('0x42')](_0x581a9e['query'][_0x018e('0x42')]);_0x1f3e7e[_0x018e('0x43')]=qs[_0x018e('0x3b')](_[_0x018e('0x44')](_0x581a9e['query'],_0x4fd059[_0x018e('0x3b')]),_0x5c34c9);if(_0x581a9e[_0x018e('0x39')]['filter']){_0x1f3e7e[_0x018e('0x43')]=_[_0x018e('0x45')](_0x1f3e7e[_0x018e('0x43')],{'$or':_[_0x018e('0x34')](_0x5c34c9,function(_0x17a0ae){if(_0x17a0ae[_0x018e('0x46')]!=='VIRTUAL'){var _0x292e32={};_0x292e32[_0x17a0ae[_0x018e('0x31')]]={'$like':'%'+_0x581a9e['query'][_0x018e('0x47')]+'%'};return _0x292e32;}})});}_0x1f3e7e=_[_0x018e('0x45')]({},_0x1f3e7e,_0x581a9e[_0x018e('0x48')]);var _0x417829={'where':_0x1f3e7e[_0x018e('0x43')]};return db[_0x018e('0x35')][_0x018e('0x24')](_0x417829)[_0x018e('0x2b')](function(_0x1f0f3b){_0x4cb785[_0x018e('0x24')]=_0x1f0f3b;if(_0x581a9e[_0x018e('0x39')]['includeAll']){_0x1f3e7e[_0x018e('0x49')]=[{'all':!![]}];}return db['VoiceContext'][_0x018e('0x4a')](_0x1f3e7e);})[_0x018e('0x2b')](function(_0x530fd2){_0x4cb785['rows']=_0x530fd2;return _0x4cb785;})[_0x018e('0x2b')](respondWithFilteredResult(_0x158f8d,_0x1f3e7e))['catch'](handleError(_0x158f8d,null));};exports['show']=function(_0x4f1df6,_0x3e26b1){var _0x16e8b0={'raw':![],'where':{'id':_0x4f1df6[_0x018e('0x4b')]['id']}},_0x22f1d4={};_0x22f1d4['model']=_[_0x018e('0x3a')](db[_0x018e('0x35')][_0x018e('0x36')]);_0x22f1d4[_0x018e('0x39')]=_[_0x018e('0x3a')](_0x4f1df6[_0x018e('0x39')]);_0x22f1d4[_0x018e('0x3b')]=_[_0x018e('0x3c')](_0x22f1d4['model'],_0x22f1d4[_0x018e('0x39')]);_0x16e8b0[_0x018e('0x3d')]=_[_0x018e('0x3c')](_0x22f1d4[_0x018e('0x3e')],qs['fields'](_0x4f1df6[_0x018e('0x39')][_0x018e('0x3f')]));_0x16e8b0[_0x018e('0x3d')]=_0x16e8b0['attributes'][_0x018e('0x40')]?_0x16e8b0[_0x018e('0x3d')]:_0x22f1d4['model'];if(_0x4f1df6[_0x018e('0x39')][_0x018e('0x4c')]){_0x16e8b0[_0x018e('0x49')]=[{'all':!![]}];}_0x16e8b0=_[_0x018e('0x45')]({},_0x16e8b0,_0x4f1df6[_0x018e('0x48')]);return db[_0x018e('0x35')]['find'](_0x16e8b0)['then'](handleEntityNotFound(_0x3e26b1,null))[_0x018e('0x2b')](respondWithResult(_0x3e26b1,null))[_0x018e('0x4d')](handleError(_0x3e26b1,null));};exports[_0x018e('0x4e')]=function(_0x53439a,_0x45bdc3,_0x586dcc){var _0x573013;return db[_0x018e('0x35')][_0x018e('0x4e')](_0x53439a[_0x018e('0x4f')],{'raw':!![]})['then'](function(_0x3e238e){_0x573013=_0x3e238e;return db[_0x018e('0x35')][_0x018e('0x4a')]({'raw':!![]});})[_0x018e('0x2b')](function(_0x1ef430){var _0x59e5f3=fs[_0x018e('0x50')](path[_0x018e('0x51')](config[_0x018e('0x52')],_0x018e('0x53')),_0x018e('0x54'));var _0x264d26=ejs[_0x018e('0x55')](_0x59e5f3,{'contexts':_0x1ef430||[]});fs[_0x018e('0x56')](_0x018e('0x57'),_0x264d26);})[_0x018e('0x2b')](function(){return respondWithRpcPromise(_0x018e('0x58'),_0x018e('0x4e'),{'module':_0x018e('0x59')});})['then'](function(){var _0x372394=_0x53439a[_0x018e('0x5a')][_0x018e('0x2d')]({'plain':!![]});if(!_0x372394)throw new Error(_0x018e('0x5b'));if(_0x372394[_0x018e('0x5c')]==='user'){var _0x290cef=_0x573013[_0x018e('0x2d')]({'plain':!![]});return db[_0x018e('0x5d')][_0x018e('0x5e')]({'where':{'name':'Contexts','userProfileId':_0x372394['userProfileId']},'raw':!![]})[_0x018e('0x2b')](function(_0xfe23d2){if(_0xfe23d2&&_0xfe23d2['autoAssociation']===0x0){return db[_0x018e('0x2f')][_0x018e('0x4e')]({'name':_0x290cef[_0x018e('0x31')],'resourceId':_0x290cef['id'],'type':_0xfe23d2['name'],'sectionId':_0xfe23d2['id']},{})['then'](function(){return _0x573013;});}else{return _0x573013;}})['catch'](function(_0x172b6a){logger['error'](_0x018e('0x5f'),_0x172b6a);throw _0x172b6a;});}return _0x573013;})[_0x018e('0x2b')](respondWithResult(_0x45bdc3,0xc9))[_0x018e('0x4d')](handleError(_0x45bdc3,null));};exports[_0x018e('0x2a')]=function(_0x445c30,_0x39e8d1,_0x53a928){var _0x24f1c2;return db[_0x018e('0x35')][_0x018e('0x5e')]({'where':{'id':_0x445c30['params']['id']}})[_0x018e('0x2b')](handleEntityNotFound(_0x39e8d1,null))[_0x018e('0x2b')](saveUpdates(_0x445c30[_0x018e('0x4f')],null))[_0x018e('0x2b')](function(_0x24819e){if(_0x24819e){_0x24f1c2=_0x24819e;return db[_0x018e('0x35')][_0x018e('0x4a')]({'raw':!![]});}})[_0x018e('0x2b')](function(_0x17c032){var _0x2700bc=fs[_0x018e('0x50')](path[_0x018e('0x51')](config[_0x018e('0x52')],'server/files/templates/context.ejs'),'utf8');var _0x4f7b95=ejs[_0x018e('0x55')](_0x2700bc,{'contexts':_0x17c032||[]});fs[_0x018e('0x56')](_0x018e('0x57'),_0x4f7b95);})['then'](function(){return respondWithRpcPromise(_0x018e('0x58'),_0x018e('0x2a'),{'module':'chan_sip.so'});})[_0x018e('0x2b')](function(){return _0x24f1c2;})[_0x018e('0x2b')](respondWithResult(_0x39e8d1,null))[_0x018e('0x4d')](handleError(_0x39e8d1,null));};exports[_0x018e('0x2c')]=function(_0x1f73d7,_0x56afdc,_0x546a36){var _0x23c102;return db[_0x018e('0x35')][_0x018e('0x5e')]({'where':{'id':_0x1f73d7['params']['id']}})[_0x018e('0x2b')](handleEntityNotFound(_0x56afdc,null))['then'](removeEntity(_0x56afdc,null))[_0x018e('0x2b')](function(){return db[_0x018e('0x35')][_0x018e('0x4a')]({'raw':!![]});})[_0x018e('0x2b')](function(_0x427691){var _0x57b47b=fs['readFileSync'](path[_0x018e('0x51')](config[_0x018e('0x52')],'server/files/templates/context.ejs'),_0x018e('0x54'));var _0x40776a=ejs[_0x018e('0x55')](_0x57b47b,{'contexts':_0x427691});fs[_0x018e('0x56')]('/etc/asterisk/extensions_xcally_contexts.conf',_0x40776a);return respondWithRpcPromise(_0x018e('0x58'),_0x018e('0x2c'),{'module':_0x018e('0x59')});})['catch'](handleError(_0x56afdc,null));};
\ No newline at end of file
+var _0x7ced=['debug','VoiceContext,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','VoiceContext,\x20%s,\x20%s','message','info','catch','end','status','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','update','destroy','Contexts','UserProfileResource','sendStatus','stack','name','index','map','VoiceContext','rawAttributes','type','key','model','keys','query','filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','options','includeAll','include','findAll','rows','show','params','length','create','body','readFileSync','join','root','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','chan_sip.so','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','server/files/templates/context.ejs','utf8','render','Reload','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','jayson/promise','client','http','request','then'];(function(_0x48e5cd,_0x46acc0){var _0x559f41=function(_0x284af1){while(--_0x284af1){_0x48e5cd['push'](_0x48e5cd['shift']());}};_0x559f41(++_0x46acc0);}(_0x7ced,0x131));var _0xd7ce=function(_0x464d1b,_0x4d4525){_0x464d1b=_0x464d1b-0x0;var _0x1b21c0=_0x7ced[_0x464d1b];return _0x1b21c0;};'use strict';var emlformat=require(_0xd7ce('0x0'));var rimraf=require(_0xd7ce('0x1'));var zipdir=require(_0xd7ce('0x2'));var jsonpatch=require(_0xd7ce('0x3'));var rp=require(_0xd7ce('0x4'));var moment=require(_0xd7ce('0x5'));var BPromise=require(_0xd7ce('0x6'));var Mustache=require(_0xd7ce('0x7'));var util=require(_0xd7ce('0x8'));var path=require(_0xd7ce('0x9'));var sox=require('sox');var csv=require(_0xd7ce('0xa'));var ejs=require(_0xd7ce('0xb'));var fs=require('fs');var fs_extra=require(_0xd7ce('0xc'));var _=require(_0xd7ce('0xd'));var squel=require(_0xd7ce('0xe'));var crypto=require(_0xd7ce('0xf'));var jsforce=require(_0xd7ce('0x10'));var deskjs=require(_0xd7ce('0x11'));var toCsv=require(_0xd7ce('0xa'));var querystring=require(_0xd7ce('0x12'));var Papa=require(_0xd7ce('0x13'));var Redis=require(_0xd7ce('0x14'));var authService=require(_0xd7ce('0x15'));var qs=require(_0xd7ce('0x16'));var as=require(_0xd7ce('0x17'));var hardwareService=require(_0xd7ce('0x18'));var logger=require(_0xd7ce('0x19'))(_0xd7ce('0x1a'));var utils=require('../../config/utils');var config=require(_0xd7ce('0x1b'));var licenseUtil=require('../../config/license/util');var db=require(_0xd7ce('0x1c'))['db'];var jayson=require(_0xd7ce('0x1d'));var client=jayson[_0xd7ce('0x1e')][_0xd7ce('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x1a5bff,_0x1f803b,_0x48a228,_0xcc536a){return new BPromise(function(_0x2d2163,_0x835e40){var _0x2d2925=_0xcc536a||client;return _0x2d2925[_0xd7ce('0x20')](_0x1a5bff,_0x48a228)[_0xd7ce('0x21')](function(_0x865a2d){logger['info']('VoiceContext,\x20%s,\x20%s',_0x1f803b,'request\x20sent');logger[_0xd7ce('0x22')](_0xd7ce('0x23'),_0x1f803b,_0xd7ce('0x24'),JSON[_0xd7ce('0x25')](_0x865a2d));if(_0x865a2d['error']){if(_0x865a2d[_0xd7ce('0x26')][_0xd7ce('0x27')]===0x1f4){logger[_0xd7ce('0x26')](_0xd7ce('0x28'),_0x1f803b,_0x865a2d[_0xd7ce('0x26')][_0xd7ce('0x29')]);return _0x835e40(_0x865a2d[_0xd7ce('0x26')][_0xd7ce('0x29')]);}logger['error'](_0xd7ce('0x28'),_0x1f803b,_0x865a2d[_0xd7ce('0x26')]['message']);return _0x2d2163(_0x865a2d['error']['message']);}else{logger[_0xd7ce('0x2a')](_0xd7ce('0x28'),_0x1f803b,_0xd7ce('0x24'));_0x2d2163(_0x865a2d['result']['message']);}})[_0xd7ce('0x2b')](function(_0x36ba4b){logger[_0xd7ce('0x26')](_0xd7ce('0x28'),_0x1f803b,_0x36ba4b);_0x835e40(_0x36ba4b);});});}function respondWithStatusCode(_0x7b4d61,_0x4489e4){_0x4489e4=_0x4489e4||0xcc;return function(_0x73dad9){if(_0x73dad9){return _0x7b4d61['sendStatus'](_0x4489e4);}return _0x7b4d61['status'](_0x4489e4)[_0xd7ce('0x2c')]();};}function respondWithResult(_0x1cc3be,_0x1af756){_0x1af756=_0x1af756||0xc8;return function(_0x2d110f){if(_0x2d110f){return _0x1cc3be[_0xd7ce('0x2d')](_0x1af756)[_0xd7ce('0x2e')](_0x2d110f);}};}function respondWithFilteredResult(_0x1efae6,_0x2ba0ca){return function(_0x2b0027){if(_0x2b0027){var _0x4dbc5f=typeof _0x2ba0ca['offset']===_0xd7ce('0x2f')&&typeof _0x2ba0ca[_0xd7ce('0x30')]===_0xd7ce('0x2f');var _0x242ee3=_0x2b0027[_0xd7ce('0x31')];var _0x14eeb2=_0x4dbc5f?0x0:_0x2ba0ca[_0xd7ce('0x32')];var _0x4804ff=_0x4dbc5f?_0x2b0027[_0xd7ce('0x31')]:_0x2ba0ca[_0xd7ce('0x32')]+_0x2ba0ca[_0xd7ce('0x30')];var _0x48d578;if(_0x4804ff>=_0x242ee3){_0x4804ff=_0x242ee3;_0x48d578=0xc8;}else{_0x48d578=0xce;}_0x1efae6[_0xd7ce('0x2d')](_0x48d578);return _0x1efae6[_0xd7ce('0x33')](_0xd7ce('0x34'),_0x14eeb2+'-'+_0x4804ff+'/'+_0x242ee3)[_0xd7ce('0x2e')](_0x2b0027);}return null;};}function patchUpdates(_0x41a470){return function(_0x3586f1){try{jsonpatch[_0xd7ce('0x35')](_0x3586f1,_0x41a470,!![]);}catch(_0x480fdb){return BPromise[_0xd7ce('0x36')](_0x480fdb);}return _0x3586f1[_0xd7ce('0x37')]();};}function saveUpdates(_0x438d7e,_0x2e9114){return function(_0x37bfa2){if(_0x37bfa2){return _0x37bfa2[_0xd7ce('0x38')](_0x438d7e)['then'](function(_0xfdaf85){return _0xfdaf85;});}return null;};}function removeEntity(_0x1baf67,_0x9537ae){return function(_0x2c7ae0){if(_0x2c7ae0){return _0x2c7ae0[_0xd7ce('0x39')]()['then'](function(){var _0xf070ca=_0x2c7ae0['get']({'plain':!![]});var _0x17b8c6=_0xd7ce('0x3a');return db[_0xd7ce('0x3b')][_0xd7ce('0x39')]({'where':{'type':_0x17b8c6,'resourceId':_0xf070ca['id']}})[_0xd7ce('0x21')](function(){return _0x2c7ae0;});})['then'](function(){_0x1baf67['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x50f21b,_0x3b4091){return function(_0x1bfeb1){if(!_0x1bfeb1){_0x50f21b[_0xd7ce('0x3c')](0x194);}return _0x1bfeb1;};}function handleError(_0x1413d,_0x1fd932){_0x1fd932=_0x1fd932||0x1f4;return function(_0x5919fa){logger['error'](_0x5919fa[_0xd7ce('0x3d')]);if(_0x5919fa[_0xd7ce('0x3e')]){delete _0x5919fa[_0xd7ce('0x3e')];}_0x1413d['status'](_0x1fd932)['send'](_0x5919fa);};}exports[_0xd7ce('0x3f')]=function(_0xd294f2,_0x2a8c9e){var _0x11fc36={},_0x5d7cff={},_0x23d41b={'count':0x0,'rows':[]};var _0x5a61f3=_[_0xd7ce('0x40')](db[_0xd7ce('0x41')][_0xd7ce('0x42')],function(_0x587fae){return{'name':_0x587fae['fieldName'],'type':_0x587fae[_0xd7ce('0x43')][_0xd7ce('0x44')]};});_0x5d7cff[_0xd7ce('0x45')]=_[_0xd7ce('0x40')](_0x5a61f3,_0xd7ce('0x3e'));_0x5d7cff['query']=_[_0xd7ce('0x46')](_0xd294f2[_0xd7ce('0x47')]);_0x5d7cff[_0xd7ce('0x48')]=_[_0xd7ce('0x49')](_0x5d7cff['model'],_0x5d7cff['query']);_0x11fc36['attributes']=_[_0xd7ce('0x49')](_0x5d7cff[_0xd7ce('0x45')],qs[_0xd7ce('0x4a')](_0xd294f2['query'][_0xd7ce('0x4a')]));_0x11fc36[_0xd7ce('0x4b')]=_0x11fc36['attributes']['length']?_0x11fc36[_0xd7ce('0x4b')]:_0x5d7cff[_0xd7ce('0x45')];if(!_0xd294f2[_0xd7ce('0x47')][_0xd7ce('0x4c')](_0xd7ce('0x4d'))){_0x11fc36[_0xd7ce('0x30')]=qs['limit'](_0xd294f2['query'][_0xd7ce('0x30')]);_0x11fc36['offset']=qs[_0xd7ce('0x32')](_0xd294f2[_0xd7ce('0x47')]['offset']);}_0x11fc36[_0xd7ce('0x4e')]=qs['sort'](_0xd294f2[_0xd7ce('0x47')][_0xd7ce('0x4f')]);_0x11fc36['where']=qs[_0xd7ce('0x48')](_[_0xd7ce('0x50')](_0xd294f2['query'],_0x5d7cff[_0xd7ce('0x48')]),_0x5a61f3);if(_0xd294f2['query'][_0xd7ce('0x51')]){_0x11fc36[_0xd7ce('0x52')]=_[_0xd7ce('0x53')](_0x11fc36['where'],{'$or':_[_0xd7ce('0x40')](_0x5a61f3,function(_0x558d6b){if(_0x558d6b[_0xd7ce('0x43')]!=='VIRTUAL'){var _0x5e30e9={};_0x5e30e9[_0x558d6b['name']]={'$like':'%'+_0xd294f2['query'][_0xd7ce('0x51')]+'%'};return _0x5e30e9;}})});}_0x11fc36=_[_0xd7ce('0x53')]({},_0x11fc36,_0xd294f2[_0xd7ce('0x54')]);var _0x50dbce={'where':_0x11fc36[_0xd7ce('0x52')]};return db[_0xd7ce('0x41')][_0xd7ce('0x31')](_0x50dbce)[_0xd7ce('0x21')](function(_0x211232){_0x23d41b['count']=_0x211232;if(_0xd294f2['query'][_0xd7ce('0x55')]){_0x11fc36[_0xd7ce('0x56')]=[{'all':!![]}];}return db[_0xd7ce('0x41')][_0xd7ce('0x57')](_0x11fc36);})['then'](function(_0x26f883){_0x23d41b[_0xd7ce('0x58')]=_0x26f883;return _0x23d41b;})[_0xd7ce('0x21')](respondWithFilteredResult(_0x2a8c9e,_0x11fc36))[_0xd7ce('0x2b')](handleError(_0x2a8c9e,null));};exports[_0xd7ce('0x59')]=function(_0x14fdc7,_0x405b31){var _0x437599={'raw':![],'where':{'id':_0x14fdc7[_0xd7ce('0x5a')]['id']}},_0x1b6f1e={};_0x1b6f1e['model']=_[_0xd7ce('0x46')](db['VoiceContext'][_0xd7ce('0x42')]);_0x1b6f1e[_0xd7ce('0x47')]=_['keys'](_0x14fdc7['query']);_0x1b6f1e[_0xd7ce('0x48')]=_['intersection'](_0x1b6f1e[_0xd7ce('0x45')],_0x1b6f1e[_0xd7ce('0x47')]);_0x437599[_0xd7ce('0x4b')]=_[_0xd7ce('0x49')](_0x1b6f1e[_0xd7ce('0x45')],qs[_0xd7ce('0x4a')](_0x14fdc7[_0xd7ce('0x47')][_0xd7ce('0x4a')]));_0x437599['attributes']=_0x437599[_0xd7ce('0x4b')][_0xd7ce('0x5b')]?_0x437599['attributes']:_0x1b6f1e[_0xd7ce('0x45')];if(_0x14fdc7[_0xd7ce('0x47')][_0xd7ce('0x55')]){_0x437599['include']=[{'all':!![]}];}_0x437599=_['merge']({},_0x437599,_0x14fdc7[_0xd7ce('0x54')]);return db['VoiceContext']['find'](_0x437599)['then'](handleEntityNotFound(_0x405b31,null))[_0xd7ce('0x21')](respondWithResult(_0x405b31,null))[_0xd7ce('0x2b')](handleError(_0x405b31,null));};exports[_0xd7ce('0x5c')]=function(_0x9f4c83,_0x59d59d,_0x4d1f77){var _0x44b564;return db['VoiceContext']['create'](_0x9f4c83[_0xd7ce('0x5d')],{'raw':!![]})[_0xd7ce('0x21')](function(_0x43eab3){_0x44b564=_0x43eab3;return db['VoiceContext'][_0xd7ce('0x57')]({'raw':!![]});})[_0xd7ce('0x21')](function(_0x2669bd){var _0x401dea=fs[_0xd7ce('0x5e')](path[_0xd7ce('0x5f')](config[_0xd7ce('0x60')],'server/files/templates/context.ejs'),'utf8');var _0x2ffd74=ejs['render'](_0x401dea,{'contexts':_0x2669bd||[]});fs[_0xd7ce('0x61')](_0xd7ce('0x62'),_0x2ffd74);})[_0xd7ce('0x21')](function(){return respondWithRpcPromise('Reload',_0xd7ce('0x5c'),{'module':_0xd7ce('0x63')});})[_0xd7ce('0x21')](function(){var _0x159396=_0x9f4c83[_0xd7ce('0x64')][_0xd7ce('0x65')]({'plain':!![]});if(!_0x159396)throw new Error(_0xd7ce('0x66'));if(_0x159396[_0xd7ce('0x67')]==='user'){var _0x41f2a0=_0x44b564['get']({'plain':!![]});return db[_0xd7ce('0x68')][_0xd7ce('0x69')]({'where':{'name':_0xd7ce('0x3a'),'userProfileId':_0x159396[_0xd7ce('0x6a')]},'raw':!![]})[_0xd7ce('0x21')](function(_0x59f7d2){if(_0x59f7d2&&_0x59f7d2[_0xd7ce('0x6b')]===0x0){return db[_0xd7ce('0x3b')][_0xd7ce('0x5c')]({'name':_0x41f2a0[_0xd7ce('0x3e')],'resourceId':_0x41f2a0['id'],'type':_0x59f7d2['name'],'sectionId':_0x59f7d2['id']},{})[_0xd7ce('0x21')](function(){return _0x44b564;});}else{return _0x44b564;}})[_0xd7ce('0x2b')](function(_0x376e1b){logger[_0xd7ce('0x26')](_0xd7ce('0x6c'),_0x376e1b);throw _0x376e1b;});}return _0x44b564;})[_0xd7ce('0x21')](respondWithResult(_0x59d59d,0xc9))[_0xd7ce('0x2b')](handleError(_0x59d59d,null));};exports[_0xd7ce('0x38')]=function(_0x1d5d44,_0x27f810,_0x483890){var _0x1cc034;return db[_0xd7ce('0x41')][_0xd7ce('0x69')]({'where':{'id':_0x1d5d44[_0xd7ce('0x5a')]['id']}})[_0xd7ce('0x21')](handleEntityNotFound(_0x27f810,null))[_0xd7ce('0x21')](saveUpdates(_0x1d5d44[_0xd7ce('0x5d')],null))['then'](function(_0x262fe7){if(_0x262fe7){_0x1cc034=_0x262fe7;return db[_0xd7ce('0x41')][_0xd7ce('0x57')]({'raw':!![]});}})[_0xd7ce('0x21')](function(_0x4ef544){var _0x5d7c7c=fs['readFileSync'](path['join'](config[_0xd7ce('0x60')],_0xd7ce('0x6d')),_0xd7ce('0x6e'));var _0x2c7b2e=ejs[_0xd7ce('0x6f')](_0x5d7c7c,{'contexts':_0x4ef544||[]});fs[_0xd7ce('0x61')]('/etc/asterisk/extensions_xcally_contexts.conf',_0x2c7b2e);})[_0xd7ce('0x21')](function(){return respondWithRpcPromise(_0xd7ce('0x70'),'update',{'module':'chan_sip.so'});})[_0xd7ce('0x21')](function(){return _0x1cc034;})[_0xd7ce('0x21')](respondWithResult(_0x27f810,null))[_0xd7ce('0x2b')](handleError(_0x27f810,null));};exports[_0xd7ce('0x39')]=function(_0x1772c6,_0x12de70,_0x2c9455){var _0x56efd4;return db[_0xd7ce('0x41')][_0xd7ce('0x69')]({'where':{'id':_0x1772c6[_0xd7ce('0x5a')]['id']}})['then'](handleEntityNotFound(_0x12de70,null))[_0xd7ce('0x21')](removeEntity(_0x12de70,null))['then'](function(){return db[_0xd7ce('0x41')][_0xd7ce('0x57')]({'raw':!![]});})[_0xd7ce('0x21')](function(_0x35d6d7){var _0x3bc3c5=fs[_0xd7ce('0x5e')](path[_0xd7ce('0x5f')](config[_0xd7ce('0x60')],_0xd7ce('0x6d')),_0xd7ce('0x6e'));var _0x2a26c0=ejs['render'](_0x3bc3c5,{'contexts':_0x35d6d7});fs[_0xd7ce('0x61')](_0xd7ce('0x62'),_0x2a26c0);return respondWithRpcPromise(_0xd7ce('0x70'),_0xd7ce('0x39'),{'module':'chan_sip.so'});})[_0xd7ce('0x2b')](handleError(_0x12de70,null));};
\ No newline at end of file