Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / voiceMusicOnHold / voiceMusicOnHold.controller.js
index 158d1ca..3557707 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x626f=['attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','show','params','find','body','sequelize','mode','files','directory','join','root','server/files/moh','create','mkdirSync','0777','user','get','role','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','transaction','readdirSync','rmdirSync','Sequelize','message','addSound','findOne','format','save_name','extname','converted_format','%s.%s','symlinkSync','removeSound','Sound','createdAt','unlinkSync','ValidationError','getSounds','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','sox','to-csv','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','limit','undefined','count','set','Content-Range','apply','reject','save','update','then','destroy','MusicOnHolds','UserProfileResource','error','stack','name','send','index','map','VoiceMusicOnHold','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection'];(function(_0x451735,_0x391a76){var _0x41d1e2=function(_0x3566d7){while(--_0x3566d7){_0x451735['push'](_0x451735['shift']());}};_0x41d1e2(++_0x391a76);}(_0x626f,0x116));var _0xf626=function(_0x20545f,_0x2dadb2){_0x20545f=_0x20545f-0x0;var _0x54f142=_0x626f[_0x20545f];return _0x54f142;};'use strict';var emlformat=require(_0xf626('0x0'));var rimraf=require(_0xf626('0x1'));var zipdir=require(_0xf626('0x2'));var jsonpatch=require(_0xf626('0x3'));var rp=require(_0xf626('0x4'));var moment=require(_0xf626('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xf626('0x6'));var path=require('path');var sox=require(_0xf626('0x7'));var csv=require(_0xf626('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf626('0x9'));var _=require(_0xf626('0xa'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xf626('0xb'));var deskjs=require(_0xf626('0xc'));var toCsv=require('to-csv');var querystring=require(_0xf626('0xd'));var Papa=require(_0xf626('0xe'));var Redis=require('ioredis');var authService=require(_0xf626('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0xf626('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf626('0x11'))('api');var utils=require(_0xf626('0x12'));var config=require(_0xf626('0x13'));var licenseUtil=require(_0xf626('0x14'));var db=require(_0xf626('0x15'))['db'];function respondWithStatusCode(_0x1b339a,_0x24d07f){_0x24d07f=_0x24d07f||0xcc;return function(_0x24dd29){if(_0x24dd29){return _0x1b339a[_0xf626('0x16')](_0x24d07f);}return _0x1b339a[_0xf626('0x17')](_0x24d07f)['end']();};}function respondWithResult(_0x135c47,_0x3b46bb){_0x3b46bb=_0x3b46bb||0xc8;return function(_0xb3f618){if(_0xb3f618){return _0x135c47[_0xf626('0x17')](_0x3b46bb)[_0xf626('0x18')](_0xb3f618);}};}function respondWithFilteredResult(_0x4347c5,_0x1d75d6){return function(_0x1fe3d3){if(_0x1fe3d3){var _0x4a1dd1=typeof _0x1d75d6[_0xf626('0x19')]==='undefined'&&typeof _0x1d75d6[_0xf626('0x1a')]===_0xf626('0x1b');var _0x5c3efd=_0x1fe3d3[_0xf626('0x1c')];var _0x527f88=_0x4a1dd1?0x0:_0x1d75d6[_0xf626('0x19')];var _0x29f5c3=_0x4a1dd1?_0x1fe3d3['count']:_0x1d75d6[_0xf626('0x19')]+_0x1d75d6[_0xf626('0x1a')];var _0x4655cc;if(_0x29f5c3>=_0x5c3efd){_0x29f5c3=_0x5c3efd;_0x4655cc=0xc8;}else{_0x4655cc=0xce;}_0x4347c5['status'](_0x4655cc);return _0x4347c5[_0xf626('0x1d')](_0xf626('0x1e'),_0x527f88+'-'+_0x29f5c3+'/'+_0x5c3efd)[_0xf626('0x18')](_0x1fe3d3);}return null;};}function patchUpdates(_0x350b1c){return function(_0x2003df){try{jsonpatch[_0xf626('0x1f')](_0x2003df,_0x350b1c,!![]);}catch(_0x65db8f){return BPromise[_0xf626('0x20')](_0x65db8f);}return _0x2003df[_0xf626('0x21')]();};}function saveUpdates(_0x2c89a1,_0x10392b){return function(_0x5eb41e){if(_0x5eb41e){return _0x5eb41e[_0xf626('0x22')](_0x2c89a1)[_0xf626('0x23')](function(_0x561074){return _0x561074;});}return null;};}function removeEntity(_0x343f57,_0x31f269){return function(_0x4d38c7){if(_0x4d38c7){return _0x4d38c7[_0xf626('0x24')]()['then'](function(){var _0x11d14d=_0x4d38c7['get']({'plain':!![]});var _0x1a2b39=_0xf626('0x25');return db[_0xf626('0x26')][_0xf626('0x24')]({'where':{'type':_0x1a2b39,'resourceId':_0x11d14d['id']}})[_0xf626('0x23')](function(){return _0x4d38c7;});})[_0xf626('0x23')](function(){_0x343f57[_0xf626('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5d1000,_0x4f41a0){return function(_0x2f483c){if(!_0x2f483c){_0x5d1000[_0xf626('0x16')](0x194);}return _0x2f483c;};}function handleError(_0x47b41c,_0x27ffb5){_0x27ffb5=_0x27ffb5||0x1f4;return function(_0x59a956){logger[_0xf626('0x27')](_0x59a956[_0xf626('0x28')]);if(_0x59a956[_0xf626('0x29')]){delete _0x59a956[_0xf626('0x29')];}_0x47b41c[_0xf626('0x17')](_0x27ffb5)[_0xf626('0x2a')](_0x59a956);};}exports[_0xf626('0x2b')]=function(_0x218728,_0x1dbd50){var _0x3b47cb={},_0x418a05={},_0x30f87c={'count':0x0,'rows':[]};var _0x3be1ea=_[_0xf626('0x2c')](db[_0xf626('0x2d')][_0xf626('0x2e')],function(_0x5df7da){return{'name':_0x5df7da[_0xf626('0x2f')],'type':_0x5df7da[_0xf626('0x30')][_0xf626('0x31')]};});_0x418a05[_0xf626('0x32')]=_['map'](_0x3be1ea,_0xf626('0x29'));_0x418a05[_0xf626('0x33')]=_[_0xf626('0x34')](_0x218728[_0xf626('0x33')]);_0x418a05[_0xf626('0x35')]=_[_0xf626('0x36')](_0x418a05[_0xf626('0x32')],_0x418a05[_0xf626('0x33')]);_0x3b47cb[_0xf626('0x37')]=_['intersection'](_0x418a05['model'],qs[_0xf626('0x38')](_0x218728[_0xf626('0x33')][_0xf626('0x38')]));_0x3b47cb[_0xf626('0x37')]=_0x3b47cb[_0xf626('0x37')][_0xf626('0x39')]?_0x3b47cb[_0xf626('0x37')]:_0x418a05[_0xf626('0x32')];if(!_0x218728['query'][_0xf626('0x3a')](_0xf626('0x3b'))){_0x3b47cb[_0xf626('0x1a')]=qs[_0xf626('0x1a')](_0x218728[_0xf626('0x33')][_0xf626('0x1a')]);_0x3b47cb[_0xf626('0x19')]=qs[_0xf626('0x19')](_0x218728[_0xf626('0x33')][_0xf626('0x19')]);}_0x3b47cb[_0xf626('0x3c')]=qs[_0xf626('0x3d')](_0x218728[_0xf626('0x33')]['sort']);delete _0x218728['query']['sort'];_0x3b47cb['where']=qs['filters'](_[_0xf626('0x3e')](_0x218728['query'],_0x418a05['filters']),_0x3be1ea);if(_0x218728[_0xf626('0x33')][_0xf626('0x3f')]){_0x3b47cb[_0xf626('0x40')]=_['merge'](_0x3b47cb[_0xf626('0x40')],{'$or':_[_0xf626('0x2c')](_0x3be1ea,function(_0x3929aa){if(_0x3929aa[_0xf626('0x30')]!==_0xf626('0x41')){var _0x5b49b7={};_0x5b49b7[_0x3929aa[_0xf626('0x29')]]={'$like':'%'+_0x218728[_0xf626('0x33')][_0xf626('0x3f')]+'%'};return _0x5b49b7;}})});}_0x3b47cb=_[_0xf626('0x42')]({},_0x3b47cb,_0x218728[_0xf626('0x43')]);var _0x44323c={'where':_0x3b47cb[_0xf626('0x40')]};return db[_0xf626('0x2d')][_0xf626('0x1c')](_0x44323c)[_0xf626('0x23')](function(_0x279887){_0x30f87c[_0xf626('0x1c')]=_0x279887;if(_0x218728[_0xf626('0x33')][_0xf626('0x44')]){_0x3b47cb[_0xf626('0x45')]=[{'all':!![]}];}return db[_0xf626('0x2d')][_0xf626('0x46')](_0x3b47cb);})[_0xf626('0x23')](function(_0x255a82){_0x30f87c[_0xf626('0x47')]=_0x255a82;return _0x30f87c;})[_0xf626('0x23')](respondWithFilteredResult(_0x1dbd50,_0x3b47cb))[_0xf626('0x48')](handleError(_0x1dbd50,null));};exports[_0xf626('0x49')]=function(_0x2d413e,_0x4abe05){var _0x2f5b11={'raw':![],'where':{'id':_0x2d413e[_0xf626('0x4a')]['id']}},_0x34fd7f={};_0x34fd7f[_0xf626('0x32')]=_[_0xf626('0x34')](db[_0xf626('0x2d')]['rawAttributes']);_0x34fd7f[_0xf626('0x33')]=_[_0xf626('0x34')](_0x2d413e[_0xf626('0x33')]);_0x34fd7f[_0xf626('0x35')]=_['intersection'](_0x34fd7f[_0xf626('0x32')],_0x34fd7f['query']);_0x2f5b11[_0xf626('0x37')]=_[_0xf626('0x36')](_0x34fd7f[_0xf626('0x32')],qs[_0xf626('0x38')](_0x2d413e[_0xf626('0x33')][_0xf626('0x38')]));_0x2f5b11[_0xf626('0x37')]=_0x2f5b11[_0xf626('0x37')]['length']?_0x2f5b11[_0xf626('0x37')]:_0x34fd7f[_0xf626('0x32')];if(_0x2d413e['query'][_0xf626('0x44')]){_0x2f5b11[_0xf626('0x45')]=[{'all':!![]}];}_0x2f5b11=_[_0xf626('0x42')]({},_0x2f5b11,_0x2d413e[_0xf626('0x43')]);return db[_0xf626('0x2d')][_0xf626('0x4b')](_0x2f5b11)[_0xf626('0x23')](handleEntityNotFound(_0x4abe05,null))['then'](respondWithResult(_0x4abe05,null))['catch'](handleError(_0x4abe05,null));};exports[_0xf626('0x22')]=function(_0x79fc35,_0x5201c0){if(_0x79fc35[_0xf626('0x4c')]['id']){delete _0x79fc35[_0xf626('0x4c')]['id'];}return db['VoiceMusicOnHold'][_0xf626('0x4b')]({'where':{'id':_0x79fc35['params']['id']}})[_0xf626('0x23')](handleEntityNotFound(_0x5201c0,null))[_0xf626('0x23')](saveUpdates(_0x79fc35[_0xf626('0x4c')],null))['then'](respondWithResult(_0x5201c0,null))['catch'](handleError(_0x5201c0,null));};exports['create']=function(_0x24b820,_0x24fef2,_0x261301){return db[_0xf626('0x4d')]['transaction'](function(_0xeb9cb3){if(_0x24b820[_0xf626('0x4c')][_0xf626('0x4e')]===_0xf626('0x4f')){_0x24b820['body'][_0xf626('0x50')]=path[_0xf626('0x51')](config[_0xf626('0x52')],_0xf626('0x53'),_0x24b820['body']['name']);}return db[_0xf626('0x2d')][_0xf626('0x54')](_0x24b820[_0xf626('0x4c')],{'transaction':_0xeb9cb3})[_0xf626('0x23')](function(_0x15012c){if(_0x24b820['body'][_0xf626('0x4e')]===_0xf626('0x4f')){fs[_0xf626('0x55')](_0x15012c[_0xf626('0x50')],parseInt(_0xf626('0x56'),0x8));}var _0x2bc35f=_0x24b820[_0xf626('0x57')][_0xf626('0x58')]({'plain':!![]});if(!_0x2bc35f)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2bc35f[_0xf626('0x59')]===_0xf626('0x57')){var _0x1f9361=_0x15012c[_0xf626('0x58')]({'plain':!![]});return db['UserProfileSection']['find']({'where':{'name':_0xf626('0x25'),'userProfileId':_0x2bc35f['userProfileId']},'raw':!![]})['then'](function(_0x4c7490){if(_0x4c7490&&_0x4c7490[_0xf626('0x5a')]===0x0){return db[_0xf626('0x26')][_0xf626('0x54')]({'name':_0x1f9361[_0xf626('0x29')],'resourceId':_0x1f9361['id'],'type':_0x4c7490[_0xf626('0x29')],'sectionId':_0x4c7490['id']},{})['then'](function(){return _0x15012c;});}else{return _0x15012c;}})[_0xf626('0x48')](function(_0x4b9630){logger[_0xf626('0x27')](_0xf626('0x5b'),_0x4b9630);});}return _0x15012c;});})[_0xf626('0x23')](respondWithResult(_0x24fef2,0xc9))[_0xf626('0x48')](handleError(_0x24fef2,null));};exports[_0xf626('0x24')]=function(_0x183e3f,_0x1098bd,_0x1c4876){var _0x5f164d;return db[_0xf626('0x2d')][_0xf626('0x4b')]({'where':{'id':_0x183e3f[_0xf626('0x4a')]['id']}})[_0xf626('0x23')](function(_0x106202){if(_0x106202){return db[_0xf626('0x4d')][_0xf626('0x5c')](function(_0x374f21){return _0x106202[_0xf626('0x24')]({'transaction':_0x374f21,'raw':!![]})[_0xf626('0x23')](function(_0x3f125e){if(_0x3f125e[_0xf626('0x50')]){fs[_0xf626('0x5d')](_0x3f125e[_0xf626('0x50')])['forEach'](function(_0x12e83f){fs['unlinkSync'](path[_0xf626('0x51')](_0x3f125e['directory'],_0x12e83f));});fs[_0xf626('0x5e')](_0x3f125e[_0xf626('0x50')]);}return _0x3f125e;});})[_0xf626('0x48')](function(_0x3c47bc){throw new db[(_0xf626('0x5f'))]['ValidationError'](_0x3c47bc[_0xf626('0x60')]);});}})[_0xf626('0x23')](handleEntityNotFound(_0x1098bd,null))['then'](removeEntity(_0x1098bd,null))[_0xf626('0x48')](handleError(_0x1098bd,null));};exports[_0xf626('0x61')]=function(_0x52a52b,_0x1a7901,_0x621c59){return db[_0xf626('0x4d')][_0xf626('0x5c')](function(_0x476cfc){var _0x14eab5;return db['VoiceMusicOnHold'][_0xf626('0x4b')]({'where':{'id':_0x52a52b[_0xf626('0x4a')]['id']}})[_0xf626('0x23')](function(_0x82ed16){if(_0x82ed16){_0x14eab5=_0x82ed16;return _0x82ed16[_0xf626('0x61')](_0x52a52b[_0xf626('0x4c')]['id'],{'transaction':_0x476cfc});}})[_0xf626('0x23')](function(_0x58a5a8){if(_0x58a5a8){return db['Sound'][_0xf626('0x62')]({'where':{'id':_0x52a52b[_0xf626('0x4c')]['id']},'attributes':['id',_0xf626('0x29'),'save_name','converted_format','createdAt'],'raw':!![]});}})['then'](function(_0x25ce54){if(_0x25ce54){var _0x405432=path[_0xf626('0x51')](config[_0xf626('0x52')],'server/files/sounds/converted',util[_0xf626('0x63')]('%s.%s',path['basename'](_0x25ce54[_0xf626('0x64')],path[_0xf626('0x65')](_0x25ce54[_0xf626('0x64')])),_0x25ce54[_0xf626('0x66')]));var _0x144d69=path[_0xf626('0x51')](config[_0xf626('0x52')],_0xf626('0x53'),_0x14eab5[_0xf626('0x29')],util[_0xf626('0x63')](_0xf626('0x67'),_0x25ce54[_0xf626('0x29')],_0x25ce54['converted_format']));fs[_0xf626('0x68')](_0x405432,_0x144d69);return _0x25ce54;}})[_0xf626('0x48')](function(_0x1f6db6){throw new db[(_0xf626('0x5f'))]['ValidationError'](_0x1f6db6[_0xf626('0x60')]);});})[_0xf626('0x23')](handleEntityNotFound(_0x1a7901,null))['then'](respondWithResult(_0x1a7901,0xc9))[_0xf626('0x48')](handleError(_0x1a7901,null));};exports[_0xf626('0x69')]=function(_0x50d20b,_0x511355,_0x459f36){return db['sequelize'][_0xf626('0x5c')](function(_0x5a10ca){var _0x412609;return db[_0xf626('0x2d')][_0xf626('0x62')]({'where':{'id':_0x50d20b['params']['id']}})[_0xf626('0x23')](handleEntityNotFound(_0x511355,null))[_0xf626('0x23')](function(_0x173a80){if(_0x173a80){_0x412609=_0x173a80;return _0x173a80[_0xf626('0x69')](_0x50d20b[_0xf626('0x4a')]['id2']);}})[_0xf626('0x23')](function(_0x4a8748){if(_0x4a8748){return db[_0xf626('0x6a')][_0xf626('0x62')]({'where':{'id':_0x50d20b['params']['id2']},'attributes':['id','name',_0xf626('0x64'),'converted_format',_0xf626('0x6b')],'raw':!![]});}})[_0xf626('0x23')](function(_0x43fdd1){if(_0x43fdd1){fs[_0xf626('0x6c')](path[_0xf626('0x51')](_0x412609[_0xf626('0x50')],util[_0xf626('0x63')](_0xf626('0x67'),_0x43fdd1['name'],_0x43fdd1['converted_format'])));return _0x43fdd1;}})[_0xf626('0x48')](function(_0xab581d){throw new db[(_0xf626('0x5f'))][(_0xf626('0x6d'))](_0xab581d[_0xf626('0x60')]);});})[_0xf626('0x23')](handleEntityNotFound(_0x511355,null))[_0xf626('0x23')](respondWithStatusCode(_0x511355,0xcc))[_0xf626('0x48')](handleError(_0x511355,null));};exports['getSounds']=function(_0x57c797,_0x481260,_0x248612){var _0x345310={};var _0x2cc8bd={};var _0x4d6fe8;var _0x83b746;return db[_0xf626('0x2d')][_0xf626('0x62')]({'where':{'id':_0x57c797[_0xf626('0x4a')]['id']}})[_0xf626('0x23')](handleEntityNotFound(_0x481260,null))[_0xf626('0x23')](function(_0x451d12){if(_0x451d12){_0x4d6fe8=_0x451d12;_0x2cc8bd[_0xf626('0x32')]=_[_0xf626('0x34')](db[_0xf626('0x6a')][_0xf626('0x2e')]);_0x2cc8bd[_0xf626('0x33')]=_[_0xf626('0x34')](_0x57c797[_0xf626('0x33')]);_0x2cc8bd[_0xf626('0x35')]=_[_0xf626('0x36')](_0x2cc8bd[_0xf626('0x32')],_0x2cc8bd[_0xf626('0x33')]);_0x345310[_0xf626('0x37')]=_[_0xf626('0x36')](_0x2cc8bd[_0xf626('0x32')],qs['fields'](_0x57c797['query'][_0xf626('0x38')]));_0x345310[_0xf626('0x37')]=_0x345310[_0xf626('0x37')][_0xf626('0x39')]?_0x345310[_0xf626('0x37')]:_0x2cc8bd[_0xf626('0x32')];_0x345310[_0xf626('0x3c')]=qs[_0xf626('0x3d')](_0x57c797[_0xf626('0x33')][_0xf626('0x3d')]);_0x345310[_0xf626('0x40')]=qs[_0xf626('0x35')](_[_0xf626('0x3e')](_0x57c797[_0xf626('0x33')],_0x2cc8bd[_0xf626('0x35')]));if(_0x57c797[_0xf626('0x33')][_0xf626('0x3f')]){_0x345310['where']=_['merge'](_0x345310['where'],{'$or':_[_0xf626('0x2c')](_0x345310['attributes'],function(_0x4f19dd){var _0x526305={};_0x526305[_0x4f19dd]={'$like':'%'+_0x57c797[_0xf626('0x33')]['filter']+'%'};return _0x526305;})});}_0x345310=_[_0xf626('0x42')]({},_0x345310,_0x57c797['options']);return _0x4d6fe8[_0xf626('0x6e')](_0x345310);}})[_0xf626('0x23')](function(_0x139e9a){if(_0x139e9a){_0x83b746=_0x139e9a['length'];if(!_0x57c797['query'][_0xf626('0x3a')](_0xf626('0x3b'))){_0x345310[_0xf626('0x1a')]=qs[_0xf626('0x1a')](_0x57c797[_0xf626('0x33')]['limit']);_0x345310[_0xf626('0x19')]=qs[_0xf626('0x19')](_0x57c797[_0xf626('0x33')][_0xf626('0x19')]);}return _0x4d6fe8[_0xf626('0x6e')](_0x345310);}})['then'](function(_0x59eda3){if(_0x59eda3){return _0x59eda3?{'count':_0x83b746,'rows':_0x59eda3}:null;}})['then'](respondWithResult(_0x481260,null))['catch'](handleError(_0x481260,null));};
\ No newline at end of file
+var _0xe90d=['sort','pick','filter','where','merge','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','filters','length','find','body','create','sequelize','files','directory','join','server/files/moh','mode','mkdirSync','0777','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','transaction','readdirSync','forEach','rmdirSync','ValidationError','message','addSound','Sound','save_name','createdAt','root','server/files/sounds/converted','%s.%s','basename','extname','converted_format','format','symlinkSync','Sequelize','removeSound','id2','findOne','unlinkSync','getSounds','eml-format','rimraf','fast-json-patch','bluebird','mustache','util','path','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','save','update','then','get','MusicOnHolds','UserProfileResource','destroy','sendStatus','error','stack','name','index','map','VoiceMusicOnHold','fieldName','type','key','model','query','keys','intersection','attributes','fields','hasOwnProperty','nolimit','order'];(function(_0xe86415,_0x4fe3ab){var _0x4dc900=function(_0xc4dd21){while(--_0xc4dd21){_0xe86415['push'](_0xe86415['shift']());}};_0x4dc900(++_0x4fe3ab);}(_0xe90d,0x123));var _0xde90=function(_0x1c80c,_0x20f7ce){_0x1c80c=_0x1c80c-0x0;var _0x347317=_0xe90d[_0x1c80c];return _0x347317;};'use strict';var emlformat=require(_0xde90('0x0'));var rimraf=require(_0xde90('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xde90('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xde90('0x3'));var Mustache=require(_0xde90('0x4'));var util=require(_0xde90('0x5'));var path=require(_0xde90('0x6'));var sox=require('sox');var csv=require(_0xde90('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xde90('0x8'));var _=require(_0xde90('0x9'));var squel=require(_0xde90('0xa'));var crypto=require(_0xde90('0xb'));var jsforce=require(_0xde90('0xc'));var deskjs=require(_0xde90('0xd'));var toCsv=require(_0xde90('0x7'));var querystring=require('querystring');var Papa=require(_0xde90('0xe'));var Redis=require('ioredis');var authService=require(_0xde90('0xf'));var qs=require(_0xde90('0x10'));var as=require(_0xde90('0x11'));var hardwareService=require(_0xde90('0x12'));var logger=require(_0xde90('0x13'))(_0xde90('0x14'));var utils=require(_0xde90('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xde90('0x16'));var db=require(_0xde90('0x17'))['db'];function respondWithStatusCode(_0xc6fbaf,_0x8258dc){_0x8258dc=_0x8258dc||0xcc;return function(_0x63ed0e){if(_0x63ed0e){return _0xc6fbaf['sendStatus'](_0x8258dc);}return _0xc6fbaf[_0xde90('0x18')](_0x8258dc)[_0xde90('0x19')]();};}function respondWithResult(_0x317c18,_0x261853){_0x261853=_0x261853||0xc8;return function(_0x30220b){if(_0x30220b){return _0x317c18[_0xde90('0x18')](_0x261853)[_0xde90('0x1a')](_0x30220b);}};}function respondWithFilteredResult(_0x22633f,_0x27e426){return function(_0x547ef8){if(_0x547ef8){var _0x246383=typeof _0x27e426[_0xde90('0x1b')]===_0xde90('0x1c')&&typeof _0x27e426[_0xde90('0x1d')]==='undefined';var _0x893881=_0x547ef8[_0xde90('0x1e')];var _0x263899=_0x246383?0x0:_0x27e426[_0xde90('0x1b')];var _0x5b4865=_0x246383?_0x547ef8[_0xde90('0x1e')]:_0x27e426['offset']+_0x27e426[_0xde90('0x1d')];var _0x24817b;if(_0x5b4865>=_0x893881){_0x5b4865=_0x893881;_0x24817b=0xc8;}else{_0x24817b=0xce;}_0x22633f[_0xde90('0x18')](_0x24817b);return _0x22633f['set'](_0xde90('0x1f'),_0x263899+'-'+_0x5b4865+'/'+_0x893881)['json'](_0x547ef8);}return null;};}function patchUpdates(_0x250598){return function(_0x119545){try{jsonpatch[_0xde90('0x20')](_0x119545,_0x250598,!![]);}catch(_0x5317d6){return BPromise[_0xde90('0x21')](_0x5317d6);}return _0x119545[_0xde90('0x22')]();};}function saveUpdates(_0x1070bc,_0x523cba){return function(_0x375596){if(_0x375596){return _0x375596[_0xde90('0x23')](_0x1070bc)[_0xde90('0x24')](function(_0x3bc6c1){return _0x3bc6c1;});}return null;};}function removeEntity(_0x485759,_0x51f095){return function(_0x313eff){if(_0x313eff){return _0x313eff['destroy']()[_0xde90('0x24')](function(){var _0x18d10a=_0x313eff[_0xde90('0x25')]({'plain':!![]});var _0x29f064=_0xde90('0x26');return db[_0xde90('0x27')][_0xde90('0x28')]({'where':{'type':_0x29f064,'resourceId':_0x18d10a['id']}})[_0xde90('0x24')](function(){return _0x313eff;});})['then'](function(){_0x485759[_0xde90('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2c0ff2,_0x210944){return function(_0x10f041){if(!_0x10f041){_0x2c0ff2[_0xde90('0x29')](0x194);}return _0x10f041;};}function handleError(_0xbf56c6,_0x55f859){_0x55f859=_0x55f859||0x1f4;return function(_0x2bb5c3){logger[_0xde90('0x2a')](_0x2bb5c3[_0xde90('0x2b')]);if(_0x2bb5c3[_0xde90('0x2c')]){delete _0x2bb5c3['name'];}_0xbf56c6[_0xde90('0x18')](_0x55f859)['send'](_0x2bb5c3);};}exports[_0xde90('0x2d')]=function(_0x5d812d,_0x5df18c){var _0x2c99a5={},_0x2301e7={},_0x3f0d84={'count':0x0,'rows':[]};var _0x360c89=_[_0xde90('0x2e')](db[_0xde90('0x2f')]['rawAttributes'],function(_0x48cb93){return{'name':_0x48cb93[_0xde90('0x30')],'type':_0x48cb93[_0xde90('0x31')][_0xde90('0x32')]};});_0x2301e7[_0xde90('0x33')]=_['map'](_0x360c89,_0xde90('0x2c'));_0x2301e7[_0xde90('0x34')]=_[_0xde90('0x35')](_0x5d812d['query']);_0x2301e7['filters']=_[_0xde90('0x36')](_0x2301e7['model'],_0x2301e7[_0xde90('0x34')]);_0x2c99a5[_0xde90('0x37')]=_[_0xde90('0x36')](_0x2301e7[_0xde90('0x33')],qs[_0xde90('0x38')](_0x5d812d['query']['fields']));_0x2c99a5['attributes']=_0x2c99a5[_0xde90('0x37')]['length']?_0x2c99a5[_0xde90('0x37')]:_0x2301e7['model'];if(!_0x5d812d['query'][_0xde90('0x39')](_0xde90('0x3a'))){_0x2c99a5['limit']=qs[_0xde90('0x1d')](_0x5d812d['query'][_0xde90('0x1d')]);_0x2c99a5[_0xde90('0x1b')]=qs[_0xde90('0x1b')](_0x5d812d[_0xde90('0x34')][_0xde90('0x1b')]);}_0x2c99a5[_0xde90('0x3b')]=qs['sort'](_0x5d812d[_0xde90('0x34')][_0xde90('0x3c')]);delete _0x5d812d['query'][_0xde90('0x3c')];_0x2c99a5['where']=qs['filters'](_[_0xde90('0x3d')](_0x5d812d[_0xde90('0x34')],_0x2301e7['filters']),_0x360c89);if(_0x5d812d['query'][_0xde90('0x3e')]){_0x2c99a5[_0xde90('0x3f')]=_[_0xde90('0x40')](_0x2c99a5['where'],{'$or':_[_0xde90('0x2e')](_0x360c89,function(_0x38b8ed){if(_0x38b8ed[_0xde90('0x31')]!=='VIRTUAL'){var _0x115f93={};_0x115f93[_0x38b8ed[_0xde90('0x2c')]]={'$like':'%'+_0x5d812d[_0xde90('0x34')][_0xde90('0x3e')]+'%'};return _0x115f93;}})});}_0x2c99a5=_[_0xde90('0x40')]({},_0x2c99a5,_0x5d812d[_0xde90('0x41')]);var _0xfc77c5={'where':_0x2c99a5[_0xde90('0x3f')]};return db['VoiceMusicOnHold'][_0xde90('0x1e')](_0xfc77c5)[_0xde90('0x24')](function(_0x14e99d){_0x3f0d84[_0xde90('0x1e')]=_0x14e99d;if(_0x5d812d['query'][_0xde90('0x42')]){_0x2c99a5[_0xde90('0x43')]=[{'all':!![]}];}return db[_0xde90('0x2f')][_0xde90('0x44')](_0x2c99a5);})[_0xde90('0x24')](function(_0x3eb0d5){_0x3f0d84[_0xde90('0x45')]=_0x3eb0d5;return _0x3f0d84;})[_0xde90('0x24')](respondWithFilteredResult(_0x5df18c,_0x2c99a5))[_0xde90('0x46')](handleError(_0x5df18c,null));};exports[_0xde90('0x47')]=function(_0x423932,_0x1018ad){var _0x117c5e={'raw':![],'where':{'id':_0x423932[_0xde90('0x48')]['id']}},_0x45789d={};_0x45789d[_0xde90('0x33')]=_[_0xde90('0x35')](db[_0xde90('0x2f')][_0xde90('0x49')]);_0x45789d[_0xde90('0x34')]=_[_0xde90('0x35')](_0x423932[_0xde90('0x34')]);_0x45789d[_0xde90('0x4a')]=_[_0xde90('0x36')](_0x45789d[_0xde90('0x33')],_0x45789d['query']);_0x117c5e[_0xde90('0x37')]=_['intersection'](_0x45789d[_0xde90('0x33')],qs[_0xde90('0x38')](_0x423932[_0xde90('0x34')][_0xde90('0x38')]));_0x117c5e[_0xde90('0x37')]=_0x117c5e[_0xde90('0x37')][_0xde90('0x4b')]?_0x117c5e[_0xde90('0x37')]:_0x45789d[_0xde90('0x33')];if(_0x423932[_0xde90('0x34')]['includeAll']){_0x117c5e[_0xde90('0x43')]=[{'all':!![]}];}_0x117c5e=_[_0xde90('0x40')]({},_0x117c5e,_0x423932[_0xde90('0x41')]);return db[_0xde90('0x2f')][_0xde90('0x4c')](_0x117c5e)[_0xde90('0x24')](handleEntityNotFound(_0x1018ad,null))[_0xde90('0x24')](respondWithResult(_0x1018ad,null))[_0xde90('0x46')](handleError(_0x1018ad,null));};exports[_0xde90('0x23')]=function(_0x4c6673,_0x35cdb8){if(_0x4c6673[_0xde90('0x4d')]['id']){delete _0x4c6673[_0xde90('0x4d')]['id'];}return db['VoiceMusicOnHold']['find']({'where':{'id':_0x4c6673[_0xde90('0x48')]['id']}})[_0xde90('0x24')](handleEntityNotFound(_0x35cdb8,null))[_0xde90('0x24')](saveUpdates(_0x4c6673[_0xde90('0x4d')],null))['then'](respondWithResult(_0x35cdb8,null))[_0xde90('0x46')](handleError(_0x35cdb8,null));};exports[_0xde90('0x4e')]=function(_0x487236,_0x22308d,_0x1dcb1d){return db[_0xde90('0x4f')]['transaction'](function(_0xd84282){if(_0x487236[_0xde90('0x4d')]['mode']===_0xde90('0x50')){_0x487236['body'][_0xde90('0x51')]=path[_0xde90('0x52')](config['root'],_0xde90('0x53'),_0x487236[_0xde90('0x4d')][_0xde90('0x2c')]);}return db[_0xde90('0x2f')][_0xde90('0x4e')](_0x487236[_0xde90('0x4d')],{'transaction':_0xd84282})[_0xde90('0x24')](function(_0x27fe46){if(_0x487236[_0xde90('0x4d')][_0xde90('0x54')]===_0xde90('0x50')){fs[_0xde90('0x55')](_0x27fe46[_0xde90('0x51')],parseInt(_0xde90('0x56'),0x8));}var _0x3206dd=_0x487236['user'][_0xde90('0x25')]({'plain':!![]});if(!_0x3206dd)throw new Error(_0xde90('0x57'));if(_0x3206dd['role']===_0xde90('0x58')){var _0x2d48e1=_0x27fe46[_0xde90('0x25')]({'plain':!![]});return db[_0xde90('0x59')][_0xde90('0x4c')]({'where':{'name':_0xde90('0x26'),'userProfileId':_0x3206dd[_0xde90('0x5a')]},'raw':!![]})['then'](function(_0x1af60c){if(_0x1af60c&&_0x1af60c[_0xde90('0x5b')]===0x0){return db[_0xde90('0x27')][_0xde90('0x4e')]({'name':_0x2d48e1[_0xde90('0x2c')],'resourceId':_0x2d48e1['id'],'type':_0x1af60c[_0xde90('0x2c')],'sectionId':_0x1af60c['id']},{})[_0xde90('0x24')](function(){return _0x27fe46;});}else{return _0x27fe46;}})[_0xde90('0x46')](function(_0x20358c){logger['error'](_0xde90('0x5c'),_0x20358c);});}return _0x27fe46;});})[_0xde90('0x24')](respondWithResult(_0x22308d,0xc9))[_0xde90('0x46')](handleError(_0x22308d,null));};exports[_0xde90('0x28')]=function(_0x15f08b,_0x35dc97,_0x4bc371){var _0x1cc323;return db['VoiceMusicOnHold'][_0xde90('0x4c')]({'where':{'id':_0x15f08b[_0xde90('0x48')]['id']}})[_0xde90('0x24')](function(_0x59d858){if(_0x59d858){return db[_0xde90('0x4f')][_0xde90('0x5d')](function(_0x142a36){return _0x59d858['destroy']({'transaction':_0x142a36,'raw':!![]})['then'](function(_0x10fbc5){if(_0x10fbc5[_0xde90('0x51')]){fs[_0xde90('0x5e')](_0x10fbc5[_0xde90('0x51')])[_0xde90('0x5f')](function(_0x4f512b){fs['unlinkSync'](path['join'](_0x10fbc5[_0xde90('0x51')],_0x4f512b));});fs[_0xde90('0x60')](_0x10fbc5[_0xde90('0x51')]);}return _0x10fbc5;});})[_0xde90('0x46')](function(_0x76d5f7){throw new db['Sequelize'][(_0xde90('0x61'))](_0x76d5f7[_0xde90('0x62')]);});}})['then'](handleEntityNotFound(_0x35dc97,null))[_0xde90('0x24')](removeEntity(_0x35dc97,null))[_0xde90('0x46')](handleError(_0x35dc97,null));};exports[_0xde90('0x63')]=function(_0x3ec1a5,_0x181b45,_0x1f7c70){return db[_0xde90('0x4f')]['transaction'](function(_0x199242){var _0x1a4691;return db[_0xde90('0x2f')]['find']({'where':{'id':_0x3ec1a5['params']['id']}})[_0xde90('0x24')](function(_0x5a6128){if(_0x5a6128){_0x1a4691=_0x5a6128;return _0x5a6128['addSound'](_0x3ec1a5[_0xde90('0x4d')]['id'],{'transaction':_0x199242});}})['then'](function(_0x571b41){if(_0x571b41){return db[_0xde90('0x64')]['findOne']({'where':{'id':_0x3ec1a5[_0xde90('0x4d')]['id']},'attributes':['id',_0xde90('0x2c'),_0xde90('0x65'),'converted_format',_0xde90('0x66')],'raw':!![]});}})[_0xde90('0x24')](function(_0x444182){if(_0x444182){var _0xe5df77=path[_0xde90('0x52')](config[_0xde90('0x67')],_0xde90('0x68'),util['format'](_0xde90('0x69'),path[_0xde90('0x6a')](_0x444182[_0xde90('0x65')],path[_0xde90('0x6b')](_0x444182['save_name'])),_0x444182[_0xde90('0x6c')]));var _0x34e7f8=path[_0xde90('0x52')](config[_0xde90('0x67')],'server/files/moh',_0x1a4691[_0xde90('0x2c')],util[_0xde90('0x6d')](_0xde90('0x69'),_0x444182['name'],_0x444182['converted_format']));fs[_0xde90('0x6e')](_0xe5df77,_0x34e7f8);return _0x444182;}})[_0xde90('0x46')](function(_0x30453f){throw new db[(_0xde90('0x6f'))][(_0xde90('0x61'))](_0x30453f[_0xde90('0x62')]);});})['then'](handleEntityNotFound(_0x181b45,null))[_0xde90('0x24')](respondWithResult(_0x181b45,0xc9))[_0xde90('0x46')](handleError(_0x181b45,null));};exports[_0xde90('0x70')]=function(_0x429fde,_0x2e4cdf,_0x127ee0){return db[_0xde90('0x4f')][_0xde90('0x5d')](function(_0x973343){var _0x47b756;return db[_0xde90('0x2f')]['findOne']({'where':{'id':_0x429fde[_0xde90('0x48')]['id']}})[_0xde90('0x24')](handleEntityNotFound(_0x2e4cdf,null))['then'](function(_0x369488){if(_0x369488){_0x47b756=_0x369488;return _0x369488[_0xde90('0x70')](_0x429fde[_0xde90('0x48')][_0xde90('0x71')]);}})[_0xde90('0x24')](function(_0x56f1e0){if(_0x56f1e0){return db[_0xde90('0x64')][_0xde90('0x72')]({'where':{'id':_0x429fde[_0xde90('0x48')]['id2']},'attributes':['id',_0xde90('0x2c'),_0xde90('0x65'),_0xde90('0x6c'),_0xde90('0x66')],'raw':!![]});}})[_0xde90('0x24')](function(_0x194400){if(_0x194400){fs[_0xde90('0x73')](path[_0xde90('0x52')](_0x47b756[_0xde90('0x51')],util[_0xde90('0x6d')]('%s.%s',_0x194400['name'],_0x194400[_0xde90('0x6c')])));return _0x194400;}})[_0xde90('0x46')](function(_0x7d0d5c){throw new db[(_0xde90('0x6f'))][(_0xde90('0x61'))](_0x7d0d5c[_0xde90('0x62')]);});})[_0xde90('0x24')](handleEntityNotFound(_0x2e4cdf,null))[_0xde90('0x24')](respondWithStatusCode(_0x2e4cdf,0xcc))[_0xde90('0x46')](handleError(_0x2e4cdf,null));};exports[_0xde90('0x74')]=function(_0x20b774,_0x1f0c9c,_0xd19342){var _0x4579b7={};var _0x2dcaed={};var _0x245cda;var _0x28b395;return db[_0xde90('0x2f')]['findOne']({'where':{'id':_0x20b774[_0xde90('0x48')]['id']}})[_0xde90('0x24')](handleEntityNotFound(_0x1f0c9c,null))[_0xde90('0x24')](function(_0x128041){if(_0x128041){_0x245cda=_0x128041;_0x2dcaed[_0xde90('0x33')]=_[_0xde90('0x35')](db[_0xde90('0x64')][_0xde90('0x49')]);_0x2dcaed[_0xde90('0x34')]=_[_0xde90('0x35')](_0x20b774[_0xde90('0x34')]);_0x2dcaed['filters']=_[_0xde90('0x36')](_0x2dcaed[_0xde90('0x33')],_0x2dcaed[_0xde90('0x34')]);_0x4579b7['attributes']=_[_0xde90('0x36')](_0x2dcaed[_0xde90('0x33')],qs[_0xde90('0x38')](_0x20b774[_0xde90('0x34')][_0xde90('0x38')]));_0x4579b7[_0xde90('0x37')]=_0x4579b7['attributes']['length']?_0x4579b7['attributes']:_0x2dcaed['model'];_0x4579b7['order']=qs['sort'](_0x20b774[_0xde90('0x34')][_0xde90('0x3c')]);_0x4579b7[_0xde90('0x3f')]=qs['filters'](_[_0xde90('0x3d')](_0x20b774[_0xde90('0x34')],_0x2dcaed[_0xde90('0x4a')]));if(_0x20b774[_0xde90('0x34')][_0xde90('0x3e')]){_0x4579b7[_0xde90('0x3f')]=_[_0xde90('0x40')](_0x4579b7[_0xde90('0x3f')],{'$or':_['map'](_0x4579b7[_0xde90('0x37')],function(_0x2574e9){var _0x39f8bd={};_0x39f8bd[_0x2574e9]={'$like':'%'+_0x20b774[_0xde90('0x34')][_0xde90('0x3e')]+'%'};return _0x39f8bd;})});}_0x4579b7=_[_0xde90('0x40')]({},_0x4579b7,_0x20b774[_0xde90('0x41')]);return _0x245cda['getSounds'](_0x4579b7);}})[_0xde90('0x24')](function(_0x562848){if(_0x562848){_0x28b395=_0x562848['length'];if(!_0x20b774[_0xde90('0x34')]['hasOwnProperty']('nolimit')){_0x4579b7[_0xde90('0x1d')]=qs['limit'](_0x20b774['query'][_0xde90('0x1d')]);_0x4579b7['offset']=qs[_0xde90('0x1b')](_0x20b774[_0xde90('0x34')]['offset']);}return _0x245cda[_0xde90('0x74')](_0x4579b7);}})[_0xde90('0x24')](function(_0x5ee773){if(_0x5ee773){return _0x5ee773?{'count':_0x28b395,'rows':_0x5ee773}:null;}})[_0xde90('0x24')](respondWithResult(_0x1f0c9c,null))['catch'](handleError(_0x1f0c9c,null));};
\ No newline at end of file