Built motion from commit 97153652.|2.6.26
[motion2.git] / server / api / voiceContext / voiceContext.controller.js
index 959dfa0..c43151a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xff7b=['readFileSync','join','server/files/templates/context.ejs','render','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','chan_sip.so','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','root','Reload','update','utf8','eml-format','rimraf','fast-json-patch','request-promise','bluebird','mustache','ejs','fs-extra','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','client','http','request','then','info','request\x20sent','debug','VoiceContext,\x20%s,\x20%s,\x20%s','stringify','error','code','VoiceContext,\x20%s,\x20%s','message','catch','sendStatus','status','end','json','offset','undefined','count','set','Content-Range','apply','reject','save','get','Contexts','UserProfileResource','destroy','stack','name','index','map','VoiceContext','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','filter','VIRTUAL','merge','options','includeAll','include','findAll','rows','show','rawAttributes','find','create','body'];(function(_0x4dbaad,_0x730318){var _0x226c72=function(_0x501972){while(--_0x501972){_0x4dbaad['push'](_0x4dbaad['shift']());}};_0x226c72(++_0x730318);}(_0xff7b,0xe8));var _0xbff7=function(_0x3ab51d,_0x2fa01d){_0x3ab51d=_0x3ab51d-0x0;var _0x29a04e=_0xff7b[_0x3ab51d];return _0x29a04e;};'use strict';var emlformat=require(_0xbff7('0x0'));var rimraf=require(_0xbff7('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xbff7('0x2'));var rp=require(_0xbff7('0x3'));var moment=require('moment');var BPromise=require(_0xbff7('0x4'));var Mustache=require(_0xbff7('0x5'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xbff7('0x6'));var fs=require('fs');var fs_extra=require(_0xbff7('0x7'));var _=require('lodash');var squel=require(_0xbff7('0x8'));var crypto=require(_0xbff7('0x9'));var jsforce=require(_0xbff7('0xa'));var deskjs=require(_0xbff7('0xb'));var toCsv=require(_0xbff7('0xc'));var querystring=require(_0xbff7('0xd'));var Papa=require(_0xbff7('0xe'));var Redis=require(_0xbff7('0xf'));var authService=require(_0xbff7('0x10'));var qs=require(_0xbff7('0x11'));var as=require(_0xbff7('0x12'));var hardwareService=require(_0xbff7('0x13'));var logger=require(_0xbff7('0x14'))('api');var utils=require(_0xbff7('0x15'));var config=require(_0xbff7('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xbff7('0x17'))['db'];var jayson=require('jayson/promise');var client=jayson[_0xbff7('0x18')][_0xbff7('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x1fb68d,_0x376ee5,_0x5d27e9,_0x2df80b){return new BPromise(function(_0x531b96,_0x1d1145){var _0x4d2652=_0x2df80b||client;return _0x4d2652[_0xbff7('0x1a')](_0x1fb68d,_0x5d27e9)[_0xbff7('0x1b')](function(_0x4b8b9b){logger[_0xbff7('0x1c')]('VoiceContext,\x20%s,\x20%s',_0x376ee5,_0xbff7('0x1d'));logger[_0xbff7('0x1e')](_0xbff7('0x1f'),_0x376ee5,_0xbff7('0x1d'),JSON[_0xbff7('0x20')](_0x4b8b9b));if(_0x4b8b9b[_0xbff7('0x21')]){if(_0x4b8b9b[_0xbff7('0x21')][_0xbff7('0x22')]===0x1f4){logger[_0xbff7('0x21')](_0xbff7('0x23'),_0x376ee5,_0x4b8b9b[_0xbff7('0x21')][_0xbff7('0x24')]);return _0x1d1145(_0x4b8b9b[_0xbff7('0x21')][_0xbff7('0x24')]);}logger[_0xbff7('0x21')]('VoiceContext,\x20%s,\x20%s',_0x376ee5,_0x4b8b9b['error'][_0xbff7('0x24')]);return _0x531b96(_0x4b8b9b[_0xbff7('0x21')][_0xbff7('0x24')]);}else{logger[_0xbff7('0x1c')](_0xbff7('0x23'),_0x376ee5,'request\x20sent');_0x531b96(_0x4b8b9b['result'][_0xbff7('0x24')]);}})[_0xbff7('0x25')](function(_0x1726b0){logger[_0xbff7('0x21')](_0xbff7('0x23'),_0x376ee5,_0x1726b0);_0x1d1145(_0x1726b0);});});}function respondWithStatusCode(_0x4966f8,_0x5c58a4){_0x5c58a4=_0x5c58a4||0xcc;return function(_0x339eac){if(_0x339eac){return _0x4966f8[_0xbff7('0x26')](_0x5c58a4);}return _0x4966f8[_0xbff7('0x27')](_0x5c58a4)[_0xbff7('0x28')]();};}function respondWithResult(_0x3b1345,_0x556978){_0x556978=_0x556978||0xc8;return function(_0x3381f7){if(_0x3381f7){return _0x3b1345[_0xbff7('0x27')](_0x556978)[_0xbff7('0x29')](_0x3381f7);}};}function respondWithFilteredResult(_0x4ae781,_0x23966f){return function(_0x59595e){if(_0x59595e){var _0x2157d1=typeof _0x23966f[_0xbff7('0x2a')]===_0xbff7('0x2b')&&typeof _0x23966f['limit']===_0xbff7('0x2b');var _0x4a14dc=_0x59595e[_0xbff7('0x2c')];var _0x10e074=_0x2157d1?0x0:_0x23966f[_0xbff7('0x2a')];var _0x292851=_0x2157d1?_0x59595e[_0xbff7('0x2c')]:_0x23966f['offset']+_0x23966f['limit'];var _0x2874b8;if(_0x292851>=_0x4a14dc){_0x292851=_0x4a14dc;_0x2874b8=0xc8;}else{_0x2874b8=0xce;}_0x4ae781['status'](_0x2874b8);return _0x4ae781[_0xbff7('0x2d')](_0xbff7('0x2e'),_0x10e074+'-'+_0x292851+'/'+_0x4a14dc)['json'](_0x59595e);}return null;};}function patchUpdates(_0x52b845){return function(_0x512e94){try{jsonpatch[_0xbff7('0x2f')](_0x512e94,_0x52b845,!![]);}catch(_0x2b74c5){return BPromise[_0xbff7('0x30')](_0x2b74c5);}return _0x512e94[_0xbff7('0x31')]();};}function saveUpdates(_0x228961,_0xf71b07){return function(_0x386369){if(_0x386369){return _0x386369['update'](_0x228961)[_0xbff7('0x1b')](function(_0x3148e7){return _0x3148e7;});}return null;};}function removeEntity(_0x14d898,_0x4507a1){return function(_0x2418bb){if(_0x2418bb){return _0x2418bb['destroy']()[_0xbff7('0x1b')](function(){var _0x246805=_0x2418bb[_0xbff7('0x32')]({'plain':!![]});var _0x175ef5=_0xbff7('0x33');return db[_0xbff7('0x34')][_0xbff7('0x35')]({'where':{'type':_0x175ef5,'resourceId':_0x246805['id']}})[_0xbff7('0x1b')](function(){return _0x2418bb;});})[_0xbff7('0x1b')](function(){_0x14d898[_0xbff7('0x27')](0xcc)[_0xbff7('0x28')]();});}};}function handleEntityNotFound(_0x4331b9,_0x3396f3){return function(_0x53c466){if(!_0x53c466){_0x4331b9[_0xbff7('0x26')](0x194);}return _0x53c466;};}function handleError(_0x3f3c17,_0x44e0dd){_0x44e0dd=_0x44e0dd||0x1f4;return function(_0x38871a){logger['error'](_0x38871a[_0xbff7('0x36')]);if(_0x38871a[_0xbff7('0x37')]){delete _0x38871a[_0xbff7('0x37')];}_0x3f3c17[_0xbff7('0x27')](_0x44e0dd)['send'](_0x38871a);};}exports[_0xbff7('0x38')]=function(_0x546590,_0x2d84ad){var _0x1ddd8d={},_0x7da14d={},_0x398c6c={'count':0x0,'rows':[]};var _0x5808fa=_[_0xbff7('0x39')](db[_0xbff7('0x3a')]['rawAttributes'],function(_0x303c51){return{'name':_0x303c51[_0xbff7('0x3b')],'type':_0x303c51[_0xbff7('0x3c')][_0xbff7('0x3d')]};});_0x7da14d[_0xbff7('0x3e')]=_['map'](_0x5808fa,_0xbff7('0x37'));_0x7da14d[_0xbff7('0x3f')]=_[_0xbff7('0x40')](_0x546590[_0xbff7('0x3f')]);_0x7da14d[_0xbff7('0x41')]=_[_0xbff7('0x42')](_0x7da14d[_0xbff7('0x3e')],_0x7da14d[_0xbff7('0x3f')]);_0x1ddd8d[_0xbff7('0x43')]=_[_0xbff7('0x42')](_0x7da14d['model'],qs[_0xbff7('0x44')](_0x546590[_0xbff7('0x3f')]['fields']));_0x1ddd8d[_0xbff7('0x43')]=_0x1ddd8d[_0xbff7('0x43')][_0xbff7('0x45')]?_0x1ddd8d[_0xbff7('0x43')]:_0x7da14d['model'];if(!_0x546590[_0xbff7('0x3f')][_0xbff7('0x46')](_0xbff7('0x47'))){_0x1ddd8d[_0xbff7('0x48')]=qs['limit'](_0x546590[_0xbff7('0x3f')][_0xbff7('0x48')]);_0x1ddd8d[_0xbff7('0x2a')]=qs[_0xbff7('0x2a')](_0x546590[_0xbff7('0x3f')][_0xbff7('0x2a')]);}_0x1ddd8d[_0xbff7('0x49')]=qs['sort'](_0x546590['query'][_0xbff7('0x4a')]);_0x1ddd8d[_0xbff7('0x4b')]=qs['filters'](_['pick'](_0x546590[_0xbff7('0x3f')],_0x7da14d[_0xbff7('0x41')]),_0x5808fa);if(_0x546590[_0xbff7('0x3f')][_0xbff7('0x4c')]){_0x1ddd8d[_0xbff7('0x4b')]=_['merge'](_0x1ddd8d[_0xbff7('0x4b')],{'$or':_[_0xbff7('0x39')](_0x5808fa,function(_0x27999f){if(_0x27999f['type']!==_0xbff7('0x4d')){var _0x3a5750={};_0x3a5750[_0x27999f['name']]={'$like':'%'+_0x546590[_0xbff7('0x3f')][_0xbff7('0x4c')]+'%'};return _0x3a5750;}})});}_0x1ddd8d=_[_0xbff7('0x4e')]({},_0x1ddd8d,_0x546590[_0xbff7('0x4f')]);var _0x2eb6ad={'where':_0x1ddd8d[_0xbff7('0x4b')]};return db[_0xbff7('0x3a')]['count'](_0x2eb6ad)['then'](function(_0x4eb54c){_0x398c6c[_0xbff7('0x2c')]=_0x4eb54c;if(_0x546590[_0xbff7('0x3f')][_0xbff7('0x50')]){_0x1ddd8d[_0xbff7('0x51')]=[{'all':!![]}];}return db[_0xbff7('0x3a')][_0xbff7('0x52')](_0x1ddd8d);})[_0xbff7('0x1b')](function(_0x36e228){_0x398c6c[_0xbff7('0x53')]=_0x36e228;return _0x398c6c;})['then'](respondWithFilteredResult(_0x2d84ad,_0x1ddd8d))[_0xbff7('0x25')](handleError(_0x2d84ad,null));};exports[_0xbff7('0x54')]=function(_0x24e3be,_0x53f84c){var _0x3a4967={'raw':![],'where':{'id':_0x24e3be['params']['id']}},_0x22fe00={};_0x22fe00['model']=_[_0xbff7('0x40')](db['VoiceContext'][_0xbff7('0x55')]);_0x22fe00[_0xbff7('0x3f')]=_['keys'](_0x24e3be[_0xbff7('0x3f')]);_0x22fe00['filters']=_['intersection'](_0x22fe00[_0xbff7('0x3e')],_0x22fe00[_0xbff7('0x3f')]);_0x3a4967[_0xbff7('0x43')]=_['intersection'](_0x22fe00[_0xbff7('0x3e')],qs[_0xbff7('0x44')](_0x24e3be[_0xbff7('0x3f')][_0xbff7('0x44')]));_0x3a4967[_0xbff7('0x43')]=_0x3a4967[_0xbff7('0x43')][_0xbff7('0x45')]?_0x3a4967[_0xbff7('0x43')]:_0x22fe00[_0xbff7('0x3e')];if(_0x24e3be[_0xbff7('0x3f')][_0xbff7('0x50')]){_0x3a4967[_0xbff7('0x51')]=[{'all':!![]}];}_0x3a4967=_[_0xbff7('0x4e')]({},_0x3a4967,_0x24e3be[_0xbff7('0x4f')]);return db[_0xbff7('0x3a')][_0xbff7('0x56')](_0x3a4967)[_0xbff7('0x1b')](handleEntityNotFound(_0x53f84c,null))[_0xbff7('0x1b')](respondWithResult(_0x53f84c,null))[_0xbff7('0x25')](handleError(_0x53f84c,null));};exports[_0xbff7('0x57')]=function(_0x318bf9,_0x5c5fef,_0x5a8733){var _0x320054;return db[_0xbff7('0x3a')][_0xbff7('0x57')](_0x318bf9[_0xbff7('0x58')],{'raw':!![]})['then'](function(_0x58ee65){_0x320054=_0x58ee65;return db[_0xbff7('0x3a')][_0xbff7('0x52')]({'raw':!![]});})[_0xbff7('0x1b')](function(_0x4ea16a){var _0xac1be0=fs[_0xbff7('0x59')](path[_0xbff7('0x5a')](config['root'],_0xbff7('0x5b')),'utf8');var _0x157997=ejs[_0xbff7('0x5c')](_0xac1be0,{'contexts':_0x4ea16a||[]});fs[_0xbff7('0x5d')](_0xbff7('0x5e'),_0x157997);})[_0xbff7('0x1b')](function(){return respondWithRpcPromise('Reload',_0xbff7('0x57'),{'module':_0xbff7('0x5f')});})[_0xbff7('0x1b')](function(){var _0x2d515f=_0x318bf9[_0xbff7('0x60')][_0xbff7('0x32')]({'plain':!![]});if(!_0x2d515f)throw new Error(_0xbff7('0x61'));if(_0x2d515f[_0xbff7('0x62')]==='user'){var _0x1a706f=_0x320054['get']({'plain':!![]});return db[_0xbff7('0x63')][_0xbff7('0x56')]({'where':{'name':_0xbff7('0x33'),'userProfileId':_0x2d515f['userProfileId']},'raw':!![]})[_0xbff7('0x1b')](function(_0x2cd0c5){if(_0x2cd0c5&&_0x2cd0c5[_0xbff7('0x64')]===0x0){return db['UserProfileResource']['create']({'name':_0x1a706f['name'],'resourceId':_0x1a706f['id'],'type':_0x2cd0c5[_0xbff7('0x37')],'sectionId':_0x2cd0c5['id']},{})[_0xbff7('0x1b')](function(){return _0x320054;});}else{return _0x320054;}})['catch'](function(_0x225016){logger[_0xbff7('0x21')](_0xbff7('0x65'),_0x225016);throw _0x225016;});}return _0x320054;})[_0xbff7('0x1b')](respondWithResult(_0x5c5fef,0xc9))['catch'](handleError(_0x5c5fef,null));};exports['update']=function(_0x12ca1d,_0x530fc6,_0x146c01){var _0x105d12;return db[_0xbff7('0x3a')][_0xbff7('0x56')]({'where':{'id':_0x12ca1d[_0xbff7('0x66')]['id']}})[_0xbff7('0x1b')](handleEntityNotFound(_0x530fc6,null))[_0xbff7('0x1b')](saveUpdates(_0x12ca1d[_0xbff7('0x58')],null))['then'](function(_0x18136c){if(_0x18136c){_0x105d12=_0x18136c;return db[_0xbff7('0x3a')]['findAll']({'raw':!![]});}})[_0xbff7('0x1b')](function(_0x3e2134){var _0x2d9262=fs[_0xbff7('0x59')](path['join'](config[_0xbff7('0x67')],'server/files/templates/context.ejs'),'utf8');var _0x3e196a=ejs[_0xbff7('0x5c')](_0x2d9262,{'contexts':_0x3e2134||[]});fs[_0xbff7('0x5d')](_0xbff7('0x5e'),_0x3e196a);})[_0xbff7('0x1b')](function(){return respondWithRpcPromise(_0xbff7('0x68'),_0xbff7('0x69'),{'module':_0xbff7('0x5f')});})[_0xbff7('0x1b')](function(){return _0x105d12;})[_0xbff7('0x1b')](respondWithResult(_0x530fc6,null))[_0xbff7('0x25')](handleError(_0x530fc6,null));};exports[_0xbff7('0x35')]=function(_0x10bdb1,_0x159644,_0x104a91){var _0x7c95;return db[_0xbff7('0x3a')][_0xbff7('0x56')]({'where':{'id':_0x10bdb1['params']['id']}})[_0xbff7('0x1b')](handleEntityNotFound(_0x159644,null))[_0xbff7('0x1b')](removeEntity(_0x159644,null))['then'](function(){return db[_0xbff7('0x3a')][_0xbff7('0x52')]({'raw':!![]});})[_0xbff7('0x1b')](function(_0x1c6911){var _0x107c88=fs['readFileSync'](path['join'](config[_0xbff7('0x67')],'server/files/templates/context.ejs'),_0xbff7('0x6a'));var _0x396de9=ejs[_0xbff7('0x5c')](_0x107c88,{'contexts':_0x1c6911});fs['writeFileSync']('/etc/asterisk/extensions_xcally_contexts.conf',_0x396de9);return respondWithRpcPromise(_0xbff7('0x68'),_0xbff7('0x35'),{'module':_0xbff7('0x5f')});})['catch'](handleError(_0x159644,null));};
\ No newline at end of file
+var _0x8781=['length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','findAll','params','find','create','body','root','server/files/templates/context.ejs','render','writeFileSync','Reload','chan_sip.so','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','Contexts','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','join','utf8','readFileSync','eml-format','rimraf','zip-dir','request-promise','moment','mustache','util','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../mysqldb','jayson/promise','client','request','then','VoiceContext,\x20%s,\x20%s','debug','VoiceContext,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','sendStatus','status','json','offset','undefined','count','limit','set','apply','reject','save','update','destroy','get','UserProfileResource','end','stack','name','send','index','VoiceContext','rawAttributes','fieldName','type','map','query','keys','filters','intersection','model','attributes'];(function(_0x38537f,_0x252124){var _0x141e23=function(_0x2809b5){while(--_0x2809b5){_0x38537f['push'](_0x38537f['shift']());}};_0x141e23(++_0x252124);}(_0x8781,0x155));var _0x1878=function(_0x138ca5,_0x44b657){_0x138ca5=_0x138ca5-0x0;var _0x43cac7=_0x8781[_0x138ca5];return _0x43cac7;};'use strict';var emlformat=require(_0x1878('0x0'));var rimraf=require(_0x1878('0x1'));var zipdir=require(_0x1878('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x1878('0x3'));var moment=require(_0x1878('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x1878('0x5'));var util=require(_0x1878('0x6'));var path=require('path');var sox=require(_0x1878('0x7'));var csv=require(_0x1878('0x8'));var ejs=require(_0x1878('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x1878('0xa'));var squel=require(_0x1878('0xb'));var crypto=require(_0x1878('0xc'));var jsforce=require(_0x1878('0xd'));var deskjs=require(_0x1878('0xe'));var toCsv=require(_0x1878('0x8'));var querystring=require(_0x1878('0xf'));var Papa=require(_0x1878('0x10'));var Redis=require(_0x1878('0x11'));var authService=require(_0x1878('0x12'));var qs=require(_0x1878('0x13'));var as=require(_0x1878('0x14'));var hardwareService=require(_0x1878('0x15'));var logger=require('../../config/logger')(_0x1878('0x16'));var utils=require('../../config/utils');var config=require(_0x1878('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0x1878('0x18'))['db'];var jayson=require(_0x1878('0x19'));var client=jayson[_0x1878('0x1a')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2e14b1,_0x81febd,_0x64c3a1,_0x3fd37a){return new BPromise(function(_0x4342ef,_0x37128a){var _0xf4a9f5=_0x3fd37a||client;return _0xf4a9f5[_0x1878('0x1b')](_0x2e14b1,_0x64c3a1)[_0x1878('0x1c')](function(_0x5b60c2){logger['info'](_0x1878('0x1d'),_0x81febd,'request\x20sent');logger[_0x1878('0x1e')](_0x1878('0x1f'),_0x81febd,_0x1878('0x20'),JSON[_0x1878('0x21')](_0x5b60c2));if(_0x5b60c2[_0x1878('0x22')]){if(_0x5b60c2[_0x1878('0x22')][_0x1878('0x23')]===0x1f4){logger[_0x1878('0x22')]('VoiceContext,\x20%s,\x20%s',_0x81febd,_0x5b60c2['error']['message']);return _0x37128a(_0x5b60c2[_0x1878('0x22')][_0x1878('0x24')]);}logger['error'](_0x1878('0x1d'),_0x81febd,_0x5b60c2['error'][_0x1878('0x24')]);return _0x4342ef(_0x5b60c2[_0x1878('0x22')]['message']);}else{logger[_0x1878('0x25')](_0x1878('0x1d'),_0x81febd,'request\x20sent');_0x4342ef(_0x5b60c2[_0x1878('0x26')][_0x1878('0x24')]);}})[_0x1878('0x27')](function(_0x1c772e){logger[_0x1878('0x22')](_0x1878('0x1d'),_0x81febd,_0x1c772e);_0x37128a(_0x1c772e);});});}function respondWithStatusCode(_0x55e7c7,_0x3c429e){_0x3c429e=_0x3c429e||0xcc;return function(_0x28cae0){if(_0x28cae0){return _0x55e7c7[_0x1878('0x28')](_0x3c429e);}return _0x55e7c7[_0x1878('0x29')](_0x3c429e)['end']();};}function respondWithResult(_0x43b334,_0x3b290c){_0x3b290c=_0x3b290c||0xc8;return function(_0x435b4f){if(_0x435b4f){return _0x43b334['status'](_0x3b290c)[_0x1878('0x2a')](_0x435b4f);}};}function respondWithFilteredResult(_0x144218,_0x4c9eb2){return function(_0x41d350){if(_0x41d350){var _0x2ef9fc=typeof _0x4c9eb2[_0x1878('0x2b')]===_0x1878('0x2c')&&typeof _0x4c9eb2['limit']==='undefined';var _0x3387a2=_0x41d350[_0x1878('0x2d')];var _0x352242=_0x2ef9fc?0x0:_0x4c9eb2['offset'];var _0x3035d1=_0x2ef9fc?_0x41d350[_0x1878('0x2d')]:_0x4c9eb2[_0x1878('0x2b')]+_0x4c9eb2[_0x1878('0x2e')];var _0x5e656f;if(_0x3035d1>=_0x3387a2){_0x3035d1=_0x3387a2;_0x5e656f=0xc8;}else{_0x5e656f=0xce;}_0x144218[_0x1878('0x29')](_0x5e656f);return _0x144218[_0x1878('0x2f')]('Content-Range',_0x352242+'-'+_0x3035d1+'/'+_0x3387a2)['json'](_0x41d350);}return null;};}function patchUpdates(_0x3c24b5){return function(_0x18de3f){try{jsonpatch[_0x1878('0x30')](_0x18de3f,_0x3c24b5,!![]);}catch(_0x5b8b6f){return BPromise[_0x1878('0x31')](_0x5b8b6f);}return _0x18de3f[_0x1878('0x32')]();};}function saveUpdates(_0x169fa8,_0x9f6053){return function(_0x4ef031){if(_0x4ef031){return _0x4ef031[_0x1878('0x33')](_0x169fa8)[_0x1878('0x1c')](function(_0x5de80a){return _0x5de80a;});}return null;};}function removeEntity(_0x5788f3,_0xabe0e5){return function(_0x5bddea){if(_0x5bddea){return _0x5bddea[_0x1878('0x34')]()[_0x1878('0x1c')](function(){var _0x1b58c1=_0x5bddea[_0x1878('0x35')]({'plain':!![]});var _0x28d6d4='Contexts';return db[_0x1878('0x36')][_0x1878('0x34')]({'where':{'type':_0x28d6d4,'resourceId':_0x1b58c1['id']}})[_0x1878('0x1c')](function(){return _0x5bddea;});})[_0x1878('0x1c')](function(){_0x5788f3[_0x1878('0x29')](0xcc)[_0x1878('0x37')]();});}};}function handleEntityNotFound(_0x55c682,_0x5f0365){return function(_0x53aac5){if(!_0x53aac5){_0x55c682[_0x1878('0x28')](0x194);}return _0x53aac5;};}function handleError(_0x25fe2a,_0x87cd3c){_0x87cd3c=_0x87cd3c||0x1f4;return function(_0x78ede5){logger[_0x1878('0x22')](_0x78ede5[_0x1878('0x38')]);if(_0x78ede5['name']){delete _0x78ede5[_0x1878('0x39')];}_0x25fe2a[_0x1878('0x29')](_0x87cd3c)[_0x1878('0x3a')](_0x78ede5);};}exports[_0x1878('0x3b')]=function(_0x2870ca,_0x497b6f){var _0x58def8={},_0x20dd93={},_0x4212fd={'count':0x0,'rows':[]};var _0x329fe4=_['map'](db[_0x1878('0x3c')][_0x1878('0x3d')],function(_0x6695df){return{'name':_0x6695df[_0x1878('0x3e')],'type':_0x6695df[_0x1878('0x3f')]['key']};});_0x20dd93['model']=_[_0x1878('0x40')](_0x329fe4,_0x1878('0x39'));_0x20dd93[_0x1878('0x41')]=_[_0x1878('0x42')](_0x2870ca['query']);_0x20dd93[_0x1878('0x43')]=_[_0x1878('0x44')](_0x20dd93[_0x1878('0x45')],_0x20dd93[_0x1878('0x41')]);_0x58def8[_0x1878('0x46')]=_[_0x1878('0x44')](_0x20dd93['model'],qs['fields'](_0x2870ca['query']['fields']));_0x58def8[_0x1878('0x46')]=_0x58def8[_0x1878('0x46')][_0x1878('0x47')]?_0x58def8[_0x1878('0x46')]:_0x20dd93[_0x1878('0x45')];if(!_0x2870ca[_0x1878('0x41')][_0x1878('0x48')](_0x1878('0x49'))){_0x58def8[_0x1878('0x2e')]=qs['limit'](_0x2870ca[_0x1878('0x41')][_0x1878('0x2e')]);_0x58def8[_0x1878('0x2b')]=qs['offset'](_0x2870ca[_0x1878('0x41')][_0x1878('0x2b')]);}_0x58def8['order']=qs[_0x1878('0x4a')](_0x2870ca[_0x1878('0x41')]['sort']);_0x58def8[_0x1878('0x4b')]=qs[_0x1878('0x43')](_[_0x1878('0x4c')](_0x2870ca['query'],_0x20dd93[_0x1878('0x43')]),_0x329fe4);if(_0x2870ca[_0x1878('0x41')][_0x1878('0x4d')]){_0x58def8[_0x1878('0x4b')]=_[_0x1878('0x4e')](_0x58def8[_0x1878('0x4b')],{'$or':_[_0x1878('0x40')](_0x329fe4,function(_0x253fa8){if(_0x253fa8['type']!==_0x1878('0x4f')){var _0x1cc2e5={};_0x1cc2e5[_0x253fa8['name']]={'$like':'%'+_0x2870ca[_0x1878('0x41')][_0x1878('0x4d')]+'%'};return _0x1cc2e5;}})});}_0x58def8=_['merge']({},_0x58def8,_0x2870ca[_0x1878('0x50')]);var _0x22b429={'where':_0x58def8[_0x1878('0x4b')]};return db['VoiceContext'][_0x1878('0x2d')](_0x22b429)[_0x1878('0x1c')](function(_0x4f236a){_0x4212fd[_0x1878('0x2d')]=_0x4f236a;if(_0x2870ca[_0x1878('0x41')][_0x1878('0x51')]){_0x58def8['include']=[{'all':!![]}];}return db[_0x1878('0x3c')][_0x1878('0x52')](_0x58def8);})[_0x1878('0x1c')](function(_0x28589f){_0x4212fd['rows']=_0x28589f;return _0x4212fd;})['then'](respondWithFilteredResult(_0x497b6f,_0x58def8))[_0x1878('0x27')](handleError(_0x497b6f,null));};exports['show']=function(_0x39df63,_0x543fb7){var _0x5815aa={'raw':![],'where':{'id':_0x39df63[_0x1878('0x53')]['id']}},_0x49942a={};_0x49942a[_0x1878('0x45')]=_[_0x1878('0x42')](db[_0x1878('0x3c')]['rawAttributes']);_0x49942a[_0x1878('0x41')]=_[_0x1878('0x42')](_0x39df63[_0x1878('0x41')]);_0x49942a[_0x1878('0x43')]=_[_0x1878('0x44')](_0x49942a[_0x1878('0x45')],_0x49942a[_0x1878('0x41')]);_0x5815aa[_0x1878('0x46')]=_['intersection'](_0x49942a[_0x1878('0x45')],qs['fields'](_0x39df63['query']['fields']));_0x5815aa[_0x1878('0x46')]=_0x5815aa[_0x1878('0x46')][_0x1878('0x47')]?_0x5815aa[_0x1878('0x46')]:_0x49942a[_0x1878('0x45')];if(_0x39df63['query'][_0x1878('0x51')]){_0x5815aa['include']=[{'all':!![]}];}_0x5815aa=_[_0x1878('0x4e')]({},_0x5815aa,_0x39df63[_0x1878('0x50')]);return db[_0x1878('0x3c')][_0x1878('0x54')](_0x5815aa)[_0x1878('0x1c')](handleEntityNotFound(_0x543fb7,null))[_0x1878('0x1c')](respondWithResult(_0x543fb7,null))[_0x1878('0x27')](handleError(_0x543fb7,null));};exports['create']=function(_0x566f72,_0x4f7dde,_0x218bcc){var _0x2a384d;return db[_0x1878('0x3c')][_0x1878('0x55')](_0x566f72[_0x1878('0x56')],{'raw':!![]})[_0x1878('0x1c')](function(_0x265c20){_0x2a384d=_0x265c20;return db[_0x1878('0x3c')][_0x1878('0x52')]({'raw':!![]});})[_0x1878('0x1c')](function(_0x3fbbfa){var _0x3af5a4=fs['readFileSync'](path['join'](config[_0x1878('0x57')],_0x1878('0x58')),'utf8');var _0x5559d9=ejs[_0x1878('0x59')](_0x3af5a4,{'contexts':_0x3fbbfa||[]});fs[_0x1878('0x5a')]('/etc/asterisk/extensions_xcally_contexts.conf',_0x5559d9);})[_0x1878('0x1c')](function(){return respondWithRpcPromise(_0x1878('0x5b'),_0x1878('0x55'),{'module':_0x1878('0x5c')});})[_0x1878('0x1c')](function(){var _0x5e877c=_0x566f72[_0x1878('0x5d')][_0x1878('0x35')]({'plain':!![]});if(!_0x5e877c)throw new Error(_0x1878('0x5e'));if(_0x5e877c['role']===_0x1878('0x5d')){var _0x3a662a=_0x2a384d[_0x1878('0x35')]({'plain':!![]});return db[_0x1878('0x5f')][_0x1878('0x54')]({'where':{'name':_0x1878('0x60'),'userProfileId':_0x5e877c[_0x1878('0x61')]},'raw':!![]})[_0x1878('0x1c')](function(_0x11a5f0){if(_0x11a5f0&&_0x11a5f0[_0x1878('0x62')]===0x0){return db[_0x1878('0x36')][_0x1878('0x55')]({'name':_0x3a662a[_0x1878('0x39')],'resourceId':_0x3a662a['id'],'type':_0x11a5f0[_0x1878('0x39')],'sectionId':_0x11a5f0['id']},{})['then'](function(){return _0x2a384d;});}else{return _0x2a384d;}})['catch'](function(_0x13c1ff){logger[_0x1878('0x22')](_0x1878('0x63'),_0x13c1ff);throw _0x13c1ff;});}return _0x2a384d;})[_0x1878('0x1c')](respondWithResult(_0x4f7dde,0xc9))[_0x1878('0x27')](handleError(_0x4f7dde,null));};exports[_0x1878('0x33')]=function(_0x1c7e18,_0xf83ee7,_0x3b739c){var _0x3e585a;return db[_0x1878('0x3c')]['find']({'where':{'id':_0x1c7e18[_0x1878('0x53')]['id']}})[_0x1878('0x1c')](handleEntityNotFound(_0xf83ee7,null))[_0x1878('0x1c')](saveUpdates(_0x1c7e18[_0x1878('0x56')],null))[_0x1878('0x1c')](function(_0x398e3f){if(_0x398e3f){_0x3e585a=_0x398e3f;return db[_0x1878('0x3c')]['findAll']({'raw':!![]});}})[_0x1878('0x1c')](function(_0x28e10f){var _0x476aaa=fs['readFileSync'](path[_0x1878('0x64')](config[_0x1878('0x57')],_0x1878('0x58')),_0x1878('0x65'));var _0x328ab9=ejs['render'](_0x476aaa,{'contexts':_0x28e10f||[]});fs['writeFileSync']('/etc/asterisk/extensions_xcally_contexts.conf',_0x328ab9);})[_0x1878('0x1c')](function(){return respondWithRpcPromise('Reload',_0x1878('0x33'),{'module':'chan_sip.so'});})['then'](function(){return _0x3e585a;})[_0x1878('0x1c')](respondWithResult(_0xf83ee7,null))[_0x1878('0x27')](handleError(_0xf83ee7,null));};exports['destroy']=function(_0x4595f5,_0x2be4f2,_0x30eece){var _0x29fe56;return db[_0x1878('0x3c')][_0x1878('0x54')]({'where':{'id':_0x4595f5[_0x1878('0x53')]['id']}})[_0x1878('0x1c')](handleEntityNotFound(_0x2be4f2,null))[_0x1878('0x1c')](removeEntity(_0x2be4f2,null))['then'](function(){return db[_0x1878('0x3c')][_0x1878('0x52')]({'raw':!![]});})[_0x1878('0x1c')](function(_0x5ee230){var _0x24687d=fs[_0x1878('0x66')](path[_0x1878('0x64')](config[_0x1878('0x57')],_0x1878('0x58')),'utf8');var _0x46ab6c=ejs['render'](_0x24687d,{'contexts':_0x5ee230});fs[_0x1878('0x5a')]('/etc/asterisk/extensions_xcally_contexts.conf',_0x46ab6c);return respondWithRpcPromise(_0x1878('0x5b'),_0x1878('0x34'),{'module':_0x1878('0x5c')});})[_0x1878('0x27')](handleError(_0x2be4f2,null));};
\ No newline at end of file