Built motion from commit a679711e.|2.6.15
[motion2.git] / server / api / voiceContext / voiceContext.controller.js
index e504ee9..2235a16 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5f66=['findAll','rows','show','params','includeAll','find','create','body','readFileSync','join','utf8','render','writeFileSync','/etc/asterisk/extensions_xcally_contexts.conf','Reload','chan_sip.so','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','root','server/files/templates/context.ejs','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','squel','crypto','jsforce','desk.js','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/license/util','jayson/promise','http','request','then','info','debug','VoiceContext,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','VoiceContext,\x20%s,\x20%s','result','catch','sendStatus','status','end','offset','limit','json','apply','reject','save','update','destroy','Contexts','UserProfileResource','stack','name','index','map','rawAttributes','type','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','VoiceContext','include'];(function(_0x261f18,_0x1d8f05){var _0x3c6894=function(_0x4cf017){while(--_0x4cf017){_0x261f18['push'](_0x261f18['shift']());}};_0x3c6894(++_0x1d8f05);}(_0x5f66,0x1a0));var _0x65f6=function(_0x126558,_0x143c9a){_0x126558=_0x126558-0x0;var _0x1f6d14=_0x5f66[_0x126558];return _0x1f6d14;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x65f6('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x65f6('0x1'));var jsonpatch=require(_0x65f6('0x2'));var rp=require(_0x65f6('0x3'));var moment=require(_0x65f6('0x4'));var BPromise=require(_0x65f6('0x5'));var Mustache=require('mustache');var util=require(_0x65f6('0x6'));var path=require('path');var sox=require(_0x65f6('0x7'));var csv=require(_0x65f6('0x8'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x65f6('0x9'));var crypto=require(_0x65f6('0xa'));var jsforce=require(_0x65f6('0xb'));var deskjs=require(_0x65f6('0xc'));var toCsv=require(_0x65f6('0x8'));var querystring=require(_0x65f6('0xd'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x65f6('0xe'));var qs=require(_0x65f6('0xf'));var as=require(_0x65f6('0x10'));var hardwareService=require(_0x65f6('0x11'));var logger=require('../../config/logger')(_0x65f6('0x12'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x65f6('0x13'));var db=require('../../mysqldb')['db'];var jayson=require(_0x65f6('0x14'));var client=jayson['client'][_0x65f6('0x15')]({'port':0x232a});function respondWithRpcPromise(_0x186a6a,_0x2c4ee5,_0x217570,_0x369f96){return new BPromise(function(_0x1d29fd,_0x44144b){var _0xb1d40a=_0x369f96||client;return _0xb1d40a[_0x65f6('0x16')](_0x186a6a,_0x217570)[_0x65f6('0x17')](function(_0x59154e){logger[_0x65f6('0x18')]('VoiceContext,\x20%s,\x20%s',_0x2c4ee5,'request\x20sent');logger[_0x65f6('0x19')](_0x65f6('0x1a'),_0x2c4ee5,_0x65f6('0x1b'),JSON[_0x65f6('0x1c')](_0x59154e));if(_0x59154e[_0x65f6('0x1d')]){if(_0x59154e[_0x65f6('0x1d')][_0x65f6('0x1e')]===0x1f4){logger[_0x65f6('0x1d')]('VoiceContext,\x20%s,\x20%s',_0x2c4ee5,_0x59154e['error'][_0x65f6('0x1f')]);return _0x44144b(_0x59154e['error']['message']);}logger['error'](_0x65f6('0x20'),_0x2c4ee5,_0x59154e[_0x65f6('0x1d')]['message']);return _0x1d29fd(_0x59154e[_0x65f6('0x1d')][_0x65f6('0x1f')]);}else{logger[_0x65f6('0x18')](_0x65f6('0x20'),_0x2c4ee5,_0x65f6('0x1b'));_0x1d29fd(_0x59154e[_0x65f6('0x21')]['message']);}})[_0x65f6('0x22')](function(_0x4bb39e){logger['error'](_0x65f6('0x20'),_0x2c4ee5,_0x4bb39e);_0x44144b(_0x4bb39e);});});}function respondWithStatusCode(_0xd173f4,_0x524e42){_0x524e42=_0x524e42||0xcc;return function(_0x1eeaaa){if(_0x1eeaaa){return _0xd173f4[_0x65f6('0x23')](_0x524e42);}return _0xd173f4[_0x65f6('0x24')](_0x524e42)[_0x65f6('0x25')]();};}function respondWithResult(_0x4f5a69,_0x9d7bb0){_0x9d7bb0=_0x9d7bb0||0xc8;return function(_0x59ea32){if(_0x59ea32){return _0x4f5a69[_0x65f6('0x24')](_0x9d7bb0)['json'](_0x59ea32);}};}function respondWithFilteredResult(_0x5cb131,_0x4fde2f){return function(_0x29abdb){if(_0x29abdb){var _0x16cde8=_0x29abdb['count'],_0x4b2292=_0x4fde2f[_0x65f6('0x26')],_0x296cd9=_0x4fde2f[_0x65f6('0x26')]+_0x4fde2f[_0x65f6('0x27')],_0x28f710;if(_0x296cd9>=_0x16cde8){_0x296cd9=_0x16cde8;_0x28f710=0xc8;}else{_0x28f710=0xce;}_0x5cb131['status'](_0x28f710);return _0x5cb131['set']('Content-Range',_0x4b2292+'-'+_0x296cd9+'/'+_0x16cde8)[_0x65f6('0x28')](_0x29abdb);}return null;};}function patchUpdates(_0x3c032f){return function(_0x4344b3){try{jsonpatch[_0x65f6('0x29')](_0x4344b3,_0x3c032f,!![]);}catch(_0x518cac){return BPromise[_0x65f6('0x2a')](_0x518cac);}return _0x4344b3[_0x65f6('0x2b')]();};}function saveUpdates(_0x4ace4c,_0x4ea23d){return function(_0x154cbd){if(_0x154cbd){return _0x154cbd[_0x65f6('0x2c')](_0x4ace4c)['then'](function(_0x4e50c0){return _0x4e50c0;});}return null;};}function removeEntity(_0x10b368,_0x1ce43c){return function(_0x11fe3b){if(_0x11fe3b){return _0x11fe3b[_0x65f6('0x2d')]()[_0x65f6('0x17')](function(){var _0x2d32be=_0x11fe3b['get']({'plain':!![]});var _0x103265=_0x65f6('0x2e');return db[_0x65f6('0x2f')]['destroy']({'where':{'type':_0x103265,'resourceId':_0x2d32be['id']}})[_0x65f6('0x17')](function(){return _0x11fe3b;});})[_0x65f6('0x17')](function(){_0x10b368[_0x65f6('0x24')](0xcc)[_0x65f6('0x25')]();});}};}function handleEntityNotFound(_0x37c086,_0x2f054c){return function(_0x4d4d84){if(!_0x4d4d84){_0x37c086[_0x65f6('0x23')](0x194);}return _0x4d4d84;};}function handleError(_0x1b24ea,_0x4f3e22){_0x4f3e22=_0x4f3e22||0x1f4;return function(_0x36dbf4){logger['error'](_0x36dbf4[_0x65f6('0x30')]);if(_0x36dbf4['name']){delete _0x36dbf4[_0x65f6('0x31')];}_0x1b24ea[_0x65f6('0x24')](_0x4f3e22)['send'](_0x36dbf4);};}exports[_0x65f6('0x32')]=function(_0x13e41a,_0x3b261d){var _0x515648={},_0x582c7e={},_0x30109d={'count':0x0,'rows':[]};var _0x4c0df4=_[_0x65f6('0x33')](db['VoiceContext'][_0x65f6('0x34')],function(_0x2b9675){return{'name':_0x2b9675['fieldName'],'type':_0x2b9675[_0x65f6('0x35')]['key']};});_0x582c7e['model']=_[_0x65f6('0x33')](_0x4c0df4,_0x65f6('0x31'));_0x582c7e[_0x65f6('0x36')]=_[_0x65f6('0x37')](_0x13e41a[_0x65f6('0x36')]);_0x582c7e[_0x65f6('0x38')]=_[_0x65f6('0x39')](_0x582c7e[_0x65f6('0x3a')],_0x582c7e['query']);_0x515648[_0x65f6('0x3b')]=_['intersection'](_0x582c7e[_0x65f6('0x3a')],qs[_0x65f6('0x3c')](_0x13e41a[_0x65f6('0x36')][_0x65f6('0x3c')]));_0x515648['attributes']=_0x515648[_0x65f6('0x3b')][_0x65f6('0x3d')]?_0x515648[_0x65f6('0x3b')]:_0x582c7e[_0x65f6('0x3a')];if(!_0x13e41a[_0x65f6('0x36')][_0x65f6('0x3e')](_0x65f6('0x3f'))){_0x515648[_0x65f6('0x27')]=qs[_0x65f6('0x27')](_0x13e41a['query'][_0x65f6('0x27')]);_0x515648[_0x65f6('0x26')]=qs[_0x65f6('0x26')](_0x13e41a[_0x65f6('0x36')][_0x65f6('0x26')]);}_0x515648[_0x65f6('0x40')]=qs[_0x65f6('0x41')](_0x13e41a[_0x65f6('0x36')][_0x65f6('0x41')]);_0x515648[_0x65f6('0x42')]=qs[_0x65f6('0x38')](_[_0x65f6('0x43')](_0x13e41a[_0x65f6('0x36')],_0x582c7e[_0x65f6('0x38')]),_0x4c0df4);if(_0x13e41a[_0x65f6('0x36')][_0x65f6('0x44')]){_0x515648['where']=_[_0x65f6('0x45')](_0x515648[_0x65f6('0x42')],{'$or':_[_0x65f6('0x33')](_0x4c0df4,function(_0x3828c9){if(_0x3828c9['type']!==_0x65f6('0x46')){var _0x2d0dac={};_0x2d0dac[_0x3828c9[_0x65f6('0x31')]]={'$like':'%'+_0x13e41a['query'][_0x65f6('0x44')]+'%'};return _0x2d0dac;}})});}_0x515648=_[_0x65f6('0x45')]({},_0x515648,_0x13e41a[_0x65f6('0x47')]);var _0x2179e5={'where':_0x515648['where']};return db[_0x65f6('0x48')]['count'](_0x2179e5)[_0x65f6('0x17')](function(_0x6968b){_0x30109d['count']=_0x6968b;if(_0x13e41a[_0x65f6('0x36')]['includeAll']){_0x515648[_0x65f6('0x49')]=[{'all':!![]}];}return db[_0x65f6('0x48')][_0x65f6('0x4a')](_0x515648);})[_0x65f6('0x17')](function(_0x3ec18f){_0x30109d[_0x65f6('0x4b')]=_0x3ec18f;return _0x30109d;})['then'](respondWithFilteredResult(_0x3b261d,_0x515648))['catch'](handleError(_0x3b261d,null));};exports[_0x65f6('0x4c')]=function(_0x15d3ba,_0x3b647a){var _0x1e9e29={'raw':![],'where':{'id':_0x15d3ba[_0x65f6('0x4d')]['id']}},_0x3b907c={};_0x3b907c[_0x65f6('0x3a')]=_[_0x65f6('0x37')](db[_0x65f6('0x48')]['rawAttributes']);_0x3b907c[_0x65f6('0x36')]=_[_0x65f6('0x37')](_0x15d3ba[_0x65f6('0x36')]);_0x3b907c['filters']=_[_0x65f6('0x39')](_0x3b907c[_0x65f6('0x3a')],_0x3b907c['query']);_0x1e9e29[_0x65f6('0x3b')]=_[_0x65f6('0x39')](_0x3b907c['model'],qs[_0x65f6('0x3c')](_0x15d3ba['query'][_0x65f6('0x3c')]));_0x1e9e29[_0x65f6('0x3b')]=_0x1e9e29[_0x65f6('0x3b')]['length']?_0x1e9e29[_0x65f6('0x3b')]:_0x3b907c[_0x65f6('0x3a')];if(_0x15d3ba['query'][_0x65f6('0x4e')]){_0x1e9e29[_0x65f6('0x49')]=[{'all':!![]}];}_0x1e9e29=_['merge']({},_0x1e9e29,_0x15d3ba[_0x65f6('0x47')]);return db[_0x65f6('0x48')][_0x65f6('0x4f')](_0x1e9e29)[_0x65f6('0x17')](handleEntityNotFound(_0x3b647a,null))[_0x65f6('0x17')](respondWithResult(_0x3b647a,null))[_0x65f6('0x22')](handleError(_0x3b647a,null));};exports[_0x65f6('0x50')]=function(_0x305131,_0x4f69d8,_0x52c5a4){var _0x5ca62e;return db[_0x65f6('0x48')][_0x65f6('0x50')](_0x305131[_0x65f6('0x51')],{'raw':!![]})[_0x65f6('0x17')](function(_0x545445){_0x5ca62e=_0x545445;return db[_0x65f6('0x48')][_0x65f6('0x4a')]({'raw':!![]});})[_0x65f6('0x17')](function(_0x50f63a){var _0x19c5fa=fs[_0x65f6('0x52')](path[_0x65f6('0x53')](config['root'],'server/files/templates/context.ejs'),_0x65f6('0x54'));var _0x44f3dd=ejs[_0x65f6('0x55')](_0x19c5fa,{'contexts':_0x50f63a||[]});fs[_0x65f6('0x56')](_0x65f6('0x57'),_0x44f3dd);})[_0x65f6('0x17')](function(){return respondWithRpcPromise(_0x65f6('0x58'),_0x65f6('0x50'),{'module':_0x65f6('0x59')});})[_0x65f6('0x17')](function(){var _0xa7eee9=_0x305131[_0x65f6('0x5a')][_0x65f6('0x5b')]({'plain':!![]});if(!_0xa7eee9)throw new Error(_0x65f6('0x5c'));if(_0xa7eee9['role']===_0x65f6('0x5a')){var _0x37d527=_0x5ca62e[_0x65f6('0x5b')]({'plain':!![]});return db['UserProfileSection'][_0x65f6('0x4f')]({'where':{'name':_0x65f6('0x2e'),'userProfileId':_0xa7eee9[_0x65f6('0x5d')]},'raw':!![]})[_0x65f6('0x17')](function(_0x4ef333){if(_0x4ef333&&_0x4ef333[_0x65f6('0x5e')]===0x0){return db[_0x65f6('0x2f')][_0x65f6('0x50')]({'name':_0x37d527[_0x65f6('0x31')],'resourceId':_0x37d527['id'],'type':_0x4ef333['name'],'sectionId':_0x4ef333['id']},{})[_0x65f6('0x17')](function(){return _0x5ca62e;});}else{return _0x5ca62e;}})[_0x65f6('0x22')](function(_0x5c55e4){logger[_0x65f6('0x1d')](_0x65f6('0x5f'),_0x5c55e4);throw _0x5c55e4;});}return _0x5ca62e;})[_0x65f6('0x17')](respondWithResult(_0x4f69d8,0xc9))['catch'](handleError(_0x4f69d8,null));};exports[_0x65f6('0x2c')]=function(_0x439365,_0x3974ef,_0x3c23e3){var _0x2b7aed;return db[_0x65f6('0x48')]['find']({'where':{'id':_0x439365['params']['id']}})['then'](handleEntityNotFound(_0x3974ef,null))[_0x65f6('0x17')](saveUpdates(_0x439365[_0x65f6('0x51')],null))[_0x65f6('0x17')](function(_0x471bec){if(_0x471bec){_0x2b7aed=_0x471bec;return db[_0x65f6('0x48')][_0x65f6('0x4a')]({'raw':!![]});}})['then'](function(_0xfbfebc){var _0x1d1532=fs['readFileSync'](path[_0x65f6('0x53')](config[_0x65f6('0x60')],_0x65f6('0x61')),'utf8');var _0x23c441=ejs[_0x65f6('0x55')](_0x1d1532,{'contexts':_0xfbfebc||[]});fs['writeFileSync'](_0x65f6('0x57'),_0x23c441);})[_0x65f6('0x17')](function(){return respondWithRpcPromise(_0x65f6('0x58'),_0x65f6('0x2c'),{'module':_0x65f6('0x59')});})[_0x65f6('0x17')](function(){return _0x2b7aed;})[_0x65f6('0x17')](respondWithResult(_0x3974ef,null))['catch'](handleError(_0x3974ef,null));};exports['destroy']=function(_0x3eb33e,_0x3da139,_0x4a9524){var _0x417ba5;return db['VoiceContext'][_0x65f6('0x4f')]({'where':{'id':_0x3eb33e['params']['id']}})[_0x65f6('0x17')](handleEntityNotFound(_0x3da139,null))[_0x65f6('0x17')](removeEntity(_0x3da139,null))[_0x65f6('0x17')](function(){return db[_0x65f6('0x48')][_0x65f6('0x4a')]({'raw':!![]});})[_0x65f6('0x17')](function(_0x1aaf75){var _0x1cc66a=fs[_0x65f6('0x52')](path['join'](config['root'],_0x65f6('0x61')),_0x65f6('0x54'));var _0x37bc3b=ejs['render'](_0x1cc66a,{'contexts':_0x1aaf75});fs['writeFileSync'](_0x65f6('0x57'),_0x37bc3b);return respondWithRpcPromise(_0x65f6('0x58'),_0x65f6('0x2d'),{'module':_0x65f6('0x59')});})[_0x65f6('0x22')](handleError(_0x3da139,null));};
\ No newline at end of file
+var _0x10d8=['fields','attributes','length','hasOwnProperty','nolimit','sort','where','filter','merge','type','VIRTUAL','includeAll','findAll','rows','show','params','include','options','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','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','get','UserProfileSection','Contexts','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','request','then','info','VoiceContext,\x20%s,\x20%s','request\x20sent','debug','VoiceContext,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','UserProfileResource','stack','name','send','index','VoiceContext','fieldName','key','map','query','keys','filters','intersection','model'];(function(_0x5e8207,_0xf26436){var _0x2d249e=function(_0x367533){while(--_0x367533){_0x5e8207['push'](_0x5e8207['shift']());}};_0x2d249e(++_0xf26436);}(_0x10d8,0x16f));var _0x810d=function(_0x2f9248,_0x1733f5){_0x2f9248=_0x2f9248-0x0;var _0x43c447=_0x10d8[_0x2f9248];return _0x43c447;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x810d('0x0'));var zipdir=require(_0x810d('0x1'));var jsonpatch=require(_0x810d('0x2'));var rp=require(_0x810d('0x3'));var moment=require(_0x810d('0x4'));var BPromise=require(_0x810d('0x5'));var Mustache=require(_0x810d('0x6'));var util=require(_0x810d('0x7'));var path=require(_0x810d('0x8'));var sox=require(_0x810d('0x9'));var csv=require('to-csv');var ejs=require(_0x810d('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x810d('0xb'));var squel=require('squel');var crypto=require(_0x810d('0xc'));var jsforce=require(_0x810d('0xd'));var deskjs=require(_0x810d('0xe'));var toCsv=require('to-csv');var querystring=require(_0x810d('0xf'));var Papa=require(_0x810d('0x10'));var Redis=require(_0x810d('0x11'));var authService=require(_0x810d('0x12'));var qs=require(_0x810d('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x810d('0x14'))('api');var utils=require(_0x810d('0x15'));var config=require(_0x810d('0x16'));var licenseUtil=require(_0x810d('0x17'));var db=require(_0x810d('0x18'))['db'];var jayson=require(_0x810d('0x19'));var client=jayson[_0x810d('0x1a')]['http']({'port':0x232a});function respondWithRpcPromise(_0x43dfbc,_0x399344,_0x37136a,_0xe68a){return new BPromise(function(_0xd6382f,_0xc1a605){var _0x4407c1=_0xe68a||client;return _0x4407c1[_0x810d('0x1b')](_0x43dfbc,_0x37136a)[_0x810d('0x1c')](function(_0xd25346){logger[_0x810d('0x1d')](_0x810d('0x1e'),_0x399344,_0x810d('0x1f'));logger[_0x810d('0x20')](_0x810d('0x21'),_0x399344,_0x810d('0x1f'),JSON[_0x810d('0x22')](_0xd25346));if(_0xd25346[_0x810d('0x23')]){if(_0xd25346[_0x810d('0x23')][_0x810d('0x24')]===0x1f4){logger[_0x810d('0x23')](_0x810d('0x1e'),_0x399344,_0xd25346[_0x810d('0x23')][_0x810d('0x25')]);return _0xc1a605(_0xd25346[_0x810d('0x23')][_0x810d('0x25')]);}logger[_0x810d('0x23')](_0x810d('0x1e'),_0x399344,_0xd25346['error'][_0x810d('0x25')]);return _0xd6382f(_0xd25346[_0x810d('0x23')]['message']);}else{logger[_0x810d('0x1d')](_0x810d('0x1e'),_0x399344,_0x810d('0x1f'));_0xd6382f(_0xd25346[_0x810d('0x26')][_0x810d('0x25')]);}})[_0x810d('0x27')](function(_0x45f3d6){logger[_0x810d('0x23')](_0x810d('0x1e'),_0x399344,_0x45f3d6);_0xc1a605(_0x45f3d6);});});}function respondWithStatusCode(_0x3d6f45,_0x3b7841){_0x3b7841=_0x3b7841||0xcc;return function(_0x463bd0){if(_0x463bd0){return _0x3d6f45[_0x810d('0x28')](_0x3b7841);}return _0x3d6f45[_0x810d('0x29')](_0x3b7841)[_0x810d('0x2a')]();};}function respondWithResult(_0x476dd8,_0x2ba470){_0x2ba470=_0x2ba470||0xc8;return function(_0xaab0a){if(_0xaab0a){return _0x476dd8[_0x810d('0x29')](_0x2ba470)[_0x810d('0x2b')](_0xaab0a);}};}function respondWithFilteredResult(_0x3d5113,_0x3d623f){return function(_0xc751c0){if(_0xc751c0){var _0x4b5148=typeof _0x3d623f[_0x810d('0x2c')]===_0x810d('0x2d')&&typeof _0x3d623f[_0x810d('0x2e')]===_0x810d('0x2d');var _0x3c9127=_0xc751c0[_0x810d('0x2f')];var _0xa69fa2=_0x4b5148?0x0:_0x3d623f[_0x810d('0x2c')];var _0x8cf860=_0x4b5148?_0xc751c0[_0x810d('0x2f')]:_0x3d623f[_0x810d('0x2c')]+_0x3d623f['limit'];var _0x2453aa;if(_0x8cf860>=_0x3c9127){_0x8cf860=_0x3c9127;_0x2453aa=0xc8;}else{_0x2453aa=0xce;}_0x3d5113[_0x810d('0x29')](_0x2453aa);return _0x3d5113[_0x810d('0x30')](_0x810d('0x31'),_0xa69fa2+'-'+_0x8cf860+'/'+_0x3c9127)['json'](_0xc751c0);}return null;};}function patchUpdates(_0xc7dff9){return function(_0x31a7e4){try{jsonpatch[_0x810d('0x32')](_0x31a7e4,_0xc7dff9,!![]);}catch(_0x3493b5){return BPromise[_0x810d('0x33')](_0x3493b5);}return _0x31a7e4[_0x810d('0x34')]();};}function saveUpdates(_0x3a3a08,_0x49d4be){return function(_0x557300){if(_0x557300){return _0x557300[_0x810d('0x35')](_0x3a3a08)[_0x810d('0x1c')](function(_0x158f95){return _0x158f95;});}return null;};}function removeEntity(_0x339fd9,_0x4b8f8e){return function(_0x111d3d){if(_0x111d3d){return _0x111d3d[_0x810d('0x36')]()['then'](function(){var _0x31a199=_0x111d3d['get']({'plain':!![]});var _0x14414b='Contexts';return db[_0x810d('0x37')][_0x810d('0x36')]({'where':{'type':_0x14414b,'resourceId':_0x31a199['id']}})[_0x810d('0x1c')](function(){return _0x111d3d;});})[_0x810d('0x1c')](function(){_0x339fd9[_0x810d('0x29')](0xcc)[_0x810d('0x2a')]();});}};}function handleEntityNotFound(_0x3c3bc6,_0x26fde7){return function(_0xd8b281){if(!_0xd8b281){_0x3c3bc6['sendStatus'](0x194);}return _0xd8b281;};}function handleError(_0x27738b,_0x35c41c){_0x35c41c=_0x35c41c||0x1f4;return function(_0x23e3c9){logger[_0x810d('0x23')](_0x23e3c9[_0x810d('0x38')]);if(_0x23e3c9[_0x810d('0x39')]){delete _0x23e3c9[_0x810d('0x39')];}_0x27738b[_0x810d('0x29')](_0x35c41c)[_0x810d('0x3a')](_0x23e3c9);};}exports[_0x810d('0x3b')]=function(_0x59f525,_0x1a657e){var _0x38f7d4={},_0x15d2ed={},_0x293ca5={'count':0x0,'rows':[]};var _0x566311=_['map'](db[_0x810d('0x3c')]['rawAttributes'],function(_0x3b0a46){return{'name':_0x3b0a46[_0x810d('0x3d')],'type':_0x3b0a46['type'][_0x810d('0x3e')]};});_0x15d2ed['model']=_[_0x810d('0x3f')](_0x566311,_0x810d('0x39'));_0x15d2ed[_0x810d('0x40')]=_[_0x810d('0x41')](_0x59f525[_0x810d('0x40')]);_0x15d2ed[_0x810d('0x42')]=_[_0x810d('0x43')](_0x15d2ed[_0x810d('0x44')],_0x15d2ed['query']);_0x38f7d4['attributes']=_[_0x810d('0x43')](_0x15d2ed[_0x810d('0x44')],qs['fields'](_0x59f525['query'][_0x810d('0x45')]));_0x38f7d4[_0x810d('0x46')]=_0x38f7d4[_0x810d('0x46')][_0x810d('0x47')]?_0x38f7d4[_0x810d('0x46')]:_0x15d2ed['model'];if(!_0x59f525[_0x810d('0x40')][_0x810d('0x48')](_0x810d('0x49'))){_0x38f7d4[_0x810d('0x2e')]=qs['limit'](_0x59f525['query'][_0x810d('0x2e')]);_0x38f7d4[_0x810d('0x2c')]=qs[_0x810d('0x2c')](_0x59f525['query'][_0x810d('0x2c')]);}_0x38f7d4['order']=qs[_0x810d('0x4a')](_0x59f525[_0x810d('0x40')][_0x810d('0x4a')]);_0x38f7d4[_0x810d('0x4b')]=qs['filters'](_['pick'](_0x59f525[_0x810d('0x40')],_0x15d2ed['filters']),_0x566311);if(_0x59f525[_0x810d('0x40')][_0x810d('0x4c')]){_0x38f7d4[_0x810d('0x4b')]=_[_0x810d('0x4d')](_0x38f7d4[_0x810d('0x4b')],{'$or':_[_0x810d('0x3f')](_0x566311,function(_0x55d3a8){if(_0x55d3a8[_0x810d('0x4e')]!==_0x810d('0x4f')){var _0x20fedf={};_0x20fedf[_0x55d3a8[_0x810d('0x39')]]={'$like':'%'+_0x59f525[_0x810d('0x40')][_0x810d('0x4c')]+'%'};return _0x20fedf;}})});}_0x38f7d4=_['merge']({},_0x38f7d4,_0x59f525['options']);var _0x3ab1e0={'where':_0x38f7d4['where']};return db[_0x810d('0x3c')][_0x810d('0x2f')](_0x3ab1e0)[_0x810d('0x1c')](function(_0x3cb1bb){_0x293ca5['count']=_0x3cb1bb;if(_0x59f525[_0x810d('0x40')][_0x810d('0x50')]){_0x38f7d4['include']=[{'all':!![]}];}return db['VoiceContext'][_0x810d('0x51')](_0x38f7d4);})[_0x810d('0x1c')](function(_0x53cbc2){_0x293ca5[_0x810d('0x52')]=_0x53cbc2;return _0x293ca5;})[_0x810d('0x1c')](respondWithFilteredResult(_0x1a657e,_0x38f7d4))[_0x810d('0x27')](handleError(_0x1a657e,null));};exports[_0x810d('0x53')]=function(_0x50342c,_0x51594a){var _0xd368eb={'raw':![],'where':{'id':_0x50342c[_0x810d('0x54')]['id']}},_0x57aa09={};_0x57aa09[_0x810d('0x44')]=_[_0x810d('0x41')](db[_0x810d('0x3c')]['rawAttributes']);_0x57aa09[_0x810d('0x40')]=_[_0x810d('0x41')](_0x50342c[_0x810d('0x40')]);_0x57aa09[_0x810d('0x42')]=_[_0x810d('0x43')](_0x57aa09[_0x810d('0x44')],_0x57aa09['query']);_0xd368eb[_0x810d('0x46')]=_[_0x810d('0x43')](_0x57aa09['model'],qs[_0x810d('0x45')](_0x50342c[_0x810d('0x40')][_0x810d('0x45')]));_0xd368eb['attributes']=_0xd368eb[_0x810d('0x46')]['length']?_0xd368eb[_0x810d('0x46')]:_0x57aa09[_0x810d('0x44')];if(_0x50342c[_0x810d('0x40')][_0x810d('0x50')]){_0xd368eb[_0x810d('0x55')]=[{'all':!![]}];}_0xd368eb=_[_0x810d('0x4d')]({},_0xd368eb,_0x50342c[_0x810d('0x56')]);return db[_0x810d('0x3c')][_0x810d('0x57')](_0xd368eb)['then'](handleEntityNotFound(_0x51594a,null))['then'](respondWithResult(_0x51594a,null))['catch'](handleError(_0x51594a,null));};exports[_0x810d('0x58')]=function(_0x396f2c,_0x4ce32f,_0x481c4a){var _0x8d7244;return db['VoiceContext']['create'](_0x396f2c[_0x810d('0x59')],{'raw':!![]})[_0x810d('0x1c')](function(_0x226d62){_0x8d7244=_0x226d62;return db[_0x810d('0x3c')][_0x810d('0x51')]({'raw':!![]});})[_0x810d('0x1c')](function(_0x42f8d9){var _0x39370e=fs[_0x810d('0x5a')](path[_0x810d('0x5b')](config[_0x810d('0x5c')],_0x810d('0x5d')),_0x810d('0x5e'));var _0x2f18a5=ejs[_0x810d('0x5f')](_0x39370e,{'contexts':_0x42f8d9||[]});fs[_0x810d('0x60')](_0x810d('0x61'),_0x2f18a5);})[_0x810d('0x1c')](function(){return respondWithRpcPromise(_0x810d('0x62'),_0x810d('0x58'),{'module':_0x810d('0x63')});})[_0x810d('0x1c')](function(){var _0x53280c=_0x396f2c[_0x810d('0x64')]['get']({'plain':!![]});if(!_0x53280c)throw new Error(_0x810d('0x65'));if(_0x53280c[_0x810d('0x66')]===_0x810d('0x64')){var _0xb69b4c=_0x8d7244[_0x810d('0x67')]({'plain':!![]});return db[_0x810d('0x68')][_0x810d('0x57')]({'where':{'name':_0x810d('0x69'),'userProfileId':_0x53280c[_0x810d('0x6a')]},'raw':!![]})['then'](function(_0x34d8a4){if(_0x34d8a4&&_0x34d8a4[_0x810d('0x6b')]===0x0){return db[_0x810d('0x37')]['create']({'name':_0xb69b4c['name'],'resourceId':_0xb69b4c['id'],'type':_0x34d8a4[_0x810d('0x39')],'sectionId':_0x34d8a4['id']},{})[_0x810d('0x1c')](function(){return _0x8d7244;});}else{return _0x8d7244;}})[_0x810d('0x27')](function(_0x560883){logger[_0x810d('0x23')](_0x810d('0x6c'),_0x560883);throw _0x560883;});}return _0x8d7244;})[_0x810d('0x1c')](respondWithResult(_0x4ce32f,0xc9))['catch'](handleError(_0x4ce32f,null));};exports[_0x810d('0x35')]=function(_0x1e78c6,_0x7a1553,_0x328c0b){var _0x55598a;return db[_0x810d('0x3c')][_0x810d('0x57')]({'where':{'id':_0x1e78c6[_0x810d('0x54')]['id']}})[_0x810d('0x1c')](handleEntityNotFound(_0x7a1553,null))[_0x810d('0x1c')](saveUpdates(_0x1e78c6[_0x810d('0x59')],null))[_0x810d('0x1c')](function(_0x1f667a){if(_0x1f667a){_0x55598a=_0x1f667a;return db[_0x810d('0x3c')][_0x810d('0x51')]({'raw':!![]});}})[_0x810d('0x1c')](function(_0x4e99df){var _0x40cff7=fs[_0x810d('0x5a')](path[_0x810d('0x5b')](config[_0x810d('0x5c')],_0x810d('0x5d')),_0x810d('0x5e'));var _0x33f3db=ejs[_0x810d('0x5f')](_0x40cff7,{'contexts':_0x4e99df||[]});fs[_0x810d('0x60')](_0x810d('0x61'),_0x33f3db);})[_0x810d('0x1c')](function(){return respondWithRpcPromise(_0x810d('0x62'),_0x810d('0x35'),{'module':_0x810d('0x63')});})['then'](function(){return _0x55598a;})['then'](respondWithResult(_0x7a1553,null))[_0x810d('0x27')](handleError(_0x7a1553,null));};exports[_0x810d('0x36')]=function(_0x84354a,_0x5bdf18,_0x22122c){var _0x1d2646;return db[_0x810d('0x3c')][_0x810d('0x57')]({'where':{'id':_0x84354a['params']['id']}})[_0x810d('0x1c')](handleEntityNotFound(_0x5bdf18,null))[_0x810d('0x1c')](removeEntity(_0x5bdf18,null))['then'](function(){return db[_0x810d('0x3c')][_0x810d('0x51')]({'raw':!![]});})[_0x810d('0x1c')](function(_0x55ed20){var _0x436174=fs[_0x810d('0x5a')](path[_0x810d('0x5b')](config[_0x810d('0x5c')],'server/files/templates/context.ejs'),_0x810d('0x5e'));var _0x4c358f=ejs[_0x810d('0x5f')](_0x436174,{'contexts':_0x55ed20});fs['writeFileSync'](_0x810d('0x61'),_0x4c358f);return respondWithRpcPromise(_0x810d('0x62'),_0x810d('0x36'),{'module':'chan_sip.so'});})[_0x810d('0x27')](handleError(_0x5bdf18,null));};
\ No newline at end of file