Built motion from commit (unavailable).|2.5.19
[motion2.git] / server / api / voiceContext / voiceContext.controller.js
index 341da9a..3317fbb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4b87=['keys','filters','intersection','model','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','filter','name','merge','options','include','findAll','rows','show','params','rawAttributes','length','includeAll','find','create','body','join','server/files/templates/context.ejs','utf8','render','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','Reload','chan_sip.so','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','readFileSync','root','html-pdf','eml-format','rimraf','zip-dir','bluebird','mustache','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','api','../../config/utils','../../config/environment','../../mysqldb','client','test','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','then','info','VoiceContext,\x20%s,\x20%s','debug','VoiceContext,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','sendStatus','status','end','json','count','offset','limit','Content-Range','apply','reject','save','update','destroy','get','UserProfileResource','send','map','VoiceContext','fieldName','type','key','query'];(function(_0xf52fb6,_0x550581){var _0x4784df=function(_0x283622){while(--_0x283622){_0xf52fb6['push'](_0xf52fb6['shift']());}};_0x4784df(++_0x550581);}(_0x4b87,0x1cc));var _0x74b8=function(_0x50d198,_0x3f1125){_0x50d198=_0x50d198-0x0;var _0x363f05=_0x4b87[_0x50d198];return _0x363f05;};'use strict';var pdf=require(_0x74b8('0x0'));var emlformat=require(_0x74b8('0x1'));var rimraf=require(_0x74b8('0x2'));var zipdir=require(_0x74b8('0x3'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x74b8('0x4'));var Mustache=require(_0x74b8('0x5'));var util=require(_0x74b8('0x6'));var path=require(_0x74b8('0x7'));var sox=require(_0x74b8('0x8'));var csv=require(_0x74b8('0x9'));var ejs=require(_0x74b8('0xa'));var fs=require('fs');var _=require('lodash');var squel=require(_0x74b8('0xb'));var crypto=require(_0x74b8('0xc'));var jsforce=require(_0x74b8('0xd'));var deskjs=require(_0x74b8('0xe'));var toCsv=require(_0x74b8('0x9'));var querystring=require(_0x74b8('0xf'));var Papa=require(_0x74b8('0x10'));var Redis=require('ioredis');var authService=require(_0x74b8('0x11'));var qs=require(_0x74b8('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x74b8('0x13'));var utils=require(_0x74b8('0x14'));var config=require(_0x74b8('0x15'));var db=require(_0x74b8('0x16'))['db'];var jayson=require('jayson/promise');var client=jayson[_0x74b8('0x17')]['http']({'port':0x232a});function checkPasswordPattern(_0x3c08aa,_0x1b849,_0x3ce59a){if(_0x3ce59a){var _0x302152=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x302152[_0x74b8('0x18')](_0x1b849)){return _0x3c08aa;}else{throw new db['Sequelize']['ValidationError'](_0x74b8('0x19'));}}else{return _0x3c08aa;}}function respondWithRpcPromise(_0x4be270,_0x1896e8,_0x4f4a6e,_0x59b71f){return new BPromise(function(_0x2625f6,_0x483537){var _0x2a0251=_0x59b71f||client;return _0x2a0251['request'](_0x4be270,_0x4f4a6e)[_0x74b8('0x1a')](function(_0x723e6d){logger[_0x74b8('0x1b')](_0x74b8('0x1c'),_0x1896e8,'request\x20sent');logger[_0x74b8('0x1d')](_0x74b8('0x1e'),_0x1896e8,_0x74b8('0x1f'),JSON[_0x74b8('0x20')](_0x723e6d));if(_0x723e6d[_0x74b8('0x21')]){if(_0x723e6d[_0x74b8('0x21')][_0x74b8('0x22')]===0x1f4){logger[_0x74b8('0x21')](_0x74b8('0x1c'),_0x1896e8,_0x723e6d[_0x74b8('0x21')][_0x74b8('0x23')]);return _0x483537(_0x723e6d[_0x74b8('0x21')][_0x74b8('0x23')]);}logger[_0x74b8('0x21')]('VoiceContext,\x20%s,\x20%s',_0x1896e8,_0x723e6d[_0x74b8('0x21')][_0x74b8('0x23')]);return _0x2625f6(_0x723e6d[_0x74b8('0x21')][_0x74b8('0x23')]);}else{logger[_0x74b8('0x1b')](_0x74b8('0x1c'),_0x1896e8,_0x74b8('0x1f'));_0x2625f6(_0x723e6d[_0x74b8('0x24')][_0x74b8('0x23')]);}})[_0x74b8('0x25')](function(_0x12497f){logger['error'](_0x74b8('0x1c'),_0x1896e8,_0x12497f);_0x483537(_0x12497f);});});}function respondWithStatusCode(_0xfc6ee,_0xed3c9e){_0xed3c9e=_0xed3c9e||0xcc;return function(_0x45af44){if(_0x45af44){return _0xfc6ee[_0x74b8('0x26')](_0xed3c9e);}return _0xfc6ee[_0x74b8('0x27')](_0xed3c9e)[_0x74b8('0x28')]();};}function respondWithResult(_0x10b7a2,_0x421d70){_0x421d70=_0x421d70||0xc8;return function(_0x16a23a){if(_0x16a23a){return _0x10b7a2[_0x74b8('0x27')](_0x421d70)[_0x74b8('0x29')](_0x16a23a);}};}function respondWithFilteredResult(_0x2b5ded,_0x1fb507){return function(_0x1e4ebf){if(_0x1e4ebf){var _0x5df5ea=_0x1e4ebf[_0x74b8('0x2a')],_0x373644=_0x1fb507[_0x74b8('0x2b')],_0x42a26b=_0x1fb507[_0x74b8('0x2b')]+_0x1fb507[_0x74b8('0x2c')],_0xebb8ff;if(_0x42a26b>=_0x5df5ea){_0x42a26b=_0x5df5ea;_0xebb8ff=0xc8;}else{_0xebb8ff=0xce;}_0x2b5ded[_0x74b8('0x27')](_0xebb8ff);return _0x2b5ded['set'](_0x74b8('0x2d'),_0x373644+'-'+_0x42a26b+'/'+_0x5df5ea)[_0x74b8('0x29')](_0x1e4ebf);}return null;};}function patchUpdates(_0x1bf792){return function(_0x3b773a){try{jsonpatch[_0x74b8('0x2e')](_0x3b773a,_0x1bf792,!![]);}catch(_0x48ed5b){return BPromise[_0x74b8('0x2f')](_0x48ed5b);}return _0x3b773a[_0x74b8('0x30')]();};}function saveUpdates(_0x5c0b79,_0x3f36ea){return function(_0x595317){if(_0x595317){return _0x595317[_0x74b8('0x31')](_0x5c0b79)[_0x74b8('0x1a')](function(_0xb350cf){return _0xb350cf;});}return null;};}function removeEntity(_0x4d1005,_0x5851c0){return function(_0x506001){if(_0x506001){return _0x506001[_0x74b8('0x32')]()[_0x74b8('0x1a')](function(){var _0x5a69eb=_0x506001[_0x74b8('0x33')]({'plain':!![]});var _0x1b89b1='Contexts';return db[_0x74b8('0x34')][_0x74b8('0x32')]({'where':{'type':_0x1b89b1,'resourceId':_0x5a69eb['id']}})[_0x74b8('0x1a')](function(){return _0x506001;});})[_0x74b8('0x1a')](function(){_0x4d1005[_0x74b8('0x27')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4114e6,_0x5a4bb9){return function(_0x5680f7){if(!_0x5680f7){_0x4114e6['sendStatus'](0x194);}return _0x5680f7;};}function handleError(_0x335a72,_0x2968e1){_0x2968e1=_0x2968e1||0x1f4;return function(_0x566a25){logger[_0x74b8('0x21')](_0x566a25['stack']);if(_0x566a25['name']){delete _0x566a25['name'];}_0x335a72[_0x74b8('0x27')](_0x2968e1)[_0x74b8('0x35')](_0x566a25);};}exports['index']=function(_0x266367,_0x375b7e){var _0x27d1df={},_0x2c4101={},_0x585823={'count':0x0,'rows':[]};var _0x8672b4=_[_0x74b8('0x36')](db[_0x74b8('0x37')]['rawAttributes'],function(_0x347f5f){return{'name':_0x347f5f[_0x74b8('0x38')],'type':_0x347f5f[_0x74b8('0x39')][_0x74b8('0x3a')]};});_0x2c4101['model']=_[_0x74b8('0x36')](_0x8672b4,'name');_0x2c4101[_0x74b8('0x3b')]=_[_0x74b8('0x3c')](_0x266367[_0x74b8('0x3b')]);_0x2c4101[_0x74b8('0x3d')]=_[_0x74b8('0x3e')](_0x2c4101[_0x74b8('0x3f')],_0x2c4101[_0x74b8('0x3b')]);_0x27d1df['attributes']=_[_0x74b8('0x3e')](_0x2c4101[_0x74b8('0x3f')],qs[_0x74b8('0x40')](_0x266367[_0x74b8('0x3b')][_0x74b8('0x40')]));_0x27d1df[_0x74b8('0x41')]=_0x27d1df['attributes']['length']?_0x27d1df[_0x74b8('0x41')]:_0x2c4101[_0x74b8('0x3f')];if(!_0x266367['query'][_0x74b8('0x42')](_0x74b8('0x43'))){_0x27d1df[_0x74b8('0x2c')]=qs[_0x74b8('0x2c')](_0x266367['query']['limit']);_0x27d1df[_0x74b8('0x2b')]=qs[_0x74b8('0x2b')](_0x266367[_0x74b8('0x3b')][_0x74b8('0x2b')]);}_0x27d1df[_0x74b8('0x44')]=qs[_0x74b8('0x45')](_0x266367['query'][_0x74b8('0x45')]);_0x27d1df[_0x74b8('0x46')]=qs[_0x74b8('0x3d')](_[_0x74b8('0x47')](_0x266367['query'],_0x2c4101[_0x74b8('0x3d')]));if(_0x266367[_0x74b8('0x3b')][_0x74b8('0x48')]){_0x27d1df[_0x74b8('0x46')]=_['merge'](_0x27d1df[_0x74b8('0x46')],{'$or':_[_0x74b8('0x36')](_0x8672b4,function(_0x2fb90b){if(_0x2fb90b['type']!=='VIRTUAL'){var _0x2be3f7={};_0x2be3f7[_0x2fb90b[_0x74b8('0x49')]]={'$like':'%'+_0x266367[_0x74b8('0x3b')]['filter']+'%'};return _0x2be3f7;}})});}_0x27d1df=_[_0x74b8('0x4a')]({},_0x27d1df,_0x266367[_0x74b8('0x4b')]);var _0x4d7f4c={'where':_0x27d1df[_0x74b8('0x46')]};return db[_0x74b8('0x37')]['count'](_0x4d7f4c)[_0x74b8('0x1a')](function(_0x2a945b){_0x585823[_0x74b8('0x2a')]=_0x2a945b;if(_0x266367['query']['includeAll']){_0x27d1df[_0x74b8('0x4c')]=[{'all':!![]}];}return db['VoiceContext'][_0x74b8('0x4d')](_0x27d1df);})[_0x74b8('0x1a')](function(_0x569e0c){_0x585823[_0x74b8('0x4e')]=_0x569e0c;return _0x585823;})[_0x74b8('0x1a')](respondWithFilteredResult(_0x375b7e,_0x27d1df))[_0x74b8('0x25')](handleError(_0x375b7e,null));};exports[_0x74b8('0x4f')]=function(_0x30abf5,_0x4f526e){var _0xfe4838={'raw':![],'where':{'id':_0x30abf5[_0x74b8('0x50')]['id']}},_0x505522={};_0x505522[_0x74b8('0x3f')]=_[_0x74b8('0x3c')](db[_0x74b8('0x37')][_0x74b8('0x51')]);_0x505522[_0x74b8('0x3b')]=_[_0x74b8('0x3c')](_0x30abf5[_0x74b8('0x3b')]);_0x505522[_0x74b8('0x3d')]=_[_0x74b8('0x3e')](_0x505522[_0x74b8('0x3f')],_0x505522[_0x74b8('0x3b')]);_0xfe4838['attributes']=_[_0x74b8('0x3e')](_0x505522['model'],qs[_0x74b8('0x40')](_0x30abf5[_0x74b8('0x3b')][_0x74b8('0x40')]));_0xfe4838[_0x74b8('0x41')]=_0xfe4838[_0x74b8('0x41')][_0x74b8('0x52')]?_0xfe4838[_0x74b8('0x41')]:_0x505522[_0x74b8('0x3f')];if(_0x30abf5[_0x74b8('0x3b')][_0x74b8('0x53')]){_0xfe4838['include']=[{'all':!![]}];}_0xfe4838=_[_0x74b8('0x4a')]({},_0xfe4838,_0x30abf5[_0x74b8('0x4b')]);return db['VoiceContext'][_0x74b8('0x54')](_0xfe4838)[_0x74b8('0x1a')](handleEntityNotFound(_0x4f526e,null))[_0x74b8('0x1a')](respondWithResult(_0x4f526e,null))[_0x74b8('0x25')](handleError(_0x4f526e,null));};exports[_0x74b8('0x55')]=function(_0x5c8597,_0xc056e9,_0x309d5e){var _0x1bdb65;return db[_0x74b8('0x37')]['create'](_0x5c8597[_0x74b8('0x56')],{'raw':!![]})['then'](function(_0x23ee20){_0x1bdb65=_0x23ee20;return db[_0x74b8('0x37')]['findAll']({'raw':!![]});})['then'](function(_0x251f2f){var _0x3f8996=fs['readFileSync'](path[_0x74b8('0x57')](config['root'],_0x74b8('0x58')),_0x74b8('0x59'));var _0x281548=ejs[_0x74b8('0x5a')](_0x3f8996,{'contexts':_0x251f2f||[]});fs[_0x74b8('0x5b')](_0x74b8('0x5c'),_0x281548);})['then'](function(){return respondWithRpcPromise(_0x74b8('0x5d'),'create',{'module':_0x74b8('0x5e')});})[_0x74b8('0x1a')](function(){var _0x511e95=_0x5c8597['user'][_0x74b8('0x33')]({'plain':!![]});if(!_0x511e95)throw new Error(_0x74b8('0x5f'));if(_0x511e95[_0x74b8('0x60')]===_0x74b8('0x61')){var _0x2ab7ce=_0x1bdb65[_0x74b8('0x33')]({'plain':!![]});return db[_0x74b8('0x62')][_0x74b8('0x54')]({'where':{'name':'Contexts','userProfileId':_0x511e95[_0x74b8('0x63')]},'raw':!![]})['then'](function(_0x158e5e){if(_0x158e5e&&_0x158e5e[_0x74b8('0x64')]===0x0){return db[_0x74b8('0x34')][_0x74b8('0x55')]({'name':_0x2ab7ce[_0x74b8('0x49')],'resourceId':_0x2ab7ce['id'],'type':_0x158e5e[_0x74b8('0x49')],'sectionId':_0x158e5e['id']},{})[_0x74b8('0x1a')](function(){return _0x1bdb65;});}else{return _0x1bdb65;}})[_0x74b8('0x25')](function(_0x41fa60){logger['error'](_0x74b8('0x65'),_0x41fa60);throw _0x41fa60;});}return _0x1bdb65;})[_0x74b8('0x1a')](respondWithResult(_0xc056e9,0xc9))[_0x74b8('0x25')](handleError(_0xc056e9,null));};exports[_0x74b8('0x31')]=function(_0x28c2f8,_0x5accb8,_0x5af252){var _0x3e2d01;return db['VoiceContext'][_0x74b8('0x54')]({'where':{'id':_0x28c2f8['params']['id']}})['then'](handleEntityNotFound(_0x5accb8,null))[_0x74b8('0x1a')](saveUpdates(_0x28c2f8['body'],null))[_0x74b8('0x1a')](function(_0x164218){if(_0x164218){_0x3e2d01=_0x164218;return db[_0x74b8('0x37')][_0x74b8('0x4d')]({'raw':!![]});}})['then'](function(_0x528914){var _0x2a3a5b=fs[_0x74b8('0x66')](path[_0x74b8('0x57')](config[_0x74b8('0x67')],_0x74b8('0x58')),_0x74b8('0x59'));var _0x43b888=ejs[_0x74b8('0x5a')](_0x2a3a5b,{'contexts':_0x528914||[]});fs[_0x74b8('0x5b')](_0x74b8('0x5c'),_0x43b888);})[_0x74b8('0x1a')](function(){return respondWithRpcPromise(_0x74b8('0x5d'),_0x74b8('0x31'),{'module':_0x74b8('0x5e')});})[_0x74b8('0x1a')](function(){return _0x3e2d01;})[_0x74b8('0x1a')](respondWithResult(_0x5accb8,null))[_0x74b8('0x25')](handleError(_0x5accb8,null));};exports[_0x74b8('0x32')]=function(_0x17e2b0,_0x565e70,_0x5f029e){var _0xff73a0;return db[_0x74b8('0x37')]['find']({'where':{'id':_0x17e2b0[_0x74b8('0x50')]['id']}})['then'](handleEntityNotFound(_0x565e70,null))['then'](removeEntity(_0x565e70,null))['then'](function(){return db[_0x74b8('0x37')][_0x74b8('0x4d')]({'raw':!![]});})['then'](function(_0x365456){var _0x1b57e8=fs['readFileSync'](path[_0x74b8('0x57')](config[_0x74b8('0x67')],_0x74b8('0x58')),_0x74b8('0x59'));var _0x3e6541=ejs[_0x74b8('0x5a')](_0x1b57e8,{'contexts':_0x365456});fs[_0x74b8('0x5b')](_0x74b8('0x5c'),_0x3e6541);return respondWithRpcPromise(_0x74b8('0x5d'),_0x74b8('0x32'),{'module':_0x74b8('0x5e')});})[_0x74b8('0x25')](handleError(_0x565e70,null));};
\ No newline at end of file
+var _0xc5ba=['client','http','then','info','VoiceContext,\x20%s,\x20%s','request\x20sent','debug','VoiceContext,\x20%s,\x20%s,\x20%s','stringify','error','message','result','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','update','destroy','get','UserProfileResource','stack','name','index','map','VoiceContext','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','nolimit','order','sort','pick','where','merge','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','show','params','keys','fields','length','find','create','body','readFileSync','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','UserProfileSection','userProfileId','autoAssociation','join','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','jayson/promise'];(function(_0x5e21ae,_0x40556b){var _0x5d2729=function(_0x5dcb11){while(--_0x5dcb11){_0x5e21ae['push'](_0x5e21ae['shift']());}};_0x5d2729(++_0x40556b);}(_0xc5ba,0xb9));var _0xac5b=function(_0x592307,_0x2b8719){_0x592307=_0x592307-0x0;var _0x244eb8=_0xc5ba[_0x592307];return _0x244eb8;};'use strict';var pdf=require(_0xac5b('0x0'));var emlformat=require(_0xac5b('0x1'));var rimraf=require(_0xac5b('0x2'));var zipdir=require(_0xac5b('0x3'));var jsonpatch=require(_0xac5b('0x4'));var rp=require(_0xac5b('0x5'));var moment=require(_0xac5b('0x6'));var BPromise=require(_0xac5b('0x7'));var Mustache=require(_0xac5b('0x8'));var util=require(_0xac5b('0x9'));var path=require(_0xac5b('0xa'));var sox=require(_0xac5b('0xb'));var csv=require(_0xac5b('0xc'));var ejs=require(_0xac5b('0xd'));var fs=require('fs');var _=require(_0xac5b('0xe'));var squel=require(_0xac5b('0xf'));var crypto=require(_0xac5b('0x10'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xac5b('0xc'));var querystring=require('querystring');var Papa=require(_0xac5b('0x11'));var Redis=require(_0xac5b('0x12'));var authService=require(_0xac5b('0x13'));var qs=require(_0xac5b('0x14'));var as=require(_0xac5b('0x15'));var hardwareService=require(_0xac5b('0x16'));var logger=require(_0xac5b('0x17'))(_0xac5b('0x18'));var utils=require(_0xac5b('0x19'));var config=require('../../config/environment');var licenseUtil=require(_0xac5b('0x1a'));var db=require(_0xac5b('0x1b'))['db'];var jayson=require(_0xac5b('0x1c'));var client=jayson[_0xac5b('0x1d')][_0xac5b('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x2deb15,_0xa754ff,_0x35eef0,_0x1566a1){return new BPromise(function(_0x58dc98,_0x45372c){var _0xab11ec=_0x1566a1||client;return _0xab11ec['request'](_0x2deb15,_0x35eef0)[_0xac5b('0x1f')](function(_0xe88a79){logger[_0xac5b('0x20')](_0xac5b('0x21'),_0xa754ff,_0xac5b('0x22'));logger[_0xac5b('0x23')](_0xac5b('0x24'),_0xa754ff,_0xac5b('0x22'),JSON[_0xac5b('0x25')](_0xe88a79));if(_0xe88a79[_0xac5b('0x26')]){if(_0xe88a79[_0xac5b('0x26')]['code']===0x1f4){logger[_0xac5b('0x26')]('VoiceContext,\x20%s,\x20%s',_0xa754ff,_0xe88a79[_0xac5b('0x26')]['message']);return _0x45372c(_0xe88a79[_0xac5b('0x26')][_0xac5b('0x27')]);}logger['error']('VoiceContext,\x20%s,\x20%s',_0xa754ff,_0xe88a79['error'][_0xac5b('0x27')]);return _0x58dc98(_0xe88a79['error'][_0xac5b('0x27')]);}else{logger[_0xac5b('0x20')](_0xac5b('0x21'),_0xa754ff,_0xac5b('0x22'));_0x58dc98(_0xe88a79[_0xac5b('0x28')]['message']);}})['catch'](function(_0x5bc6e7){logger[_0xac5b('0x26')]('VoiceContext,\x20%s,\x20%s',_0xa754ff,_0x5bc6e7);_0x45372c(_0x5bc6e7);});});}function respondWithStatusCode(_0x1e3d41,_0x32d186){_0x32d186=_0x32d186||0xcc;return function(_0x5a8a5a){if(_0x5a8a5a){return _0x1e3d41[_0xac5b('0x29')](_0x32d186);}return _0x1e3d41[_0xac5b('0x2a')](_0x32d186)[_0xac5b('0x2b')]();};}function respondWithResult(_0x44209e,_0x3c3b08){_0x3c3b08=_0x3c3b08||0xc8;return function(_0x40e99f){if(_0x40e99f){return _0x44209e[_0xac5b('0x2a')](_0x3c3b08)[_0xac5b('0x2c')](_0x40e99f);}};}function respondWithFilteredResult(_0x220cbd,_0x16a03a){return function(_0x578d11){if(_0x578d11){var _0x2b6211=_0x578d11[_0xac5b('0x2d')],_0xa48194=_0x16a03a[_0xac5b('0x2e')],_0x351d33=_0x16a03a[_0xac5b('0x2e')]+_0x16a03a[_0xac5b('0x2f')],_0x4191a7;if(_0x351d33>=_0x2b6211){_0x351d33=_0x2b6211;_0x4191a7=0xc8;}else{_0x4191a7=0xce;}_0x220cbd[_0xac5b('0x2a')](_0x4191a7);return _0x220cbd[_0xac5b('0x30')](_0xac5b('0x31'),_0xa48194+'-'+_0x351d33+'/'+_0x2b6211)['json'](_0x578d11);}return null;};}function patchUpdates(_0x27891e){return function(_0x367ba9){try{jsonpatch[_0xac5b('0x32')](_0x367ba9,_0x27891e,!![]);}catch(_0x59c870){return BPromise[_0xac5b('0x33')](_0x59c870);}return _0x367ba9['save']();};}function saveUpdates(_0x3b4a99,_0x3c5e8b){return function(_0x2559f8){if(_0x2559f8){return _0x2559f8[_0xac5b('0x34')](_0x3b4a99)['then'](function(_0x1e046a){return _0x1e046a;});}return null;};}function removeEntity(_0x5e8627,_0x486245){return function(_0x23d51d){if(_0x23d51d){return _0x23d51d[_0xac5b('0x35')]()['then'](function(){var _0x529ec5=_0x23d51d[_0xac5b('0x36')]({'plain':!![]});var _0x17577f='Contexts';return db[_0xac5b('0x37')][_0xac5b('0x35')]({'where':{'type':_0x17577f,'resourceId':_0x529ec5['id']}})[_0xac5b('0x1f')](function(){return _0x23d51d;});})['then'](function(){_0x5e8627['status'](0xcc)[_0xac5b('0x2b')]();});}};}function handleEntityNotFound(_0x41bf26,_0x57a460){return function(_0x2f7e7f){if(!_0x2f7e7f){_0x41bf26[_0xac5b('0x29')](0x194);}return _0x2f7e7f;};}function handleError(_0x3f267b,_0x5f1c77){_0x5f1c77=_0x5f1c77||0x1f4;return function(_0x5b8cf6){logger[_0xac5b('0x26')](_0x5b8cf6[_0xac5b('0x38')]);if(_0x5b8cf6[_0xac5b('0x39')]){delete _0x5b8cf6[_0xac5b('0x39')];}_0x3f267b[_0xac5b('0x2a')](_0x5f1c77)['send'](_0x5b8cf6);};}exports[_0xac5b('0x3a')]=function(_0x5e5b1c,_0x2c53c1){var _0x5596cf={},_0x3b08aa={},_0x4337ac={'count':0x0,'rows':[]};var _0x33099a=_[_0xac5b('0x3b')](db[_0xac5b('0x3c')][_0xac5b('0x3d')],function(_0x5e39a1){return{'name':_0x5e39a1[_0xac5b('0x3e')],'type':_0x5e39a1[_0xac5b('0x3f')][_0xac5b('0x40')]};});_0x3b08aa[_0xac5b('0x41')]=_[_0xac5b('0x3b')](_0x33099a,_0xac5b('0x39'));_0x3b08aa[_0xac5b('0x42')]=_['keys'](_0x5e5b1c[_0xac5b('0x42')]);_0x3b08aa[_0xac5b('0x43')]=_[_0xac5b('0x44')](_0x3b08aa[_0xac5b('0x41')],_0x3b08aa[_0xac5b('0x42')]);_0x5596cf[_0xac5b('0x45')]=_['intersection'](_0x3b08aa[_0xac5b('0x41')],qs['fields'](_0x5e5b1c[_0xac5b('0x42')]['fields']));_0x5596cf[_0xac5b('0x45')]=_0x5596cf['attributes']['length']?_0x5596cf['attributes']:_0x3b08aa['model'];if(!_0x5e5b1c['query']['hasOwnProperty'](_0xac5b('0x46'))){_0x5596cf['limit']=qs[_0xac5b('0x2f')](_0x5e5b1c[_0xac5b('0x42')][_0xac5b('0x2f')]);_0x5596cf['offset']=qs['offset'](_0x5e5b1c[_0xac5b('0x42')]['offset']);}_0x5596cf[_0xac5b('0x47')]=qs[_0xac5b('0x48')](_0x5e5b1c[_0xac5b('0x42')][_0xac5b('0x48')]);_0x5596cf['where']=qs[_0xac5b('0x43')](_[_0xac5b('0x49')](_0x5e5b1c[_0xac5b('0x42')],_0x3b08aa['filters']),_0x33099a);if(_0x5e5b1c[_0xac5b('0x42')]['filter']){_0x5596cf[_0xac5b('0x4a')]=_[_0xac5b('0x4b')](_0x5596cf[_0xac5b('0x4a')],{'$or':_['map'](_0x33099a,function(_0x277bed){if(_0x277bed[_0xac5b('0x3f')]!==_0xac5b('0x4c')){var _0x46163a={};_0x46163a[_0x277bed[_0xac5b('0x39')]]={'$like':'%'+_0x5e5b1c[_0xac5b('0x42')][_0xac5b('0x4d')]+'%'};return _0x46163a;}})});}_0x5596cf=_[_0xac5b('0x4b')]({},_0x5596cf,_0x5e5b1c[_0xac5b('0x4e')]);var _0x5bf030={'where':_0x5596cf['where']};return db[_0xac5b('0x3c')]['count'](_0x5bf030)['then'](function(_0x50719d){_0x4337ac['count']=_0x50719d;if(_0x5e5b1c['query'][_0xac5b('0x4f')]){_0x5596cf[_0xac5b('0x50')]=[{'all':!![]}];}return db[_0xac5b('0x3c')][_0xac5b('0x51')](_0x5596cf);})[_0xac5b('0x1f')](function(_0x514ffa){_0x4337ac[_0xac5b('0x52')]=_0x514ffa;return _0x4337ac;})[_0xac5b('0x1f')](respondWithFilteredResult(_0x2c53c1,_0x5596cf))[_0xac5b('0x53')](handleError(_0x2c53c1,null));};exports[_0xac5b('0x54')]=function(_0x166bb1,_0x46836c){var _0x2e5fe8={'raw':![],'where':{'id':_0x166bb1[_0xac5b('0x55')]['id']}},_0x3934ff={};_0x3934ff['model']=_[_0xac5b('0x56')](db[_0xac5b('0x3c')][_0xac5b('0x3d')]);_0x3934ff[_0xac5b('0x42')]=_[_0xac5b('0x56')](_0x166bb1[_0xac5b('0x42')]);_0x3934ff[_0xac5b('0x43')]=_['intersection'](_0x3934ff[_0xac5b('0x41')],_0x3934ff[_0xac5b('0x42')]);_0x2e5fe8['attributes']=_['intersection'](_0x3934ff[_0xac5b('0x41')],qs[_0xac5b('0x57')](_0x166bb1[_0xac5b('0x42')][_0xac5b('0x57')]));_0x2e5fe8[_0xac5b('0x45')]=_0x2e5fe8[_0xac5b('0x45')][_0xac5b('0x58')]?_0x2e5fe8[_0xac5b('0x45')]:_0x3934ff[_0xac5b('0x41')];if(_0x166bb1[_0xac5b('0x42')][_0xac5b('0x4f')]){_0x2e5fe8[_0xac5b('0x50')]=[{'all':!![]}];}_0x2e5fe8=_[_0xac5b('0x4b')]({},_0x2e5fe8,_0x166bb1[_0xac5b('0x4e')]);return db[_0xac5b('0x3c')][_0xac5b('0x59')](_0x2e5fe8)[_0xac5b('0x1f')](handleEntityNotFound(_0x46836c,null))[_0xac5b('0x1f')](respondWithResult(_0x46836c,null))[_0xac5b('0x53')](handleError(_0x46836c,null));};exports[_0xac5b('0x5a')]=function(_0x31cfed,_0x1be6ff,_0x34983f){var _0x45af95;return db[_0xac5b('0x3c')]['create'](_0x31cfed[_0xac5b('0x5b')],{'raw':!![]})[_0xac5b('0x1f')](function(_0x204aa7){_0x45af95=_0x204aa7;return db[_0xac5b('0x3c')]['findAll']({'raw':!![]});})[_0xac5b('0x1f')](function(_0x43f804){var _0x43729e=fs[_0xac5b('0x5c')](path['join'](config[_0xac5b('0x5d')],_0xac5b('0x5e')),_0xac5b('0x5f'));var _0x2bff3f=ejs[_0xac5b('0x60')](_0x43729e,{'contexts':_0x43f804||[]});fs[_0xac5b('0x61')](_0xac5b('0x62'),_0x2bff3f);})['then'](function(){return respondWithRpcPromise(_0xac5b('0x63'),'create',{'module':_0xac5b('0x64')});})[_0xac5b('0x1f')](function(){var _0x13e377=_0x31cfed[_0xac5b('0x65')][_0xac5b('0x36')]({'plain':!![]});if(!_0x13e377)throw new Error(_0xac5b('0x66'));if(_0x13e377['role']===_0xac5b('0x65')){var _0x267db3=_0x45af95['get']({'plain':!![]});return db[_0xac5b('0x67')][_0xac5b('0x59')]({'where':{'name':'Contexts','userProfileId':_0x13e377[_0xac5b('0x68')]},'raw':!![]})['then'](function(_0x3be074){if(_0x3be074&&_0x3be074[_0xac5b('0x69')]===0x0){return db[_0xac5b('0x37')]['create']({'name':_0x267db3[_0xac5b('0x39')],'resourceId':_0x267db3['id'],'type':_0x3be074[_0xac5b('0x39')],'sectionId':_0x3be074['id']},{})[_0xac5b('0x1f')](function(){return _0x45af95;});}else{return _0x45af95;}})[_0xac5b('0x53')](function(_0x3e648f){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x3e648f);throw _0x3e648f;});}return _0x45af95;})['then'](respondWithResult(_0x1be6ff,0xc9))[_0xac5b('0x53')](handleError(_0x1be6ff,null));};exports[_0xac5b('0x34')]=function(_0x2d14da,_0x5e17b8,_0x3ccea0){var _0x1fc9bc;return db[_0xac5b('0x3c')][_0xac5b('0x59')]({'where':{'id':_0x2d14da[_0xac5b('0x55')]['id']}})[_0xac5b('0x1f')](handleEntityNotFound(_0x5e17b8,null))['then'](saveUpdates(_0x2d14da['body'],null))['then'](function(_0x18792a){if(_0x18792a){_0x1fc9bc=_0x18792a;return db[_0xac5b('0x3c')][_0xac5b('0x51')]({'raw':!![]});}})[_0xac5b('0x1f')](function(_0x1bd3b3){var _0x4d2d4d=fs[_0xac5b('0x5c')](path[_0xac5b('0x6a')](config[_0xac5b('0x5d')],_0xac5b('0x5e')),'utf8');var _0x191964=ejs[_0xac5b('0x60')](_0x4d2d4d,{'contexts':_0x1bd3b3||[]});fs['writeFileSync'](_0xac5b('0x62'),_0x191964);})[_0xac5b('0x1f')](function(){return respondWithRpcPromise(_0xac5b('0x63'),'update',{'module':_0xac5b('0x64')});})['then'](function(){return _0x1fc9bc;})[_0xac5b('0x1f')](respondWithResult(_0x5e17b8,null))['catch'](handleError(_0x5e17b8,null));};exports[_0xac5b('0x35')]=function(_0x527b7f,_0x2ae223,_0x5bcc27){var _0x3945c2;return db[_0xac5b('0x3c')][_0xac5b('0x59')]({'where':{'id':_0x527b7f[_0xac5b('0x55')]['id']}})['then'](handleEntityNotFound(_0x2ae223,null))[_0xac5b('0x1f')](removeEntity(_0x2ae223,null))['then'](function(){return db['VoiceContext'][_0xac5b('0x51')]({'raw':!![]});})['then'](function(_0x4f9f15){var _0x2659f2=fs['readFileSync'](path[_0xac5b('0x6a')](config[_0xac5b('0x5d')],_0xac5b('0x5e')),_0xac5b('0x5f'));var _0x485528=ejs[_0xac5b('0x60')](_0x2659f2,{'contexts':_0x4f9f15});fs[_0xac5b('0x61')](_0xac5b('0x62'),_0x485528);return respondWithRpcPromise(_0xac5b('0x63'),_0xac5b('0x35'),{'module':_0xac5b('0x64')});})['catch'](handleError(_0x2ae223,null));};
\ No newline at end of file