Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / voiceContext / voiceContext.controller.js
index d7ed287..bdd0aea 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6b61=['save','update','then','destroy','get','Contexts','UserProfileResource','end','stack','name','send','index','map','VoiceContext','fieldName','key','model','query','intersection','attributes','fields','length','nolimit','order','sort','where','filters','pick','merge','type','filter','options','count','includeAll','include','findAll','rows','show','keys','rawAttributes','find','create','body','readFileSync','join','root','server/files/templates/context.ejs','utf8','render','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','Reload','chan_sip.so','user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','lodash','squel','jsforce','desk.js','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','client','http','debug','error','code','VoiceContext,\x20%s,\x20%s','message','info','request\x20sent','result','catch','sendStatus','status','json','offset','limit','set','Content-Range','reject'];(function(_0x3132e8,_0x499a0e){var _0x43eb8c=function(_0x2321e1){while(--_0x2321e1){_0x3132e8['push'](_0x3132e8['shift']());}};_0x43eb8c(++_0x499a0e);}(_0x6b61,0x16a));var _0x16b6=function(_0x4eec9b,_0x4aea09){_0x4eec9b=_0x4eec9b-0x0;var _0x2e3849=_0x6b61[_0x4eec9b];return _0x2e3849;};'use strict';var pdf=require(_0x16b6('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x16b6('0x1'));var zipdir=require(_0x16b6('0x2'));var jsonpatch=require(_0x16b6('0x3'));var rp=require(_0x16b6('0x4'));var moment=require(_0x16b6('0x5'));var BPromise=require(_0x16b6('0x6'));var Mustache=require(_0x16b6('0x7'));var util=require(_0x16b6('0x8'));var path=require('path');var sox=require(_0x16b6('0x9'));var csv=require(_0x16b6('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x16b6('0xb'));var squel=require(_0x16b6('0xc'));var crypto=require('crypto');var jsforce=require(_0x16b6('0xd'));var deskjs=require(_0x16b6('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x16b6('0xf'));var authService=require('../../components/auth/service');var qs=require(_0x16b6('0x10'));var as=require(_0x16b6('0x11'));var hardwareService=require(_0x16b6('0x12'));var logger=require(_0x16b6('0x13'))(_0x16b6('0x14'));var utils=require(_0x16b6('0x15'));var config=require(_0x16b6('0x16'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var jayson=require('jayson/promise');var client=jayson[_0x16b6('0x17')][_0x16b6('0x18')]({'port':0x232a});function respondWithRpcPromise(_0x22cfba,_0x250b7b,_0x132d71,_0x13158a){return new BPromise(function(_0x37e479,_0x5434c8){var _0x43600e=_0x13158a||client;return _0x43600e['request'](_0x22cfba,_0x132d71)['then'](function(_0x4f8a1e){logger['info']('VoiceContext,\x20%s,\x20%s',_0x250b7b,'request\x20sent');logger[_0x16b6('0x19')]('VoiceContext,\x20%s,\x20%s,\x20%s',_0x250b7b,'request\x20sent',JSON['stringify'](_0x4f8a1e));if(_0x4f8a1e[_0x16b6('0x1a')]){if(_0x4f8a1e[_0x16b6('0x1a')][_0x16b6('0x1b')]===0x1f4){logger[_0x16b6('0x1a')](_0x16b6('0x1c'),_0x250b7b,_0x4f8a1e[_0x16b6('0x1a')][_0x16b6('0x1d')]);return _0x5434c8(_0x4f8a1e[_0x16b6('0x1a')][_0x16b6('0x1d')]);}logger['error'](_0x16b6('0x1c'),_0x250b7b,_0x4f8a1e['error'][_0x16b6('0x1d')]);return _0x37e479(_0x4f8a1e['error']['message']);}else{logger[_0x16b6('0x1e')](_0x16b6('0x1c'),_0x250b7b,_0x16b6('0x1f'));_0x37e479(_0x4f8a1e[_0x16b6('0x20')][_0x16b6('0x1d')]);}})[_0x16b6('0x21')](function(_0x293a67){logger[_0x16b6('0x1a')]('VoiceContext,\x20%s,\x20%s',_0x250b7b,_0x293a67);_0x5434c8(_0x293a67);});});}function respondWithStatusCode(_0x20a807,_0xb56485){_0xb56485=_0xb56485||0xcc;return function(_0x47fcf0){if(_0x47fcf0){return _0x20a807[_0x16b6('0x22')](_0xb56485);}return _0x20a807[_0x16b6('0x23')](_0xb56485)['end']();};}function respondWithResult(_0x35c00e,_0x20995e){_0x20995e=_0x20995e||0xc8;return function(_0x4bb1b1){if(_0x4bb1b1){return _0x35c00e[_0x16b6('0x23')](_0x20995e)[_0x16b6('0x24')](_0x4bb1b1);}};}function respondWithFilteredResult(_0x4be96d,_0x4394e9){return function(_0x2c12aa){if(_0x2c12aa){var _0x4451a1=_0x2c12aa['count'],_0x35b127=_0x4394e9[_0x16b6('0x25')],_0x599aa0=_0x4394e9['offset']+_0x4394e9[_0x16b6('0x26')],_0x44fa79;if(_0x599aa0>=_0x4451a1){_0x599aa0=_0x4451a1;_0x44fa79=0xc8;}else{_0x44fa79=0xce;}_0x4be96d['status'](_0x44fa79);return _0x4be96d[_0x16b6('0x27')](_0x16b6('0x28'),_0x35b127+'-'+_0x599aa0+'/'+_0x4451a1)[_0x16b6('0x24')](_0x2c12aa);}return null;};}function patchUpdates(_0x2c1e63){return function(_0x4e3191){try{jsonpatch['apply'](_0x4e3191,_0x2c1e63,!![]);}catch(_0x278a8c){return BPromise[_0x16b6('0x29')](_0x278a8c);}return _0x4e3191[_0x16b6('0x2a')]();};}function saveUpdates(_0x2314bb,_0x2f1be8){return function(_0x3d6957){if(_0x3d6957){return _0x3d6957[_0x16b6('0x2b')](_0x2314bb)[_0x16b6('0x2c')](function(_0x1c870e){return _0x1c870e;});}return null;};}function removeEntity(_0x4fa98e,_0x2149a3){return function(_0x279047){if(_0x279047){return _0x279047[_0x16b6('0x2d')]()[_0x16b6('0x2c')](function(){var _0x3519cc=_0x279047[_0x16b6('0x2e')]({'plain':!![]});var _0x49ac87=_0x16b6('0x2f');return db[_0x16b6('0x30')]['destroy']({'where':{'type':_0x49ac87,'resourceId':_0x3519cc['id']}})[_0x16b6('0x2c')](function(){return _0x279047;});})['then'](function(){_0x4fa98e[_0x16b6('0x23')](0xcc)[_0x16b6('0x31')]();});}};}function handleEntityNotFound(_0x2b7e36,_0x13af30){return function(_0x197a5b){if(!_0x197a5b){_0x2b7e36[_0x16b6('0x22')](0x194);}return _0x197a5b;};}function handleError(_0x3950ed,_0x1de239){_0x1de239=_0x1de239||0x1f4;return function(_0x163b49){logger[_0x16b6('0x1a')](_0x163b49[_0x16b6('0x32')]);if(_0x163b49[_0x16b6('0x33')]){delete _0x163b49[_0x16b6('0x33')];}_0x3950ed[_0x16b6('0x23')](_0x1de239)[_0x16b6('0x34')](_0x163b49);};}exports[_0x16b6('0x35')]=function(_0x2460fb,_0x34ade4){var _0x5a8be3={},_0x540d28={},_0x71e904={'count':0x0,'rows':[]};var _0x14c640=_[_0x16b6('0x36')](db[_0x16b6('0x37')]['rawAttributes'],function(_0x5af29e){return{'name':_0x5af29e[_0x16b6('0x38')],'type':_0x5af29e['type'][_0x16b6('0x39')]};});_0x540d28[_0x16b6('0x3a')]=_[_0x16b6('0x36')](_0x14c640,'name');_0x540d28[_0x16b6('0x3b')]=_['keys'](_0x2460fb[_0x16b6('0x3b')]);_0x540d28['filters']=_[_0x16b6('0x3c')](_0x540d28[_0x16b6('0x3a')],_0x540d28[_0x16b6('0x3b')]);_0x5a8be3[_0x16b6('0x3d')]=_['intersection'](_0x540d28['model'],qs[_0x16b6('0x3e')](_0x2460fb[_0x16b6('0x3b')]['fields']));_0x5a8be3[_0x16b6('0x3d')]=_0x5a8be3['attributes'][_0x16b6('0x3f')]?_0x5a8be3['attributes']:_0x540d28['model'];if(!_0x2460fb[_0x16b6('0x3b')]['hasOwnProperty'](_0x16b6('0x40'))){_0x5a8be3[_0x16b6('0x26')]=qs[_0x16b6('0x26')](_0x2460fb[_0x16b6('0x3b')][_0x16b6('0x26')]);_0x5a8be3[_0x16b6('0x25')]=qs[_0x16b6('0x25')](_0x2460fb[_0x16b6('0x3b')][_0x16b6('0x25')]);}_0x5a8be3[_0x16b6('0x41')]=qs[_0x16b6('0x42')](_0x2460fb[_0x16b6('0x3b')][_0x16b6('0x42')]);_0x5a8be3[_0x16b6('0x43')]=qs[_0x16b6('0x44')](_[_0x16b6('0x45')](_0x2460fb[_0x16b6('0x3b')],_0x540d28[_0x16b6('0x44')]),_0x14c640);if(_0x2460fb['query']['filter']){_0x5a8be3['where']=_[_0x16b6('0x46')](_0x5a8be3['where'],{'$or':_['map'](_0x14c640,function(_0x33c5b7){if(_0x33c5b7[_0x16b6('0x47')]!=='VIRTUAL'){var _0xea7112={};_0xea7112[_0x33c5b7[_0x16b6('0x33')]]={'$like':'%'+_0x2460fb['query'][_0x16b6('0x48')]+'%'};return _0xea7112;}})});}_0x5a8be3=_[_0x16b6('0x46')]({},_0x5a8be3,_0x2460fb[_0x16b6('0x49')]);var _0x58ee76={'where':_0x5a8be3[_0x16b6('0x43')]};return db[_0x16b6('0x37')][_0x16b6('0x4a')](_0x58ee76)['then'](function(_0x269f94){_0x71e904['count']=_0x269f94;if(_0x2460fb[_0x16b6('0x3b')][_0x16b6('0x4b')]){_0x5a8be3[_0x16b6('0x4c')]=[{'all':!![]}];}return db[_0x16b6('0x37')][_0x16b6('0x4d')](_0x5a8be3);})['then'](function(_0x3fa71b){_0x71e904[_0x16b6('0x4e')]=_0x3fa71b;return _0x71e904;})[_0x16b6('0x2c')](respondWithFilteredResult(_0x34ade4,_0x5a8be3))['catch'](handleError(_0x34ade4,null));};exports[_0x16b6('0x4f')]=function(_0x24b9f3,_0x53d2ca){var _0x445877={'raw':![],'where':{'id':_0x24b9f3['params']['id']}},_0x37b4fb={};_0x37b4fb['model']=_[_0x16b6('0x50')](db[_0x16b6('0x37')][_0x16b6('0x51')]);_0x37b4fb[_0x16b6('0x3b')]=_[_0x16b6('0x50')](_0x24b9f3[_0x16b6('0x3b')]);_0x37b4fb[_0x16b6('0x44')]=_['intersection'](_0x37b4fb[_0x16b6('0x3a')],_0x37b4fb[_0x16b6('0x3b')]);_0x445877['attributes']=_[_0x16b6('0x3c')](_0x37b4fb[_0x16b6('0x3a')],qs[_0x16b6('0x3e')](_0x24b9f3[_0x16b6('0x3b')]['fields']));_0x445877['attributes']=_0x445877[_0x16b6('0x3d')][_0x16b6('0x3f')]?_0x445877[_0x16b6('0x3d')]:_0x37b4fb[_0x16b6('0x3a')];if(_0x24b9f3[_0x16b6('0x3b')][_0x16b6('0x4b')]){_0x445877[_0x16b6('0x4c')]=[{'all':!![]}];}_0x445877=_[_0x16b6('0x46')]({},_0x445877,_0x24b9f3[_0x16b6('0x49')]);return db['VoiceContext'][_0x16b6('0x52')](_0x445877)[_0x16b6('0x2c')](handleEntityNotFound(_0x53d2ca,null))[_0x16b6('0x2c')](respondWithResult(_0x53d2ca,null))[_0x16b6('0x21')](handleError(_0x53d2ca,null));};exports[_0x16b6('0x53')]=function(_0x4b7ad4,_0x141fe9,_0x47f8e5){var _0x199285;return db[_0x16b6('0x37')][_0x16b6('0x53')](_0x4b7ad4[_0x16b6('0x54')],{'raw':!![]})[_0x16b6('0x2c')](function(_0x5c49bc){_0x199285=_0x5c49bc;return db[_0x16b6('0x37')][_0x16b6('0x4d')]({'raw':!![]});})[_0x16b6('0x2c')](function(_0x2d9b2f){var _0x39d621=fs[_0x16b6('0x55')](path[_0x16b6('0x56')](config[_0x16b6('0x57')],_0x16b6('0x58')),_0x16b6('0x59'));var _0x110a2e=ejs[_0x16b6('0x5a')](_0x39d621,{'contexts':_0x2d9b2f||[]});fs[_0x16b6('0x5b')](_0x16b6('0x5c'),_0x110a2e);})[_0x16b6('0x2c')](function(){return respondWithRpcPromise(_0x16b6('0x5d'),_0x16b6('0x53'),{'module':_0x16b6('0x5e')});})[_0x16b6('0x2c')](function(){var _0x4e61d8=_0x4b7ad4[_0x16b6('0x5f')][_0x16b6('0x2e')]({'plain':!![]});if(!_0x4e61d8)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x4e61d8[_0x16b6('0x60')]===_0x16b6('0x5f')){var _0x47d5ba=_0x199285[_0x16b6('0x2e')]({'plain':!![]});return db[_0x16b6('0x61')][_0x16b6('0x52')]({'where':{'name':_0x16b6('0x2f'),'userProfileId':_0x4e61d8['userProfileId']},'raw':!![]})[_0x16b6('0x2c')](function(_0x314699){if(_0x314699&&_0x314699[_0x16b6('0x62')]===0x0){return db[_0x16b6('0x30')][_0x16b6('0x53')]({'name':_0x47d5ba[_0x16b6('0x33')],'resourceId':_0x47d5ba['id'],'type':_0x314699['name'],'sectionId':_0x314699['id']},{})[_0x16b6('0x2c')](function(){return _0x199285;});}else{return _0x199285;}})[_0x16b6('0x21')](function(_0x3f26a0){logger[_0x16b6('0x1a')](_0x16b6('0x63'),_0x3f26a0);throw _0x3f26a0;});}return _0x199285;})[_0x16b6('0x2c')](respondWithResult(_0x141fe9,0xc9))[_0x16b6('0x21')](handleError(_0x141fe9,null));};exports[_0x16b6('0x2b')]=function(_0x496e34,_0x12f658,_0x84022){var _0x477ae5;return db[_0x16b6('0x37')][_0x16b6('0x52')]({'where':{'id':_0x496e34[_0x16b6('0x64')]['id']}})['then'](handleEntityNotFound(_0x12f658,null))['then'](saveUpdates(_0x496e34[_0x16b6('0x54')],null))['then'](function(_0x150607){if(_0x150607){_0x477ae5=_0x150607;return db[_0x16b6('0x37')][_0x16b6('0x4d')]({'raw':!![]});}})[_0x16b6('0x2c')](function(_0x2bf2da){var _0x348fa8=fs[_0x16b6('0x55')](path[_0x16b6('0x56')](config[_0x16b6('0x57')],_0x16b6('0x58')),_0x16b6('0x59'));var _0x3e099a=ejs[_0x16b6('0x5a')](_0x348fa8,{'contexts':_0x2bf2da||[]});fs['writeFileSync']('/etc/asterisk/extensions_xcally_contexts.conf',_0x3e099a);})['then'](function(){return respondWithRpcPromise('Reload','update',{'module':_0x16b6('0x5e')});})[_0x16b6('0x2c')](function(){return _0x477ae5;})['then'](respondWithResult(_0x12f658,null))[_0x16b6('0x21')](handleError(_0x12f658,null));};exports['destroy']=function(_0x580c26,_0x23803a,_0x39d2c9){var _0x1535ad;return db[_0x16b6('0x37')][_0x16b6('0x52')]({'where':{'id':_0x580c26[_0x16b6('0x64')]['id']}})[_0x16b6('0x2c')](handleEntityNotFound(_0x23803a,null))[_0x16b6('0x2c')](removeEntity(_0x23803a,null))['then'](function(){return db[_0x16b6('0x37')][_0x16b6('0x4d')]({'raw':!![]});})[_0x16b6('0x2c')](function(_0x541a5c){var _0x398e6f=fs[_0x16b6('0x55')](path[_0x16b6('0x56')](config['root'],'server/files/templates/context.ejs'),_0x16b6('0x59'));var _0x18193f=ejs[_0x16b6('0x5a')](_0x398e6f,{'contexts':_0x541a5c});fs[_0x16b6('0x5b')](_0x16b6('0x5c'),_0x18193f);return respondWithRpcPromise(_0x16b6('0x5d'),'destroy',{'module':_0x16b6('0x5e')});})[_0x16b6('0x21')](handleError(_0x23803a,null));};
\ No newline at end of file
+var _0xa8d9=['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','count','limit','Content-Range','apply','reject','save','update','destroy','get','Contexts','UserProfileResource','stack','name','index','map','VoiceContext','fieldName','type','key','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','options','include','rows','show','rawAttributes','includeAll','find','create','findAll','join','root','server/files/templates/context.ejs','utf8','render','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','Reload','chan_sip.so','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','rimraf','zip-dir','moment','mustache','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','client','http','request','then','info'];(function(_0x1399d6,_0x2c1661){var _0x4a9db4=function(_0x4666b8){while(--_0x4666b8){_0x1399d6['push'](_0x1399d6['shift']());}};_0x4a9db4(++_0x2c1661);}(_0xa8d9,0xb0));var _0x9a8d=function(_0x2dafbe,_0x5d04de){_0x2dafbe=_0x2dafbe-0x0;var _0x58a45a=_0xa8d9[_0x2dafbe];return _0x58a45a;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x9a8d('0x0'));var zipdir=require(_0x9a8d('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x9a8d('0x2'));var BPromise=require('bluebird');var Mustache=require(_0x9a8d('0x3'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0x9a8d('0x4'));var ejs=require(_0x9a8d('0x5'));var fs=require('fs');var fs_extra=require(_0x9a8d('0x6'));var _=require(_0x9a8d('0x7'));var squel=require(_0x9a8d('0x8'));var crypto=require(_0x9a8d('0x9'));var jsforce=require('jsforce');var deskjs=require(_0x9a8d('0xa'));var toCsv=require(_0x9a8d('0x4'));var querystring=require(_0x9a8d('0xb'));var Papa=require(_0x9a8d('0xc'));var Redis=require(_0x9a8d('0xd'));var authService=require(_0x9a8d('0xe'));var qs=require(_0x9a8d('0xf'));var as=require(_0x9a8d('0x10'));var hardwareService=require(_0x9a8d('0x11'));var logger=require(_0x9a8d('0x12'))(_0x9a8d('0x13'));var utils=require(_0x9a8d('0x14'));var config=require(_0x9a8d('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0x9a8d('0x16'))['db'];var jayson=require('jayson/promise');var client=jayson[_0x9a8d('0x17')][_0x9a8d('0x18')]({'port':0x232a});function respondWithRpcPromise(_0x58d7bc,_0x11ccb0,_0x36ab9b,_0x156ada){return new BPromise(function(_0x3c6e22,_0x5d4c52){var _0x2dc875=_0x156ada||client;return _0x2dc875[_0x9a8d('0x19')](_0x58d7bc,_0x36ab9b)[_0x9a8d('0x1a')](function(_0x22efce){logger[_0x9a8d('0x1b')](_0x9a8d('0x1c'),_0x11ccb0,_0x9a8d('0x1d'));logger[_0x9a8d('0x1e')](_0x9a8d('0x1f'),_0x11ccb0,_0x9a8d('0x1d'),JSON[_0x9a8d('0x20')](_0x22efce));if(_0x22efce[_0x9a8d('0x21')]){if(_0x22efce[_0x9a8d('0x21')][_0x9a8d('0x22')]===0x1f4){logger[_0x9a8d('0x21')](_0x9a8d('0x1c'),_0x11ccb0,_0x22efce[_0x9a8d('0x21')]['message']);return _0x5d4c52(_0x22efce['error'][_0x9a8d('0x23')]);}logger[_0x9a8d('0x21')](_0x9a8d('0x1c'),_0x11ccb0,_0x22efce[_0x9a8d('0x21')][_0x9a8d('0x23')]);return _0x3c6e22(_0x22efce[_0x9a8d('0x21')]['message']);}else{logger[_0x9a8d('0x1b')]('VoiceContext,\x20%s,\x20%s',_0x11ccb0,_0x9a8d('0x1d'));_0x3c6e22(_0x22efce[_0x9a8d('0x24')]['message']);}})[_0x9a8d('0x25')](function(_0x28e964){logger[_0x9a8d('0x21')](_0x9a8d('0x1c'),_0x11ccb0,_0x28e964);_0x5d4c52(_0x28e964);});});}function respondWithStatusCode(_0x59465a,_0x148d49){_0x148d49=_0x148d49||0xcc;return function(_0x422ee7){if(_0x422ee7){return _0x59465a[_0x9a8d('0x26')](_0x148d49);}return _0x59465a[_0x9a8d('0x27')](_0x148d49)[_0x9a8d('0x28')]();};}function respondWithResult(_0x5e4e00,_0x31e403){_0x31e403=_0x31e403||0xc8;return function(_0x3f4f44){if(_0x3f4f44){return _0x5e4e00['status'](_0x31e403)[_0x9a8d('0x29')](_0x3f4f44);}};}function respondWithFilteredResult(_0x56aae2,_0x37645e){return function(_0x597088){if(_0x597088){var _0x2ed1aa=typeof _0x37645e[_0x9a8d('0x2a')]==='undefined'&&typeof _0x37645e['limit']==='undefined';var _0x5e315b=_0x597088['count'];var _0x1973cd=_0x2ed1aa?0x0:_0x37645e[_0x9a8d('0x2a')];var _0x3c7830=_0x2ed1aa?_0x597088[_0x9a8d('0x2b')]:_0x37645e[_0x9a8d('0x2a')]+_0x37645e[_0x9a8d('0x2c')];var _0x122c00;if(_0x3c7830>=_0x5e315b){_0x3c7830=_0x5e315b;_0x122c00=0xc8;}else{_0x122c00=0xce;}_0x56aae2[_0x9a8d('0x27')](_0x122c00);return _0x56aae2['set'](_0x9a8d('0x2d'),_0x1973cd+'-'+_0x3c7830+'/'+_0x5e315b)['json'](_0x597088);}return null;};}function patchUpdates(_0x1c4f58){return function(_0x2795a4){try{jsonpatch[_0x9a8d('0x2e')](_0x2795a4,_0x1c4f58,!![]);}catch(_0x4c0e9c){return BPromise[_0x9a8d('0x2f')](_0x4c0e9c);}return _0x2795a4[_0x9a8d('0x30')]();};}function saveUpdates(_0x221799,_0xbb2f76){return function(_0x3b1fd5){if(_0x3b1fd5){return _0x3b1fd5[_0x9a8d('0x31')](_0x221799)[_0x9a8d('0x1a')](function(_0xdba7ec){return _0xdba7ec;});}return null;};}function removeEntity(_0x73f786,_0x10eef2){return function(_0x233096){if(_0x233096){return _0x233096[_0x9a8d('0x32')]()[_0x9a8d('0x1a')](function(){var _0x589e1b=_0x233096[_0x9a8d('0x33')]({'plain':!![]});var _0x5e7265=_0x9a8d('0x34');return db[_0x9a8d('0x35')][_0x9a8d('0x32')]({'where':{'type':_0x5e7265,'resourceId':_0x589e1b['id']}})['then'](function(){return _0x233096;});})[_0x9a8d('0x1a')](function(){_0x73f786[_0x9a8d('0x27')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3f4d1e,_0x21eee5){return function(_0x2b8e67){if(!_0x2b8e67){_0x3f4d1e[_0x9a8d('0x26')](0x194);}return _0x2b8e67;};}function handleError(_0x55f34c,_0x4750c7){_0x4750c7=_0x4750c7||0x1f4;return function(_0xa83847){logger[_0x9a8d('0x21')](_0xa83847[_0x9a8d('0x36')]);if(_0xa83847[_0x9a8d('0x37')]){delete _0xa83847['name'];}_0x55f34c[_0x9a8d('0x27')](_0x4750c7)['send'](_0xa83847);};}exports[_0x9a8d('0x38')]=function(_0x36d38f,_0x287be8){var _0x46b7b2={},_0x4fcb59={},_0xa1674f={'count':0x0,'rows':[]};var _0x564706=_[_0x9a8d('0x39')](db[_0x9a8d('0x3a')]['rawAttributes'],function(_0x5af7bf){return{'name':_0x5af7bf[_0x9a8d('0x3b')],'type':_0x5af7bf[_0x9a8d('0x3c')][_0x9a8d('0x3d')]};});_0x4fcb59[_0x9a8d('0x3e')]=_['map'](_0x564706,_0x9a8d('0x37'));_0x4fcb59['query']=_['keys'](_0x36d38f[_0x9a8d('0x3f')]);_0x4fcb59[_0x9a8d('0x40')]=_[_0x9a8d('0x41')](_0x4fcb59[_0x9a8d('0x3e')],_0x4fcb59['query']);_0x46b7b2['attributes']=_[_0x9a8d('0x41')](_0x4fcb59[_0x9a8d('0x3e')],qs[_0x9a8d('0x42')](_0x36d38f[_0x9a8d('0x3f')][_0x9a8d('0x42')]));_0x46b7b2[_0x9a8d('0x43')]=_0x46b7b2[_0x9a8d('0x43')][_0x9a8d('0x44')]?_0x46b7b2[_0x9a8d('0x43')]:_0x4fcb59[_0x9a8d('0x3e')];if(!_0x36d38f['query'][_0x9a8d('0x45')](_0x9a8d('0x46'))){_0x46b7b2[_0x9a8d('0x2c')]=qs[_0x9a8d('0x2c')](_0x36d38f[_0x9a8d('0x3f')]['limit']);_0x46b7b2['offset']=qs[_0x9a8d('0x2a')](_0x36d38f[_0x9a8d('0x3f')][_0x9a8d('0x2a')]);}_0x46b7b2[_0x9a8d('0x47')]=qs[_0x9a8d('0x48')](_0x36d38f[_0x9a8d('0x3f')][_0x9a8d('0x48')]);_0x46b7b2['where']=qs[_0x9a8d('0x40')](_[_0x9a8d('0x49')](_0x36d38f[_0x9a8d('0x3f')],_0x4fcb59['filters']),_0x564706);if(_0x36d38f[_0x9a8d('0x3f')][_0x9a8d('0x4a')]){_0x46b7b2[_0x9a8d('0x4b')]=_['merge'](_0x46b7b2[_0x9a8d('0x4b')],{'$or':_[_0x9a8d('0x39')](_0x564706,function(_0xe9345c){if(_0xe9345c[_0x9a8d('0x3c')]!=='VIRTUAL'){var _0x33b858={};_0x33b858[_0xe9345c[_0x9a8d('0x37')]]={'$like':'%'+_0x36d38f['query'][_0x9a8d('0x4a')]+'%'};return _0x33b858;}})});}_0x46b7b2=_[_0x9a8d('0x4c')]({},_0x46b7b2,_0x36d38f[_0x9a8d('0x4d')]);var _0xd5526e={'where':_0x46b7b2['where']};return db['VoiceContext'][_0x9a8d('0x2b')](_0xd5526e)[_0x9a8d('0x1a')](function(_0x128542){_0xa1674f[_0x9a8d('0x2b')]=_0x128542;if(_0x36d38f[_0x9a8d('0x3f')]['includeAll']){_0x46b7b2[_0x9a8d('0x4e')]=[{'all':!![]}];}return db[_0x9a8d('0x3a')]['findAll'](_0x46b7b2);})['then'](function(_0x5601b6){_0xa1674f[_0x9a8d('0x4f')]=_0x5601b6;return _0xa1674f;})[_0x9a8d('0x1a')](respondWithFilteredResult(_0x287be8,_0x46b7b2))[_0x9a8d('0x25')](handleError(_0x287be8,null));};exports[_0x9a8d('0x50')]=function(_0x43c324,_0x5cde7b){var _0x9d9103={'raw':![],'where':{'id':_0x43c324['params']['id']}},_0x41f6f1={};_0x41f6f1[_0x9a8d('0x3e')]=_['keys'](db[_0x9a8d('0x3a')][_0x9a8d('0x51')]);_0x41f6f1[_0x9a8d('0x3f')]=_['keys'](_0x43c324['query']);_0x41f6f1[_0x9a8d('0x40')]=_[_0x9a8d('0x41')](_0x41f6f1['model'],_0x41f6f1[_0x9a8d('0x3f')]);_0x9d9103[_0x9a8d('0x43')]=_[_0x9a8d('0x41')](_0x41f6f1[_0x9a8d('0x3e')],qs[_0x9a8d('0x42')](_0x43c324[_0x9a8d('0x3f')]['fields']));_0x9d9103[_0x9a8d('0x43')]=_0x9d9103[_0x9a8d('0x43')][_0x9a8d('0x44')]?_0x9d9103[_0x9a8d('0x43')]:_0x41f6f1['model'];if(_0x43c324[_0x9a8d('0x3f')][_0x9a8d('0x52')]){_0x9d9103['include']=[{'all':!![]}];}_0x9d9103=_['merge']({},_0x9d9103,_0x43c324[_0x9a8d('0x4d')]);return db[_0x9a8d('0x3a')][_0x9a8d('0x53')](_0x9d9103)[_0x9a8d('0x1a')](handleEntityNotFound(_0x5cde7b,null))[_0x9a8d('0x1a')](respondWithResult(_0x5cde7b,null))['catch'](handleError(_0x5cde7b,null));};exports[_0x9a8d('0x54')]=function(_0x9b5db0,_0x18be93,_0x3b3769){var _0xb22004;return db[_0x9a8d('0x3a')][_0x9a8d('0x54')](_0x9b5db0['body'],{'raw':!![]})[_0x9a8d('0x1a')](function(_0x388610){_0xb22004=_0x388610;return db[_0x9a8d('0x3a')][_0x9a8d('0x55')]({'raw':!![]});})[_0x9a8d('0x1a')](function(_0x42f2a3){var _0x6a9eb5=fs['readFileSync'](path[_0x9a8d('0x56')](config[_0x9a8d('0x57')],_0x9a8d('0x58')),_0x9a8d('0x59'));var _0x31a39d=ejs[_0x9a8d('0x5a')](_0x6a9eb5,{'contexts':_0x42f2a3||[]});fs[_0x9a8d('0x5b')](_0x9a8d('0x5c'),_0x31a39d);})['then'](function(){return respondWithRpcPromise(_0x9a8d('0x5d'),_0x9a8d('0x54'),{'module':_0x9a8d('0x5e')});})['then'](function(){var _0x273e6e=_0x9b5db0[_0x9a8d('0x5f')][_0x9a8d('0x33')]({'plain':!![]});if(!_0x273e6e)throw new Error(_0x9a8d('0x60'));if(_0x273e6e[_0x9a8d('0x61')]===_0x9a8d('0x5f')){var _0x1e8025=_0xb22004[_0x9a8d('0x33')]({'plain':!![]});return db[_0x9a8d('0x62')][_0x9a8d('0x53')]({'where':{'name':_0x9a8d('0x34'),'userProfileId':_0x273e6e[_0x9a8d('0x63')]},'raw':!![]})['then'](function(_0x39bb60){if(_0x39bb60&&_0x39bb60['autoAssociation']===0x0){return db[_0x9a8d('0x35')]['create']({'name':_0x1e8025['name'],'resourceId':_0x1e8025['id'],'type':_0x39bb60[_0x9a8d('0x37')],'sectionId':_0x39bb60['id']},{})['then'](function(){return _0xb22004;});}else{return _0xb22004;}})[_0x9a8d('0x25')](function(_0x51ab44){logger[_0x9a8d('0x21')](_0x9a8d('0x64'),_0x51ab44);throw _0x51ab44;});}return _0xb22004;})['then'](respondWithResult(_0x18be93,0xc9))[_0x9a8d('0x25')](handleError(_0x18be93,null));};exports[_0x9a8d('0x31')]=function(_0x328402,_0x2cf25e,_0x2c8b20){var _0x738d9c;return db[_0x9a8d('0x3a')][_0x9a8d('0x53')]({'where':{'id':_0x328402['params']['id']}})[_0x9a8d('0x1a')](handleEntityNotFound(_0x2cf25e,null))[_0x9a8d('0x1a')](saveUpdates(_0x328402[_0x9a8d('0x65')],null))[_0x9a8d('0x1a')](function(_0xab6f04){if(_0xab6f04){_0x738d9c=_0xab6f04;return db[_0x9a8d('0x3a')]['findAll']({'raw':!![]});}})[_0x9a8d('0x1a')](function(_0x4f0afe){var _0x3e4256=fs['readFileSync'](path[_0x9a8d('0x56')](config[_0x9a8d('0x57')],_0x9a8d('0x58')),_0x9a8d('0x59'));var _0x5d3813=ejs['render'](_0x3e4256,{'contexts':_0x4f0afe||[]});fs['writeFileSync'](_0x9a8d('0x5c'),_0x5d3813);})[_0x9a8d('0x1a')](function(){return respondWithRpcPromise('Reload',_0x9a8d('0x31'),{'module':_0x9a8d('0x5e')});})['then'](function(){return _0x738d9c;})[_0x9a8d('0x1a')](respondWithResult(_0x2cf25e,null))[_0x9a8d('0x25')](handleError(_0x2cf25e,null));};exports[_0x9a8d('0x32')]=function(_0x2b4ba1,_0x4298e4,_0x2be86d){var _0xf87b5f;return db[_0x9a8d('0x3a')]['find']({'where':{'id':_0x2b4ba1['params']['id']}})[_0x9a8d('0x1a')](handleEntityNotFound(_0x4298e4,null))['then'](removeEntity(_0x4298e4,null))[_0x9a8d('0x1a')](function(){return db['VoiceContext'][_0x9a8d('0x55')]({'raw':!![]});})[_0x9a8d('0x1a')](function(_0x173d01){var _0xbc89a3=fs['readFileSync'](path['join'](config['root'],_0x9a8d('0x58')),_0x9a8d('0x59'));var _0x2a8107=ejs[_0x9a8d('0x5a')](_0xbc89a3,{'contexts':_0x173d01});fs['writeFileSync'](_0x9a8d('0x5c'),_0x2a8107);return respondWithRpcPromise(_0x9a8d('0x5d'),_0x9a8d('0x32'),{'module':_0x9a8d('0x5e')});})[_0x9a8d('0x25')](handleError(_0x4298e4,null));};
\ No newline at end of file