Built motion from commit 013e4bb4.|2.6.18
[motion2.git] / server / api / voiceContext / voiceContext.controller.js
index 227b1d1..78afecb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x340f=['userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','server/files/templates/context.ejs','chan_sip.so','eml-format','zip-dir','fast-json-patch','bluebird','util','path','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../mysqldb','jayson/promise','client','http','request','then','info','request\x20sent','debug','VoiceContext,\x20%s,\x20%s,\x20%s','stringify','code','error','message','VoiceContext,\x20%s,\x20%s','result','catch','status','end','json','offset','undefined','limit','count','apply','update','destroy','get','Contexts','UserProfileResource','stack','name','index','map','VoiceContext','rawAttributes','fieldName','type','key','model','query','keys','attributes','intersection','fields','sort','where','filters','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','params','length','find','create','body','readFileSync','join','root','utf8','render','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','Reload','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection'];(function(_0x5aee6a,_0x1efc01){var _0x978673=function(_0xc63ff4){while(--_0xc63ff4){_0x5aee6a['push'](_0x5aee6a['shift']());}};_0x978673(++_0x1efc01);}(_0x340f,0x1ef));var _0xf340=function(_0x3138de,_0x24e89c){_0x3138de=_0x3138de-0x0;var _0x3f7256=_0x340f[_0x3138de];return _0x3f7256;};'use strict';var emlformat=require(_0xf340('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xf340('0x1'));var jsonpatch=require(_0xf340('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xf340('0x3'));var Mustache=require('mustache');var util=require(_0xf340('0x4'));var path=require(_0xf340('0x5'));var sox=require('sox');var csv=require(_0xf340('0x6'));var ejs=require(_0xf340('0x7'));var fs=require('fs');var fs_extra=require(_0xf340('0x8'));var _=require('lodash');var squel=require(_0xf340('0x9'));var crypto=require(_0xf340('0xa'));var jsforce=require(_0xf340('0xb'));var deskjs=require(_0xf340('0xc'));var toCsv=require(_0xf340('0x6'));var querystring=require(_0xf340('0xd'));var Papa=require(_0xf340('0xe'));var Redis=require(_0xf340('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xf340('0x10'));var as=require(_0xf340('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf340('0x12'))('api');var utils=require(_0xf340('0x13'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xf340('0x14'))['db'];var jayson=require(_0xf340('0x15'));var client=jayson[_0xf340('0x16')][_0xf340('0x17')]({'port':0x232a});function respondWithRpcPromise(_0x9e1d60,_0x2510c2,_0xe76d42,_0x39ff88){return new BPromise(function(_0x50f09b,_0x44f1b9){var _0x3a2023=_0x39ff88||client;return _0x3a2023[_0xf340('0x18')](_0x9e1d60,_0xe76d42)[_0xf340('0x19')](function(_0x4b0737){logger[_0xf340('0x1a')]('VoiceContext,\x20%s,\x20%s',_0x2510c2,_0xf340('0x1b'));logger[_0xf340('0x1c')](_0xf340('0x1d'),_0x2510c2,_0xf340('0x1b'),JSON[_0xf340('0x1e')](_0x4b0737));if(_0x4b0737['error']){if(_0x4b0737['error'][_0xf340('0x1f')]===0x1f4){logger[_0xf340('0x20')]('VoiceContext,\x20%s,\x20%s',_0x2510c2,_0x4b0737['error'][_0xf340('0x21')]);return _0x44f1b9(_0x4b0737[_0xf340('0x20')]['message']);}logger[_0xf340('0x20')](_0xf340('0x22'),_0x2510c2,_0x4b0737[_0xf340('0x20')]['message']);return _0x50f09b(_0x4b0737[_0xf340('0x20')][_0xf340('0x21')]);}else{logger[_0xf340('0x1a')](_0xf340('0x22'),_0x2510c2,_0xf340('0x1b'));_0x50f09b(_0x4b0737[_0xf340('0x23')]['message']);}})[_0xf340('0x24')](function(_0x172ddb){logger[_0xf340('0x20')](_0xf340('0x22'),_0x2510c2,_0x172ddb);_0x44f1b9(_0x172ddb);});});}function respondWithStatusCode(_0x1f335a,_0x500041){_0x500041=_0x500041||0xcc;return function(_0x45b16f){if(_0x45b16f){return _0x1f335a['sendStatus'](_0x500041);}return _0x1f335a[_0xf340('0x25')](_0x500041)[_0xf340('0x26')]();};}function respondWithResult(_0x44c279,_0x53beea){_0x53beea=_0x53beea||0xc8;return function(_0x43cafd){if(_0x43cafd){return _0x44c279[_0xf340('0x25')](_0x53beea)[_0xf340('0x27')](_0x43cafd);}};}function respondWithFilteredResult(_0x485caf,_0x5643bb){return function(_0x472014){if(_0x472014){var _0x19f787=typeof _0x5643bb[_0xf340('0x28')]===_0xf340('0x29')&&typeof _0x5643bb[_0xf340('0x2a')]===_0xf340('0x29');var _0x2a706f=_0x472014['count'];var _0x2f08c8=_0x19f787?0x0:_0x5643bb[_0xf340('0x28')];var _0x2e014b=_0x19f787?_0x472014[_0xf340('0x2b')]:_0x5643bb[_0xf340('0x28')]+_0x5643bb['limit'];var _0x2c5893;if(_0x2e014b>=_0x2a706f){_0x2e014b=_0x2a706f;_0x2c5893=0xc8;}else{_0x2c5893=0xce;}_0x485caf['status'](_0x2c5893);return _0x485caf['set']('Content-Range',_0x2f08c8+'-'+_0x2e014b+'/'+_0x2a706f)[_0xf340('0x27')](_0x472014);}return null;};}function patchUpdates(_0x3a2ac3){return function(_0x2b2779){try{jsonpatch[_0xf340('0x2c')](_0x2b2779,_0x3a2ac3,!![]);}catch(_0xc73d6b){return BPromise['reject'](_0xc73d6b);}return _0x2b2779['save']();};}function saveUpdates(_0x435f41,_0x58ade0){return function(_0x4ab354){if(_0x4ab354){return _0x4ab354[_0xf340('0x2d')](_0x435f41)['then'](function(_0x4b0756){return _0x4b0756;});}return null;};}function removeEntity(_0x1c10a5,_0x4871a3){return function(_0x569b92){if(_0x569b92){return _0x569b92[_0xf340('0x2e')]()[_0xf340('0x19')](function(){var _0x492da1=_0x569b92[_0xf340('0x2f')]({'plain':!![]});var _0x1a6932=_0xf340('0x30');return db[_0xf340('0x31')][_0xf340('0x2e')]({'where':{'type':_0x1a6932,'resourceId':_0x492da1['id']}})[_0xf340('0x19')](function(){return _0x569b92;});})[_0xf340('0x19')](function(){_0x1c10a5[_0xf340('0x25')](0xcc)[_0xf340('0x26')]();});}};}function handleEntityNotFound(_0x283697,_0x11f778){return function(_0x30c810){if(!_0x30c810){_0x283697['sendStatus'](0x194);}return _0x30c810;};}function handleError(_0x4c4c9f,_0x83cd12){_0x83cd12=_0x83cd12||0x1f4;return function(_0x29b8e9){logger['error'](_0x29b8e9[_0xf340('0x32')]);if(_0x29b8e9[_0xf340('0x33')]){delete _0x29b8e9[_0xf340('0x33')];}_0x4c4c9f[_0xf340('0x25')](_0x83cd12)['send'](_0x29b8e9);};}exports[_0xf340('0x34')]=function(_0x29a0de,_0x4d49d8){var _0x52c621={},_0x3eb8a1={},_0x48e097={'count':0x0,'rows':[]};var _0x41cebf=_[_0xf340('0x35')](db[_0xf340('0x36')][_0xf340('0x37')],function(_0x3b6f81){return{'name':_0x3b6f81[_0xf340('0x38')],'type':_0x3b6f81[_0xf340('0x39')][_0xf340('0x3a')]};});_0x3eb8a1[_0xf340('0x3b')]=_['map'](_0x41cebf,_0xf340('0x33'));_0x3eb8a1[_0xf340('0x3c')]=_[_0xf340('0x3d')](_0x29a0de[_0xf340('0x3c')]);_0x3eb8a1['filters']=_['intersection'](_0x3eb8a1[_0xf340('0x3b')],_0x3eb8a1['query']);_0x52c621[_0xf340('0x3e')]=_[_0xf340('0x3f')](_0x3eb8a1[_0xf340('0x3b')],qs[_0xf340('0x40')](_0x29a0de[_0xf340('0x3c')][_0xf340('0x40')]));_0x52c621[_0xf340('0x3e')]=_0x52c621[_0xf340('0x3e')]['length']?_0x52c621[_0xf340('0x3e')]:_0x3eb8a1[_0xf340('0x3b')];if(!_0x29a0de[_0xf340('0x3c')]['hasOwnProperty']('nolimit')){_0x52c621['limit']=qs[_0xf340('0x2a')](_0x29a0de[_0xf340('0x3c')][_0xf340('0x2a')]);_0x52c621['offset']=qs[_0xf340('0x28')](_0x29a0de[_0xf340('0x3c')][_0xf340('0x28')]);}_0x52c621['order']=qs[_0xf340('0x41')](_0x29a0de[_0xf340('0x3c')][_0xf340('0x41')]);_0x52c621[_0xf340('0x42')]=qs['filters'](_['pick'](_0x29a0de['query'],_0x3eb8a1[_0xf340('0x43')]),_0x41cebf);if(_0x29a0de['query'][_0xf340('0x44')]){_0x52c621[_0xf340('0x42')]=_[_0xf340('0x45')](_0x52c621[_0xf340('0x42')],{'$or':_[_0xf340('0x35')](_0x41cebf,function(_0x1a5b03){if(_0x1a5b03[_0xf340('0x39')]!==_0xf340('0x46')){var _0x159b00={};_0x159b00[_0x1a5b03[_0xf340('0x33')]]={'$like':'%'+_0x29a0de[_0xf340('0x3c')][_0xf340('0x44')]+'%'};return _0x159b00;}})});}_0x52c621=_[_0xf340('0x45')]({},_0x52c621,_0x29a0de[_0xf340('0x47')]);var _0x6dc672={'where':_0x52c621[_0xf340('0x42')]};return db[_0xf340('0x36')][_0xf340('0x2b')](_0x6dc672)[_0xf340('0x19')](function(_0x3a1c4c){_0x48e097[_0xf340('0x2b')]=_0x3a1c4c;if(_0x29a0de[_0xf340('0x3c')][_0xf340('0x48')]){_0x52c621[_0xf340('0x49')]=[{'all':!![]}];}return db['VoiceContext'][_0xf340('0x4a')](_0x52c621);})[_0xf340('0x19')](function(_0x5b717d){_0x48e097[_0xf340('0x4b')]=_0x5b717d;return _0x48e097;})[_0xf340('0x19')](respondWithFilteredResult(_0x4d49d8,_0x52c621))[_0xf340('0x24')](handleError(_0x4d49d8,null));};exports['show']=function(_0x431dbb,_0x2be6bf){var _0x13385e={'raw':![],'where':{'id':_0x431dbb[_0xf340('0x4c')]['id']}},_0x1145c4={};_0x1145c4[_0xf340('0x3b')]=_['keys'](db[_0xf340('0x36')]['rawAttributes']);_0x1145c4[_0xf340('0x3c')]=_[_0xf340('0x3d')](_0x431dbb[_0xf340('0x3c')]);_0x1145c4[_0xf340('0x43')]=_[_0xf340('0x3f')](_0x1145c4[_0xf340('0x3b')],_0x1145c4[_0xf340('0x3c')]);_0x13385e[_0xf340('0x3e')]=_['intersection'](_0x1145c4[_0xf340('0x3b')],qs[_0xf340('0x40')](_0x431dbb[_0xf340('0x3c')][_0xf340('0x40')]));_0x13385e[_0xf340('0x3e')]=_0x13385e['attributes'][_0xf340('0x4d')]?_0x13385e[_0xf340('0x3e')]:_0x1145c4[_0xf340('0x3b')];if(_0x431dbb[_0xf340('0x3c')][_0xf340('0x48')]){_0x13385e[_0xf340('0x49')]=[{'all':!![]}];}_0x13385e=_[_0xf340('0x45')]({},_0x13385e,_0x431dbb['options']);return db[_0xf340('0x36')][_0xf340('0x4e')](_0x13385e)[_0xf340('0x19')](handleEntityNotFound(_0x2be6bf,null))[_0xf340('0x19')](respondWithResult(_0x2be6bf,null))['catch'](handleError(_0x2be6bf,null));};exports[_0xf340('0x4f')]=function(_0x22473d,_0x383436,_0x9ad8be){var _0x5eed7b;return db['VoiceContext'][_0xf340('0x4f')](_0x22473d[_0xf340('0x50')],{'raw':!![]})[_0xf340('0x19')](function(_0x169314){_0x5eed7b=_0x169314;return db[_0xf340('0x36')][_0xf340('0x4a')]({'raw':!![]});})[_0xf340('0x19')](function(_0x58e38e){var _0x428191=fs[_0xf340('0x51')](path[_0xf340('0x52')](config[_0xf340('0x53')],'server/files/templates/context.ejs'),_0xf340('0x54'));var _0x209a21=ejs[_0xf340('0x55')](_0x428191,{'contexts':_0x58e38e||[]});fs[_0xf340('0x56')](_0xf340('0x57'),_0x209a21);})[_0xf340('0x19')](function(){return respondWithRpcPromise(_0xf340('0x58'),_0xf340('0x4f'),{'module':'chan_sip.so'});})['then'](function(){var _0x1fe940=_0x22473d[_0xf340('0x59')][_0xf340('0x2f')]({'plain':!![]});if(!_0x1fe940)throw new Error(_0xf340('0x5a'));if(_0x1fe940[_0xf340('0x5b')]===_0xf340('0x59')){var _0x522152=_0x5eed7b['get']({'plain':!![]});return db[_0xf340('0x5c')][_0xf340('0x4e')]({'where':{'name':_0xf340('0x30'),'userProfileId':_0x1fe940[_0xf340('0x5d')]},'raw':!![]})[_0xf340('0x19')](function(_0x1c318c){if(_0x1c318c&&_0x1c318c[_0xf340('0x5e')]===0x0){return db[_0xf340('0x31')][_0xf340('0x4f')]({'name':_0x522152[_0xf340('0x33')],'resourceId':_0x522152['id'],'type':_0x1c318c[_0xf340('0x33')],'sectionId':_0x1c318c['id']},{})[_0xf340('0x19')](function(){return _0x5eed7b;});}else{return _0x5eed7b;}})[_0xf340('0x24')](function(_0x265d37){logger[_0xf340('0x20')](_0xf340('0x5f'),_0x265d37);throw _0x265d37;});}return _0x5eed7b;})[_0xf340('0x19')](respondWithResult(_0x383436,0xc9))[_0xf340('0x24')](handleError(_0x383436,null));};exports['update']=function(_0x4b8da3,_0x2b5edd,_0x48748f){var _0x3591da;return db[_0xf340('0x36')]['find']({'where':{'id':_0x4b8da3['params']['id']}})['then'](handleEntityNotFound(_0x2b5edd,null))[_0xf340('0x19')](saveUpdates(_0x4b8da3['body'],null))['then'](function(_0x5095f0){if(_0x5095f0){_0x3591da=_0x5095f0;return db['VoiceContext']['findAll']({'raw':!![]});}})[_0xf340('0x19')](function(_0x32c85b){var _0x2e995c=fs[_0xf340('0x51')](path[_0xf340('0x52')](config[_0xf340('0x53')],_0xf340('0x60')),_0xf340('0x54'));var _0x16c7c6=ejs['render'](_0x2e995c,{'contexts':_0x32c85b||[]});fs[_0xf340('0x56')](_0xf340('0x57'),_0x16c7c6);})[_0xf340('0x19')](function(){return respondWithRpcPromise(_0xf340('0x58'),_0xf340('0x2d'),{'module':_0xf340('0x61')});})[_0xf340('0x19')](function(){return _0x3591da;})['then'](respondWithResult(_0x2b5edd,null))['catch'](handleError(_0x2b5edd,null));};exports[_0xf340('0x2e')]=function(_0x56554a,_0x4724d0,_0x55e4a3){var _0x24a44e;return db[_0xf340('0x36')][_0xf340('0x4e')]({'where':{'id':_0x56554a[_0xf340('0x4c')]['id']}})[_0xf340('0x19')](handleEntityNotFound(_0x4724d0,null))[_0xf340('0x19')](removeEntity(_0x4724d0,null))[_0xf340('0x19')](function(){return db[_0xf340('0x36')][_0xf340('0x4a')]({'raw':!![]});})[_0xf340('0x19')](function(_0x42426e){var _0x1467f0=fs[_0xf340('0x51')](path[_0xf340('0x52')](config[_0xf340('0x53')],'server/files/templates/context.ejs'),'utf8');var _0x26fcb2=ejs['render'](_0x1467f0,{'contexts':_0x42426e});fs[_0xf340('0x56')]('/etc/asterisk/extensions_xcally_contexts.conf',_0x26fcb2);return respondWithRpcPromise(_0xf340('0x58'),_0xf340('0x2e'),{'module':'chan_sip.so'});})['catch'](handleError(_0x4724d0,null));};
\ No newline at end of file
+var _0x5687=['fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','findAll','show','params','include','create','body','join','root','server/files/templates/context.ejs','utf8','render','writeFileSync','role','user','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','readFileSync','chan_sip.so','/etc/asterisk/extensions_xcally_contexts.conf','Reload','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','request','then','info','request\x20sent','debug','VoiceContext,\x20%s,\x20%s,\x20%s','error','code','message','catch','VoiceContext,\x20%s,\x20%s','sendStatus','status','end','json','undefined','limit','offset','count','set','apply','reject','save','update','destroy','get','Contexts','UserProfileResource','stack','send','map','VoiceContext','rawAttributes','fieldName','type','model','name','query','keys','filters','intersection','attributes'];(function(_0x3fae3a,_0x1508a6){var _0x45adb4=function(_0x367514){while(--_0x367514){_0x3fae3a['push'](_0x3fae3a['shift']());}};_0x45adb4(++_0x1508a6);}(_0x5687,0x155));var _0x7568=function(_0x3f7f66,_0x12a90c){_0x3f7f66=_0x3f7f66-0x0;var _0x4383d0=_0x5687[_0x3f7f66];return _0x4383d0;};'use strict';var emlformat=require(_0x7568('0x0'));var rimraf=require(_0x7568('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x7568('0x2'));var rp=require(_0x7568('0x3'));var moment=require(_0x7568('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x7568('0x5'));var util=require(_0x7568('0x6'));var path=require(_0x7568('0x7'));var sox=require(_0x7568('0x8'));var csv=require(_0x7568('0x9'));var ejs=require(_0x7568('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x7568('0xb'));var crypto=require(_0x7568('0xc'));var jsforce=require(_0x7568('0xd'));var deskjs=require(_0x7568('0xe'));var toCsv=require(_0x7568('0x9'));var querystring=require(_0x7568('0xf'));var Papa=require(_0x7568('0x10'));var Redis=require(_0x7568('0x11'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x7568('0x12'));var hardwareService=require(_0x7568('0x13'));var logger=require(_0x7568('0x14'))('api');var utils=require(_0x7568('0x15'));var config=require(_0x7568('0x16'));var licenseUtil=require(_0x7568('0x17'));var db=require(_0x7568('0x18'))['db'];var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x4acb24,_0x3fa529,_0x1acd4e,_0x4b3d48){return new BPromise(function(_0x48b266,_0x34445f){var _0x2ea730=_0x4b3d48||client;return _0x2ea730[_0x7568('0x19')](_0x4acb24,_0x1acd4e)[_0x7568('0x1a')](function(_0x2248e3){logger[_0x7568('0x1b')]('VoiceContext,\x20%s,\x20%s',_0x3fa529,_0x7568('0x1c'));logger[_0x7568('0x1d')](_0x7568('0x1e'),_0x3fa529,_0x7568('0x1c'),JSON['stringify'](_0x2248e3));if(_0x2248e3[_0x7568('0x1f')]){if(_0x2248e3[_0x7568('0x1f')][_0x7568('0x20')]===0x1f4){logger[_0x7568('0x1f')]('VoiceContext,\x20%s,\x20%s',_0x3fa529,_0x2248e3['error'][_0x7568('0x21')]);return _0x34445f(_0x2248e3[_0x7568('0x1f')][_0x7568('0x21')]);}logger['error']('VoiceContext,\x20%s,\x20%s',_0x3fa529,_0x2248e3[_0x7568('0x1f')][_0x7568('0x21')]);return _0x48b266(_0x2248e3[_0x7568('0x1f')][_0x7568('0x21')]);}else{logger[_0x7568('0x1b')]('VoiceContext,\x20%s,\x20%s',_0x3fa529,_0x7568('0x1c'));_0x48b266(_0x2248e3['result'][_0x7568('0x21')]);}})[_0x7568('0x22')](function(_0x1d7a4e){logger[_0x7568('0x1f')](_0x7568('0x23'),_0x3fa529,_0x1d7a4e);_0x34445f(_0x1d7a4e);});});}function respondWithStatusCode(_0x154aef,_0x4a0fcf){_0x4a0fcf=_0x4a0fcf||0xcc;return function(_0x5a7c91){if(_0x5a7c91){return _0x154aef[_0x7568('0x24')](_0x4a0fcf);}return _0x154aef[_0x7568('0x25')](_0x4a0fcf)[_0x7568('0x26')]();};}function respondWithResult(_0xa0c11d,_0x331330){_0x331330=_0x331330||0xc8;return function(_0x597866){if(_0x597866){return _0xa0c11d['status'](_0x331330)[_0x7568('0x27')](_0x597866);}};}function respondWithFilteredResult(_0x1bf151,_0x5c565d){return function(_0x259c2c){if(_0x259c2c){var _0x47fa45=typeof _0x5c565d['offset']===_0x7568('0x28')&&typeof _0x5c565d[_0x7568('0x29')]===_0x7568('0x28');var _0x215e4a=_0x259c2c['count'];var _0x520816=_0x47fa45?0x0:_0x5c565d[_0x7568('0x2a')];var _0x4a6fc7=_0x47fa45?_0x259c2c[_0x7568('0x2b')]:_0x5c565d[_0x7568('0x2a')]+_0x5c565d[_0x7568('0x29')];var _0x130c74;if(_0x4a6fc7>=_0x215e4a){_0x4a6fc7=_0x215e4a;_0x130c74=0xc8;}else{_0x130c74=0xce;}_0x1bf151['status'](_0x130c74);return _0x1bf151[_0x7568('0x2c')]('Content-Range',_0x520816+'-'+_0x4a6fc7+'/'+_0x215e4a)[_0x7568('0x27')](_0x259c2c);}return null;};}function patchUpdates(_0x11dbc8){return function(_0x1d7b70){try{jsonpatch[_0x7568('0x2d')](_0x1d7b70,_0x11dbc8,!![]);}catch(_0x2c037e){return BPromise[_0x7568('0x2e')](_0x2c037e);}return _0x1d7b70[_0x7568('0x2f')]();};}function saveUpdates(_0x149663,_0x3c77e6){return function(_0x260a06){if(_0x260a06){return _0x260a06[_0x7568('0x30')](_0x149663)[_0x7568('0x1a')](function(_0x1d9c0b){return _0x1d9c0b;});}return null;};}function removeEntity(_0x1862a0,_0xd34b5){return function(_0x5c70d0){if(_0x5c70d0){return _0x5c70d0[_0x7568('0x31')]()[_0x7568('0x1a')](function(){var _0xa809f9=_0x5c70d0[_0x7568('0x32')]({'plain':!![]});var _0x289e98=_0x7568('0x33');return db[_0x7568('0x34')][_0x7568('0x31')]({'where':{'type':_0x289e98,'resourceId':_0xa809f9['id']}})[_0x7568('0x1a')](function(){return _0x5c70d0;});})[_0x7568('0x1a')](function(){_0x1862a0['status'](0xcc)[_0x7568('0x26')]();});}};}function handleEntityNotFound(_0x2bfa73,_0x1211a9){return function(_0x1c9a0e){if(!_0x1c9a0e){_0x2bfa73['sendStatus'](0x194);}return _0x1c9a0e;};}function handleError(_0x3093ce,_0xc1bc7){_0xc1bc7=_0xc1bc7||0x1f4;return function(_0x24f46f){logger[_0x7568('0x1f')](_0x24f46f[_0x7568('0x35')]);if(_0x24f46f['name']){delete _0x24f46f['name'];}_0x3093ce['status'](_0xc1bc7)[_0x7568('0x36')](_0x24f46f);};}exports['index']=function(_0x13892b,_0x21f8c0){var _0x469b8f={},_0x58862e={},_0x33bdad={'count':0x0,'rows':[]};var _0x55a6bf=_[_0x7568('0x37')](db[_0x7568('0x38')][_0x7568('0x39')],function(_0x44f3a0){return{'name':_0x44f3a0[_0x7568('0x3a')],'type':_0x44f3a0[_0x7568('0x3b')]['key']};});_0x58862e[_0x7568('0x3c')]=_[_0x7568('0x37')](_0x55a6bf,_0x7568('0x3d'));_0x58862e[_0x7568('0x3e')]=_[_0x7568('0x3f')](_0x13892b[_0x7568('0x3e')]);_0x58862e[_0x7568('0x40')]=_[_0x7568('0x41')](_0x58862e[_0x7568('0x3c')],_0x58862e[_0x7568('0x3e')]);_0x469b8f[_0x7568('0x42')]=_[_0x7568('0x41')](_0x58862e[_0x7568('0x3c')],qs[_0x7568('0x43')](_0x13892b[_0x7568('0x3e')][_0x7568('0x43')]));_0x469b8f[_0x7568('0x42')]=_0x469b8f[_0x7568('0x42')][_0x7568('0x44')]?_0x469b8f[_0x7568('0x42')]:_0x58862e[_0x7568('0x3c')];if(!_0x13892b[_0x7568('0x3e')][_0x7568('0x45')](_0x7568('0x46'))){_0x469b8f['limit']=qs[_0x7568('0x29')](_0x13892b[_0x7568('0x3e')][_0x7568('0x29')]);_0x469b8f[_0x7568('0x2a')]=qs[_0x7568('0x2a')](_0x13892b[_0x7568('0x3e')]['offset']);}_0x469b8f[_0x7568('0x47')]=qs[_0x7568('0x48')](_0x13892b[_0x7568('0x3e')][_0x7568('0x48')]);_0x469b8f[_0x7568('0x49')]=qs[_0x7568('0x40')](_[_0x7568('0x4a')](_0x13892b[_0x7568('0x3e')],_0x58862e[_0x7568('0x40')]),_0x55a6bf);if(_0x13892b['query'][_0x7568('0x4b')]){_0x469b8f[_0x7568('0x49')]=_['merge'](_0x469b8f[_0x7568('0x49')],{'$or':_[_0x7568('0x37')](_0x55a6bf,function(_0x36cb0a){if(_0x36cb0a['type']!==_0x7568('0x4c')){var _0x43fc79={};_0x43fc79[_0x36cb0a[_0x7568('0x3d')]]={'$like':'%'+_0x13892b[_0x7568('0x3e')][_0x7568('0x4b')]+'%'};return _0x43fc79;}})});}_0x469b8f=_[_0x7568('0x4d')]({},_0x469b8f,_0x13892b[_0x7568('0x4e')]);var _0x5cfd34={'where':_0x469b8f[_0x7568('0x49')]};return db[_0x7568('0x38')][_0x7568('0x2b')](_0x5cfd34)[_0x7568('0x1a')](function(_0x4fdff7){_0x33bdad['count']=_0x4fdff7;if(_0x13892b[_0x7568('0x3e')][_0x7568('0x4f')]){_0x469b8f['include']=[{'all':!![]}];}return db[_0x7568('0x38')][_0x7568('0x50')](_0x469b8f);})[_0x7568('0x1a')](function(_0x10e5e2){_0x33bdad['rows']=_0x10e5e2;return _0x33bdad;})['then'](respondWithFilteredResult(_0x21f8c0,_0x469b8f))['catch'](handleError(_0x21f8c0,null));};exports[_0x7568('0x51')]=function(_0x4455da,_0x23129e){var _0x4e16d3={'raw':![],'where':{'id':_0x4455da[_0x7568('0x52')]['id']}},_0x424e85={};_0x424e85[_0x7568('0x3c')]=_['keys'](db[_0x7568('0x38')][_0x7568('0x39')]);_0x424e85['query']=_[_0x7568('0x3f')](_0x4455da['query']);_0x424e85['filters']=_[_0x7568('0x41')](_0x424e85['model'],_0x424e85[_0x7568('0x3e')]);_0x4e16d3[_0x7568('0x42')]=_[_0x7568('0x41')](_0x424e85[_0x7568('0x3c')],qs[_0x7568('0x43')](_0x4455da['query'][_0x7568('0x43')]));_0x4e16d3['attributes']=_0x4e16d3[_0x7568('0x42')][_0x7568('0x44')]?_0x4e16d3['attributes']:_0x424e85['model'];if(_0x4455da['query']['includeAll']){_0x4e16d3[_0x7568('0x53')]=[{'all':!![]}];}_0x4e16d3=_[_0x7568('0x4d')]({},_0x4e16d3,_0x4455da[_0x7568('0x4e')]);return db[_0x7568('0x38')]['find'](_0x4e16d3)[_0x7568('0x1a')](handleEntityNotFound(_0x23129e,null))[_0x7568('0x1a')](respondWithResult(_0x23129e,null))[_0x7568('0x22')](handleError(_0x23129e,null));};exports[_0x7568('0x54')]=function(_0x278fbf,_0x442d3f,_0x5d8069){var _0x4b71ca;return db[_0x7568('0x38')][_0x7568('0x54')](_0x278fbf[_0x7568('0x55')],{'raw':!![]})[_0x7568('0x1a')](function(_0x1be10a){_0x4b71ca=_0x1be10a;return db[_0x7568('0x38')]['findAll']({'raw':!![]});})['then'](function(_0x5c1762){var _0x56f5d5=fs['readFileSync'](path[_0x7568('0x56')](config[_0x7568('0x57')],_0x7568('0x58')),_0x7568('0x59'));var _0x31bcf9=ejs[_0x7568('0x5a')](_0x56f5d5,{'contexts':_0x5c1762||[]});fs[_0x7568('0x5b')]('/etc/asterisk/extensions_xcally_contexts.conf',_0x31bcf9);})[_0x7568('0x1a')](function(){return respondWithRpcPromise('Reload',_0x7568('0x54'),{'module':'chan_sip.so'});})['then'](function(){var _0x535538=_0x278fbf['user'][_0x7568('0x32')]({'plain':!![]});if(!_0x535538)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x535538[_0x7568('0x5c')]===_0x7568('0x5d')){var _0xf8fe7=_0x4b71ca[_0x7568('0x32')]({'plain':!![]});return db['UserProfileSection'][_0x7568('0x5e')]({'where':{'name':_0x7568('0x33'),'userProfileId':_0x535538[_0x7568('0x5f')]},'raw':!![]})[_0x7568('0x1a')](function(_0x7d7702){if(_0x7d7702&&_0x7d7702[_0x7568('0x60')]===0x0){return db['UserProfileResource'][_0x7568('0x54')]({'name':_0xf8fe7[_0x7568('0x3d')],'resourceId':_0xf8fe7['id'],'type':_0x7d7702['name'],'sectionId':_0x7d7702['id']},{})['then'](function(){return _0x4b71ca;});}else{return _0x4b71ca;}})['catch'](function(_0x294547){logger[_0x7568('0x1f')](_0x7568('0x61'),_0x294547);throw _0x294547;});}return _0x4b71ca;})['then'](respondWithResult(_0x442d3f,0xc9))[_0x7568('0x22')](handleError(_0x442d3f,null));};exports[_0x7568('0x30')]=function(_0x210120,_0x16e4d6,_0x26d63){var _0x16b185;return db[_0x7568('0x38')][_0x7568('0x5e')]({'where':{'id':_0x210120[_0x7568('0x52')]['id']}})['then'](handleEntityNotFound(_0x16e4d6,null))[_0x7568('0x1a')](saveUpdates(_0x210120[_0x7568('0x55')],null))[_0x7568('0x1a')](function(_0x181e38){if(_0x181e38){_0x16b185=_0x181e38;return db[_0x7568('0x38')][_0x7568('0x50')]({'raw':!![]});}})['then'](function(_0x1eea26){var _0x2124c4=fs[_0x7568('0x62')](path[_0x7568('0x56')](config[_0x7568('0x57')],_0x7568('0x58')),_0x7568('0x59'));var _0x3855b1=ejs[_0x7568('0x5a')](_0x2124c4,{'contexts':_0x1eea26||[]});fs[_0x7568('0x5b')]('/etc/asterisk/extensions_xcally_contexts.conf',_0x3855b1);})[_0x7568('0x1a')](function(){return respondWithRpcPromise('Reload',_0x7568('0x30'),{'module':_0x7568('0x63')});})[_0x7568('0x1a')](function(){return _0x16b185;})[_0x7568('0x1a')](respondWithResult(_0x16e4d6,null))[_0x7568('0x22')](handleError(_0x16e4d6,null));};exports[_0x7568('0x31')]=function(_0x1c50a6,_0x9cbd7a,_0x2db5e2){var _0x566bd2;return db['VoiceContext'][_0x7568('0x5e')]({'where':{'id':_0x1c50a6[_0x7568('0x52')]['id']}})[_0x7568('0x1a')](handleEntityNotFound(_0x9cbd7a,null))[_0x7568('0x1a')](removeEntity(_0x9cbd7a,null))[_0x7568('0x1a')](function(){return db['VoiceContext'][_0x7568('0x50')]({'raw':!![]});})[_0x7568('0x1a')](function(_0x1c56cd){var _0x4ace2d=fs[_0x7568('0x62')](path[_0x7568('0x56')](config['root'],_0x7568('0x58')),'utf8');var _0x31dd63=ejs['render'](_0x4ace2d,{'contexts':_0x1c56cd});fs[_0x7568('0x5b')](_0x7568('0x64'),_0x31dd63);return respondWithRpcPromise(_0x7568('0x65'),'destroy',{'module':_0x7568('0x63')});})[_0x7568('0x22')](handleError(_0x9cbd7a,null));};
\ No newline at end of file