Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / voiceMusicOnHold / voiceMusicOnHold.controller.js
index 158d1ca..37662b6 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 _0xb631=['basename','save_name','Sequelize','removeSound','findOne','id2','Sound','getSounds','hasOwnProperty','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','ejs','fs-extra','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','Content-Range','json','apply','reject','save','update','then','destroy','get','MusicOnHolds','UserProfileResource','error','stack','name','send','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','VoiceMusicOnHold','includeAll','include','findAll','show','length','find','catch','body','params','sequelize','join','root','server/files/moh','create','mode','mkdirSync','directory','0777','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','userProfileId','autoAssociation','readdirSync','forEach','unlinkSync','rmdirSync','ValidationError','message','addSound','transaction','converted_format','createdAt','server/files/sounds/converted','format','%s.%s'];(function(_0x7d7c85,_0x4fda4f){var _0x5a255c=function(_0x33519b){while(--_0x33519b){_0x7d7c85['push'](_0x7d7c85['shift']());}};_0x5a255c(++_0x4fda4f);}(_0xb631,0x7a));var _0x1b63=function(_0x5959e1,_0x17bb1a){_0x5959e1=_0x5959e1-0x0;var _0x54f6cc=_0xb631[_0x5959e1];return _0x54f6cc;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x1b63('0x0'));var zipdir=require(_0x1b63('0x1'));var jsonpatch=require(_0x1b63('0x2'));var rp=require('request-promise');var moment=require(_0x1b63('0x3'));var BPromise=require(_0x1b63('0x4'));var Mustache=require(_0x1b63('0x5'));var util=require(_0x1b63('0x6'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x1b63('0x7'));var fs=require('fs');var fs_extra=require(_0x1b63('0x8'));var _=require('lodash');var squel=require(_0x1b63('0x9'));var crypto=require(_0x1b63('0xa'));var jsforce=require(_0x1b63('0xb'));var deskjs=require(_0x1b63('0xc'));var toCsv=require(_0x1b63('0xd'));var querystring=require(_0x1b63('0xe'));var Papa=require(_0x1b63('0xf'));var Redis=require(_0x1b63('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x1b63('0x11'));var as=require(_0x1b63('0x12'));var hardwareService=require(_0x1b63('0x13'));var logger=require(_0x1b63('0x14'))('api');var utils=require(_0x1b63('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x1b63('0x16'));var db=require(_0x1b63('0x17'))['db'];function respondWithStatusCode(_0x2ab929,_0x2f3a4f){_0x2f3a4f=_0x2f3a4f||0xcc;return function(_0x50f591){if(_0x50f591){return _0x2ab929[_0x1b63('0x18')](_0x2f3a4f);}return _0x2ab929[_0x1b63('0x19')](_0x2f3a4f)[_0x1b63('0x1a')]();};}function respondWithResult(_0x105c6c,_0x562376){_0x562376=_0x562376||0xc8;return function(_0x1a97cc){if(_0x1a97cc){return _0x105c6c['status'](_0x562376)['json'](_0x1a97cc);}};}function respondWithFilteredResult(_0x4eb08f,_0x209bf4){return function(_0x2d795d){if(_0x2d795d){var _0x1c31e8=typeof _0x209bf4[_0x1b63('0x1b')]===_0x1b63('0x1c')&&typeof _0x209bf4[_0x1b63('0x1d')]===_0x1b63('0x1c');var _0x1e2c52=_0x2d795d[_0x1b63('0x1e')];var _0x259e23=_0x1c31e8?0x0:_0x209bf4[_0x1b63('0x1b')];var _0x171cc4=_0x1c31e8?_0x2d795d[_0x1b63('0x1e')]:_0x209bf4[_0x1b63('0x1b')]+_0x209bf4[_0x1b63('0x1d')];var _0x2acf84;if(_0x171cc4>=_0x1e2c52){_0x171cc4=_0x1e2c52;_0x2acf84=0xc8;}else{_0x2acf84=0xce;}_0x4eb08f[_0x1b63('0x19')](_0x2acf84);return _0x4eb08f['set'](_0x1b63('0x1f'),_0x259e23+'-'+_0x171cc4+'/'+_0x1e2c52)[_0x1b63('0x20')](_0x2d795d);}return null;};}function patchUpdates(_0x35e40e){return function(_0x50fe9e){try{jsonpatch[_0x1b63('0x21')](_0x50fe9e,_0x35e40e,!![]);}catch(_0x1971ee){return BPromise[_0x1b63('0x22')](_0x1971ee);}return _0x50fe9e[_0x1b63('0x23')]();};}function saveUpdates(_0x39caa0,_0x5107b4){return function(_0x51f98c){if(_0x51f98c){return _0x51f98c[_0x1b63('0x24')](_0x39caa0)[_0x1b63('0x25')](function(_0x1dc8af){return _0x1dc8af;});}return null;};}function removeEntity(_0x49098f,_0x7df4cf){return function(_0x5bee31){if(_0x5bee31){return _0x5bee31[_0x1b63('0x26')]()[_0x1b63('0x25')](function(){var _0x4606de=_0x5bee31[_0x1b63('0x27')]({'plain':!![]});var _0x11acfe=_0x1b63('0x28');return db[_0x1b63('0x29')]['destroy']({'where':{'type':_0x11acfe,'resourceId':_0x4606de['id']}})[_0x1b63('0x25')](function(){return _0x5bee31;});})[_0x1b63('0x25')](function(){_0x49098f['status'](0xcc)[_0x1b63('0x1a')]();});}};}function handleEntityNotFound(_0x53acc6,_0x9ababe){return function(_0x971a0c){if(!_0x971a0c){_0x53acc6['sendStatus'](0x194);}return _0x971a0c;};}function handleError(_0x2af398,_0x2ddf4c){_0x2ddf4c=_0x2ddf4c||0x1f4;return function(_0x544000){logger[_0x1b63('0x2a')](_0x544000[_0x1b63('0x2b')]);if(_0x544000['name']){delete _0x544000[_0x1b63('0x2c')];}_0x2af398[_0x1b63('0x19')](_0x2ddf4c)[_0x1b63('0x2d')](_0x544000);};}exports['index']=function(_0x18ee6c,_0x1c021b){var _0x782c2a={},_0x5a2ad8={},_0x3a5ebf={'count':0x0,'rows':[]};var _0x2a686f=_[_0x1b63('0x2e')](db['VoiceMusicOnHold'][_0x1b63('0x2f')],function(_0xbabe45){return{'name':_0xbabe45[_0x1b63('0x30')],'type':_0xbabe45[_0x1b63('0x31')][_0x1b63('0x32')]};});_0x5a2ad8[_0x1b63('0x33')]=_[_0x1b63('0x2e')](_0x2a686f,_0x1b63('0x2c'));_0x5a2ad8[_0x1b63('0x34')]=_[_0x1b63('0x35')](_0x18ee6c['query']);_0x5a2ad8[_0x1b63('0x36')]=_[_0x1b63('0x37')](_0x5a2ad8['model'],_0x5a2ad8['query']);_0x782c2a['attributes']=_[_0x1b63('0x37')](_0x5a2ad8[_0x1b63('0x33')],qs[_0x1b63('0x38')](_0x18ee6c['query'][_0x1b63('0x38')]));_0x782c2a[_0x1b63('0x39')]=_0x782c2a['attributes']['length']?_0x782c2a['attributes']:_0x5a2ad8[_0x1b63('0x33')];if(!_0x18ee6c[_0x1b63('0x34')]['hasOwnProperty'](_0x1b63('0x3a'))){_0x782c2a[_0x1b63('0x1d')]=qs['limit'](_0x18ee6c['query'][_0x1b63('0x1d')]);_0x782c2a[_0x1b63('0x1b')]=qs[_0x1b63('0x1b')](_0x18ee6c[_0x1b63('0x34')][_0x1b63('0x1b')]);}_0x782c2a[_0x1b63('0x3b')]=qs['sort'](_0x18ee6c['query']['sort']);delete _0x18ee6c[_0x1b63('0x34')][_0x1b63('0x3c')];_0x782c2a[_0x1b63('0x3d')]=qs['filters'](_[_0x1b63('0x3e')](_0x18ee6c[_0x1b63('0x34')],_0x5a2ad8[_0x1b63('0x36')]),_0x2a686f);if(_0x18ee6c['query'][_0x1b63('0x3f')]){_0x782c2a[_0x1b63('0x3d')]=_['merge'](_0x782c2a['where'],{'$or':_[_0x1b63('0x2e')](_0x2a686f,function(_0x48b7d9){if(_0x48b7d9[_0x1b63('0x31')]!==_0x1b63('0x40')){var _0x489043={};_0x489043[_0x48b7d9[_0x1b63('0x2c')]]={'$like':'%'+_0x18ee6c['query']['filter']+'%'};return _0x489043;}})});}_0x782c2a=_[_0x1b63('0x41')]({},_0x782c2a,_0x18ee6c[_0x1b63('0x42')]);var _0x27a885={'where':_0x782c2a['where']};return db[_0x1b63('0x43')][_0x1b63('0x1e')](_0x27a885)[_0x1b63('0x25')](function(_0x1ce9b2){_0x3a5ebf[_0x1b63('0x1e')]=_0x1ce9b2;if(_0x18ee6c['query'][_0x1b63('0x44')]){_0x782c2a[_0x1b63('0x45')]=[{'all':!![]}];}return db['VoiceMusicOnHold'][_0x1b63('0x46')](_0x782c2a);})[_0x1b63('0x25')](function(_0x14e2f2){_0x3a5ebf['rows']=_0x14e2f2;return _0x3a5ebf;})[_0x1b63('0x25')](respondWithFilteredResult(_0x1c021b,_0x782c2a))['catch'](handleError(_0x1c021b,null));};exports[_0x1b63('0x47')]=function(_0x16b4b2,_0x34f86d){var _0x5120f4={'raw':![],'where':{'id':_0x16b4b2['params']['id']}},_0x3413a7={};_0x3413a7[_0x1b63('0x33')]=_[_0x1b63('0x35')](db[_0x1b63('0x43')][_0x1b63('0x2f')]);_0x3413a7[_0x1b63('0x34')]=_[_0x1b63('0x35')](_0x16b4b2['query']);_0x3413a7[_0x1b63('0x36')]=_[_0x1b63('0x37')](_0x3413a7[_0x1b63('0x33')],_0x3413a7[_0x1b63('0x34')]);_0x5120f4[_0x1b63('0x39')]=_[_0x1b63('0x37')](_0x3413a7[_0x1b63('0x33')],qs[_0x1b63('0x38')](_0x16b4b2[_0x1b63('0x34')][_0x1b63('0x38')]));_0x5120f4[_0x1b63('0x39')]=_0x5120f4[_0x1b63('0x39')][_0x1b63('0x48')]?_0x5120f4[_0x1b63('0x39')]:_0x3413a7[_0x1b63('0x33')];if(_0x16b4b2[_0x1b63('0x34')][_0x1b63('0x44')]){_0x5120f4['include']=[{'all':!![]}];}_0x5120f4=_[_0x1b63('0x41')]({},_0x5120f4,_0x16b4b2[_0x1b63('0x42')]);return db[_0x1b63('0x43')][_0x1b63('0x49')](_0x5120f4)['then'](handleEntityNotFound(_0x34f86d,null))[_0x1b63('0x25')](respondWithResult(_0x34f86d,null))[_0x1b63('0x4a')](handleError(_0x34f86d,null));};exports[_0x1b63('0x24')]=function(_0x295075,_0x3221f0){if(_0x295075['body']['id']){delete _0x295075[_0x1b63('0x4b')]['id'];}return db[_0x1b63('0x43')][_0x1b63('0x49')]({'where':{'id':_0x295075[_0x1b63('0x4c')]['id']}})[_0x1b63('0x25')](handleEntityNotFound(_0x3221f0,null))[_0x1b63('0x25')](saveUpdates(_0x295075[_0x1b63('0x4b')],null))[_0x1b63('0x25')](respondWithResult(_0x3221f0,null))[_0x1b63('0x4a')](handleError(_0x3221f0,null));};exports['create']=function(_0x5ddabb,_0x49c55f,_0x265c93){return db[_0x1b63('0x4d')]['transaction'](function(_0x4f5181){if(_0x5ddabb['body']['mode']==='files'){_0x5ddabb[_0x1b63('0x4b')]['directory']=path[_0x1b63('0x4e')](config[_0x1b63('0x4f')],_0x1b63('0x50'),_0x5ddabb[_0x1b63('0x4b')][_0x1b63('0x2c')]);}return db[_0x1b63('0x43')][_0x1b63('0x51')](_0x5ddabb[_0x1b63('0x4b')],{'transaction':_0x4f5181})[_0x1b63('0x25')](function(_0x3e7176){if(_0x5ddabb['body'][_0x1b63('0x52')]==='files'){fs[_0x1b63('0x53')](_0x3e7176[_0x1b63('0x54')],parseInt(_0x1b63('0x55'),0x8));}var _0x4bd4ff=_0x5ddabb['user'][_0x1b63('0x27')]({'plain':!![]});if(!_0x4bd4ff)throw new Error(_0x1b63('0x56'));if(_0x4bd4ff[_0x1b63('0x57')]===_0x1b63('0x58')){var _0x3abef2=_0x3e7176[_0x1b63('0x27')]({'plain':!![]});return db['UserProfileSection']['find']({'where':{'name':'MusicOnHolds','userProfileId':_0x4bd4ff[_0x1b63('0x59')]},'raw':!![]})[_0x1b63('0x25')](function(_0x2f518e){if(_0x2f518e&&_0x2f518e[_0x1b63('0x5a')]===0x0){return db['UserProfileResource'][_0x1b63('0x51')]({'name':_0x3abef2[_0x1b63('0x2c')],'resourceId':_0x3abef2['id'],'type':_0x2f518e['name'],'sectionId':_0x2f518e['id']},{})['then'](function(){return _0x3e7176;});}else{return _0x3e7176;}})[_0x1b63('0x4a')](function(_0x13bdcb){logger[_0x1b63('0x2a')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x13bdcb);});}return _0x3e7176;});})[_0x1b63('0x25')](respondWithResult(_0x49c55f,0xc9))[_0x1b63('0x4a')](handleError(_0x49c55f,null));};exports['destroy']=function(_0x4a3285,_0x1e8c4f,_0x4b04b6){var _0x7f1f6e;return db[_0x1b63('0x43')][_0x1b63('0x49')]({'where':{'id':_0x4a3285['params']['id']}})[_0x1b63('0x25')](function(_0x300d0e){if(_0x300d0e){return db['sequelize']['transaction'](function(_0x120e50){return _0x300d0e[_0x1b63('0x26')]({'transaction':_0x120e50,'raw':!![]})[_0x1b63('0x25')](function(_0x1f439e){if(_0x1f439e[_0x1b63('0x54')]){fs[_0x1b63('0x5b')](_0x1f439e[_0x1b63('0x54')])[_0x1b63('0x5c')](function(_0xaeca74){fs[_0x1b63('0x5d')](path[_0x1b63('0x4e')](_0x1f439e[_0x1b63('0x54')],_0xaeca74));});fs[_0x1b63('0x5e')](_0x1f439e[_0x1b63('0x54')]);}return _0x1f439e;});})[_0x1b63('0x4a')](function(_0xcdcca5){throw new db['Sequelize'][(_0x1b63('0x5f'))](_0xcdcca5[_0x1b63('0x60')]);});}})[_0x1b63('0x25')](handleEntityNotFound(_0x1e8c4f,null))[_0x1b63('0x25')](removeEntity(_0x1e8c4f,null))[_0x1b63('0x4a')](handleError(_0x1e8c4f,null));};exports[_0x1b63('0x61')]=function(_0x25a97c,_0x26e0cb,_0x6ae504){return db[_0x1b63('0x4d')][_0x1b63('0x62')](function(_0x2a7d37){var _0x2b1557;return db['VoiceMusicOnHold'][_0x1b63('0x49')]({'where':{'id':_0x25a97c['params']['id']}})[_0x1b63('0x25')](function(_0x23fc80){if(_0x23fc80){_0x2b1557=_0x23fc80;return _0x23fc80[_0x1b63('0x61')](_0x25a97c[_0x1b63('0x4b')]['id'],{'transaction':_0x2a7d37});}})[_0x1b63('0x25')](function(_0xedb07e){if(_0xedb07e){return db['Sound']['findOne']({'where':{'id':_0x25a97c[_0x1b63('0x4b')]['id']},'attributes':['id',_0x1b63('0x2c'),'save_name',_0x1b63('0x63'),_0x1b63('0x64')],'raw':!![]});}})[_0x1b63('0x25')](function(_0x55cafb){if(_0x55cafb){var _0x3a8054=path['join'](config[_0x1b63('0x4f')],_0x1b63('0x65'),util[_0x1b63('0x66')](_0x1b63('0x67'),path[_0x1b63('0x68')](_0x55cafb[_0x1b63('0x69')],path['extname'](_0x55cafb[_0x1b63('0x69')])),_0x55cafb[_0x1b63('0x63')]));var _0x448a6d=path[_0x1b63('0x4e')](config['root'],_0x1b63('0x50'),_0x2b1557[_0x1b63('0x2c')],util['format']('%s.%s',_0x55cafb[_0x1b63('0x2c')],_0x55cafb[_0x1b63('0x63')]));fs['symlinkSync'](_0x3a8054,_0x448a6d);return _0x55cafb;}})['catch'](function(_0xdc37d1){throw new db[(_0x1b63('0x6a'))][(_0x1b63('0x5f'))](_0xdc37d1[_0x1b63('0x60')]);});})[_0x1b63('0x25')](handleEntityNotFound(_0x26e0cb,null))['then'](respondWithResult(_0x26e0cb,0xc9))[_0x1b63('0x4a')](handleError(_0x26e0cb,null));};exports[_0x1b63('0x6b')]=function(_0x4af27f,_0x256c8f,_0x4f391a){return db[_0x1b63('0x4d')][_0x1b63('0x62')](function(_0x3cd7e4){var _0x223d6c;return db['VoiceMusicOnHold'][_0x1b63('0x6c')]({'where':{'id':_0x4af27f[_0x1b63('0x4c')]['id']}})[_0x1b63('0x25')](handleEntityNotFound(_0x256c8f,null))['then'](function(_0x611d1a){if(_0x611d1a){_0x223d6c=_0x611d1a;return _0x611d1a[_0x1b63('0x6b')](_0x4af27f['params'][_0x1b63('0x6d')]);}})[_0x1b63('0x25')](function(_0xa1ec39){if(_0xa1ec39){return db[_0x1b63('0x6e')][_0x1b63('0x6c')]({'where':{'id':_0x4af27f['params'][_0x1b63('0x6d')]},'attributes':['id','name',_0x1b63('0x69'),_0x1b63('0x63'),_0x1b63('0x64')],'raw':!![]});}})[_0x1b63('0x25')](function(_0x4c4370){if(_0x4c4370){fs[_0x1b63('0x5d')](path[_0x1b63('0x4e')](_0x223d6c[_0x1b63('0x54')],util[_0x1b63('0x66')](_0x1b63('0x67'),_0x4c4370[_0x1b63('0x2c')],_0x4c4370[_0x1b63('0x63')])));return _0x4c4370;}})['catch'](function(_0x1cb102){throw new db[(_0x1b63('0x6a'))][(_0x1b63('0x5f'))](_0x1cb102['message']);});})[_0x1b63('0x25')](handleEntityNotFound(_0x256c8f,null))[_0x1b63('0x25')](respondWithStatusCode(_0x256c8f,0xcc))['catch'](handleError(_0x256c8f,null));};exports[_0x1b63('0x6f')]=function(_0x463072,_0x4469b6,_0x29965c){var _0x3d86d2={};var _0x2d542d={};var _0x110b7f;var _0x3dc2ae;return db['VoiceMusicOnHold']['findOne']({'where':{'id':_0x463072[_0x1b63('0x4c')]['id']}})[_0x1b63('0x25')](handleEntityNotFound(_0x4469b6,null))[_0x1b63('0x25')](function(_0x4baede){if(_0x4baede){_0x110b7f=_0x4baede;_0x2d542d[_0x1b63('0x33')]=_[_0x1b63('0x35')](db[_0x1b63('0x6e')][_0x1b63('0x2f')]);_0x2d542d[_0x1b63('0x34')]=_[_0x1b63('0x35')](_0x463072['query']);_0x2d542d[_0x1b63('0x36')]=_[_0x1b63('0x37')](_0x2d542d[_0x1b63('0x33')],_0x2d542d[_0x1b63('0x34')]);_0x3d86d2[_0x1b63('0x39')]=_['intersection'](_0x2d542d['model'],qs[_0x1b63('0x38')](_0x463072[_0x1b63('0x34')][_0x1b63('0x38')]));_0x3d86d2[_0x1b63('0x39')]=_0x3d86d2[_0x1b63('0x39')]['length']?_0x3d86d2[_0x1b63('0x39')]:_0x2d542d[_0x1b63('0x33')];_0x3d86d2['order']=qs[_0x1b63('0x3c')](_0x463072['query']['sort']);_0x3d86d2[_0x1b63('0x3d')]=qs[_0x1b63('0x36')](_[_0x1b63('0x3e')](_0x463072['query'],_0x2d542d[_0x1b63('0x36')]));if(_0x463072['query'][_0x1b63('0x3f')]){_0x3d86d2[_0x1b63('0x3d')]=_[_0x1b63('0x41')](_0x3d86d2['where'],{'$or':_[_0x1b63('0x2e')](_0x3d86d2[_0x1b63('0x39')],function(_0x50a4e2){var _0x266327={};_0x266327[_0x50a4e2]={'$like':'%'+_0x463072[_0x1b63('0x34')][_0x1b63('0x3f')]+'%'};return _0x266327;})});}_0x3d86d2=_[_0x1b63('0x41')]({},_0x3d86d2,_0x463072['options']);return _0x110b7f['getSounds'](_0x3d86d2);}})[_0x1b63('0x25')](function(_0x32f06d){if(_0x32f06d){_0x3dc2ae=_0x32f06d[_0x1b63('0x48')];if(!_0x463072['query'][_0x1b63('0x70')](_0x1b63('0x3a'))){_0x3d86d2[_0x1b63('0x1d')]=qs[_0x1b63('0x1d')](_0x463072[_0x1b63('0x34')][_0x1b63('0x1d')]);_0x3d86d2[_0x1b63('0x1b')]=qs['offset'](_0x463072[_0x1b63('0x34')]['offset']);}return _0x110b7f[_0x1b63('0x6f')](_0x3d86d2);}})[_0x1b63('0x25')](function(_0x33649c){if(_0x33649c){return _0x33649c?{'count':_0x3dc2ae,'rows':_0x33649c}:null;}})[_0x1b63('0x25')](respondWithResult(_0x4469b6,null))['catch'](handleError(_0x4469b6,null));};
\ No newline at end of file