Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / voiceContext / voiceContext.controller.js
index bd66c67..65c896d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd52a=['userProfileId','create','server/files/templates/context.ejs','Reload','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','lodash','crypto','desk.js','to-csv','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../mysqldb','jayson/promise','client','http','request','then','info','VoiceContext,\x20%s,\x20%s','request\x20sent','debug','VoiceContext,\x20%s,\x20%s,\x20%s','error','code','message','result','sendStatus','status','count','offset','limit','set','Content-Range','apply','reject','update','destroy','get','Contexts','UserProfileResource','end','stack','name','send','index','map','VoiceContext','rawAttributes','fieldName','type','key','model','keys','filters','intersection','query','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','rows','params','includeAll','find','catch','body','findAll','join','root','utf8','render','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','chan_sip.so','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection'];(function(_0x432724,_0x1b6237){var _0x1a47ef=function(_0x474cf7){while(--_0x474cf7){_0x432724['push'](_0x432724['shift']());}};_0x1a47ef(++_0x1b6237);}(_0xd52a,0xca));var _0xad52=function(_0x538516,_0x4e4006){_0x538516=_0x538516-0x0;var _0x330d8e=_0xd52a[_0x538516];return _0x330d8e;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xad52('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xad52('0x1'));var jsonpatch=require(_0xad52('0x2'));var rp=require(_0xad52('0x3'));var moment=require('moment');var BPromise=require(_0xad52('0x4'));var Mustache=require(_0xad52('0x5'));var util=require(_0xad52('0x6'));var path=require(_0xad52('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0xad52('0x8'));var squel=require('squel');var crypto=require(_0xad52('0x9'));var jsforce=require('jsforce');var deskjs=require(_0xad52('0xa'));var toCsv=require(_0xad52('0xb'));var querystring=require('querystring');var Papa=require(_0xad52('0xc'));var Redis=require('ioredis');var authService=require(_0xad52('0xd'));var qs=require('../../components/parsers/qs');var as=require(_0xad52('0xe'));var hardwareService=require(_0xad52('0xf'));var logger=require(_0xad52('0x10'))(_0xad52('0x11'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xad52('0x12'))['db'];var jayson=require(_0xad52('0x13'));var client=jayson[_0xad52('0x14')][_0xad52('0x15')]({'port':0x232a});function respondWithRpcPromise(_0x11127c,_0x230eaa,_0x16e0f7,_0xd04cde){return new BPromise(function(_0x3d2df6,_0x5727a2){var _0x330794=_0xd04cde||client;return _0x330794[_0xad52('0x16')](_0x11127c,_0x16e0f7)[_0xad52('0x17')](function(_0x42eb20){logger[_0xad52('0x18')](_0xad52('0x19'),_0x230eaa,_0xad52('0x1a'));logger[_0xad52('0x1b')](_0xad52('0x1c'),_0x230eaa,'request\x20sent',JSON['stringify'](_0x42eb20));if(_0x42eb20[_0xad52('0x1d')]){if(_0x42eb20[_0xad52('0x1d')][_0xad52('0x1e')]===0x1f4){logger[_0xad52('0x1d')](_0xad52('0x19'),_0x230eaa,_0x42eb20['error'][_0xad52('0x1f')]);return _0x5727a2(_0x42eb20['error'][_0xad52('0x1f')]);}logger[_0xad52('0x1d')](_0xad52('0x19'),_0x230eaa,_0x42eb20['error'][_0xad52('0x1f')]);return _0x3d2df6(_0x42eb20['error'][_0xad52('0x1f')]);}else{logger[_0xad52('0x18')](_0xad52('0x19'),_0x230eaa,_0xad52('0x1a'));_0x3d2df6(_0x42eb20[_0xad52('0x20')][_0xad52('0x1f')]);}})['catch'](function(_0x7de59d){logger['error'](_0xad52('0x19'),_0x230eaa,_0x7de59d);_0x5727a2(_0x7de59d);});});}function respondWithStatusCode(_0x2acbb4,_0x2fa90c){_0x2fa90c=_0x2fa90c||0xcc;return function(_0x5bce67){if(_0x5bce67){return _0x2acbb4[_0xad52('0x21')](_0x2fa90c);}return _0x2acbb4['status'](_0x2fa90c)['end']();};}function respondWithResult(_0x2809f7,_0x583999){_0x583999=_0x583999||0xc8;return function(_0x477b47){if(_0x477b47){return _0x2809f7[_0xad52('0x22')](_0x583999)['json'](_0x477b47);}};}function respondWithFilteredResult(_0x58adf5,_0xb526bf){return function(_0x31b5e0){if(_0x31b5e0){var _0x42db69=_0x31b5e0[_0xad52('0x23')],_0x50431e=_0xb526bf[_0xad52('0x24')],_0x132e94=_0xb526bf[_0xad52('0x24')]+_0xb526bf[_0xad52('0x25')],_0x5771ce;if(_0x132e94>=_0x42db69){_0x132e94=_0x42db69;_0x5771ce=0xc8;}else{_0x5771ce=0xce;}_0x58adf5['status'](_0x5771ce);return _0x58adf5[_0xad52('0x26')](_0xad52('0x27'),_0x50431e+'-'+_0x132e94+'/'+_0x42db69)['json'](_0x31b5e0);}return null;};}function patchUpdates(_0x3f5757){return function(_0x3a0fd6){try{jsonpatch[_0xad52('0x28')](_0x3a0fd6,_0x3f5757,!![]);}catch(_0x75dfb6){return BPromise[_0xad52('0x29')](_0x75dfb6);}return _0x3a0fd6['save']();};}function saveUpdates(_0x5ccd33,_0x4c389e){return function(_0xc2553d){if(_0xc2553d){return _0xc2553d[_0xad52('0x2a')](_0x5ccd33)[_0xad52('0x17')](function(_0x548d04){return _0x548d04;});}return null;};}function removeEntity(_0x52e3cc,_0x2e77fe){return function(_0x1af23e){if(_0x1af23e){return _0x1af23e[_0xad52('0x2b')]()[_0xad52('0x17')](function(){var _0x919c28=_0x1af23e[_0xad52('0x2c')]({'plain':!![]});var _0x504d75=_0xad52('0x2d');return db[_0xad52('0x2e')][_0xad52('0x2b')]({'where':{'type':_0x504d75,'resourceId':_0x919c28['id']}})[_0xad52('0x17')](function(){return _0x1af23e;});})[_0xad52('0x17')](function(){_0x52e3cc[_0xad52('0x22')](0xcc)[_0xad52('0x2f')]();});}};}function handleEntityNotFound(_0x123f30,_0x3d863d){return function(_0x434762){if(!_0x434762){_0x123f30[_0xad52('0x21')](0x194);}return _0x434762;};}function handleError(_0x5027c1,_0x1745e0){_0x1745e0=_0x1745e0||0x1f4;return function(_0x2c3676){logger[_0xad52('0x1d')](_0x2c3676[_0xad52('0x30')]);if(_0x2c3676[_0xad52('0x31')]){delete _0x2c3676[_0xad52('0x31')];}_0x5027c1['status'](_0x1745e0)[_0xad52('0x32')](_0x2c3676);};}exports[_0xad52('0x33')]=function(_0xc9461d,_0x596a3a){var _0x2ff49c={},_0x1d16b4={},_0x268353={'count':0x0,'rows':[]};var _0x4ad21c=_[_0xad52('0x34')](db[_0xad52('0x35')][_0xad52('0x36')],function(_0x49260f){return{'name':_0x49260f[_0xad52('0x37')],'type':_0x49260f[_0xad52('0x38')][_0xad52('0x39')]};});_0x1d16b4[_0xad52('0x3a')]=_[_0xad52('0x34')](_0x4ad21c,_0xad52('0x31'));_0x1d16b4['query']=_[_0xad52('0x3b')](_0xc9461d['query']);_0x1d16b4[_0xad52('0x3c')]=_[_0xad52('0x3d')](_0x1d16b4[_0xad52('0x3a')],_0x1d16b4[_0xad52('0x3e')]);_0x2ff49c[_0xad52('0x3f')]=_['intersection'](_0x1d16b4[_0xad52('0x3a')],qs[_0xad52('0x40')](_0xc9461d[_0xad52('0x3e')]['fields']));_0x2ff49c[_0xad52('0x3f')]=_0x2ff49c[_0xad52('0x3f')][_0xad52('0x41')]?_0x2ff49c['attributes']:_0x1d16b4[_0xad52('0x3a')];if(!_0xc9461d['query'][_0xad52('0x42')](_0xad52('0x43'))){_0x2ff49c[_0xad52('0x25')]=qs[_0xad52('0x25')](_0xc9461d['query'][_0xad52('0x25')]);_0x2ff49c[_0xad52('0x24')]=qs[_0xad52('0x24')](_0xc9461d[_0xad52('0x3e')][_0xad52('0x24')]);}_0x2ff49c[_0xad52('0x44')]=qs[_0xad52('0x45')](_0xc9461d[_0xad52('0x3e')]['sort']);_0x2ff49c[_0xad52('0x46')]=qs['filters'](_[_0xad52('0x47')](_0xc9461d[_0xad52('0x3e')],_0x1d16b4[_0xad52('0x3c')]),_0x4ad21c);if(_0xc9461d[_0xad52('0x3e')][_0xad52('0x48')]){_0x2ff49c[_0xad52('0x46')]=_[_0xad52('0x49')](_0x2ff49c[_0xad52('0x46')],{'$or':_[_0xad52('0x34')](_0x4ad21c,function(_0x24b970){if(_0x24b970[_0xad52('0x38')]!==_0xad52('0x4a')){var _0x4411eb={};_0x4411eb[_0x24b970[_0xad52('0x31')]]={'$like':'%'+_0xc9461d[_0xad52('0x3e')][_0xad52('0x48')]+'%'};return _0x4411eb;}})});}_0x2ff49c=_[_0xad52('0x49')]({},_0x2ff49c,_0xc9461d[_0xad52('0x4b')]);var _0x711cc6={'where':_0x2ff49c[_0xad52('0x46')]};return db['VoiceContext'][_0xad52('0x23')](_0x711cc6)[_0xad52('0x17')](function(_0x14b87b){_0x268353['count']=_0x14b87b;if(_0xc9461d[_0xad52('0x3e')]['includeAll']){_0x2ff49c[_0xad52('0x4c')]=[{'all':!![]}];}return db['VoiceContext']['findAll'](_0x2ff49c);})[_0xad52('0x17')](function(_0x1746b0){_0x268353[_0xad52('0x4d')]=_0x1746b0;return _0x268353;})[_0xad52('0x17')](respondWithFilteredResult(_0x596a3a,_0x2ff49c))['catch'](handleError(_0x596a3a,null));};exports['show']=function(_0x254416,_0x5dede4){var _0x207096={'raw':![],'where':{'id':_0x254416[_0xad52('0x4e')]['id']}},_0x581f41={};_0x581f41[_0xad52('0x3a')]=_[_0xad52('0x3b')](db[_0xad52('0x35')][_0xad52('0x36')]);_0x581f41[_0xad52('0x3e')]=_['keys'](_0x254416[_0xad52('0x3e')]);_0x581f41[_0xad52('0x3c')]=_[_0xad52('0x3d')](_0x581f41[_0xad52('0x3a')],_0x581f41['query']);_0x207096[_0xad52('0x3f')]=_[_0xad52('0x3d')](_0x581f41[_0xad52('0x3a')],qs['fields'](_0x254416[_0xad52('0x3e')][_0xad52('0x40')]));_0x207096[_0xad52('0x3f')]=_0x207096[_0xad52('0x3f')]['length']?_0x207096[_0xad52('0x3f')]:_0x581f41[_0xad52('0x3a')];if(_0x254416[_0xad52('0x3e')][_0xad52('0x4f')]){_0x207096[_0xad52('0x4c')]=[{'all':!![]}];}_0x207096=_['merge']({},_0x207096,_0x254416['options']);return db[_0xad52('0x35')][_0xad52('0x50')](_0x207096)[_0xad52('0x17')](handleEntityNotFound(_0x5dede4,null))[_0xad52('0x17')](respondWithResult(_0x5dede4,null))[_0xad52('0x51')](handleError(_0x5dede4,null));};exports['create']=function(_0x21f850,_0x4ccf7b,_0x5fe34c){var _0xa72c7;return db[_0xad52('0x35')]['create'](_0x21f850[_0xad52('0x52')],{'raw':!![]})['then'](function(_0x3784b5){_0xa72c7=_0x3784b5;return db[_0xad52('0x35')][_0xad52('0x53')]({'raw':!![]});})['then'](function(_0x490866){var _0xf0fc0d=fs['readFileSync'](path[_0xad52('0x54')](config[_0xad52('0x55')],'server/files/templates/context.ejs'),_0xad52('0x56'));var _0x4b51fd=ejs[_0xad52('0x57')](_0xf0fc0d,{'contexts':_0x490866||[]});fs[_0xad52('0x58')](_0xad52('0x59'),_0x4b51fd);})[_0xad52('0x17')](function(){return respondWithRpcPromise('Reload','create',{'module':_0xad52('0x5a')});})[_0xad52('0x17')](function(){var _0x541fd3=_0x21f850[_0xad52('0x5b')][_0xad52('0x2c')]({'plain':!![]});if(!_0x541fd3)throw new Error(_0xad52('0x5c'));if(_0x541fd3[_0xad52('0x5d')]==='user'){var _0xba9665=_0xa72c7[_0xad52('0x2c')]({'plain':!![]});return db[_0xad52('0x5e')][_0xad52('0x50')]({'where':{'name':_0xad52('0x2d'),'userProfileId':_0x541fd3[_0xad52('0x5f')]},'raw':!![]})[_0xad52('0x17')](function(_0x16807a){if(_0x16807a&&_0x16807a['autoAssociation']===0x0){return db['UserProfileResource'][_0xad52('0x60')]({'name':_0xba9665[_0xad52('0x31')],'resourceId':_0xba9665['id'],'type':_0x16807a[_0xad52('0x31')],'sectionId':_0x16807a['id']},{})['then'](function(){return _0xa72c7;});}else{return _0xa72c7;}})[_0xad52('0x51')](function(_0x805bc3){logger[_0xad52('0x1d')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x805bc3);throw _0x805bc3;});}return _0xa72c7;})[_0xad52('0x17')](respondWithResult(_0x4ccf7b,0xc9))['catch'](handleError(_0x4ccf7b,null));};exports[_0xad52('0x2a')]=function(_0x56fca3,_0x538c7b,_0x3db9d6){var _0x2c6c48;return db['VoiceContext']['find']({'where':{'id':_0x56fca3['params']['id']}})[_0xad52('0x17')](handleEntityNotFound(_0x538c7b,null))[_0xad52('0x17')](saveUpdates(_0x56fca3['body'],null))[_0xad52('0x17')](function(_0x352302){if(_0x352302){_0x2c6c48=_0x352302;return db[_0xad52('0x35')]['findAll']({'raw':!![]});}})[_0xad52('0x17')](function(_0x2622a4){var _0x26935e=fs['readFileSync'](path['join'](config[_0xad52('0x55')],_0xad52('0x61')),_0xad52('0x56'));var _0xe22d76=ejs['render'](_0x26935e,{'contexts':_0x2622a4||[]});fs[_0xad52('0x58')]('/etc/asterisk/extensions_xcally_contexts.conf',_0xe22d76);})[_0xad52('0x17')](function(){return respondWithRpcPromise('Reload',_0xad52('0x2a'),{'module':_0xad52('0x5a')});})[_0xad52('0x17')](function(){return _0x2c6c48;})[_0xad52('0x17')](respondWithResult(_0x538c7b,null))[_0xad52('0x51')](handleError(_0x538c7b,null));};exports[_0xad52('0x2b')]=function(_0xa4097c,_0x15f49d,_0x41b710){var _0x2b71e2;return db[_0xad52('0x35')]['find']({'where':{'id':_0xa4097c['params']['id']}})[_0xad52('0x17')](handleEntityNotFound(_0x15f49d,null))['then'](removeEntity(_0x15f49d,null))[_0xad52('0x17')](function(){return db[_0xad52('0x35')][_0xad52('0x53')]({'raw':!![]});})['then'](function(_0x3b865f){var _0x55b17b=fs['readFileSync'](path[_0xad52('0x54')](config[_0xad52('0x55')],_0xad52('0x61')),_0xad52('0x56'));var _0x72f326=ejs['render'](_0x55b17b,{'contexts':_0x3b865f});fs[_0xad52('0x58')]('/etc/asterisk/extensions_xcally_contexts.conf',_0x72f326);return respondWithRpcPromise(_0xad52('0x62'),_0xad52('0x2b'),{'module':'chan_sip.so'});})[_0xad52('0x51')](handleError(_0x15f49d,null));};
\ No newline at end of file
+var _0x1dc1=['where','options','includeAll','include','findAll','show','rawAttributes','merge','find','create','readFileSync','join','root','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','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','params','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','then','info','VoiceContext,\x20%s,\x20%s','request\x20sent','VoiceContext,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','reject','save','destroy','get','UserProfileResource','name','send','index','map','VoiceContext','fieldName','type','keys','intersection','model','query','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filters','pick','filter'];(function(_0x413feb,_0x10477f){var _0x40ee88=function(_0x32a3f6){while(--_0x32a3f6){_0x413feb['push'](_0x413feb['shift']());}};_0x40ee88(++_0x10477f);}(_0x1dc1,0xe5));var _0x11dc=function(_0x3fdaec,_0x17c64d){_0x3fdaec=_0x3fdaec-0x0;var _0x2e3cb3=_0x1dc1[_0x3fdaec];return _0x2e3cb3;};'use strict';var emlformat=require(_0x11dc('0x0'));var rimraf=require(_0x11dc('0x1'));var zipdir=require(_0x11dc('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x11dc('0x3'));var moment=require(_0x11dc('0x4'));var BPromise=require(_0x11dc('0x5'));var Mustache=require(_0x11dc('0x6'));var util=require(_0x11dc('0x7'));var path=require(_0x11dc('0x8'));var sox=require(_0x11dc('0x9'));var csv=require(_0x11dc('0xa'));var ejs=require(_0x11dc('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x11dc('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x11dc('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x11dc('0xa'));var querystring=require(_0x11dc('0xe'));var Papa=require(_0x11dc('0xf'));var Redis=require(_0x11dc('0x10'));var authService=require(_0x11dc('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x11dc('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x11dc('0x13'))(_0x11dc('0x14'));var utils=require(_0x11dc('0x15'));var config=require(_0x11dc('0x16'));var licenseUtil=require(_0x11dc('0x17'));var db=require(_0x11dc('0x18'))['db'];var jayson=require(_0x11dc('0x19'));var client=jayson[_0x11dc('0x1a')][_0x11dc('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x5ec7f4,_0x46a20f,_0x8d17c0,_0x10b427){return new BPromise(function(_0x368470,_0x1e1e0b){var _0x145b66=_0x10b427||client;return _0x145b66[_0x11dc('0x1c')](_0x5ec7f4,_0x8d17c0)[_0x11dc('0x1d')](function(_0x5edeb8){logger[_0x11dc('0x1e')](_0x11dc('0x1f'),_0x46a20f,_0x11dc('0x20'));logger['debug'](_0x11dc('0x21'),_0x46a20f,_0x11dc('0x20'),JSON[_0x11dc('0x22')](_0x5edeb8));if(_0x5edeb8[_0x11dc('0x23')]){if(_0x5edeb8['error']['code']===0x1f4){logger['error'](_0x11dc('0x1f'),_0x46a20f,_0x5edeb8['error'][_0x11dc('0x24')]);return _0x1e1e0b(_0x5edeb8[_0x11dc('0x23')][_0x11dc('0x24')]);}logger['error'](_0x11dc('0x1f'),_0x46a20f,_0x5edeb8[_0x11dc('0x23')][_0x11dc('0x24')]);return _0x368470(_0x5edeb8[_0x11dc('0x23')][_0x11dc('0x24')]);}else{logger['info']('VoiceContext,\x20%s,\x20%s',_0x46a20f,'request\x20sent');_0x368470(_0x5edeb8['result'][_0x11dc('0x24')]);}})[_0x11dc('0x25')](function(_0x4a1493){logger[_0x11dc('0x23')](_0x11dc('0x1f'),_0x46a20f,_0x4a1493);_0x1e1e0b(_0x4a1493);});});}function respondWithStatusCode(_0x312677,_0x1f9570){_0x1f9570=_0x1f9570||0xcc;return function(_0x4a9874){if(_0x4a9874){return _0x312677[_0x11dc('0x26')](_0x1f9570);}return _0x312677[_0x11dc('0x27')](_0x1f9570)[_0x11dc('0x28')]();};}function respondWithResult(_0x5124dc,_0x39630f){_0x39630f=_0x39630f||0xc8;return function(_0x5a35e5){if(_0x5a35e5){return _0x5124dc[_0x11dc('0x27')](_0x39630f)[_0x11dc('0x29')](_0x5a35e5);}};}function respondWithFilteredResult(_0x41bfca,_0x49bcc0){return function(_0x27bd74){if(_0x27bd74){var _0x40d192=typeof _0x49bcc0[_0x11dc('0x2a')]===_0x11dc('0x2b')&&typeof _0x49bcc0[_0x11dc('0x2c')]===_0x11dc('0x2b');var _0x2284c6=_0x27bd74['count'];var _0x172b43=_0x40d192?0x0:_0x49bcc0['offset'];var _0x4ee65d=_0x40d192?_0x27bd74[_0x11dc('0x2d')]:_0x49bcc0[_0x11dc('0x2a')]+_0x49bcc0[_0x11dc('0x2c')];var _0x2b43c6;if(_0x4ee65d>=_0x2284c6){_0x4ee65d=_0x2284c6;_0x2b43c6=0xc8;}else{_0x2b43c6=0xce;}_0x41bfca[_0x11dc('0x27')](_0x2b43c6);return _0x41bfca[_0x11dc('0x2e')](_0x11dc('0x2f'),_0x172b43+'-'+_0x4ee65d+'/'+_0x2284c6)[_0x11dc('0x29')](_0x27bd74);}return null;};}function patchUpdates(_0x4bc37c){return function(_0x7b74bf){try{jsonpatch['apply'](_0x7b74bf,_0x4bc37c,!![]);}catch(_0x1bf016){return BPromise[_0x11dc('0x30')](_0x1bf016);}return _0x7b74bf[_0x11dc('0x31')]();};}function saveUpdates(_0x294819,_0xa0f6f8){return function(_0x35283a){if(_0x35283a){return _0x35283a['update'](_0x294819)[_0x11dc('0x1d')](function(_0x1d7242){return _0x1d7242;});}return null;};}function removeEntity(_0x6cff2d,_0x3ace28){return function(_0x3ecaa2){if(_0x3ecaa2){return _0x3ecaa2[_0x11dc('0x32')]()[_0x11dc('0x1d')](function(){var _0xcae523=_0x3ecaa2[_0x11dc('0x33')]({'plain':!![]});var _0x1773d1='Contexts';return db[_0x11dc('0x34')][_0x11dc('0x32')]({'where':{'type':_0x1773d1,'resourceId':_0xcae523['id']}})[_0x11dc('0x1d')](function(){return _0x3ecaa2;});})[_0x11dc('0x1d')](function(){_0x6cff2d[_0x11dc('0x27')](0xcc)[_0x11dc('0x28')]();});}};}function handleEntityNotFound(_0x2dd461,_0x42d7f6){return function(_0x55a9ab){if(!_0x55a9ab){_0x2dd461[_0x11dc('0x26')](0x194);}return _0x55a9ab;};}function handleError(_0x1fab53,_0xa9a9d4){_0xa9a9d4=_0xa9a9d4||0x1f4;return function(_0x51fc3e){logger[_0x11dc('0x23')](_0x51fc3e['stack']);if(_0x51fc3e[_0x11dc('0x35')]){delete _0x51fc3e[_0x11dc('0x35')];}_0x1fab53[_0x11dc('0x27')](_0xa9a9d4)[_0x11dc('0x36')](_0x51fc3e);};}exports[_0x11dc('0x37')]=function(_0x3abd51,_0x512e7f){var _0x5aae23={},_0x1839f3={},_0x2daa1f={'count':0x0,'rows':[]};var _0xebce1=_[_0x11dc('0x38')](db[_0x11dc('0x39')]['rawAttributes'],function(_0xcc0f06){return{'name':_0xcc0f06[_0x11dc('0x3a')],'type':_0xcc0f06[_0x11dc('0x3b')]['key']};});_0x1839f3['model']=_[_0x11dc('0x38')](_0xebce1,_0x11dc('0x35'));_0x1839f3['query']=_[_0x11dc('0x3c')](_0x3abd51['query']);_0x1839f3['filters']=_[_0x11dc('0x3d')](_0x1839f3[_0x11dc('0x3e')],_0x1839f3[_0x11dc('0x3f')]);_0x5aae23[_0x11dc('0x40')]=_[_0x11dc('0x3d')](_0x1839f3[_0x11dc('0x3e')],qs[_0x11dc('0x41')](_0x3abd51[_0x11dc('0x3f')]['fields']));_0x5aae23[_0x11dc('0x40')]=_0x5aae23[_0x11dc('0x40')][_0x11dc('0x42')]?_0x5aae23[_0x11dc('0x40')]:_0x1839f3[_0x11dc('0x3e')];if(!_0x3abd51['query'][_0x11dc('0x43')](_0x11dc('0x44'))){_0x5aae23[_0x11dc('0x2c')]=qs[_0x11dc('0x2c')](_0x3abd51[_0x11dc('0x3f')][_0x11dc('0x2c')]);_0x5aae23[_0x11dc('0x2a')]=qs[_0x11dc('0x2a')](_0x3abd51[_0x11dc('0x3f')][_0x11dc('0x2a')]);}_0x5aae23[_0x11dc('0x45')]=qs[_0x11dc('0x46')](_0x3abd51[_0x11dc('0x3f')][_0x11dc('0x46')]);_0x5aae23['where']=qs[_0x11dc('0x47')](_[_0x11dc('0x48')](_0x3abd51['query'],_0x1839f3[_0x11dc('0x47')]),_0xebce1);if(_0x3abd51[_0x11dc('0x3f')][_0x11dc('0x49')]){_0x5aae23[_0x11dc('0x4a')]=_['merge'](_0x5aae23[_0x11dc('0x4a')],{'$or':_[_0x11dc('0x38')](_0xebce1,function(_0x39ce7b){if(_0x39ce7b[_0x11dc('0x3b')]!=='VIRTUAL'){var _0x4af9b6={};_0x4af9b6[_0x39ce7b[_0x11dc('0x35')]]={'$like':'%'+_0x3abd51[_0x11dc('0x3f')]['filter']+'%'};return _0x4af9b6;}})});}_0x5aae23=_['merge']({},_0x5aae23,_0x3abd51[_0x11dc('0x4b')]);var _0x66d235={'where':_0x5aae23[_0x11dc('0x4a')]};return db[_0x11dc('0x39')]['count'](_0x66d235)['then'](function(_0xf97c29){_0x2daa1f[_0x11dc('0x2d')]=_0xf97c29;if(_0x3abd51['query'][_0x11dc('0x4c')]){_0x5aae23[_0x11dc('0x4d')]=[{'all':!![]}];}return db[_0x11dc('0x39')][_0x11dc('0x4e')](_0x5aae23);})[_0x11dc('0x1d')](function(_0x32c856){_0x2daa1f['rows']=_0x32c856;return _0x2daa1f;})[_0x11dc('0x1d')](respondWithFilteredResult(_0x512e7f,_0x5aae23))[_0x11dc('0x25')](handleError(_0x512e7f,null));};exports[_0x11dc('0x4f')]=function(_0x3e2c89,_0x43cce8){var _0x30fffa={'raw':![],'where':{'id':_0x3e2c89['params']['id']}},_0x5159fb={};_0x5159fb[_0x11dc('0x3e')]=_[_0x11dc('0x3c')](db[_0x11dc('0x39')][_0x11dc('0x50')]);_0x5159fb[_0x11dc('0x3f')]=_['keys'](_0x3e2c89[_0x11dc('0x3f')]);_0x5159fb['filters']=_['intersection'](_0x5159fb['model'],_0x5159fb['query']);_0x30fffa[_0x11dc('0x40')]=_['intersection'](_0x5159fb[_0x11dc('0x3e')],qs['fields'](_0x3e2c89[_0x11dc('0x3f')][_0x11dc('0x41')]));_0x30fffa[_0x11dc('0x40')]=_0x30fffa[_0x11dc('0x40')]['length']?_0x30fffa[_0x11dc('0x40')]:_0x5159fb[_0x11dc('0x3e')];if(_0x3e2c89[_0x11dc('0x3f')]['includeAll']){_0x30fffa[_0x11dc('0x4d')]=[{'all':!![]}];}_0x30fffa=_[_0x11dc('0x51')]({},_0x30fffa,_0x3e2c89[_0x11dc('0x4b')]);return db[_0x11dc('0x39')][_0x11dc('0x52')](_0x30fffa)['then'](handleEntityNotFound(_0x43cce8,null))[_0x11dc('0x1d')](respondWithResult(_0x43cce8,null))[_0x11dc('0x25')](handleError(_0x43cce8,null));};exports['create']=function(_0x4f87ae,_0x55f67f,_0xf7d446){var _0x88d55a;return db[_0x11dc('0x39')][_0x11dc('0x53')](_0x4f87ae['body'],{'raw':!![]})['then'](function(_0x51dd02){_0x88d55a=_0x51dd02;return db[_0x11dc('0x39')]['findAll']({'raw':!![]});})[_0x11dc('0x1d')](function(_0x1f4f91){var _0x3f73cf=fs[_0x11dc('0x54')](path[_0x11dc('0x55')](config[_0x11dc('0x56')],_0x11dc('0x57')),_0x11dc('0x58'));var _0xc9ee2f=ejs[_0x11dc('0x59')](_0x3f73cf,{'contexts':_0x1f4f91||[]});fs[_0x11dc('0x5a')](_0x11dc('0x5b'),_0xc9ee2f);})['then'](function(){return respondWithRpcPromise(_0x11dc('0x5c'),_0x11dc('0x53'),{'module':_0x11dc('0x5d')});})[_0x11dc('0x1d')](function(){var _0x2bd7bb=_0x4f87ae['user'][_0x11dc('0x33')]({'plain':!![]});if(!_0x2bd7bb)throw new Error(_0x11dc('0x5e'));if(_0x2bd7bb[_0x11dc('0x5f')]===_0x11dc('0x60')){var _0x5423cb=_0x88d55a['get']({'plain':!![]});return db['UserProfileSection'][_0x11dc('0x52')]({'where':{'name':'Contexts','userProfileId':_0x2bd7bb['userProfileId']},'raw':!![]})[_0x11dc('0x1d')](function(_0x33a97a){if(_0x33a97a&&_0x33a97a[_0x11dc('0x61')]===0x0){return db['UserProfileResource']['create']({'name':_0x5423cb[_0x11dc('0x35')],'resourceId':_0x5423cb['id'],'type':_0x33a97a['name'],'sectionId':_0x33a97a['id']},{})['then'](function(){return _0x88d55a;});}else{return _0x88d55a;}})[_0x11dc('0x25')](function(_0x470e28){logger[_0x11dc('0x23')](_0x11dc('0x62'),_0x470e28);throw _0x470e28;});}return _0x88d55a;})['then'](respondWithResult(_0x55f67f,0xc9))[_0x11dc('0x25')](handleError(_0x55f67f,null));};exports[_0x11dc('0x63')]=function(_0x53e4fe,_0x448e21,_0x2fa644){var _0x1655d4;return db[_0x11dc('0x39')][_0x11dc('0x52')]({'where':{'id':_0x53e4fe[_0x11dc('0x64')]['id']}})[_0x11dc('0x1d')](handleEntityNotFound(_0x448e21,null))[_0x11dc('0x1d')](saveUpdates(_0x53e4fe['body'],null))[_0x11dc('0x1d')](function(_0x3243b6){if(_0x3243b6){_0x1655d4=_0x3243b6;return db['VoiceContext'][_0x11dc('0x4e')]({'raw':!![]});}})['then'](function(_0x71b57b){var _0x2cd9b5=fs[_0x11dc('0x54')](path[_0x11dc('0x55')](config['root'],'server/files/templates/context.ejs'),_0x11dc('0x58'));var _0xe8eae0=ejs[_0x11dc('0x59')](_0x2cd9b5,{'contexts':_0x71b57b||[]});fs[_0x11dc('0x5a')](_0x11dc('0x5b'),_0xe8eae0);})[_0x11dc('0x1d')](function(){return respondWithRpcPromise(_0x11dc('0x5c'),'update',{'module':'chan_sip.so'});})[_0x11dc('0x1d')](function(){return _0x1655d4;})['then'](respondWithResult(_0x448e21,null))['catch'](handleError(_0x448e21,null));};exports[_0x11dc('0x32')]=function(_0x3c0384,_0x4c5089,_0x5733f1){var _0x7ab070;return db[_0x11dc('0x39')][_0x11dc('0x52')]({'where':{'id':_0x3c0384[_0x11dc('0x64')]['id']}})['then'](handleEntityNotFound(_0x4c5089,null))['then'](removeEntity(_0x4c5089,null))[_0x11dc('0x1d')](function(){return db[_0x11dc('0x39')][_0x11dc('0x4e')]({'raw':!![]});})[_0x11dc('0x1d')](function(_0x28ed02){var _0x16db27=fs['readFileSync'](path[_0x11dc('0x55')](config[_0x11dc('0x56')],_0x11dc('0x57')),_0x11dc('0x58'));var _0x2bbb9c=ejs['render'](_0x16db27,{'contexts':_0x28ed02});fs[_0x11dc('0x5a')](_0x11dc('0x5b'),_0x2bbb9c);return respondWithRpcPromise('Reload',_0x11dc('0x32'),{'module':_0x11dc('0x5d')});})['catch'](handleError(_0x4c5089,null));};
\ No newline at end of file