Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / api / voiceContext / voiceContext.controller.js
index f8fa51b..9f9e2c0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x31f9=['offset','limit','undefined','set','Content-Range','apply','save','update','destroy','get','Contexts','UserProfileResource','sendStatus','stack','name','send','index','map','VoiceContext','rawAttributes','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','type','VIRTUAL','options','count','include','findAll','rows','show','params','keys','includeAll','find','create','body','readFileSync','join','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','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','root','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','sox','to-csv','fs-extra','squel','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','jayson/promise','http','request','then','info','VoiceContext,\x20%s,\x20%s','debug','VoiceContext,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','status','end','json'];(function(_0x338581,_0x85c756){var _0x306123=function(_0x127017){while(--_0x127017){_0x338581['push'](_0x338581['shift']());}};_0x306123(++_0x85c756);}(_0x31f9,0x10f));var _0x931f=function(_0x159605,_0x4beba1){_0x159605=_0x159605-0x0;var _0x5ac800=_0x31f9[_0x159605];return _0x5ac800;};'use strict';var emlformat=require(_0x931f('0x0'));var rimraf=require(_0x931f('0x1'));var zipdir=require(_0x931f('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x931f('0x3'));var moment=require(_0x931f('0x4'));var BPromise=require(_0x931f('0x5'));var Mustache=require(_0x931f('0x6'));var util=require(_0x931f('0x7'));var path=require('path');var sox=require(_0x931f('0x8'));var csv=require(_0x931f('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x931f('0xa'));var _=require('lodash');var squel=require(_0x931f('0xb'));var crypto=require(_0x931f('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x931f('0xd'));var toCsv=require(_0x931f('0x9'));var querystring=require(_0x931f('0xe'));var Papa=require('papaparse');var Redis=require(_0x931f('0xf'));var authService=require(_0x931f('0x10'));var qs=require(_0x931f('0x11'));var as=require(_0x931f('0x12'));var hardwareService=require(_0x931f('0x13'));var logger=require('../../config/logger')(_0x931f('0x14'));var utils=require(_0x931f('0x15'));var config=require(_0x931f('0x16'));var licenseUtil=require(_0x931f('0x17'));var db=require('../../mysqldb')['db'];var jayson=require(_0x931f('0x18'));var client=jayson['client'][_0x931f('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x2a2512,_0x53f21e,_0x5e0464,_0x38e67a){return new BPromise(function(_0x5a3e31,_0x5e2e3b){var _0x53d39b=_0x38e67a||client;return _0x53d39b[_0x931f('0x1a')](_0x2a2512,_0x5e0464)[_0x931f('0x1b')](function(_0x25ec98){logger[_0x931f('0x1c')](_0x931f('0x1d'),_0x53f21e,'request\x20sent');logger[_0x931f('0x1e')](_0x931f('0x1f'),_0x53f21e,'request\x20sent',JSON[_0x931f('0x20')](_0x25ec98));if(_0x25ec98['error']){if(_0x25ec98[_0x931f('0x21')][_0x931f('0x22')]===0x1f4){logger[_0x931f('0x21')](_0x931f('0x1d'),_0x53f21e,_0x25ec98[_0x931f('0x21')]['message']);return _0x5e2e3b(_0x25ec98[_0x931f('0x21')][_0x931f('0x23')]);}logger[_0x931f('0x21')](_0x931f('0x1d'),_0x53f21e,_0x25ec98[_0x931f('0x21')]['message']);return _0x5a3e31(_0x25ec98[_0x931f('0x21')][_0x931f('0x23')]);}else{logger['info'](_0x931f('0x1d'),_0x53f21e,'request\x20sent');_0x5a3e31(_0x25ec98[_0x931f('0x24')]['message']);}})[_0x931f('0x25')](function(_0x276673){logger[_0x931f('0x21')](_0x931f('0x1d'),_0x53f21e,_0x276673);_0x5e2e3b(_0x276673);});});}function respondWithStatusCode(_0x521b4b,_0x456dfc){_0x456dfc=_0x456dfc||0xcc;return function(_0x1cfd22){if(_0x1cfd22){return _0x521b4b['sendStatus'](_0x456dfc);}return _0x521b4b[_0x931f('0x26')](_0x456dfc)[_0x931f('0x27')]();};}function respondWithResult(_0x146830,_0x4b41f7){_0x4b41f7=_0x4b41f7||0xc8;return function(_0x583582){if(_0x583582){return _0x146830[_0x931f('0x26')](_0x4b41f7)[_0x931f('0x28')](_0x583582);}};}function respondWithFilteredResult(_0x371fea,_0x3066fb){return function(_0x33673a){if(_0x33673a){var _0x1f4053=typeof _0x3066fb[_0x931f('0x29')]==='undefined'&&typeof _0x3066fb[_0x931f('0x2a')]===_0x931f('0x2b');var _0x23b45c=_0x33673a['count'];var _0x37e8e7=_0x1f4053?0x0:_0x3066fb[_0x931f('0x29')];var _0x4cea8b=_0x1f4053?_0x33673a['count']:_0x3066fb[_0x931f('0x29')]+_0x3066fb[_0x931f('0x2a')];var _0x505aac;if(_0x4cea8b>=_0x23b45c){_0x4cea8b=_0x23b45c;_0x505aac=0xc8;}else{_0x505aac=0xce;}_0x371fea[_0x931f('0x26')](_0x505aac);return _0x371fea[_0x931f('0x2c')](_0x931f('0x2d'),_0x37e8e7+'-'+_0x4cea8b+'/'+_0x23b45c)[_0x931f('0x28')](_0x33673a);}return null;};}function patchUpdates(_0x4ffcb4){return function(_0x4a1795){try{jsonpatch[_0x931f('0x2e')](_0x4a1795,_0x4ffcb4,!![]);}catch(_0x150b8b){return BPromise['reject'](_0x150b8b);}return _0x4a1795[_0x931f('0x2f')]();};}function saveUpdates(_0x3ff2e6,_0x3621d3){return function(_0x525902){if(_0x525902){return _0x525902[_0x931f('0x30')](_0x3ff2e6)[_0x931f('0x1b')](function(_0x35711e){return _0x35711e;});}return null;};}function removeEntity(_0x2f13e4,_0x2ae5f6){return function(_0x5824ce){if(_0x5824ce){return _0x5824ce[_0x931f('0x31')]()[_0x931f('0x1b')](function(){var _0x5e6c8e=_0x5824ce[_0x931f('0x32')]({'plain':!![]});var _0x572351=_0x931f('0x33');return db[_0x931f('0x34')][_0x931f('0x31')]({'where':{'type':_0x572351,'resourceId':_0x5e6c8e['id']}})[_0x931f('0x1b')](function(){return _0x5824ce;});})[_0x931f('0x1b')](function(){_0x2f13e4[_0x931f('0x26')](0xcc)['end']();});}};}function handleEntityNotFound(_0x121650,_0x155493){return function(_0x1373f1){if(!_0x1373f1){_0x121650[_0x931f('0x35')](0x194);}return _0x1373f1;};}function handleError(_0x5e622a,_0x33f583){_0x33f583=_0x33f583||0x1f4;return function(_0x6e6d7f){logger[_0x931f('0x21')](_0x6e6d7f[_0x931f('0x36')]);if(_0x6e6d7f['name']){delete _0x6e6d7f[_0x931f('0x37')];}_0x5e622a[_0x931f('0x26')](_0x33f583)[_0x931f('0x38')](_0x6e6d7f);};}exports[_0x931f('0x39')]=function(_0x7bfddf,_0x5dcf1c){var _0x382f82={},_0x440870={},_0x15fd49={'count':0x0,'rows':[]};var _0x3cc407=_[_0x931f('0x3a')](db[_0x931f('0x3b')][_0x931f('0x3c')],function(_0x561b41){return{'name':_0x561b41['fieldName'],'type':_0x561b41['type']['key']};});_0x440870[_0x931f('0x3d')]=_[_0x931f('0x3a')](_0x3cc407,_0x931f('0x37'));_0x440870[_0x931f('0x3e')]=_['keys'](_0x7bfddf[_0x931f('0x3e')]);_0x440870[_0x931f('0x3f')]=_[_0x931f('0x40')](_0x440870[_0x931f('0x3d')],_0x440870['query']);_0x382f82[_0x931f('0x41')]=_[_0x931f('0x40')](_0x440870[_0x931f('0x3d')],qs[_0x931f('0x42')](_0x7bfddf[_0x931f('0x3e')]['fields']));_0x382f82['attributes']=_0x382f82['attributes'][_0x931f('0x43')]?_0x382f82[_0x931f('0x41')]:_0x440870[_0x931f('0x3d')];if(!_0x7bfddf[_0x931f('0x3e')][_0x931f('0x44')]('nolimit')){_0x382f82[_0x931f('0x2a')]=qs[_0x931f('0x2a')](_0x7bfddf[_0x931f('0x3e')][_0x931f('0x2a')]);_0x382f82[_0x931f('0x29')]=qs[_0x931f('0x29')](_0x7bfddf[_0x931f('0x3e')][_0x931f('0x29')]);}_0x382f82[_0x931f('0x45')]=qs[_0x931f('0x46')](_0x7bfddf[_0x931f('0x3e')][_0x931f('0x46')]);_0x382f82[_0x931f('0x47')]=qs[_0x931f('0x3f')](_[_0x931f('0x48')](_0x7bfddf['query'],_0x440870[_0x931f('0x3f')]),_0x3cc407);if(_0x7bfddf[_0x931f('0x3e')][_0x931f('0x49')]){_0x382f82[_0x931f('0x47')]=_[_0x931f('0x4a')](_0x382f82[_0x931f('0x47')],{'$or':_[_0x931f('0x3a')](_0x3cc407,function(_0x30ee28){if(_0x30ee28[_0x931f('0x4b')]!==_0x931f('0x4c')){var _0x42cc79={};_0x42cc79[_0x30ee28[_0x931f('0x37')]]={'$like':'%'+_0x7bfddf['query']['filter']+'%'};return _0x42cc79;}})});}_0x382f82=_[_0x931f('0x4a')]({},_0x382f82,_0x7bfddf[_0x931f('0x4d')]);var _0x3519d2={'where':_0x382f82[_0x931f('0x47')]};return db[_0x931f('0x3b')][_0x931f('0x4e')](_0x3519d2)[_0x931f('0x1b')](function(_0x16924e){_0x15fd49[_0x931f('0x4e')]=_0x16924e;if(_0x7bfddf[_0x931f('0x3e')]['includeAll']){_0x382f82[_0x931f('0x4f')]=[{'all':!![]}];}return db[_0x931f('0x3b')][_0x931f('0x50')](_0x382f82);})[_0x931f('0x1b')](function(_0xfa2c0a){_0x15fd49[_0x931f('0x51')]=_0xfa2c0a;return _0x15fd49;})['then'](respondWithFilteredResult(_0x5dcf1c,_0x382f82))[_0x931f('0x25')](handleError(_0x5dcf1c,null));};exports[_0x931f('0x52')]=function(_0x37bb31,_0x278347){var _0x3c0bbc={'raw':![],'where':{'id':_0x37bb31[_0x931f('0x53')]['id']}},_0x2b43d8={};_0x2b43d8['model']=_[_0x931f('0x54')](db['VoiceContext'][_0x931f('0x3c')]);_0x2b43d8[_0x931f('0x3e')]=_['keys'](_0x37bb31[_0x931f('0x3e')]);_0x2b43d8[_0x931f('0x3f')]=_['intersection'](_0x2b43d8['model'],_0x2b43d8[_0x931f('0x3e')]);_0x3c0bbc['attributes']=_['intersection'](_0x2b43d8[_0x931f('0x3d')],qs['fields'](_0x37bb31['query']['fields']));_0x3c0bbc[_0x931f('0x41')]=_0x3c0bbc[_0x931f('0x41')][_0x931f('0x43')]?_0x3c0bbc[_0x931f('0x41')]:_0x2b43d8[_0x931f('0x3d')];if(_0x37bb31[_0x931f('0x3e')][_0x931f('0x55')]){_0x3c0bbc[_0x931f('0x4f')]=[{'all':!![]}];}_0x3c0bbc=_['merge']({},_0x3c0bbc,_0x37bb31['options']);return db[_0x931f('0x3b')][_0x931f('0x56')](_0x3c0bbc)[_0x931f('0x1b')](handleEntityNotFound(_0x278347,null))['then'](respondWithResult(_0x278347,null))['catch'](handleError(_0x278347,null));};exports[_0x931f('0x57')]=function(_0x577ab1,_0x304ae8,_0x32827d){var _0x15dda1;return db['VoiceContext'][_0x931f('0x57')](_0x577ab1[_0x931f('0x58')],{'raw':!![]})[_0x931f('0x1b')](function(_0x2178e2){_0x15dda1=_0x2178e2;return db[_0x931f('0x3b')][_0x931f('0x50')]({'raw':!![]});})[_0x931f('0x1b')](function(_0x9bb71f){var _0x5bc199=fs[_0x931f('0x59')](path[_0x931f('0x5a')](config['root'],_0x931f('0x5b')),_0x931f('0x5c'));var _0x428768=ejs[_0x931f('0x5d')](_0x5bc199,{'contexts':_0x9bb71f||[]});fs[_0x931f('0x5e')](_0x931f('0x5f'),_0x428768);})[_0x931f('0x1b')](function(){return respondWithRpcPromise(_0x931f('0x60'),_0x931f('0x57'),{'module':_0x931f('0x61')});})[_0x931f('0x1b')](function(){var _0x3ea94a=_0x577ab1[_0x931f('0x62')][_0x931f('0x32')]({'plain':!![]});if(!_0x3ea94a)throw new Error(_0x931f('0x63'));if(_0x3ea94a[_0x931f('0x64')]===_0x931f('0x62')){var _0x4062fa=_0x15dda1[_0x931f('0x32')]({'plain':!![]});return db['UserProfileSection'][_0x931f('0x56')]({'where':{'name':_0x931f('0x33'),'userProfileId':_0x3ea94a[_0x931f('0x65')]},'raw':!![]})['then'](function(_0x119570){if(_0x119570&&_0x119570['autoAssociation']===0x0){return db['UserProfileResource'][_0x931f('0x57')]({'name':_0x4062fa[_0x931f('0x37')],'resourceId':_0x4062fa['id'],'type':_0x119570[_0x931f('0x37')],'sectionId':_0x119570['id']},{})[_0x931f('0x1b')](function(){return _0x15dda1;});}else{return _0x15dda1;}})[_0x931f('0x25')](function(_0xf1a3d9){logger['error'](_0x931f('0x66'),_0xf1a3d9);throw _0xf1a3d9;});}return _0x15dda1;})[_0x931f('0x1b')](respondWithResult(_0x304ae8,0xc9))[_0x931f('0x25')](handleError(_0x304ae8,null));};exports[_0x931f('0x30')]=function(_0x115276,_0x59a275,_0x2acde5){var _0x497a01;return db[_0x931f('0x3b')][_0x931f('0x56')]({'where':{'id':_0x115276['params']['id']}})[_0x931f('0x1b')](handleEntityNotFound(_0x59a275,null))[_0x931f('0x1b')](saveUpdates(_0x115276[_0x931f('0x58')],null))[_0x931f('0x1b')](function(_0x55ca9d){if(_0x55ca9d){_0x497a01=_0x55ca9d;return db[_0x931f('0x3b')][_0x931f('0x50')]({'raw':!![]});}})[_0x931f('0x1b')](function(_0x524fad){var _0x4054d=fs['readFileSync'](path[_0x931f('0x5a')](config['root'],_0x931f('0x5b')),'utf8');var _0x1b063d=ejs[_0x931f('0x5d')](_0x4054d,{'contexts':_0x524fad||[]});fs[_0x931f('0x5e')](_0x931f('0x5f'),_0x1b063d);})[_0x931f('0x1b')](function(){return respondWithRpcPromise(_0x931f('0x60'),_0x931f('0x30'),{'module':_0x931f('0x61')});})[_0x931f('0x1b')](function(){return _0x497a01;})['then'](respondWithResult(_0x59a275,null))[_0x931f('0x25')](handleError(_0x59a275,null));};exports[_0x931f('0x31')]=function(_0x1e1e65,_0x342b6c,_0x199fa0){var _0x334c5b;return db[_0x931f('0x3b')][_0x931f('0x56')]({'where':{'id':_0x1e1e65['params']['id']}})[_0x931f('0x1b')](handleEntityNotFound(_0x342b6c,null))['then'](removeEntity(_0x342b6c,null))[_0x931f('0x1b')](function(){return db[_0x931f('0x3b')][_0x931f('0x50')]({'raw':!![]});})[_0x931f('0x1b')](function(_0x2b1a66){var _0x21fe15=fs[_0x931f('0x59')](path[_0x931f('0x5a')](config[_0x931f('0x67')],_0x931f('0x5b')),_0x931f('0x5c'));var _0x2cc06f=ejs['render'](_0x21fe15,{'contexts':_0x2b1a66});fs['writeFileSync'](_0x931f('0x5f'),_0x2cc06f);return respondWithRpcPromise('Reload',_0x931f('0x31'),{'module':_0x931f('0x61')});})[_0x931f('0x25')](handleError(_0x342b6c,null));};
\ No newline at end of file
+var _0x184a=['limit','count','set','Content-Range','json','apply','reject','destroy','UserProfileResource','end','stack','name','map','VoiceContext','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','show','params','rawAttributes','length','includeAll','include','create','body','findAll','readFileSync','join','server/files/templates/context.ejs','utf8','render','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','Reload','chan_sip.so','get','user','UserProfileSection','find','Contexts','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','root','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','util','to-csv','ejs','lodash','squel','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../mysqldb','jayson/promise','client','http','then','info','VoiceContext,\x20%s,\x20%s','request\x20sent','debug','VoiceContext,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','status','offset','undefined'];(function(_0x2283dc,_0x2fcfc5){var _0x16db90=function(_0x376c35){while(--_0x376c35){_0x2283dc['push'](_0x2283dc['shift']());}};_0x16db90(++_0x2fcfc5);}(_0x184a,0x1c5));var _0xa184=function(_0x368380,_0x2ac0ca){_0x368380=_0x368380-0x0;var _0x47911d=_0x184a[_0x368380];return _0x47911d;};'use strict';var emlformat=require(_0xa184('0x0'));var rimraf=require(_0xa184('0x1'));var zipdir=require(_0xa184('0x2'));var jsonpatch=require(_0xa184('0x3'));var rp=require(_0xa184('0x4'));var moment=require('moment');var BPromise=require(_0xa184('0x5'));var Mustache=require('mustache');var util=require(_0xa184('0x6'));var path=require('path');var sox=require('sox');var csv=require(_0xa184('0x7'));var ejs=require(_0xa184('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xa184('0x9'));var squel=require(_0xa184('0xa'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xa184('0xb'));var toCsv=require(_0xa184('0x7'));var querystring=require('querystring');var Papa=require(_0xa184('0xc'));var Redis=require(_0xa184('0xd'));var authService=require('../../components/auth/service');var qs=require(_0xa184('0xe'));var as=require(_0xa184('0xf'));var hardwareService=require(_0xa184('0x10'));var logger=require(_0xa184('0x11'))(_0xa184('0x12'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xa184('0x13'))['db'];var jayson=require(_0xa184('0x14'));var client=jayson[_0xa184('0x15')][_0xa184('0x16')]({'port':0x232a});function respondWithRpcPromise(_0x183866,_0x4c677a,_0x1ea7ca,_0x44399f){return new BPromise(function(_0x3a78ab,_0x3a4f54){var _0x2ab7ea=_0x44399f||client;return _0x2ab7ea['request'](_0x183866,_0x1ea7ca)[_0xa184('0x17')](function(_0x5c6def){logger[_0xa184('0x18')](_0xa184('0x19'),_0x4c677a,_0xa184('0x1a'));logger[_0xa184('0x1b')](_0xa184('0x1c'),_0x4c677a,_0xa184('0x1a'),JSON['stringify'](_0x5c6def));if(_0x5c6def['error']){if(_0x5c6def[_0xa184('0x1d')][_0xa184('0x1e')]===0x1f4){logger[_0xa184('0x1d')](_0xa184('0x19'),_0x4c677a,_0x5c6def[_0xa184('0x1d')][_0xa184('0x1f')]);return _0x3a4f54(_0x5c6def[_0xa184('0x1d')][_0xa184('0x1f')]);}logger[_0xa184('0x1d')](_0xa184('0x19'),_0x4c677a,_0x5c6def[_0xa184('0x1d')][_0xa184('0x1f')]);return _0x3a78ab(_0x5c6def[_0xa184('0x1d')][_0xa184('0x1f')]);}else{logger['info'](_0xa184('0x19'),_0x4c677a,_0xa184('0x1a'));_0x3a78ab(_0x5c6def[_0xa184('0x20')][_0xa184('0x1f')]);}})[_0xa184('0x21')](function(_0x10f9bd){logger['error']('VoiceContext,\x20%s,\x20%s',_0x4c677a,_0x10f9bd);_0x3a4f54(_0x10f9bd);});});}function respondWithStatusCode(_0x12082f,_0x58dd0f){_0x58dd0f=_0x58dd0f||0xcc;return function(_0x2e0d43){if(_0x2e0d43){return _0x12082f['sendStatus'](_0x58dd0f);}return _0x12082f[_0xa184('0x22')](_0x58dd0f)['end']();};}function respondWithResult(_0x40a46b,_0x193aa3){_0x193aa3=_0x193aa3||0xc8;return function(_0x385c4b){if(_0x385c4b){return _0x40a46b[_0xa184('0x22')](_0x193aa3)['json'](_0x385c4b);}};}function respondWithFilteredResult(_0x1e7d77,_0xd325a4){return function(_0x401545){if(_0x401545){var _0x3995a6=typeof _0xd325a4[_0xa184('0x23')]===_0xa184('0x24')&&typeof _0xd325a4[_0xa184('0x25')]===_0xa184('0x24');var _0x5e6009=_0x401545[_0xa184('0x26')];var _0x490d00=_0x3995a6?0x0:_0xd325a4[_0xa184('0x23')];var _0x6b72b3=_0x3995a6?_0x401545['count']:_0xd325a4[_0xa184('0x23')]+_0xd325a4['limit'];var _0x184d6b;if(_0x6b72b3>=_0x5e6009){_0x6b72b3=_0x5e6009;_0x184d6b=0xc8;}else{_0x184d6b=0xce;}_0x1e7d77['status'](_0x184d6b);return _0x1e7d77[_0xa184('0x27')](_0xa184('0x28'),_0x490d00+'-'+_0x6b72b3+'/'+_0x5e6009)[_0xa184('0x29')](_0x401545);}return null;};}function patchUpdates(_0x3c5896){return function(_0x23bef1){try{jsonpatch[_0xa184('0x2a')](_0x23bef1,_0x3c5896,!![]);}catch(_0x1dd048){return BPromise[_0xa184('0x2b')](_0x1dd048);}return _0x23bef1['save']();};}function saveUpdates(_0x42f380,_0x190512){return function(_0x496e69){if(_0x496e69){return _0x496e69['update'](_0x42f380)['then'](function(_0x3f3d68){return _0x3f3d68;});}return null;};}function removeEntity(_0x24c674,_0xf56b4b){return function(_0x22dc54){if(_0x22dc54){return _0x22dc54[_0xa184('0x2c')]()['then'](function(){var _0x431b8a=_0x22dc54['get']({'plain':!![]});var _0xe966e6='Contexts';return db[_0xa184('0x2d')][_0xa184('0x2c')]({'where':{'type':_0xe966e6,'resourceId':_0x431b8a['id']}})[_0xa184('0x17')](function(){return _0x22dc54;});})[_0xa184('0x17')](function(){_0x24c674[_0xa184('0x22')](0xcc)[_0xa184('0x2e')]();});}};}function handleEntityNotFound(_0xe5220d,_0x3a513c){return function(_0x5b443a){if(!_0x5b443a){_0xe5220d['sendStatus'](0x194);}return _0x5b443a;};}function handleError(_0xd2319,_0x389a27){_0x389a27=_0x389a27||0x1f4;return function(_0x580522){logger[_0xa184('0x1d')](_0x580522[_0xa184('0x2f')]);if(_0x580522[_0xa184('0x30')]){delete _0x580522[_0xa184('0x30')];}_0xd2319[_0xa184('0x22')](_0x389a27)['send'](_0x580522);};}exports['index']=function(_0x4f9e60,_0x511dc1){var _0x552c8f={},_0xfca84c={},_0xcf3a42={'count':0x0,'rows':[]};var _0x3b5d58=_[_0xa184('0x31')](db[_0xa184('0x32')]['rawAttributes'],function(_0x3f7ec5){return{'name':_0x3f7ec5[_0xa184('0x33')],'type':_0x3f7ec5[_0xa184('0x34')][_0xa184('0x35')]};});_0xfca84c[_0xa184('0x36')]=_[_0xa184('0x31')](_0x3b5d58,_0xa184('0x30'));_0xfca84c[_0xa184('0x37')]=_[_0xa184('0x38')](_0x4f9e60[_0xa184('0x37')]);_0xfca84c[_0xa184('0x39')]=_[_0xa184('0x3a')](_0xfca84c['model'],_0xfca84c[_0xa184('0x37')]);_0x552c8f[_0xa184('0x3b')]=_[_0xa184('0x3a')](_0xfca84c[_0xa184('0x36')],qs['fields'](_0x4f9e60[_0xa184('0x37')][_0xa184('0x3c')]));_0x552c8f[_0xa184('0x3b')]=_0x552c8f[_0xa184('0x3b')]['length']?_0x552c8f[_0xa184('0x3b')]:_0xfca84c['model'];if(!_0x4f9e60['query']['hasOwnProperty'](_0xa184('0x3d'))){_0x552c8f['limit']=qs['limit'](_0x4f9e60[_0xa184('0x37')][_0xa184('0x25')]);_0x552c8f['offset']=qs[_0xa184('0x23')](_0x4f9e60['query'][_0xa184('0x23')]);}_0x552c8f[_0xa184('0x3e')]=qs['sort'](_0x4f9e60[_0xa184('0x37')][_0xa184('0x3f')]);_0x552c8f[_0xa184('0x40')]=qs[_0xa184('0x39')](_[_0xa184('0x41')](_0x4f9e60[_0xa184('0x37')],_0xfca84c[_0xa184('0x39')]),_0x3b5d58);if(_0x4f9e60[_0xa184('0x37')]['filter']){_0x552c8f[_0xa184('0x40')]=_[_0xa184('0x42')](_0x552c8f[_0xa184('0x40')],{'$or':_['map'](_0x3b5d58,function(_0x43e28c){if(_0x43e28c['type']!==_0xa184('0x43')){var _0x1741d8={};_0x1741d8[_0x43e28c['name']]={'$like':'%'+_0x4f9e60[_0xa184('0x37')][_0xa184('0x44')]+'%'};return _0x1741d8;}})});}_0x552c8f=_['merge']({},_0x552c8f,_0x4f9e60[_0xa184('0x45')]);var _0x1bd6d3={'where':_0x552c8f[_0xa184('0x40')]};return db[_0xa184('0x32')][_0xa184('0x26')](_0x1bd6d3)[_0xa184('0x17')](function(_0x371f){_0xcf3a42[_0xa184('0x26')]=_0x371f;if(_0x4f9e60[_0xa184('0x37')]['includeAll']){_0x552c8f['include']=[{'all':!![]}];}return db[_0xa184('0x32')]['findAll'](_0x552c8f);})[_0xa184('0x17')](function(_0x3a707d){_0xcf3a42['rows']=_0x3a707d;return _0xcf3a42;})[_0xa184('0x17')](respondWithFilteredResult(_0x511dc1,_0x552c8f))['catch'](handleError(_0x511dc1,null));};exports[_0xa184('0x46')]=function(_0x54ebcd,_0x37a84d){var _0x3e26a3={'raw':![],'where':{'id':_0x54ebcd[_0xa184('0x47')]['id']}},_0x5884e0={};_0x5884e0[_0xa184('0x36')]=_[_0xa184('0x38')](db[_0xa184('0x32')][_0xa184('0x48')]);_0x5884e0[_0xa184('0x37')]=_[_0xa184('0x38')](_0x54ebcd[_0xa184('0x37')]);_0x5884e0[_0xa184('0x39')]=_['intersection'](_0x5884e0[_0xa184('0x36')],_0x5884e0[_0xa184('0x37')]);_0x3e26a3[_0xa184('0x3b')]=_[_0xa184('0x3a')](_0x5884e0['model'],qs['fields'](_0x54ebcd[_0xa184('0x37')][_0xa184('0x3c')]));_0x3e26a3[_0xa184('0x3b')]=_0x3e26a3[_0xa184('0x3b')][_0xa184('0x49')]?_0x3e26a3[_0xa184('0x3b')]:_0x5884e0[_0xa184('0x36')];if(_0x54ebcd[_0xa184('0x37')][_0xa184('0x4a')]){_0x3e26a3[_0xa184('0x4b')]=[{'all':!![]}];}_0x3e26a3=_[_0xa184('0x42')]({},_0x3e26a3,_0x54ebcd[_0xa184('0x45')]);return db[_0xa184('0x32')]['find'](_0x3e26a3)[_0xa184('0x17')](handleEntityNotFound(_0x37a84d,null))[_0xa184('0x17')](respondWithResult(_0x37a84d,null))['catch'](handleError(_0x37a84d,null));};exports['create']=function(_0xbf09fd,_0x46af8e,_0x326274){var _0x448b51;return db[_0xa184('0x32')][_0xa184('0x4c')](_0xbf09fd[_0xa184('0x4d')],{'raw':!![]})[_0xa184('0x17')](function(_0x5d41b9){_0x448b51=_0x5d41b9;return db[_0xa184('0x32')][_0xa184('0x4e')]({'raw':!![]});})[_0xa184('0x17')](function(_0x4924e0){var _0x5de205=fs[_0xa184('0x4f')](path[_0xa184('0x50')](config['root'],_0xa184('0x51')),_0xa184('0x52'));var _0x18d956=ejs[_0xa184('0x53')](_0x5de205,{'contexts':_0x4924e0||[]});fs[_0xa184('0x54')](_0xa184('0x55'),_0x18d956);})['then'](function(){return respondWithRpcPromise(_0xa184('0x56'),'create',{'module':_0xa184('0x57')});})['then'](function(){var _0x9df6f3=_0xbf09fd['user'][_0xa184('0x58')]({'plain':!![]});if(!_0x9df6f3)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x9df6f3['role']===_0xa184('0x59')){var _0x4d0191=_0x448b51['get']({'plain':!![]});return db[_0xa184('0x5a')][_0xa184('0x5b')]({'where':{'name':_0xa184('0x5c'),'userProfileId':_0x9df6f3[_0xa184('0x5d')]},'raw':!![]})[_0xa184('0x17')](function(_0x8f73a0){if(_0x8f73a0&&_0x8f73a0[_0xa184('0x5e')]===0x0){return db[_0xa184('0x2d')]['create']({'name':_0x4d0191['name'],'resourceId':_0x4d0191['id'],'type':_0x8f73a0[_0xa184('0x30')],'sectionId':_0x8f73a0['id']},{})[_0xa184('0x17')](function(){return _0x448b51;});}else{return _0x448b51;}})['catch'](function(_0x527663){logger['error'](_0xa184('0x5f'),_0x527663);throw _0x527663;});}return _0x448b51;})[_0xa184('0x17')](respondWithResult(_0x46af8e,0xc9))[_0xa184('0x21')](handleError(_0x46af8e,null));};exports[_0xa184('0x60')]=function(_0x4f2663,_0x7fc577,_0x4691f9){var _0x3c6fdf;return db['VoiceContext'][_0xa184('0x5b')]({'where':{'id':_0x4f2663[_0xa184('0x47')]['id']}})[_0xa184('0x17')](handleEntityNotFound(_0x7fc577,null))[_0xa184('0x17')](saveUpdates(_0x4f2663['body'],null))[_0xa184('0x17')](function(_0x53c47c){if(_0x53c47c){_0x3c6fdf=_0x53c47c;return db[_0xa184('0x32')]['findAll']({'raw':!![]});}})['then'](function(_0x163f31){var _0xcc333=fs['readFileSync'](path[_0xa184('0x50')](config[_0xa184('0x61')],_0xa184('0x51')),'utf8');var _0x200692=ejs[_0xa184('0x53')](_0xcc333,{'contexts':_0x163f31||[]});fs[_0xa184('0x54')](_0xa184('0x55'),_0x200692);})['then'](function(){return respondWithRpcPromise(_0xa184('0x56'),_0xa184('0x60'),{'module':_0xa184('0x57')});})[_0xa184('0x17')](function(){return _0x3c6fdf;})[_0xa184('0x17')](respondWithResult(_0x7fc577,null))[_0xa184('0x21')](handleError(_0x7fc577,null));};exports['destroy']=function(_0x1eace8,_0x1180a6,_0x38b0d6){var _0x53680c;return db[_0xa184('0x32')]['find']({'where':{'id':_0x1eace8['params']['id']}})[_0xa184('0x17')](handleEntityNotFound(_0x1180a6,null))[_0xa184('0x17')](removeEntity(_0x1180a6,null))[_0xa184('0x17')](function(){return db['VoiceContext']['findAll']({'raw':!![]});})[_0xa184('0x17')](function(_0x57e968){var _0x40c24d=fs[_0xa184('0x4f')](path[_0xa184('0x50')](config[_0xa184('0x61')],'server/files/templates/context.ejs'),'utf8');var _0x3a4c16=ejs['render'](_0x40c24d,{'contexts':_0x57e968});fs[_0xa184('0x54')](_0xa184('0x55'),_0x3a4c16);return respondWithRpcPromise(_0xa184('0x56'),_0xa184('0x2c'),{'module':_0xa184('0x57')});})[_0xa184('0x21')](handleError(_0x1180a6,null));};
\ No newline at end of file