Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / api / voiceMusicOnHold / voiceMusicOnHold.controller.js
index 71549d5..995e062 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd7f0=['ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','Content-Range','apply','reject','save','update','UserProfileResource','destroy','then','stack','send','map','fieldName','type','key','model','name','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','VoiceMusicOnHold','includeAll','findAll','rows','catch','show','params','rawAttributes','options','find','body','create','sequelize','files','directory','join','root','mkdirSync','0777','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','MusicOnHolds','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','transaction','readdirSync','forEach','unlinkSync','rmdirSync','Sequelize','ValidationError','addSound','Sound','findOne','save_name','converted_format','createdAt','server/files/sounds/converted','format','extname','server/files/moh','%s.%s','message','removeSound','id2','order','getSounds','eml-format','rimraf','zip-dir','moment','bluebird','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','papaparse'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xd7f0,0xd5));var _0x0d7f=function(_0x4175fc,_0x3e6923){_0x4175fc=_0x4175fc-0x0;var _0x48d531=_0xd7f0[_0x4175fc];return _0x48d531;};'use strict';var emlformat=require(_0x0d7f('0x0'));var rimraf=require(_0x0d7f('0x1'));var zipdir=require(_0x0d7f('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x0d7f('0x3'));var BPromise=require(_0x0d7f('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0x0d7f('0x5'));var sox=require(_0x0d7f('0x6'));var csv=require(_0x0d7f('0x7'));var ejs=require(_0x0d7f('0x8'));var fs=require('fs');var fs_extra=require(_0x0d7f('0x9'));var _=require(_0x0d7f('0xa'));var squel=require('squel');var crypto=require(_0x0d7f('0xb'));var jsforce=require(_0x0d7f('0xc'));var deskjs=require(_0x0d7f('0xd'));var toCsv=require(_0x0d7f('0x7'));var querystring=require('querystring');var Papa=require(_0x0d7f('0xe'));var Redis=require(_0x0d7f('0xf'));var authService=require(_0x0d7f('0x10'));var qs=require(_0x0d7f('0x11'));var as=require(_0x0d7f('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x0d7f('0x13'));var utils=require(_0x0d7f('0x14'));var config=require(_0x0d7f('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0x0d7f('0x16'))['db'];function respondWithStatusCode(_0x18aefd,_0x57d4d8){_0x57d4d8=_0x57d4d8||0xcc;return function(_0x2d45c4){if(_0x2d45c4){return _0x18aefd[_0x0d7f('0x17')](_0x57d4d8);}return _0x18aefd[_0x0d7f('0x18')](_0x57d4d8)[_0x0d7f('0x19')]();};}function respondWithResult(_0xde4a22,_0x283749){_0x283749=_0x283749||0xc8;return function(_0x95a584){if(_0x95a584){return _0xde4a22[_0x0d7f('0x18')](_0x283749)[_0x0d7f('0x1a')](_0x95a584);}};}function respondWithFilteredResult(_0x281735,_0x1e422d){return function(_0x5a09a6){if(_0x5a09a6){var _0x1179c7=typeof _0x1e422d[_0x0d7f('0x1b')]===_0x0d7f('0x1c')&&typeof _0x1e422d['limit']==='undefined';var _0x1ed7de=_0x5a09a6['count'];var _0x2b3ce6=_0x1179c7?0x0:_0x1e422d[_0x0d7f('0x1b')];var _0x315009=_0x1179c7?_0x5a09a6[_0x0d7f('0x1d')]:_0x1e422d[_0x0d7f('0x1b')]+_0x1e422d[_0x0d7f('0x1e')];var _0x3df96d;if(_0x315009>=_0x1ed7de){_0x315009=_0x1ed7de;_0x3df96d=0xc8;}else{_0x3df96d=0xce;}_0x281735[_0x0d7f('0x18')](_0x3df96d);return _0x281735['set'](_0x0d7f('0x1f'),_0x2b3ce6+'-'+_0x315009+'/'+_0x1ed7de)['json'](_0x5a09a6);}return null;};}function patchUpdates(_0x57f61b){return function(_0x4b1bea){try{jsonpatch[_0x0d7f('0x20')](_0x4b1bea,_0x57f61b,!![]);}catch(_0x3ff4ac){return BPromise[_0x0d7f('0x21')](_0x3ff4ac);}return _0x4b1bea[_0x0d7f('0x22')]();};}function saveUpdates(_0x1dde80,_0x2fe24a){return function(_0x4f0e35){if(_0x4f0e35){return _0x4f0e35[_0x0d7f('0x23')](_0x1dde80)['then'](function(_0x38d79f){return _0x38d79f;});}return null;};}function removeEntity(_0x10b11f,_0x3ed7b3){return function(_0x56f04f){if(_0x56f04f){return _0x56f04f['destroy']()['then'](function(){var _0x280255=_0x56f04f['get']({'plain':!![]});var _0x39732a='MusicOnHolds';return db[_0x0d7f('0x24')][_0x0d7f('0x25')]({'where':{'type':_0x39732a,'resourceId':_0x280255['id']}})['then'](function(){return _0x56f04f;});})[_0x0d7f('0x26')](function(){_0x10b11f['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x206c21,_0x2e6d47){return function(_0x13e2fb){if(!_0x13e2fb){_0x206c21['sendStatus'](0x194);}return _0x13e2fb;};}function handleError(_0x4b515e,_0x5ce504){_0x5ce504=_0x5ce504||0x1f4;return function(_0x242197){logger['error'](_0x242197[_0x0d7f('0x27')]);if(_0x242197['name']){delete _0x242197['name'];}_0x4b515e[_0x0d7f('0x18')](_0x5ce504)[_0x0d7f('0x28')](_0x242197);};}exports['index']=function(_0x314c9f,_0x357e93){var _0x1a7c10={},_0x5c3b20={},_0x3a3c8b={'count':0x0,'rows':[]};var _0x49d21e=_[_0x0d7f('0x29')](db['VoiceMusicOnHold']['rawAttributes'],function(_0x2804d0){return{'name':_0x2804d0[_0x0d7f('0x2a')],'type':_0x2804d0[_0x0d7f('0x2b')][_0x0d7f('0x2c')]};});_0x5c3b20[_0x0d7f('0x2d')]=_[_0x0d7f('0x29')](_0x49d21e,_0x0d7f('0x2e'));_0x5c3b20[_0x0d7f('0x2f')]=_[_0x0d7f('0x30')](_0x314c9f[_0x0d7f('0x2f')]);_0x5c3b20[_0x0d7f('0x31')]=_[_0x0d7f('0x32')](_0x5c3b20[_0x0d7f('0x2d')],_0x5c3b20[_0x0d7f('0x2f')]);_0x1a7c10[_0x0d7f('0x33')]=_[_0x0d7f('0x32')](_0x5c3b20[_0x0d7f('0x2d')],qs[_0x0d7f('0x34')](_0x314c9f['query'][_0x0d7f('0x34')]));_0x1a7c10['attributes']=_0x1a7c10[_0x0d7f('0x33')][_0x0d7f('0x35')]?_0x1a7c10[_0x0d7f('0x33')]:_0x5c3b20['model'];if(!_0x314c9f[_0x0d7f('0x2f')][_0x0d7f('0x36')](_0x0d7f('0x37'))){_0x1a7c10[_0x0d7f('0x1e')]=qs[_0x0d7f('0x1e')](_0x314c9f[_0x0d7f('0x2f')][_0x0d7f('0x1e')]);_0x1a7c10[_0x0d7f('0x1b')]=qs['offset'](_0x314c9f[_0x0d7f('0x2f')][_0x0d7f('0x1b')]);}_0x1a7c10['order']=qs[_0x0d7f('0x38')](_0x314c9f[_0x0d7f('0x2f')][_0x0d7f('0x38')]);delete _0x314c9f[_0x0d7f('0x2f')][_0x0d7f('0x38')];_0x1a7c10[_0x0d7f('0x39')]=qs[_0x0d7f('0x31')](_[_0x0d7f('0x3a')](_0x314c9f['query'],_0x5c3b20[_0x0d7f('0x31')]),_0x49d21e);if(_0x314c9f[_0x0d7f('0x2f')][_0x0d7f('0x3b')]){_0x1a7c10[_0x0d7f('0x39')]=_[_0x0d7f('0x3c')](_0x1a7c10[_0x0d7f('0x39')],{'$or':_[_0x0d7f('0x29')](_0x49d21e,function(_0x52e70e){if(_0x52e70e[_0x0d7f('0x2b')]!==_0x0d7f('0x3d')){var _0x13ec7c={};_0x13ec7c[_0x52e70e[_0x0d7f('0x2e')]]={'$like':'%'+_0x314c9f[_0x0d7f('0x2f')][_0x0d7f('0x3b')]+'%'};return _0x13ec7c;}})});}_0x1a7c10=_[_0x0d7f('0x3c')]({},_0x1a7c10,_0x314c9f['options']);var _0x545d1e={'where':_0x1a7c10[_0x0d7f('0x39')]};return db[_0x0d7f('0x3e')][_0x0d7f('0x1d')](_0x545d1e)[_0x0d7f('0x26')](function(_0x559370){_0x3a3c8b[_0x0d7f('0x1d')]=_0x559370;if(_0x314c9f[_0x0d7f('0x2f')][_0x0d7f('0x3f')]){_0x1a7c10['include']=[{'all':!![]}];}return db[_0x0d7f('0x3e')][_0x0d7f('0x40')](_0x1a7c10);})[_0x0d7f('0x26')](function(_0x513f54){_0x3a3c8b[_0x0d7f('0x41')]=_0x513f54;return _0x3a3c8b;})[_0x0d7f('0x26')](respondWithFilteredResult(_0x357e93,_0x1a7c10))[_0x0d7f('0x42')](handleError(_0x357e93,null));};exports[_0x0d7f('0x43')]=function(_0x2697fd,_0x5488fb){var _0xcacd5d={'raw':![],'where':{'id':_0x2697fd[_0x0d7f('0x44')]['id']}},_0xbcd618={};_0xbcd618[_0x0d7f('0x2d')]=_[_0x0d7f('0x30')](db['VoiceMusicOnHold'][_0x0d7f('0x45')]);_0xbcd618[_0x0d7f('0x2f')]=_['keys'](_0x2697fd[_0x0d7f('0x2f')]);_0xbcd618[_0x0d7f('0x31')]=_[_0x0d7f('0x32')](_0xbcd618[_0x0d7f('0x2d')],_0xbcd618[_0x0d7f('0x2f')]);_0xcacd5d[_0x0d7f('0x33')]=_[_0x0d7f('0x32')](_0xbcd618[_0x0d7f('0x2d')],qs[_0x0d7f('0x34')](_0x2697fd[_0x0d7f('0x2f')]['fields']));_0xcacd5d[_0x0d7f('0x33')]=_0xcacd5d[_0x0d7f('0x33')][_0x0d7f('0x35')]?_0xcacd5d['attributes']:_0xbcd618['model'];if(_0x2697fd[_0x0d7f('0x2f')][_0x0d7f('0x3f')]){_0xcacd5d['include']=[{'all':!![]}];}_0xcacd5d=_[_0x0d7f('0x3c')]({},_0xcacd5d,_0x2697fd[_0x0d7f('0x46')]);return db[_0x0d7f('0x3e')][_0x0d7f('0x47')](_0xcacd5d)[_0x0d7f('0x26')](handleEntityNotFound(_0x5488fb,null))['then'](respondWithResult(_0x5488fb,null))['catch'](handleError(_0x5488fb,null));};exports[_0x0d7f('0x23')]=function(_0x2628e5,_0x3bea1f){if(_0x2628e5[_0x0d7f('0x48')]['id']){delete _0x2628e5[_0x0d7f('0x48')]['id'];}return db[_0x0d7f('0x3e')][_0x0d7f('0x47')]({'where':{'id':_0x2628e5[_0x0d7f('0x44')]['id']}})['then'](handleEntityNotFound(_0x3bea1f,null))[_0x0d7f('0x26')](saveUpdates(_0x2628e5[_0x0d7f('0x48')],null))[_0x0d7f('0x26')](respondWithResult(_0x3bea1f,null))[_0x0d7f('0x42')](handleError(_0x3bea1f,null));};exports[_0x0d7f('0x49')]=function(_0x20631b,_0x283875,_0x1ba72f){return db[_0x0d7f('0x4a')]['transaction'](function(_0x31f4fa){if(_0x20631b[_0x0d7f('0x48')]['mode']===_0x0d7f('0x4b')){_0x20631b['body'][_0x0d7f('0x4c')]=path[_0x0d7f('0x4d')](config[_0x0d7f('0x4e')],'server/files/moh',_0x20631b['body'][_0x0d7f('0x2e')]);}return db[_0x0d7f('0x3e')][_0x0d7f('0x49')](_0x20631b['body'],{'transaction':_0x31f4fa})[_0x0d7f('0x26')](function(_0x6d34fc){if(_0x20631b[_0x0d7f('0x48')]['mode']===_0x0d7f('0x4b')){fs[_0x0d7f('0x4f')](_0x6d34fc['directory'],parseInt(_0x0d7f('0x50'),0x8));}var _0x145ea7=_0x20631b[_0x0d7f('0x51')][_0x0d7f('0x52')]({'plain':!![]});if(!_0x145ea7)throw new Error(_0x0d7f('0x53'));if(_0x145ea7[_0x0d7f('0x54')]===_0x0d7f('0x51')){var _0x2f5fa0=_0x6d34fc[_0x0d7f('0x52')]({'plain':!![]});return db[_0x0d7f('0x55')][_0x0d7f('0x47')]({'where':{'name':_0x0d7f('0x56'),'userProfileId':_0x145ea7[_0x0d7f('0x57')]},'raw':!![]})['then'](function(_0x100fa1){if(_0x100fa1&&_0x100fa1[_0x0d7f('0x58')]===0x0){return db[_0x0d7f('0x24')]['create']({'name':_0x2f5fa0[_0x0d7f('0x2e')],'resourceId':_0x2f5fa0['id'],'type':_0x100fa1[_0x0d7f('0x2e')],'sectionId':_0x100fa1['id']},{})['then'](function(){return _0x6d34fc;});}else{return _0x6d34fc;}})[_0x0d7f('0x42')](function(_0x3733ac){logger[_0x0d7f('0x59')](_0x0d7f('0x5a'),_0x3733ac);});}return _0x6d34fc;});})['then'](respondWithResult(_0x283875,0xc9))['catch'](handleError(_0x283875,null));};exports[_0x0d7f('0x25')]=function(_0x1618ef,_0x4f5648,_0x1a9fc4){var _0x1fd97c;return db[_0x0d7f('0x3e')][_0x0d7f('0x47')]({'where':{'id':_0x1618ef[_0x0d7f('0x44')]['id']}})['then'](function(_0x1f09c6){if(_0x1f09c6){return db[_0x0d7f('0x4a')][_0x0d7f('0x5b')](function(_0x2dee11){return _0x1f09c6[_0x0d7f('0x25')]({'transaction':_0x2dee11,'raw':!![]})[_0x0d7f('0x26')](function(_0xd6c3de){if(_0xd6c3de['directory']){fs[_0x0d7f('0x5c')](_0xd6c3de['directory'])[_0x0d7f('0x5d')](function(_0x349143){fs[_0x0d7f('0x5e')](path[_0x0d7f('0x4d')](_0xd6c3de['directory'],_0x349143));});fs[_0x0d7f('0x5f')](_0xd6c3de['directory']);}return _0xd6c3de;});})[_0x0d7f('0x42')](function(_0x35a7a5){throw new db[(_0x0d7f('0x60'))][(_0x0d7f('0x61'))](_0x35a7a5['message']);});}})[_0x0d7f('0x26')](handleEntityNotFound(_0x4f5648,null))['then'](removeEntity(_0x4f5648,null))[_0x0d7f('0x42')](handleError(_0x4f5648,null));};exports['addSound']=function(_0x1e2377,_0x5ef2c5,_0x316700){return db[_0x0d7f('0x4a')]['transaction'](function(_0x1ebac7){var _0x4ba745;return db[_0x0d7f('0x3e')]['find']({'where':{'id':_0x1e2377[_0x0d7f('0x44')]['id']}})['then'](function(_0x589f08){if(_0x589f08){_0x4ba745=_0x589f08;return _0x589f08[_0x0d7f('0x62')](_0x1e2377[_0x0d7f('0x48')]['id'],{'transaction':_0x1ebac7});}})['then'](function(_0x49b0cc){if(_0x49b0cc){return db[_0x0d7f('0x63')][_0x0d7f('0x64')]({'where':{'id':_0x1e2377[_0x0d7f('0x48')]['id']},'attributes':['id',_0x0d7f('0x2e'),_0x0d7f('0x65'),_0x0d7f('0x66'),_0x0d7f('0x67')],'raw':!![]});}})[_0x0d7f('0x26')](function(_0x217cfd){if(_0x217cfd){var _0x2559a8=path[_0x0d7f('0x4d')](config[_0x0d7f('0x4e')],_0x0d7f('0x68'),util[_0x0d7f('0x69')]('%s.%s',path['basename'](_0x217cfd[_0x0d7f('0x65')],path[_0x0d7f('0x6a')](_0x217cfd[_0x0d7f('0x65')])),_0x217cfd[_0x0d7f('0x66')]));var _0x410c46=path[_0x0d7f('0x4d')](config[_0x0d7f('0x4e')],_0x0d7f('0x6b'),_0x4ba745[_0x0d7f('0x2e')],util[_0x0d7f('0x69')](_0x0d7f('0x6c'),_0x217cfd[_0x0d7f('0x2e')],_0x217cfd[_0x0d7f('0x66')]));fs['symlinkSync'](_0x2559a8,_0x410c46);return _0x217cfd;}})['catch'](function(_0x2779b0){throw new db[(_0x0d7f('0x60'))]['ValidationError'](_0x2779b0[_0x0d7f('0x6d')]);});})[_0x0d7f('0x26')](handleEntityNotFound(_0x5ef2c5,null))[_0x0d7f('0x26')](respondWithResult(_0x5ef2c5,0xc9))[_0x0d7f('0x42')](handleError(_0x5ef2c5,null));};exports[_0x0d7f('0x6e')]=function(_0x5cf69f,_0x24e92d,_0x33fcc6){return db[_0x0d7f('0x4a')][_0x0d7f('0x5b')](function(_0x18f8e9){var _0x11ba6e;return db[_0x0d7f('0x3e')][_0x0d7f('0x64')]({'where':{'id':_0x5cf69f[_0x0d7f('0x44')]['id']}})['then'](handleEntityNotFound(_0x24e92d,null))['then'](function(_0x48cc39){if(_0x48cc39){_0x11ba6e=_0x48cc39;return _0x48cc39['removeSound'](_0x5cf69f['params'][_0x0d7f('0x6f')]);}})[_0x0d7f('0x26')](function(_0x34a4c1){if(_0x34a4c1){return db['Sound'][_0x0d7f('0x64')]({'where':{'id':_0x5cf69f[_0x0d7f('0x44')]['id2']},'attributes':['id',_0x0d7f('0x2e'),_0x0d7f('0x65'),_0x0d7f('0x66'),_0x0d7f('0x67')],'raw':!![]});}})[_0x0d7f('0x26')](function(_0x551e4b){if(_0x551e4b){fs[_0x0d7f('0x5e')](path[_0x0d7f('0x4d')](_0x11ba6e[_0x0d7f('0x4c')],util['format'](_0x0d7f('0x6c'),_0x551e4b['name'],_0x551e4b[_0x0d7f('0x66')])));return _0x551e4b;}})['catch'](function(_0x2e477a){throw new db[(_0x0d7f('0x60'))][(_0x0d7f('0x61'))](_0x2e477a[_0x0d7f('0x6d')]);});})[_0x0d7f('0x26')](handleEntityNotFound(_0x24e92d,null))['then'](respondWithStatusCode(_0x24e92d,0xcc))['catch'](handleError(_0x24e92d,null));};exports['getSounds']=function(_0x43830b,_0x42c740,_0x3f127c){var _0x50ee28={};var _0x487865={};var _0x1e539e;var _0x178b89;return db['VoiceMusicOnHold'][_0x0d7f('0x64')]({'where':{'id':_0x43830b[_0x0d7f('0x44')]['id']}})[_0x0d7f('0x26')](handleEntityNotFound(_0x42c740,null))[_0x0d7f('0x26')](function(_0x9876c1){if(_0x9876c1){_0x1e539e=_0x9876c1;_0x487865[_0x0d7f('0x2d')]=_[_0x0d7f('0x30')](db[_0x0d7f('0x63')][_0x0d7f('0x45')]);_0x487865[_0x0d7f('0x2f')]=_[_0x0d7f('0x30')](_0x43830b[_0x0d7f('0x2f')]);_0x487865[_0x0d7f('0x31')]=_[_0x0d7f('0x32')](_0x487865['model'],_0x487865[_0x0d7f('0x2f')]);_0x50ee28[_0x0d7f('0x33')]=_[_0x0d7f('0x32')](_0x487865['model'],qs[_0x0d7f('0x34')](_0x43830b[_0x0d7f('0x2f')]['fields']));_0x50ee28[_0x0d7f('0x33')]=_0x50ee28['attributes'][_0x0d7f('0x35')]?_0x50ee28['attributes']:_0x487865['model'];_0x50ee28[_0x0d7f('0x70')]=qs[_0x0d7f('0x38')](_0x43830b['query'][_0x0d7f('0x38')]);_0x50ee28['where']=qs['filters'](_[_0x0d7f('0x3a')](_0x43830b[_0x0d7f('0x2f')],_0x487865[_0x0d7f('0x31')]));if(_0x43830b[_0x0d7f('0x2f')]['filter']){_0x50ee28[_0x0d7f('0x39')]=_[_0x0d7f('0x3c')](_0x50ee28[_0x0d7f('0x39')],{'$or':_['map'](_0x50ee28[_0x0d7f('0x33')],function(_0xf5c577){var _0x27b173={};_0x27b173[_0xf5c577]={'$like':'%'+_0x43830b['query'][_0x0d7f('0x3b')]+'%'};return _0x27b173;})});}_0x50ee28=_['merge']({},_0x50ee28,_0x43830b[_0x0d7f('0x46')]);return _0x1e539e['getSounds'](_0x50ee28);}})[_0x0d7f('0x26')](function(_0x127ad2){if(_0x127ad2){_0x178b89=_0x127ad2[_0x0d7f('0x35')];if(!_0x43830b[_0x0d7f('0x2f')]['hasOwnProperty']('nolimit')){_0x50ee28[_0x0d7f('0x1e')]=qs[_0x0d7f('0x1e')](_0x43830b['query']['limit']);_0x50ee28[_0x0d7f('0x1b')]=qs[_0x0d7f('0x1b')](_0x43830b[_0x0d7f('0x2f')]['offset']);}return _0x1e539e[_0x0d7f('0x71')](_0x50ee28);}})[_0x0d7f('0x26')](function(_0x317f5a){if(_0x317f5a){return _0x317f5a?{'count':_0x178b89,'rows':_0x317f5a}:null;}})[_0x0d7f('0x26')](respondWithResult(_0x42c740,null))['catch'](handleError(_0x42c740,null));};
\ No newline at end of file
+var _0xdad6=['root','server/files/moh','directory','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','forEach','rmdirSync','Sequelize','message','addSound','Sound','converted_format','server/files/sounds/converted','format','%s.%s','basename','save_name','extname','ValidationError','removeSound','id2','findOne','createdAt','unlinkSync','getSounds','nolimit','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','fs-extra','lodash','squel','crypto','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','undefined','count','offset','set','Content-Range','save','update','then','destroy','get','MusicOnHolds','UserProfileResource','error','stack','name','send','index','VoiceMusicOnHold','fieldName','type','key','model','map','query','attributes','intersection','hasOwnProperty','limit','order','sort','where','pick','filters','filter','merge','VIRTUAL','options','include','rows','catch','show','params','keys','rawAttributes','fields','length','find','body','create','sequelize','transaction','mode','files','join'];(function(_0x5a2d3f,_0x27b04e){var _0x5c65d8=function(_0x2d1965){while(--_0x2d1965){_0x5a2d3f['push'](_0x5a2d3f['shift']());}};_0x5c65d8(++_0x27b04e);}(_0xdad6,0x101));var _0x6dad=function(_0x1115e9,_0x3ed1cd){_0x1115e9=_0x1115e9-0x0;var _0x1153ed=_0xdad6[_0x1115e9];return _0x1153ed;};'use strict';var emlformat=require(_0x6dad('0x0'));var rimraf=require(_0x6dad('0x1'));var zipdir=require(_0x6dad('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x6dad('0x3'));var moment=require(_0x6dad('0x4'));var BPromise=require(_0x6dad('0x5'));var Mustache=require(_0x6dad('0x6'));var util=require(_0x6dad('0x7'));var path=require(_0x6dad('0x8'));var sox=require(_0x6dad('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x6dad('0xa'));var _=require(_0x6dad('0xb'));var squel=require(_0x6dad('0xc'));var crypto=require(_0x6dad('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x6dad('0xe'));var querystring=require(_0x6dad('0xf'));var Papa=require(_0x6dad('0x10'));var Redis=require('ioredis');var authService=require(_0x6dad('0x11'));var qs=require(_0x6dad('0x12'));var as=require(_0x6dad('0x13'));var hardwareService=require(_0x6dad('0x14'));var logger=require(_0x6dad('0x15'))(_0x6dad('0x16'));var utils=require(_0x6dad('0x17'));var config=require(_0x6dad('0x18'));var licenseUtil=require(_0x6dad('0x19'));var db=require(_0x6dad('0x1a'))['db'];function respondWithStatusCode(_0x4573ca,_0x46a6ff){_0x46a6ff=_0x46a6ff||0xcc;return function(_0xabc338){if(_0xabc338){return _0x4573ca[_0x6dad('0x1b')](_0x46a6ff);}return _0x4573ca['status'](_0x46a6ff)[_0x6dad('0x1c')]();};}function respondWithResult(_0x520a42,_0x30a166){_0x30a166=_0x30a166||0xc8;return function(_0x3e21d6){if(_0x3e21d6){return _0x520a42[_0x6dad('0x1d')](_0x30a166)[_0x6dad('0x1e')](_0x3e21d6);}};}function respondWithFilteredResult(_0x344614,_0x9bea91){return function(_0x1b27ab){if(_0x1b27ab){var _0x19862b=typeof _0x9bea91['offset']===_0x6dad('0x1f')&&typeof _0x9bea91['limit']===_0x6dad('0x1f');var _0x47e22b=_0x1b27ab['count'];var _0x34aa36=_0x19862b?0x0:_0x9bea91['offset'];var _0x3498ee=_0x19862b?_0x1b27ab[_0x6dad('0x20')]:_0x9bea91[_0x6dad('0x21')]+_0x9bea91['limit'];var _0x48655c;if(_0x3498ee>=_0x47e22b){_0x3498ee=_0x47e22b;_0x48655c=0xc8;}else{_0x48655c=0xce;}_0x344614['status'](_0x48655c);return _0x344614[_0x6dad('0x22')](_0x6dad('0x23'),_0x34aa36+'-'+_0x3498ee+'/'+_0x47e22b)[_0x6dad('0x1e')](_0x1b27ab);}return null;};}function patchUpdates(_0x45beb8){return function(_0x37bbda){try{jsonpatch['apply'](_0x37bbda,_0x45beb8,!![]);}catch(_0x20ee78){return BPromise['reject'](_0x20ee78);}return _0x37bbda[_0x6dad('0x24')]();};}function saveUpdates(_0x58b2b2,_0x3656a6){return function(_0x457bd3){if(_0x457bd3){return _0x457bd3[_0x6dad('0x25')](_0x58b2b2)[_0x6dad('0x26')](function(_0x2cb02f){return _0x2cb02f;});}return null;};}function removeEntity(_0x24aeb6,_0x140539){return function(_0x2eabbf){if(_0x2eabbf){return _0x2eabbf[_0x6dad('0x27')]()[_0x6dad('0x26')](function(){var _0x110d81=_0x2eabbf[_0x6dad('0x28')]({'plain':!![]});var _0x2e06b6=_0x6dad('0x29');return db[_0x6dad('0x2a')][_0x6dad('0x27')]({'where':{'type':_0x2e06b6,'resourceId':_0x110d81['id']}})['then'](function(){return _0x2eabbf;});})[_0x6dad('0x26')](function(){_0x24aeb6[_0x6dad('0x1d')](0xcc)[_0x6dad('0x1c')]();});}};}function handleEntityNotFound(_0x1ddb69,_0x503999){return function(_0x479961){if(!_0x479961){_0x1ddb69[_0x6dad('0x1b')](0x194);}return _0x479961;};}function handleError(_0x5dbfd2,_0x2bf600){_0x2bf600=_0x2bf600||0x1f4;return function(_0x552af7){logger[_0x6dad('0x2b')](_0x552af7[_0x6dad('0x2c')]);if(_0x552af7['name']){delete _0x552af7[_0x6dad('0x2d')];}_0x5dbfd2[_0x6dad('0x1d')](_0x2bf600)[_0x6dad('0x2e')](_0x552af7);};}exports[_0x6dad('0x2f')]=function(_0x5af207,_0x53ae1d){var _0xf1a152={},_0x56a8e7={},_0x365cbf={'count':0x0,'rows':[]};var _0xa34cd6=_['map'](db[_0x6dad('0x30')]['rawAttributes'],function(_0x363ff0){return{'name':_0x363ff0[_0x6dad('0x31')],'type':_0x363ff0[_0x6dad('0x32')][_0x6dad('0x33')]};});_0x56a8e7[_0x6dad('0x34')]=_[_0x6dad('0x35')](_0xa34cd6,_0x6dad('0x2d'));_0x56a8e7[_0x6dad('0x36')]=_['keys'](_0x5af207[_0x6dad('0x36')]);_0x56a8e7['filters']=_['intersection'](_0x56a8e7[_0x6dad('0x34')],_0x56a8e7[_0x6dad('0x36')]);_0xf1a152[_0x6dad('0x37')]=_[_0x6dad('0x38')](_0x56a8e7[_0x6dad('0x34')],qs['fields'](_0x5af207[_0x6dad('0x36')]['fields']));_0xf1a152['attributes']=_0xf1a152[_0x6dad('0x37')]['length']?_0xf1a152[_0x6dad('0x37')]:_0x56a8e7[_0x6dad('0x34')];if(!_0x5af207[_0x6dad('0x36')][_0x6dad('0x39')]('nolimit')){_0xf1a152[_0x6dad('0x3a')]=qs[_0x6dad('0x3a')](_0x5af207[_0x6dad('0x36')][_0x6dad('0x3a')]);_0xf1a152['offset']=qs[_0x6dad('0x21')](_0x5af207[_0x6dad('0x36')][_0x6dad('0x21')]);}_0xf1a152[_0x6dad('0x3b')]=qs[_0x6dad('0x3c')](_0x5af207['query'][_0x6dad('0x3c')]);delete _0x5af207[_0x6dad('0x36')]['sort'];_0xf1a152[_0x6dad('0x3d')]=qs['filters'](_[_0x6dad('0x3e')](_0x5af207[_0x6dad('0x36')],_0x56a8e7[_0x6dad('0x3f')]),_0xa34cd6);if(_0x5af207['query'][_0x6dad('0x40')]){_0xf1a152[_0x6dad('0x3d')]=_[_0x6dad('0x41')](_0xf1a152[_0x6dad('0x3d')],{'$or':_['map'](_0xa34cd6,function(_0x39e659){if(_0x39e659['type']!==_0x6dad('0x42')){var _0x1fef6c={};_0x1fef6c[_0x39e659[_0x6dad('0x2d')]]={'$like':'%'+_0x5af207['query'][_0x6dad('0x40')]+'%'};return _0x1fef6c;}})});}_0xf1a152=_[_0x6dad('0x41')]({},_0xf1a152,_0x5af207[_0x6dad('0x43')]);var _0x7a54a0={'where':_0xf1a152[_0x6dad('0x3d')]};return db[_0x6dad('0x30')][_0x6dad('0x20')](_0x7a54a0)[_0x6dad('0x26')](function(_0x540dc1){_0x365cbf[_0x6dad('0x20')]=_0x540dc1;if(_0x5af207['query']['includeAll']){_0xf1a152[_0x6dad('0x44')]=[{'all':!![]}];}return db['VoiceMusicOnHold']['findAll'](_0xf1a152);})[_0x6dad('0x26')](function(_0x2441f8){_0x365cbf[_0x6dad('0x45')]=_0x2441f8;return _0x365cbf;})[_0x6dad('0x26')](respondWithFilteredResult(_0x53ae1d,_0xf1a152))[_0x6dad('0x46')](handleError(_0x53ae1d,null));};exports[_0x6dad('0x47')]=function(_0xf1c176,_0x336d7d){var _0xf10291={'raw':![],'where':{'id':_0xf1c176[_0x6dad('0x48')]['id']}},_0x3029f6={};_0x3029f6[_0x6dad('0x34')]=_[_0x6dad('0x49')](db[_0x6dad('0x30')][_0x6dad('0x4a')]);_0x3029f6[_0x6dad('0x36')]=_[_0x6dad('0x49')](_0xf1c176['query']);_0x3029f6[_0x6dad('0x3f')]=_[_0x6dad('0x38')](_0x3029f6[_0x6dad('0x34')],_0x3029f6[_0x6dad('0x36')]);_0xf10291[_0x6dad('0x37')]=_[_0x6dad('0x38')](_0x3029f6['model'],qs[_0x6dad('0x4b')](_0xf1c176['query'][_0x6dad('0x4b')]));_0xf10291[_0x6dad('0x37')]=_0xf10291[_0x6dad('0x37')][_0x6dad('0x4c')]?_0xf10291[_0x6dad('0x37')]:_0x3029f6['model'];if(_0xf1c176[_0x6dad('0x36')]['includeAll']){_0xf10291['include']=[{'all':!![]}];}_0xf10291=_[_0x6dad('0x41')]({},_0xf10291,_0xf1c176[_0x6dad('0x43')]);return db[_0x6dad('0x30')][_0x6dad('0x4d')](_0xf10291)[_0x6dad('0x26')](handleEntityNotFound(_0x336d7d,null))[_0x6dad('0x26')](respondWithResult(_0x336d7d,null))[_0x6dad('0x46')](handleError(_0x336d7d,null));};exports[_0x6dad('0x25')]=function(_0x8ff35f,_0x2a2bdb){if(_0x8ff35f[_0x6dad('0x4e')]['id']){delete _0x8ff35f[_0x6dad('0x4e')]['id'];}return db[_0x6dad('0x30')]['find']({'where':{'id':_0x8ff35f[_0x6dad('0x48')]['id']}})[_0x6dad('0x26')](handleEntityNotFound(_0x2a2bdb,null))[_0x6dad('0x26')](saveUpdates(_0x8ff35f['body'],null))[_0x6dad('0x26')](respondWithResult(_0x2a2bdb,null))[_0x6dad('0x46')](handleError(_0x2a2bdb,null));};exports[_0x6dad('0x4f')]=function(_0x543a3a,_0x3803dd,_0x23e64c){return db[_0x6dad('0x50')][_0x6dad('0x51')](function(_0x434910){if(_0x543a3a[_0x6dad('0x4e')][_0x6dad('0x52')]===_0x6dad('0x53')){_0x543a3a[_0x6dad('0x4e')]['directory']=path[_0x6dad('0x54')](config[_0x6dad('0x55')],_0x6dad('0x56'),_0x543a3a['body'][_0x6dad('0x2d')]);}return db['VoiceMusicOnHold']['create'](_0x543a3a[_0x6dad('0x4e')],{'transaction':_0x434910})[_0x6dad('0x26')](function(_0x20f18a){if(_0x543a3a['body'][_0x6dad('0x52')]===_0x6dad('0x53')){fs['mkdirSync'](_0x20f18a[_0x6dad('0x57')],parseInt('0777',0x8));}var _0x143ce2=_0x543a3a[_0x6dad('0x58')][_0x6dad('0x28')]({'plain':!![]});if(!_0x143ce2)throw new Error(_0x6dad('0x59'));if(_0x143ce2[_0x6dad('0x5a')]===_0x6dad('0x58')){var _0x275ee3=_0x20f18a[_0x6dad('0x28')]({'plain':!![]});return db[_0x6dad('0x5b')]['find']({'where':{'name':_0x6dad('0x29'),'userProfileId':_0x143ce2['userProfileId']},'raw':!![]})[_0x6dad('0x26')](function(_0x9ade49){if(_0x9ade49&&_0x9ade49['autoAssociation']===0x0){return db[_0x6dad('0x2a')][_0x6dad('0x4f')]({'name':_0x275ee3[_0x6dad('0x2d')],'resourceId':_0x275ee3['id'],'type':_0x9ade49['name'],'sectionId':_0x9ade49['id']},{})['then'](function(){return _0x20f18a;});}else{return _0x20f18a;}})[_0x6dad('0x46')](function(_0x1584f7){logger[_0x6dad('0x2b')](_0x6dad('0x5c'),_0x1584f7);});}return _0x20f18a;});})['then'](respondWithResult(_0x3803dd,0xc9))[_0x6dad('0x46')](handleError(_0x3803dd,null));};exports[_0x6dad('0x27')]=function(_0x66bbeb,_0x1187ba,_0xa21121){var _0x43ce7e;return db[_0x6dad('0x30')]['find']({'where':{'id':_0x66bbeb[_0x6dad('0x48')]['id']}})[_0x6dad('0x26')](function(_0x4ee78a){if(_0x4ee78a){return db['sequelize']['transaction'](function(_0x49431b){return _0x4ee78a[_0x6dad('0x27')]({'transaction':_0x49431b,'raw':!![]})['then'](function(_0x380e46){if(_0x380e46['directory']){fs['readdirSync'](_0x380e46[_0x6dad('0x57')])[_0x6dad('0x5d')](function(_0x52aa0a){fs['unlinkSync'](path[_0x6dad('0x54')](_0x380e46[_0x6dad('0x57')],_0x52aa0a));});fs[_0x6dad('0x5e')](_0x380e46[_0x6dad('0x57')]);}return _0x380e46;});})[_0x6dad('0x46')](function(_0x48acff){throw new db[(_0x6dad('0x5f'))]['ValidationError'](_0x48acff[_0x6dad('0x60')]);});}})[_0x6dad('0x26')](handleEntityNotFound(_0x1187ba,null))['then'](removeEntity(_0x1187ba,null))['catch'](handleError(_0x1187ba,null));};exports[_0x6dad('0x61')]=function(_0x18534b,_0x33edcf,_0x1ecda3){return db['sequelize'][_0x6dad('0x51')](function(_0x184bf9){var _0xf0dc36;return db[_0x6dad('0x30')][_0x6dad('0x4d')]({'where':{'id':_0x18534b[_0x6dad('0x48')]['id']}})[_0x6dad('0x26')](function(_0x499f01){if(_0x499f01){_0xf0dc36=_0x499f01;return _0x499f01[_0x6dad('0x61')](_0x18534b['body']['id'],{'transaction':_0x184bf9});}})[_0x6dad('0x26')](function(_0x164446){if(_0x164446){return db[_0x6dad('0x62')]['findOne']({'where':{'id':_0x18534b[_0x6dad('0x4e')]['id']},'attributes':['id',_0x6dad('0x2d'),'save_name',_0x6dad('0x63'),'createdAt'],'raw':!![]});}})['then'](function(_0x50b461){if(_0x50b461){var _0x19796a=path[_0x6dad('0x54')](config[_0x6dad('0x55')],_0x6dad('0x64'),util[_0x6dad('0x65')](_0x6dad('0x66'),path[_0x6dad('0x67')](_0x50b461[_0x6dad('0x68')],path[_0x6dad('0x69')](_0x50b461[_0x6dad('0x68')])),_0x50b461['converted_format']));var _0x26783a=path[_0x6dad('0x54')](config[_0x6dad('0x55')],'server/files/moh',_0xf0dc36[_0x6dad('0x2d')],util['format'](_0x6dad('0x66'),_0x50b461[_0x6dad('0x2d')],_0x50b461['converted_format']));fs['symlinkSync'](_0x19796a,_0x26783a);return _0x50b461;}})['catch'](function(_0x186d90){throw new db[(_0x6dad('0x5f'))][(_0x6dad('0x6a'))](_0x186d90[_0x6dad('0x60')]);});})[_0x6dad('0x26')](handleEntityNotFound(_0x33edcf,null))[_0x6dad('0x26')](respondWithResult(_0x33edcf,0xc9))[_0x6dad('0x46')](handleError(_0x33edcf,null));};exports['removeSound']=function(_0x396eb6,_0x2d3e56,_0x2dd578){return db[_0x6dad('0x50')]['transaction'](function(_0x515aec){var _0x594c0b;return db[_0x6dad('0x30')]['findOne']({'where':{'id':_0x396eb6[_0x6dad('0x48')]['id']}})[_0x6dad('0x26')](handleEntityNotFound(_0x2d3e56,null))[_0x6dad('0x26')](function(_0x1f1ff0){if(_0x1f1ff0){_0x594c0b=_0x1f1ff0;return _0x1f1ff0[_0x6dad('0x6b')](_0x396eb6[_0x6dad('0x48')][_0x6dad('0x6c')]);}})[_0x6dad('0x26')](function(_0x3cc927){if(_0x3cc927){return db[_0x6dad('0x62')][_0x6dad('0x6d')]({'where':{'id':_0x396eb6[_0x6dad('0x48')][_0x6dad('0x6c')]},'attributes':['id',_0x6dad('0x2d'),_0x6dad('0x68'),_0x6dad('0x63'),_0x6dad('0x6e')],'raw':!![]});}})[_0x6dad('0x26')](function(_0x9050f2){if(_0x9050f2){fs[_0x6dad('0x6f')](path[_0x6dad('0x54')](_0x594c0b['directory'],util['format'](_0x6dad('0x66'),_0x9050f2[_0x6dad('0x2d')],_0x9050f2[_0x6dad('0x63')])));return _0x9050f2;}})[_0x6dad('0x46')](function(_0xd8e73d){throw new db[(_0x6dad('0x5f'))]['ValidationError'](_0xd8e73d[_0x6dad('0x60')]);});})['then'](handleEntityNotFound(_0x2d3e56,null))[_0x6dad('0x26')](respondWithStatusCode(_0x2d3e56,0xcc))[_0x6dad('0x46')](handleError(_0x2d3e56,null));};exports[_0x6dad('0x70')]=function(_0x80a319,_0x39d657,_0x2316e1){var _0x4d03d6={};var _0x419fb3={};var _0x283ba8;var _0x1a4f39;return db[_0x6dad('0x30')][_0x6dad('0x6d')]({'where':{'id':_0x80a319[_0x6dad('0x48')]['id']}})[_0x6dad('0x26')](handleEntityNotFound(_0x39d657,null))[_0x6dad('0x26')](function(_0x105ba8){if(_0x105ba8){_0x283ba8=_0x105ba8;_0x419fb3['model']=_[_0x6dad('0x49')](db['Sound']['rawAttributes']);_0x419fb3[_0x6dad('0x36')]=_[_0x6dad('0x49')](_0x80a319[_0x6dad('0x36')]);_0x419fb3[_0x6dad('0x3f')]=_[_0x6dad('0x38')](_0x419fb3[_0x6dad('0x34')],_0x419fb3[_0x6dad('0x36')]);_0x4d03d6[_0x6dad('0x37')]=_[_0x6dad('0x38')](_0x419fb3[_0x6dad('0x34')],qs[_0x6dad('0x4b')](_0x80a319[_0x6dad('0x36')]['fields']));_0x4d03d6[_0x6dad('0x37')]=_0x4d03d6['attributes'][_0x6dad('0x4c')]?_0x4d03d6[_0x6dad('0x37')]:_0x419fb3[_0x6dad('0x34')];_0x4d03d6[_0x6dad('0x3b')]=qs[_0x6dad('0x3c')](_0x80a319[_0x6dad('0x36')]['sort']);_0x4d03d6['where']=qs[_0x6dad('0x3f')](_['pick'](_0x80a319[_0x6dad('0x36')],_0x419fb3[_0x6dad('0x3f')]));if(_0x80a319[_0x6dad('0x36')]['filter']){_0x4d03d6[_0x6dad('0x3d')]=_[_0x6dad('0x41')](_0x4d03d6[_0x6dad('0x3d')],{'$or':_[_0x6dad('0x35')](_0x4d03d6[_0x6dad('0x37')],function(_0x459da1){var _0xc683bc={};_0xc683bc[_0x459da1]={'$like':'%'+_0x80a319['query'][_0x6dad('0x40')]+'%'};return _0xc683bc;})});}_0x4d03d6=_[_0x6dad('0x41')]({},_0x4d03d6,_0x80a319[_0x6dad('0x43')]);return _0x283ba8[_0x6dad('0x70')](_0x4d03d6);}})['then'](function(_0x45f18e){if(_0x45f18e){_0x1a4f39=_0x45f18e['length'];if(!_0x80a319[_0x6dad('0x36')][_0x6dad('0x39')](_0x6dad('0x71'))){_0x4d03d6[_0x6dad('0x3a')]=qs[_0x6dad('0x3a')](_0x80a319[_0x6dad('0x36')][_0x6dad('0x3a')]);_0x4d03d6[_0x6dad('0x21')]=qs['offset'](_0x80a319[_0x6dad('0x36')][_0x6dad('0x21')]);}return _0x283ba8[_0x6dad('0x70')](_0x4d03d6);}})[_0x6dad('0x26')](function(_0x53ec6b){if(_0x53ec6b){return _0x53ec6b?{'count':_0x1a4f39,'rows':_0x53ec6b}:null;}})['then'](respondWithResult(_0x39d657,null))['catch'](handleError(_0x39d657,null));};
\ No newline at end of file