Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / api / voiceContext / voiceContext.controller.js
index f22401c..e7e4d15 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbb48=['hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','includeAll','show','params','include','options','find','create','body','findAll','readFileSync','server/files/templates/context.ejs','utf8','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','join','render','Reload','eml-format','rimraf','request-promise','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','jayson/promise','client','http','request','info','VoiceContext,\x20%s,\x20%s','request\x20sent','debug','VoiceContext,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','then','destroy','get','Contexts','UserProfileResource','stack','name','send','index','VoiceContext','rawAttributes','fieldName','type','model','map','keys','query','filters','attributes','intersection','fields'];(function(_0x4e67df,_0x59308c){var _0x1a49a9=function(_0x396881){while(--_0x396881){_0x4e67df['push'](_0x4e67df['shift']());}};_0x1a49a9(++_0x59308c);}(_0xbb48,0x1bc));var _0x8bb4=function(_0x2c91e9,_0x2fb965){_0x2c91e9=_0x2c91e9-0x0;var _0x13f0ff=_0xbb48[_0x2c91e9];return _0x13f0ff;};'use strict';var emlformat=require(_0x8bb4('0x0'));var rimraf=require(_0x8bb4('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x8bb4('0x2'));var moment=require('moment');var BPromise=require(_0x8bb4('0x3'));var Mustache=require(_0x8bb4('0x4'));var util=require(_0x8bb4('0x5'));var path=require('path');var sox=require(_0x8bb4('0x6'));var csv=require(_0x8bb4('0x7'));var ejs=require(_0x8bb4('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x8bb4('0x9'));var squel=require(_0x8bb4('0xa'));var crypto=require(_0x8bb4('0xb'));var jsforce=require(_0x8bb4('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x8bb4('0xd'));var Papa=require(_0x8bb4('0xe'));var Redis=require(_0x8bb4('0xf'));var authService=require(_0x8bb4('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x8bb4('0x11'));var hardwareService=require(_0x8bb4('0x12'));var logger=require('../../config/logger')(_0x8bb4('0x13'));var utils=require(_0x8bb4('0x14'));var config=require(_0x8bb4('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0x8bb4('0x16'))['db'];var jayson=require(_0x8bb4('0x17'));var client=jayson[_0x8bb4('0x18')][_0x8bb4('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x515692,_0x4cff8e,_0x2e13d3,_0x4238ae){return new BPromise(function(_0x35bdd4,_0x2c777c){var _0x1b9f96=_0x4238ae||client;return _0x1b9f96[_0x8bb4('0x1a')](_0x515692,_0x2e13d3)['then'](function(_0x42f849){logger[_0x8bb4('0x1b')](_0x8bb4('0x1c'),_0x4cff8e,_0x8bb4('0x1d'));logger[_0x8bb4('0x1e')](_0x8bb4('0x1f'),_0x4cff8e,_0x8bb4('0x1d'),JSON[_0x8bb4('0x20')](_0x42f849));if(_0x42f849[_0x8bb4('0x21')]){if(_0x42f849[_0x8bb4('0x21')][_0x8bb4('0x22')]===0x1f4){logger['error'](_0x8bb4('0x1c'),_0x4cff8e,_0x42f849[_0x8bb4('0x21')][_0x8bb4('0x23')]);return _0x2c777c(_0x42f849[_0x8bb4('0x21')][_0x8bb4('0x23')]);}logger['error'](_0x8bb4('0x1c'),_0x4cff8e,_0x42f849['error'][_0x8bb4('0x23')]);return _0x35bdd4(_0x42f849[_0x8bb4('0x21')][_0x8bb4('0x23')]);}else{logger['info'](_0x8bb4('0x1c'),_0x4cff8e,_0x8bb4('0x1d'));_0x35bdd4(_0x42f849[_0x8bb4('0x24')][_0x8bb4('0x23')]);}})[_0x8bb4('0x25')](function(_0x22a0af){logger['error'](_0x8bb4('0x1c'),_0x4cff8e,_0x22a0af);_0x2c777c(_0x22a0af);});});}function respondWithStatusCode(_0x2ff997,_0xba3bbc){_0xba3bbc=_0xba3bbc||0xcc;return function(_0x2f487c){if(_0x2f487c){return _0x2ff997[_0x8bb4('0x26')](_0xba3bbc);}return _0x2ff997[_0x8bb4('0x27')](_0xba3bbc)[_0x8bb4('0x28')]();};}function respondWithResult(_0x402556,_0x5ef6cc){_0x5ef6cc=_0x5ef6cc||0xc8;return function(_0x2c0e4b){if(_0x2c0e4b){return _0x402556[_0x8bb4('0x27')](_0x5ef6cc)[_0x8bb4('0x29')](_0x2c0e4b);}};}function respondWithFilteredResult(_0x376c57,_0x31f0ee){return function(_0x4847fd){if(_0x4847fd){var _0x2a4782=typeof _0x31f0ee[_0x8bb4('0x2a')]===_0x8bb4('0x2b')&&typeof _0x31f0ee[_0x8bb4('0x2c')]===_0x8bb4('0x2b');var _0xb131af=_0x4847fd[_0x8bb4('0x2d')];var _0x56aa85=_0x2a4782?0x0:_0x31f0ee[_0x8bb4('0x2a')];var _0x587ef1=_0x2a4782?_0x4847fd['count']:_0x31f0ee[_0x8bb4('0x2a')]+_0x31f0ee[_0x8bb4('0x2c')];var _0x73a0ef;if(_0x587ef1>=_0xb131af){_0x587ef1=_0xb131af;_0x73a0ef=0xc8;}else{_0x73a0ef=0xce;}_0x376c57[_0x8bb4('0x27')](_0x73a0ef);return _0x376c57[_0x8bb4('0x2e')](_0x8bb4('0x2f'),_0x56aa85+'-'+_0x587ef1+'/'+_0xb131af)[_0x8bb4('0x29')](_0x4847fd);}return null;};}function patchUpdates(_0xe6a89f){return function(_0x510293){try{jsonpatch[_0x8bb4('0x30')](_0x510293,_0xe6a89f,!![]);}catch(_0xa83fc5){return BPromise[_0x8bb4('0x31')](_0xa83fc5);}return _0x510293['save']();};}function saveUpdates(_0x31ca9f,_0xd92a00){return function(_0x2ce606){if(_0x2ce606){return _0x2ce606['update'](_0x31ca9f)[_0x8bb4('0x32')](function(_0x2c0e3f){return _0x2c0e3f;});}return null;};}function removeEntity(_0x3fa8c5,_0xe0c685){return function(_0x340101){if(_0x340101){return _0x340101[_0x8bb4('0x33')]()[_0x8bb4('0x32')](function(){var _0x4c8551=_0x340101[_0x8bb4('0x34')]({'plain':!![]});var _0x276110=_0x8bb4('0x35');return db[_0x8bb4('0x36')]['destroy']({'where':{'type':_0x276110,'resourceId':_0x4c8551['id']}})[_0x8bb4('0x32')](function(){return _0x340101;});})[_0x8bb4('0x32')](function(){_0x3fa8c5['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x33e1e2,_0x3ab05d){return function(_0x1d3658){if(!_0x1d3658){_0x33e1e2[_0x8bb4('0x26')](0x194);}return _0x1d3658;};}function handleError(_0xdcee52,_0x54be3b){_0x54be3b=_0x54be3b||0x1f4;return function(_0x14db3c){logger[_0x8bb4('0x21')](_0x14db3c[_0x8bb4('0x37')]);if(_0x14db3c[_0x8bb4('0x38')]){delete _0x14db3c[_0x8bb4('0x38')];}_0xdcee52[_0x8bb4('0x27')](_0x54be3b)[_0x8bb4('0x39')](_0x14db3c);};}exports[_0x8bb4('0x3a')]=function(_0x1b51b1,_0x4208cb){var _0x42693a={},_0x42746a={},_0x29e2d7={'count':0x0,'rows':[]};var _0x165b7d=_['map'](db[_0x8bb4('0x3b')][_0x8bb4('0x3c')],function(_0x5755a6){return{'name':_0x5755a6[_0x8bb4('0x3d')],'type':_0x5755a6[_0x8bb4('0x3e')]['key']};});_0x42746a[_0x8bb4('0x3f')]=_[_0x8bb4('0x40')](_0x165b7d,_0x8bb4('0x38'));_0x42746a['query']=_[_0x8bb4('0x41')](_0x1b51b1[_0x8bb4('0x42')]);_0x42746a[_0x8bb4('0x43')]=_['intersection'](_0x42746a[_0x8bb4('0x3f')],_0x42746a[_0x8bb4('0x42')]);_0x42693a[_0x8bb4('0x44')]=_[_0x8bb4('0x45')](_0x42746a[_0x8bb4('0x3f')],qs['fields'](_0x1b51b1[_0x8bb4('0x42')][_0x8bb4('0x46')]));_0x42693a['attributes']=_0x42693a[_0x8bb4('0x44')]['length']?_0x42693a[_0x8bb4('0x44')]:_0x42746a[_0x8bb4('0x3f')];if(!_0x1b51b1[_0x8bb4('0x42')][_0x8bb4('0x47')](_0x8bb4('0x48'))){_0x42693a[_0x8bb4('0x2c')]=qs[_0x8bb4('0x2c')](_0x1b51b1[_0x8bb4('0x42')][_0x8bb4('0x2c')]);_0x42693a['offset']=qs[_0x8bb4('0x2a')](_0x1b51b1[_0x8bb4('0x42')]['offset']);}_0x42693a[_0x8bb4('0x49')]=qs[_0x8bb4('0x4a')](_0x1b51b1[_0x8bb4('0x42')][_0x8bb4('0x4a')]);_0x42693a['where']=qs[_0x8bb4('0x43')](_[_0x8bb4('0x4b')](_0x1b51b1['query'],_0x42746a['filters']),_0x165b7d);if(_0x1b51b1['query'][_0x8bb4('0x4c')]){_0x42693a[_0x8bb4('0x4d')]=_[_0x8bb4('0x4e')](_0x42693a[_0x8bb4('0x4d')],{'$or':_[_0x8bb4('0x40')](_0x165b7d,function(_0x3a3516){if(_0x3a3516[_0x8bb4('0x3e')]!==_0x8bb4('0x4f')){var _0x4ec5a6={};_0x4ec5a6[_0x3a3516[_0x8bb4('0x38')]]={'$like':'%'+_0x1b51b1[_0x8bb4('0x42')][_0x8bb4('0x4c')]+'%'};return _0x4ec5a6;}})});}_0x42693a=_[_0x8bb4('0x4e')]({},_0x42693a,_0x1b51b1['options']);var _0xf0609b={'where':_0x42693a['where']};return db[_0x8bb4('0x3b')][_0x8bb4('0x2d')](_0xf0609b)[_0x8bb4('0x32')](function(_0x525735){_0x29e2d7[_0x8bb4('0x2d')]=_0x525735;if(_0x1b51b1[_0x8bb4('0x42')][_0x8bb4('0x50')]){_0x42693a['include']=[{'all':!![]}];}return db[_0x8bb4('0x3b')]['findAll'](_0x42693a);})[_0x8bb4('0x32')](function(_0x62f180){_0x29e2d7['rows']=_0x62f180;return _0x29e2d7;})[_0x8bb4('0x32')](respondWithFilteredResult(_0x4208cb,_0x42693a))[_0x8bb4('0x25')](handleError(_0x4208cb,null));};exports[_0x8bb4('0x51')]=function(_0x9e528b,_0x243223){var _0x5db9c2={'raw':![],'where':{'id':_0x9e528b[_0x8bb4('0x52')]['id']}},_0x222939={};_0x222939['model']=_['keys'](db['VoiceContext'][_0x8bb4('0x3c')]);_0x222939[_0x8bb4('0x42')]=_[_0x8bb4('0x41')](_0x9e528b['query']);_0x222939[_0x8bb4('0x43')]=_['intersection'](_0x222939[_0x8bb4('0x3f')],_0x222939[_0x8bb4('0x42')]);_0x5db9c2['attributes']=_['intersection'](_0x222939[_0x8bb4('0x3f')],qs[_0x8bb4('0x46')](_0x9e528b[_0x8bb4('0x42')][_0x8bb4('0x46')]));_0x5db9c2[_0x8bb4('0x44')]=_0x5db9c2[_0x8bb4('0x44')]['length']?_0x5db9c2[_0x8bb4('0x44')]:_0x222939[_0x8bb4('0x3f')];if(_0x9e528b[_0x8bb4('0x42')][_0x8bb4('0x50')]){_0x5db9c2[_0x8bb4('0x53')]=[{'all':!![]}];}_0x5db9c2=_[_0x8bb4('0x4e')]({},_0x5db9c2,_0x9e528b[_0x8bb4('0x54')]);return db[_0x8bb4('0x3b')][_0x8bb4('0x55')](_0x5db9c2)[_0x8bb4('0x32')](handleEntityNotFound(_0x243223,null))[_0x8bb4('0x32')](respondWithResult(_0x243223,null))[_0x8bb4('0x25')](handleError(_0x243223,null));};exports[_0x8bb4('0x56')]=function(_0x1a500c,_0x123d2f,_0x11b27d){var _0x12bd68;return db[_0x8bb4('0x3b')][_0x8bb4('0x56')](_0x1a500c[_0x8bb4('0x57')],{'raw':!![]})[_0x8bb4('0x32')](function(_0x1233b5){_0x12bd68=_0x1233b5;return db[_0x8bb4('0x3b')][_0x8bb4('0x58')]({'raw':!![]});})[_0x8bb4('0x32')](function(_0x53e63b){var _0x3187e1=fs[_0x8bb4('0x59')](path['join'](config['root'],_0x8bb4('0x5a')),_0x8bb4('0x5b'));var _0x5ef708=ejs['render'](_0x3187e1,{'contexts':_0x53e63b||[]});fs[_0x8bb4('0x5c')](_0x8bb4('0x5d'),_0x5ef708);})['then'](function(){return respondWithRpcPromise('Reload',_0x8bb4('0x56'),{'module':'chan_sip.so'});})[_0x8bb4('0x32')](function(){var _0x3652f2=_0x1a500c[_0x8bb4('0x5e')][_0x8bb4('0x34')]({'plain':!![]});if(!_0x3652f2)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3652f2[_0x8bb4('0x5f')]===_0x8bb4('0x5e')){var _0x1d2af4=_0x12bd68[_0x8bb4('0x34')]({'plain':!![]});return db[_0x8bb4('0x60')]['find']({'where':{'name':_0x8bb4('0x35'),'userProfileId':_0x3652f2[_0x8bb4('0x61')]},'raw':!![]})['then'](function(_0x47a28f){if(_0x47a28f&&_0x47a28f[_0x8bb4('0x62')]===0x0){return db['UserProfileResource'][_0x8bb4('0x56')]({'name':_0x1d2af4[_0x8bb4('0x38')],'resourceId':_0x1d2af4['id'],'type':_0x47a28f[_0x8bb4('0x38')],'sectionId':_0x47a28f['id']},{})[_0x8bb4('0x32')](function(){return _0x12bd68;});}else{return _0x12bd68;}})[_0x8bb4('0x25')](function(_0x3632a0){logger[_0x8bb4('0x21')](_0x8bb4('0x63'),_0x3632a0);throw _0x3632a0;});}return _0x12bd68;})[_0x8bb4('0x32')](respondWithResult(_0x123d2f,0xc9))[_0x8bb4('0x25')](handleError(_0x123d2f,null));};exports['update']=function(_0x41bb2f,_0x56f19f,_0x3acaf2){var _0x1a4c67;return db[_0x8bb4('0x3b')][_0x8bb4('0x55')]({'where':{'id':_0x41bb2f[_0x8bb4('0x52')]['id']}})[_0x8bb4('0x32')](handleEntityNotFound(_0x56f19f,null))['then'](saveUpdates(_0x41bb2f[_0x8bb4('0x57')],null))['then'](function(_0x3fa879){if(_0x3fa879){_0x1a4c67=_0x3fa879;return db[_0x8bb4('0x3b')][_0x8bb4('0x58')]({'raw':!![]});}})[_0x8bb4('0x32')](function(_0x10fcbb){var _0x1ce7b9=fs[_0x8bb4('0x59')](path[_0x8bb4('0x64')](config['root'],_0x8bb4('0x5a')),_0x8bb4('0x5b'));var _0xf349=ejs[_0x8bb4('0x65')](_0x1ce7b9,{'contexts':_0x10fcbb||[]});fs[_0x8bb4('0x5c')](_0x8bb4('0x5d'),_0xf349);})[_0x8bb4('0x32')](function(){return respondWithRpcPromise(_0x8bb4('0x66'),'update',{'module':'chan_sip.so'});})['then'](function(){return _0x1a4c67;})['then'](respondWithResult(_0x56f19f,null))[_0x8bb4('0x25')](handleError(_0x56f19f,null));};exports[_0x8bb4('0x33')]=function(_0x765f96,_0x47aa29,_0x35105e){var _0x3164f1;return db[_0x8bb4('0x3b')][_0x8bb4('0x55')]({'where':{'id':_0x765f96[_0x8bb4('0x52')]['id']}})[_0x8bb4('0x32')](handleEntityNotFound(_0x47aa29,null))[_0x8bb4('0x32')](removeEntity(_0x47aa29,null))[_0x8bb4('0x32')](function(){return db[_0x8bb4('0x3b')]['findAll']({'raw':!![]});})[_0x8bb4('0x32')](function(_0x575e37){var _0x5b9358=fs[_0x8bb4('0x59')](path['join'](config['root'],_0x8bb4('0x5a')),_0x8bb4('0x5b'));var _0x1c44c1=ejs['render'](_0x5b9358,{'contexts':_0x575e37});fs[_0x8bb4('0x5c')](_0x8bb4('0x5d'),_0x1c44c1);return respondWithRpcPromise(_0x8bb4('0x66'),_0x8bb4('0x33'),{'module':'chan_sip.so'});})[_0x8bb4('0x25')](handleError(_0x47aa29,null));};
\ No newline at end of file
+var _0x485b=['writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','Reload','chan_sip.so','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','join','root','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','path','sox','to-csv','fs-extra','squel','crypto','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','jayson/promise','client','request','then','info','VoiceContext,\x20%s,\x20%s','debug','VoiceContext,\x20%s,\x20%s,\x20%s','error','message','request\x20sent','catch','sendStatus','end','status','json','offset','limit','undefined','count','set','Content-Range','apply','reject','save','update','destroy','get','Contexts','name','map','VoiceContext','rawAttributes','type','key','model','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','findAll','rows','show','params','find','create','body','readFileSync','server/files/templates/context.ejs','utf8','render'];(function(_0xc36007,_0x433c1e){var _0x2ddf75=function(_0xfc4eb2){while(--_0xfc4eb2){_0xc36007['push'](_0xc36007['shift']());}};_0x2ddf75(++_0x433c1e);}(_0x485b,0x19d));var _0xb485=function(_0x291f8b,_0x3b5591){_0x291f8b=_0x291f8b-0x0;var _0x275171=_0x485b[_0x291f8b];return _0x275171;};'use strict';var emlformat=require(_0xb485('0x0'));var rimraf=require(_0xb485('0x1'));var zipdir=require(_0xb485('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xb485('0x3'));var moment=require(_0xb485('0x4'));var BPromise=require(_0xb485('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0xb485('0x6'));var sox=require(_0xb485('0x7'));var csv=require(_0xb485('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xb485('0x9'));var _=require('lodash');var squel=require(_0xb485('0xa'));var crypto=require(_0xb485('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xb485('0xc'));var toCsv=require(_0xb485('0x8'));var querystring=require('querystring');var Papa=require(_0xb485('0xd'));var Redis=require(_0xb485('0xe'));var authService=require('../../components/auth/service');var qs=require(_0xb485('0xf'));var as=require(_0xb485('0x10'));var hardwareService=require(_0xb485('0x11'));var logger=require(_0xb485('0x12'))(_0xb485('0x13'));var utils=require(_0xb485('0x14'));var config=require(_0xb485('0x15'));var licenseUtil=require(_0xb485('0x16'));var db=require('../../mysqldb')['db'];var jayson=require(_0xb485('0x17'));var client=jayson[_0xb485('0x18')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2d2c95,_0x43c9ba,_0x159c42,_0x2548f4){return new BPromise(function(_0x240590,_0x20230a){var _0x3fbcc3=_0x2548f4||client;return _0x3fbcc3[_0xb485('0x19')](_0x2d2c95,_0x159c42)[_0xb485('0x1a')](function(_0x300153){logger[_0xb485('0x1b')](_0xb485('0x1c'),_0x43c9ba,'request\x20sent');logger[_0xb485('0x1d')](_0xb485('0x1e'),_0x43c9ba,'request\x20sent',JSON['stringify'](_0x300153));if(_0x300153[_0xb485('0x1f')]){if(_0x300153[_0xb485('0x1f')]['code']===0x1f4){logger[_0xb485('0x1f')](_0xb485('0x1c'),_0x43c9ba,_0x300153[_0xb485('0x1f')]['message']);return _0x20230a(_0x300153[_0xb485('0x1f')][_0xb485('0x20')]);}logger[_0xb485('0x1f')](_0xb485('0x1c'),_0x43c9ba,_0x300153['error'][_0xb485('0x20')]);return _0x240590(_0x300153['error']['message']);}else{logger[_0xb485('0x1b')](_0xb485('0x1c'),_0x43c9ba,_0xb485('0x21'));_0x240590(_0x300153['result'][_0xb485('0x20')]);}})[_0xb485('0x22')](function(_0x461197){logger['error'](_0xb485('0x1c'),_0x43c9ba,_0x461197);_0x20230a(_0x461197);});});}function respondWithStatusCode(_0x257566,_0x52d92f){_0x52d92f=_0x52d92f||0xcc;return function(_0x40e151){if(_0x40e151){return _0x257566[_0xb485('0x23')](_0x52d92f);}return _0x257566['status'](_0x52d92f)[_0xb485('0x24')]();};}function respondWithResult(_0x661e97,_0x28a746){_0x28a746=_0x28a746||0xc8;return function(_0x2d4d3e){if(_0x2d4d3e){return _0x661e97[_0xb485('0x25')](_0x28a746)[_0xb485('0x26')](_0x2d4d3e);}};}function respondWithFilteredResult(_0x14f2c5,_0x3be8a6){return function(_0x23e962){if(_0x23e962){var _0x5905c9=typeof _0x3be8a6[_0xb485('0x27')]==='undefined'&&typeof _0x3be8a6[_0xb485('0x28')]===_0xb485('0x29');var _0x58a58f=_0x23e962[_0xb485('0x2a')];var _0x1a9da2=_0x5905c9?0x0:_0x3be8a6['offset'];var _0xf901f1=_0x5905c9?_0x23e962[_0xb485('0x2a')]:_0x3be8a6[_0xb485('0x27')]+_0x3be8a6['limit'];var _0x5218f2;if(_0xf901f1>=_0x58a58f){_0xf901f1=_0x58a58f;_0x5218f2=0xc8;}else{_0x5218f2=0xce;}_0x14f2c5['status'](_0x5218f2);return _0x14f2c5[_0xb485('0x2b')](_0xb485('0x2c'),_0x1a9da2+'-'+_0xf901f1+'/'+_0x58a58f)[_0xb485('0x26')](_0x23e962);}return null;};}function patchUpdates(_0x3d8474){return function(_0x2c58c4){try{jsonpatch[_0xb485('0x2d')](_0x2c58c4,_0x3d8474,!![]);}catch(_0x5166b9){return BPromise[_0xb485('0x2e')](_0x5166b9);}return _0x2c58c4[_0xb485('0x2f')]();};}function saveUpdates(_0x3251a0,_0x20d1fa){return function(_0xfcaea3){if(_0xfcaea3){return _0xfcaea3[_0xb485('0x30')](_0x3251a0)['then'](function(_0x351789){return _0x351789;});}return null;};}function removeEntity(_0x1aaad4,_0x4aee2e){return function(_0xb001df){if(_0xb001df){return _0xb001df[_0xb485('0x31')]()[_0xb485('0x1a')](function(){var _0x2a0c41=_0xb001df[_0xb485('0x32')]({'plain':!![]});var _0x1068c8=_0xb485('0x33');return db['UserProfileResource'][_0xb485('0x31')]({'where':{'type':_0x1068c8,'resourceId':_0x2a0c41['id']}})['then'](function(){return _0xb001df;});})[_0xb485('0x1a')](function(){_0x1aaad4['status'](0xcc)[_0xb485('0x24')]();});}};}function handleEntityNotFound(_0x5b0879,_0x1a49e4){return function(_0x2543f7){if(!_0x2543f7){_0x5b0879[_0xb485('0x23')](0x194);}return _0x2543f7;};}function handleError(_0x4a9ae6,_0x35ec02){_0x35ec02=_0x35ec02||0x1f4;return function(_0x35b887){logger['error'](_0x35b887['stack']);if(_0x35b887[_0xb485('0x34')]){delete _0x35b887[_0xb485('0x34')];}_0x4a9ae6['status'](_0x35ec02)['send'](_0x35b887);};}exports['index']=function(_0x19affe,_0x8868c4){var _0x2fc36f={},_0x48a55c={},_0x2f90da={'count':0x0,'rows':[]};var _0x45085d=_[_0xb485('0x35')](db[_0xb485('0x36')][_0xb485('0x37')],function(_0x578629){return{'name':_0x578629['fieldName'],'type':_0x578629[_0xb485('0x38')][_0xb485('0x39')]};});_0x48a55c[_0xb485('0x3a')]=_[_0xb485('0x35')](_0x45085d,_0xb485('0x34'));_0x48a55c[_0xb485('0x3b')]=_[_0xb485('0x3c')](_0x19affe['query']);_0x48a55c['filters']=_[_0xb485('0x3d')](_0x48a55c[_0xb485('0x3a')],_0x48a55c[_0xb485('0x3b')]);_0x2fc36f['attributes']=_[_0xb485('0x3d')](_0x48a55c['model'],qs[_0xb485('0x3e')](_0x19affe['query']['fields']));_0x2fc36f[_0xb485('0x3f')]=_0x2fc36f[_0xb485('0x3f')][_0xb485('0x40')]?_0x2fc36f['attributes']:_0x48a55c[_0xb485('0x3a')];if(!_0x19affe['query'][_0xb485('0x41')](_0xb485('0x42'))){_0x2fc36f[_0xb485('0x28')]=qs[_0xb485('0x28')](_0x19affe[_0xb485('0x3b')]['limit']);_0x2fc36f['offset']=qs['offset'](_0x19affe[_0xb485('0x3b')][_0xb485('0x27')]);}_0x2fc36f['order']=qs[_0xb485('0x43')](_0x19affe[_0xb485('0x3b')][_0xb485('0x43')]);_0x2fc36f[_0xb485('0x44')]=qs[_0xb485('0x45')](_[_0xb485('0x46')](_0x19affe[_0xb485('0x3b')],_0x48a55c[_0xb485('0x45')]),_0x45085d);if(_0x19affe[_0xb485('0x3b')][_0xb485('0x47')]){_0x2fc36f[_0xb485('0x44')]=_[_0xb485('0x48')](_0x2fc36f[_0xb485('0x44')],{'$or':_[_0xb485('0x35')](_0x45085d,function(_0x1b98d1){if(_0x1b98d1['type']!==_0xb485('0x49')){var _0x27608b={};_0x27608b[_0x1b98d1[_0xb485('0x34')]]={'$like':'%'+_0x19affe['query'][_0xb485('0x47')]+'%'};return _0x27608b;}})});}_0x2fc36f=_[_0xb485('0x48')]({},_0x2fc36f,_0x19affe[_0xb485('0x4a')]);var _0x5d27a3={'where':_0x2fc36f[_0xb485('0x44')]};return db[_0xb485('0x36')][_0xb485('0x2a')](_0x5d27a3)['then'](function(_0x3ca608){_0x2f90da['count']=_0x3ca608;if(_0x19affe['query'][_0xb485('0x4b')]){_0x2fc36f['include']=[{'all':!![]}];}return db[_0xb485('0x36')][_0xb485('0x4c')](_0x2fc36f);})['then'](function(_0x17ca11){_0x2f90da[_0xb485('0x4d')]=_0x17ca11;return _0x2f90da;})[_0xb485('0x1a')](respondWithFilteredResult(_0x8868c4,_0x2fc36f))[_0xb485('0x22')](handleError(_0x8868c4,null));};exports[_0xb485('0x4e')]=function(_0x13f8d5,_0x230625){var _0x23d667={'raw':![],'where':{'id':_0x13f8d5[_0xb485('0x4f')]['id']}},_0x178b71={};_0x178b71[_0xb485('0x3a')]=_[_0xb485('0x3c')](db['VoiceContext']['rawAttributes']);_0x178b71[_0xb485('0x3b')]=_['keys'](_0x13f8d5[_0xb485('0x3b')]);_0x178b71[_0xb485('0x45')]=_['intersection'](_0x178b71[_0xb485('0x3a')],_0x178b71[_0xb485('0x3b')]);_0x23d667[_0xb485('0x3f')]=_[_0xb485('0x3d')](_0x178b71['model'],qs['fields'](_0x13f8d5[_0xb485('0x3b')][_0xb485('0x3e')]));_0x23d667['attributes']=_0x23d667['attributes'][_0xb485('0x40')]?_0x23d667[_0xb485('0x3f')]:_0x178b71[_0xb485('0x3a')];if(_0x13f8d5[_0xb485('0x3b')][_0xb485('0x4b')]){_0x23d667['include']=[{'all':!![]}];}_0x23d667=_[_0xb485('0x48')]({},_0x23d667,_0x13f8d5[_0xb485('0x4a')]);return db['VoiceContext'][_0xb485('0x50')](_0x23d667)[_0xb485('0x1a')](handleEntityNotFound(_0x230625,null))[_0xb485('0x1a')](respondWithResult(_0x230625,null))['catch'](handleError(_0x230625,null));};exports[_0xb485('0x51')]=function(_0x3f19fc,_0x5f20e1,_0x2ffa1a){var _0x4c75d8;return db['VoiceContext'][_0xb485('0x51')](_0x3f19fc[_0xb485('0x52')],{'raw':!![]})[_0xb485('0x1a')](function(_0x33235a){_0x4c75d8=_0x33235a;return db[_0xb485('0x36')][_0xb485('0x4c')]({'raw':!![]});})['then'](function(_0xc4ee47){var _0x446c85=fs[_0xb485('0x53')](path['join'](config['root'],_0xb485('0x54')),_0xb485('0x55'));var _0x1b2916=ejs[_0xb485('0x56')](_0x446c85,{'contexts':_0xc4ee47||[]});fs[_0xb485('0x57')](_0xb485('0x58'),_0x1b2916);})[_0xb485('0x1a')](function(){return respondWithRpcPromise(_0xb485('0x59'),_0xb485('0x51'),{'module':_0xb485('0x5a')});})[_0xb485('0x1a')](function(){var _0x9823be=_0x3f19fc['user'][_0xb485('0x32')]({'plain':!![]});if(!_0x9823be)throw new Error(_0xb485('0x5b'));if(_0x9823be[_0xb485('0x5c')]==='user'){var _0x248e14=_0x4c75d8['get']({'plain':!![]});return db[_0xb485('0x5d')][_0xb485('0x50')]({'where':{'name':_0xb485('0x33'),'userProfileId':_0x9823be[_0xb485('0x5e')]},'raw':!![]})[_0xb485('0x1a')](function(_0x1625d9){if(_0x1625d9&&_0x1625d9[_0xb485('0x5f')]===0x0){return db[_0xb485('0x60')][_0xb485('0x51')]({'name':_0x248e14[_0xb485('0x34')],'resourceId':_0x248e14['id'],'type':_0x1625d9[_0xb485('0x34')],'sectionId':_0x1625d9['id']},{})[_0xb485('0x1a')](function(){return _0x4c75d8;});}else{return _0x4c75d8;}})['catch'](function(_0x53a4d0){logger[_0xb485('0x1f')](_0xb485('0x61'),_0x53a4d0);throw _0x53a4d0;});}return _0x4c75d8;})[_0xb485('0x1a')](respondWithResult(_0x5f20e1,0xc9))[_0xb485('0x22')](handleError(_0x5f20e1,null));};exports[_0xb485('0x30')]=function(_0x2efe9a,_0x82a2dc,_0x33e309){var _0x427549;return db[_0xb485('0x36')][_0xb485('0x50')]({'where':{'id':_0x2efe9a['params']['id']}})[_0xb485('0x1a')](handleEntityNotFound(_0x82a2dc,null))[_0xb485('0x1a')](saveUpdates(_0x2efe9a[_0xb485('0x52')],null))['then'](function(_0x2556f7){if(_0x2556f7){_0x427549=_0x2556f7;return db['VoiceContext'][_0xb485('0x4c')]({'raw':!![]});}})['then'](function(_0x3dd49e){var _0x1ab988=fs[_0xb485('0x53')](path[_0xb485('0x62')](config[_0xb485('0x63')],'server/files/templates/context.ejs'),_0xb485('0x55'));var _0x1772d6=ejs[_0xb485('0x56')](_0x1ab988,{'contexts':_0x3dd49e||[]});fs[_0xb485('0x57')](_0xb485('0x58'),_0x1772d6);})[_0xb485('0x1a')](function(){return respondWithRpcPromise(_0xb485('0x59'),_0xb485('0x30'),{'module':_0xb485('0x5a')});})['then'](function(){return _0x427549;})[_0xb485('0x1a')](respondWithResult(_0x82a2dc,null))[_0xb485('0x22')](handleError(_0x82a2dc,null));};exports[_0xb485('0x31')]=function(_0x2c205c,_0x507c20,_0x2dfcd0){var _0x281649;return db[_0xb485('0x36')]['find']({'where':{'id':_0x2c205c['params']['id']}})[_0xb485('0x1a')](handleEntityNotFound(_0x507c20,null))[_0xb485('0x1a')](removeEntity(_0x507c20,null))[_0xb485('0x1a')](function(){return db[_0xb485('0x36')][_0xb485('0x4c')]({'raw':!![]});})[_0xb485('0x1a')](function(_0x5a9c95){var _0x1dc990=fs[_0xb485('0x53')](path[_0xb485('0x62')](config[_0xb485('0x63')],_0xb485('0x54')),'utf8');var _0x4b84ca=ejs[_0xb485('0x56')](_0x1dc990,{'contexts':_0x5a9c95});fs['writeFileSync'](_0xb485('0x58'),_0x4b84ca);return respondWithRpcPromise('Reload',_0xb485('0x31'),{'module':'chan_sip.so'});})[_0xb485('0x22')](handleError(_0x507c20,null));};
\ No newline at end of file