Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / api / voiceMusicOnHold / voiceMusicOnHold.controller.js
index 530f5d5..7698df8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdb63=['basename','extname','format','symlinkSync','removeSound','findOne','id2','Sound','filter','getSounds','fast-json-patch','request-promise','mustache','path','sox','to-csv','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','status','json','offset','undefined','limit','count','set','apply','save','update','then','destroy','get','MusicOnHolds','end','error','stack','name','send','index','map','VoiceMusicOnHold','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','options','include','rows','catch','show','params','includeAll','find','body','create','sequelize','transaction','mode','files','directory','join','root','server/files/moh','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','readdirSync','unlinkSync','rmdirSync','Sequelize','ValidationError','message','addSound','save_name','converted_format','createdAt','server/files/sounds/converted','%s.%s'];(function(_0x5814f5,_0x407ac5){var _0x499dfe=function(_0x3cf741){while(--_0x3cf741){_0x5814f5['push'](_0x5814f5['shift']());}};_0x499dfe(++_0x407ac5);}(_0xdb63,0x1ae));var _0x3db6=function(_0x24bb6b,_0x50cd0b){_0x24bb6b=_0x24bb6b-0x0;var _0x20635b=_0xdb63[_0x24bb6b];return _0x20635b;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x3db6('0x0'));var rp=require(_0x3db6('0x1'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x3db6('0x2'));var util=require('util');var path=require(_0x3db6('0x3'));var sox=require(_0x3db6('0x4'));var csv=require(_0x3db6('0x5'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x3db6('0x6'));var squel=require('squel');var crypto=require(_0x3db6('0x7'));var jsforce=require(_0x3db6('0x8'));var deskjs=require(_0x3db6('0x9'));var toCsv=require(_0x3db6('0x5'));var querystring=require(_0x3db6('0xa'));var Papa=require(_0x3db6('0xb'));var Redis=require(_0x3db6('0xc'));var authService=require('../../components/auth/service');var qs=require(_0x3db6('0xd'));var as=require(_0x3db6('0xe'));var hardwareService=require(_0x3db6('0xf'));var logger=require(_0x3db6('0x10'))(_0x3db6('0x11'));var utils=require('../../config/utils');var config=require(_0x3db6('0x12'));var licenseUtil=require(_0x3db6('0x13'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x34cb2d,_0x1e0fb1){_0x1e0fb1=_0x1e0fb1||0xcc;return function(_0xe5a478){if(_0xe5a478){return _0x34cb2d[_0x3db6('0x14')](_0x1e0fb1);}return _0x34cb2d[_0x3db6('0x15')](_0x1e0fb1)['end']();};}function respondWithResult(_0x3082b0,_0x3cb8f6){_0x3cb8f6=_0x3cb8f6||0xc8;return function(_0x37ab13){if(_0x37ab13){return _0x3082b0['status'](_0x3cb8f6)[_0x3db6('0x16')](_0x37ab13);}};}function respondWithFilteredResult(_0x34949b,_0x1c8397){return function(_0x5c7b7c){if(_0x5c7b7c){var _0x3e426f=typeof _0x1c8397[_0x3db6('0x17')]===_0x3db6('0x18')&&typeof _0x1c8397[_0x3db6('0x19')]===_0x3db6('0x18');var _0x5d81dc=_0x5c7b7c[_0x3db6('0x1a')];var _0x7218db=_0x3e426f?0x0:_0x1c8397[_0x3db6('0x17')];var _0x9613d4=_0x3e426f?_0x5c7b7c[_0x3db6('0x1a')]:_0x1c8397[_0x3db6('0x17')]+_0x1c8397[_0x3db6('0x19')];var _0x4721bc;if(_0x9613d4>=_0x5d81dc){_0x9613d4=_0x5d81dc;_0x4721bc=0xc8;}else{_0x4721bc=0xce;}_0x34949b['status'](_0x4721bc);return _0x34949b[_0x3db6('0x1b')]('Content-Range',_0x7218db+'-'+_0x9613d4+'/'+_0x5d81dc)[_0x3db6('0x16')](_0x5c7b7c);}return null;};}function patchUpdates(_0x4e788e){return function(_0x30f9a3){try{jsonpatch[_0x3db6('0x1c')](_0x30f9a3,_0x4e788e,!![]);}catch(_0x40387a){return BPromise['reject'](_0x40387a);}return _0x30f9a3[_0x3db6('0x1d')]();};}function saveUpdates(_0x223d4d,_0x1086f3){return function(_0x33bfc4){if(_0x33bfc4){return _0x33bfc4[_0x3db6('0x1e')](_0x223d4d)[_0x3db6('0x1f')](function(_0x16a6eb){return _0x16a6eb;});}return null;};}function removeEntity(_0x2e5043,_0x5e33a4){return function(_0x23ddfc){if(_0x23ddfc){return _0x23ddfc[_0x3db6('0x20')]()[_0x3db6('0x1f')](function(){var _0x27c1b2=_0x23ddfc[_0x3db6('0x21')]({'plain':!![]});var _0x223ae5=_0x3db6('0x22');return db['UserProfileResource'][_0x3db6('0x20')]({'where':{'type':_0x223ae5,'resourceId':_0x27c1b2['id']}})[_0x3db6('0x1f')](function(){return _0x23ddfc;});})[_0x3db6('0x1f')](function(){_0x2e5043['status'](0xcc)[_0x3db6('0x23')]();});}};}function handleEntityNotFound(_0x48796c,_0x187993){return function(_0x1c4cab){if(!_0x1c4cab){_0x48796c[_0x3db6('0x14')](0x194);}return _0x1c4cab;};}function handleError(_0x4f9dc5,_0x11ac40){_0x11ac40=_0x11ac40||0x1f4;return function(_0x208b1b){logger[_0x3db6('0x24')](_0x208b1b[_0x3db6('0x25')]);if(_0x208b1b[_0x3db6('0x26')]){delete _0x208b1b[_0x3db6('0x26')];}_0x4f9dc5[_0x3db6('0x15')](_0x11ac40)[_0x3db6('0x27')](_0x208b1b);};}exports[_0x3db6('0x28')]=function(_0x1f8e30,_0x500392){var _0x8ec869={},_0x4c7fa7={},_0x19f3e5={'count':0x0,'rows':[]};var _0x5c7f3d=_[_0x3db6('0x29')](db[_0x3db6('0x2a')][_0x3db6('0x2b')],function(_0x34224a){return{'name':_0x34224a[_0x3db6('0x2c')],'type':_0x34224a[_0x3db6('0x2d')]['key']};});_0x4c7fa7[_0x3db6('0x2e')]=_[_0x3db6('0x29')](_0x5c7f3d,'name');_0x4c7fa7[_0x3db6('0x2f')]=_[_0x3db6('0x30')](_0x1f8e30['query']);_0x4c7fa7[_0x3db6('0x31')]=_[_0x3db6('0x32')](_0x4c7fa7[_0x3db6('0x2e')],_0x4c7fa7[_0x3db6('0x2f')]);_0x8ec869[_0x3db6('0x33')]=_[_0x3db6('0x32')](_0x4c7fa7['model'],qs['fields'](_0x1f8e30['query'][_0x3db6('0x34')]));_0x8ec869[_0x3db6('0x33')]=_0x8ec869[_0x3db6('0x33')][_0x3db6('0x35')]?_0x8ec869[_0x3db6('0x33')]:_0x4c7fa7[_0x3db6('0x2e')];if(!_0x1f8e30[_0x3db6('0x2f')][_0x3db6('0x36')](_0x3db6('0x37'))){_0x8ec869['limit']=qs[_0x3db6('0x19')](_0x1f8e30[_0x3db6('0x2f')][_0x3db6('0x19')]);_0x8ec869[_0x3db6('0x17')]=qs[_0x3db6('0x17')](_0x1f8e30[_0x3db6('0x2f')]['offset']);}_0x8ec869[_0x3db6('0x38')]=qs['sort'](_0x1f8e30[_0x3db6('0x2f')]['sort']);delete _0x1f8e30[_0x3db6('0x2f')][_0x3db6('0x39')];_0x8ec869[_0x3db6('0x3a')]=qs[_0x3db6('0x31')](_[_0x3db6('0x3b')](_0x1f8e30[_0x3db6('0x2f')],_0x4c7fa7[_0x3db6('0x31')]),_0x5c7f3d);if(_0x1f8e30['query']['filter']){_0x8ec869[_0x3db6('0x3a')]=_[_0x3db6('0x3c')](_0x8ec869[_0x3db6('0x3a')],{'$or':_['map'](_0x5c7f3d,function(_0x14b699){if(_0x14b699['type']!==_0x3db6('0x3d')){var _0x5b39a9={};_0x5b39a9[_0x14b699[_0x3db6('0x26')]]={'$like':'%'+_0x1f8e30['query']['filter']+'%'};return _0x5b39a9;}})});}_0x8ec869=_[_0x3db6('0x3c')]({},_0x8ec869,_0x1f8e30[_0x3db6('0x3e')]);var _0x7a92f4={'where':_0x8ec869['where']};return db[_0x3db6('0x2a')]['count'](_0x7a92f4)['then'](function(_0x3be83f){_0x19f3e5[_0x3db6('0x1a')]=_0x3be83f;if(_0x1f8e30[_0x3db6('0x2f')]['includeAll']){_0x8ec869[_0x3db6('0x3f')]=[{'all':!![]}];}return db['VoiceMusicOnHold']['findAll'](_0x8ec869);})[_0x3db6('0x1f')](function(_0x1ef665){_0x19f3e5[_0x3db6('0x40')]=_0x1ef665;return _0x19f3e5;})[_0x3db6('0x1f')](respondWithFilteredResult(_0x500392,_0x8ec869))[_0x3db6('0x41')](handleError(_0x500392,null));};exports[_0x3db6('0x42')]=function(_0x5298b0,_0x38d6ba){var _0x5a13b2={'raw':![],'where':{'id':_0x5298b0[_0x3db6('0x43')]['id']}},_0x18bd70={};_0x18bd70['model']=_[_0x3db6('0x30')](db[_0x3db6('0x2a')][_0x3db6('0x2b')]);_0x18bd70[_0x3db6('0x2f')]=_['keys'](_0x5298b0[_0x3db6('0x2f')]);_0x18bd70['filters']=_[_0x3db6('0x32')](_0x18bd70[_0x3db6('0x2e')],_0x18bd70[_0x3db6('0x2f')]);_0x5a13b2[_0x3db6('0x33')]=_[_0x3db6('0x32')](_0x18bd70['model'],qs[_0x3db6('0x34')](_0x5298b0[_0x3db6('0x2f')][_0x3db6('0x34')]));_0x5a13b2[_0x3db6('0x33')]=_0x5a13b2[_0x3db6('0x33')][_0x3db6('0x35')]?_0x5a13b2[_0x3db6('0x33')]:_0x18bd70[_0x3db6('0x2e')];if(_0x5298b0['query'][_0x3db6('0x44')]){_0x5a13b2[_0x3db6('0x3f')]=[{'all':!![]}];}_0x5a13b2=_[_0x3db6('0x3c')]({},_0x5a13b2,_0x5298b0[_0x3db6('0x3e')]);return db['VoiceMusicOnHold'][_0x3db6('0x45')](_0x5a13b2)['then'](handleEntityNotFound(_0x38d6ba,null))[_0x3db6('0x1f')](respondWithResult(_0x38d6ba,null))[_0x3db6('0x41')](handleError(_0x38d6ba,null));};exports[_0x3db6('0x1e')]=function(_0x4eda0a,_0x10c966){if(_0x4eda0a[_0x3db6('0x46')]['id']){delete _0x4eda0a[_0x3db6('0x46')]['id'];}return db[_0x3db6('0x2a')][_0x3db6('0x45')]({'where':{'id':_0x4eda0a[_0x3db6('0x43')]['id']}})[_0x3db6('0x1f')](handleEntityNotFound(_0x10c966,null))['then'](saveUpdates(_0x4eda0a['body'],null))[_0x3db6('0x1f')](respondWithResult(_0x10c966,null))[_0x3db6('0x41')](handleError(_0x10c966,null));};exports[_0x3db6('0x47')]=function(_0x431fb6,_0x2411bc,_0x198980){return db[_0x3db6('0x48')][_0x3db6('0x49')](function(_0x3928ce){if(_0x431fb6[_0x3db6('0x46')][_0x3db6('0x4a')]===_0x3db6('0x4b')){_0x431fb6[_0x3db6('0x46')][_0x3db6('0x4c')]=path[_0x3db6('0x4d')](config[_0x3db6('0x4e')],_0x3db6('0x4f'),_0x431fb6[_0x3db6('0x46')][_0x3db6('0x26')]);}return db['VoiceMusicOnHold'][_0x3db6('0x47')](_0x431fb6[_0x3db6('0x46')],{'transaction':_0x3928ce})[_0x3db6('0x1f')](function(_0xa408c0){if(_0x431fb6[_0x3db6('0x46')][_0x3db6('0x4a')]===_0x3db6('0x4b')){fs['mkdirSync'](_0xa408c0[_0x3db6('0x4c')],parseInt('0777',0x8));}var _0x12e19c=_0x431fb6[_0x3db6('0x50')][_0x3db6('0x21')]({'plain':!![]});if(!_0x12e19c)throw new Error(_0x3db6('0x51'));if(_0x12e19c[_0x3db6('0x52')]===_0x3db6('0x50')){var _0x175134=_0xa408c0[_0x3db6('0x21')]({'plain':!![]});return db['UserProfileSection'][_0x3db6('0x45')]({'where':{'name':_0x3db6('0x22'),'userProfileId':_0x12e19c['userProfileId']},'raw':!![]})['then'](function(_0x5e0b27){if(_0x5e0b27&&_0x5e0b27['autoAssociation']===0x0){return db['UserProfileResource'][_0x3db6('0x47')]({'name':_0x175134[_0x3db6('0x26')],'resourceId':_0x175134['id'],'type':_0x5e0b27['name'],'sectionId':_0x5e0b27['id']},{})[_0x3db6('0x1f')](function(){return _0xa408c0;});}else{return _0xa408c0;}})[_0x3db6('0x41')](function(_0x1e40f3){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1e40f3);});}return _0xa408c0;});})[_0x3db6('0x1f')](respondWithResult(_0x2411bc,0xc9))['catch'](handleError(_0x2411bc,null));};exports['destroy']=function(_0x11c38a,_0x4c4079,_0x5b74c5){var _0x5d67aa;return db['VoiceMusicOnHold']['find']({'where':{'id':_0x11c38a[_0x3db6('0x43')]['id']}})[_0x3db6('0x1f')](function(_0x540d1d){if(_0x540d1d){return db[_0x3db6('0x48')][_0x3db6('0x49')](function(_0x86d38d){return _0x540d1d[_0x3db6('0x20')]({'transaction':_0x86d38d,'raw':!![]})[_0x3db6('0x1f')](function(_0x1bf822){if(_0x1bf822['directory']){fs[_0x3db6('0x53')](_0x1bf822[_0x3db6('0x4c')])['forEach'](function(_0x1f3b9f){fs[_0x3db6('0x54')](path[_0x3db6('0x4d')](_0x1bf822[_0x3db6('0x4c')],_0x1f3b9f));});fs[_0x3db6('0x55')](_0x1bf822['directory']);}return _0x1bf822;});})[_0x3db6('0x41')](function(_0x1d8fd9){throw new db[(_0x3db6('0x56'))][(_0x3db6('0x57'))](_0x1d8fd9[_0x3db6('0x58')]);});}})[_0x3db6('0x1f')](handleEntityNotFound(_0x4c4079,null))[_0x3db6('0x1f')](removeEntity(_0x4c4079,null))[_0x3db6('0x41')](handleError(_0x4c4079,null));};exports['addSound']=function(_0x13b469,_0x1b98fa,_0x3814f3){return db['sequelize']['transaction'](function(_0x3d8246){var _0x2d1e0d;return db['VoiceMusicOnHold'][_0x3db6('0x45')]({'where':{'id':_0x13b469['params']['id']}})[_0x3db6('0x1f')](function(_0x137888){if(_0x137888){_0x2d1e0d=_0x137888;return _0x137888[_0x3db6('0x59')](_0x13b469[_0x3db6('0x46')]['id'],{'transaction':_0x3d8246});}})[_0x3db6('0x1f')](function(_0x288ed7){if(_0x288ed7){return db['Sound']['findOne']({'where':{'id':_0x13b469[_0x3db6('0x46')]['id']},'attributes':['id',_0x3db6('0x26'),_0x3db6('0x5a'),_0x3db6('0x5b'),_0x3db6('0x5c')],'raw':!![]});}})['then'](function(_0x49f452){if(_0x49f452){var _0x57b923=path[_0x3db6('0x4d')](config[_0x3db6('0x4e')],_0x3db6('0x5d'),util['format'](_0x3db6('0x5e'),path[_0x3db6('0x5f')](_0x49f452[_0x3db6('0x5a')],path[_0x3db6('0x60')](_0x49f452[_0x3db6('0x5a')])),_0x49f452[_0x3db6('0x5b')]));var _0x1a3a94=path[_0x3db6('0x4d')](config[_0x3db6('0x4e')],_0x3db6('0x4f'),_0x2d1e0d[_0x3db6('0x26')],util[_0x3db6('0x61')](_0x3db6('0x5e'),_0x49f452[_0x3db6('0x26')],_0x49f452[_0x3db6('0x5b')]));fs[_0x3db6('0x62')](_0x57b923,_0x1a3a94);return _0x49f452;}})[_0x3db6('0x41')](function(_0x9bcbc3){throw new db[(_0x3db6('0x56'))][(_0x3db6('0x57'))](_0x9bcbc3['message']);});})['then'](handleEntityNotFound(_0x1b98fa,null))[_0x3db6('0x1f')](respondWithResult(_0x1b98fa,0xc9))[_0x3db6('0x41')](handleError(_0x1b98fa,null));};exports[_0x3db6('0x63')]=function(_0x57774a,_0x160bb6,_0x3daaf5){return db[_0x3db6('0x48')][_0x3db6('0x49')](function(_0x1f9ea0){var _0x395445;return db[_0x3db6('0x2a')][_0x3db6('0x64')]({'where':{'id':_0x57774a[_0x3db6('0x43')]['id']}})[_0x3db6('0x1f')](handleEntityNotFound(_0x160bb6,null))['then'](function(_0x49cf73){if(_0x49cf73){_0x395445=_0x49cf73;return _0x49cf73[_0x3db6('0x63')](_0x57774a[_0x3db6('0x43')][_0x3db6('0x65')]);}})[_0x3db6('0x1f')](function(_0x5d9e0b){if(_0x5d9e0b){return db[_0x3db6('0x66')]['findOne']({'where':{'id':_0x57774a[_0x3db6('0x43')][_0x3db6('0x65')]},'attributes':['id',_0x3db6('0x26'),'save_name',_0x3db6('0x5b'),'createdAt'],'raw':!![]});}})[_0x3db6('0x1f')](function(_0x3a6307){if(_0x3a6307){fs[_0x3db6('0x54')](path[_0x3db6('0x4d')](_0x395445[_0x3db6('0x4c')],util[_0x3db6('0x61')]('%s.%s',_0x3a6307['name'],_0x3a6307[_0x3db6('0x5b')])));return _0x3a6307;}})[_0x3db6('0x41')](function(_0x2e09b1){throw new db[(_0x3db6('0x56'))]['ValidationError'](_0x2e09b1[_0x3db6('0x58')]);});})[_0x3db6('0x1f')](handleEntityNotFound(_0x160bb6,null))[_0x3db6('0x1f')](respondWithStatusCode(_0x160bb6,0xcc))[_0x3db6('0x41')](handleError(_0x160bb6,null));};exports['getSounds']=function(_0xf49290,_0x526360,_0x12730e){var _0x23dfcb={};var _0x263ec7={};var _0x36721d;var _0x4e9b7a;return db[_0x3db6('0x2a')]['findOne']({'where':{'id':_0xf49290[_0x3db6('0x43')]['id']}})[_0x3db6('0x1f')](handleEntityNotFound(_0x526360,null))[_0x3db6('0x1f')](function(_0x1c4dd3){if(_0x1c4dd3){_0x36721d=_0x1c4dd3;_0x263ec7[_0x3db6('0x2e')]=_[_0x3db6('0x30')](db[_0x3db6('0x66')][_0x3db6('0x2b')]);_0x263ec7[_0x3db6('0x2f')]=_[_0x3db6('0x30')](_0xf49290[_0x3db6('0x2f')]);_0x263ec7[_0x3db6('0x31')]=_['intersection'](_0x263ec7['model'],_0x263ec7[_0x3db6('0x2f')]);_0x23dfcb[_0x3db6('0x33')]=_[_0x3db6('0x32')](_0x263ec7[_0x3db6('0x2e')],qs[_0x3db6('0x34')](_0xf49290[_0x3db6('0x2f')][_0x3db6('0x34')]));_0x23dfcb[_0x3db6('0x33')]=_0x23dfcb['attributes'][_0x3db6('0x35')]?_0x23dfcb[_0x3db6('0x33')]:_0x263ec7[_0x3db6('0x2e')];_0x23dfcb[_0x3db6('0x38')]=qs[_0x3db6('0x39')](_0xf49290[_0x3db6('0x2f')][_0x3db6('0x39')]);_0x23dfcb[_0x3db6('0x3a')]=qs[_0x3db6('0x31')](_[_0x3db6('0x3b')](_0xf49290[_0x3db6('0x2f')],_0x263ec7['filters']));if(_0xf49290[_0x3db6('0x2f')][_0x3db6('0x67')]){_0x23dfcb[_0x3db6('0x3a')]=_['merge'](_0x23dfcb[_0x3db6('0x3a')],{'$or':_[_0x3db6('0x29')](_0x23dfcb[_0x3db6('0x33')],function(_0x446af1){var _0x107338={};_0x107338[_0x446af1]={'$like':'%'+_0xf49290[_0x3db6('0x2f')][_0x3db6('0x67')]+'%'};return _0x107338;})});}_0x23dfcb=_['merge']({},_0x23dfcb,_0xf49290[_0x3db6('0x3e')]);return _0x36721d[_0x3db6('0x68')](_0x23dfcb);}})[_0x3db6('0x1f')](function(_0x85d912){if(_0x85d912){_0x4e9b7a=_0x85d912[_0x3db6('0x35')];if(!_0xf49290[_0x3db6('0x2f')][_0x3db6('0x36')]('nolimit')){_0x23dfcb[_0x3db6('0x19')]=qs['limit'](_0xf49290[_0x3db6('0x2f')][_0x3db6('0x19')]);_0x23dfcb[_0x3db6('0x17')]=qs[_0x3db6('0x17')](_0xf49290['query']['offset']);}return _0x36721d[_0x3db6('0x68')](_0x23dfcb);}})[_0x3db6('0x1f')](function(_0x357c84){if(_0x357c84){return _0x357c84?{'count':_0x4e9b7a,'rows':_0x357c84}:null;}})[_0x3db6('0x1f')](respondWithResult(_0x526360,null))['catch'](handleError(_0x526360,null));};
\ No newline at end of file
+var _0xb0b0=['to-csv','ejs','fs-extra','lodash','squel','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','offset','undefined','limit','set','Content-Range','json','save','update','then','destroy','get','MusicOnHolds','UserProfileResource','end','stack','name','send','index','map','VoiceMusicOnHold','rawAttributes','fieldName','type','query','keys','filters','intersection','model','attributes','fields','length','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','count','include','findAll','rows','catch','show','params','includeAll','body','create','sequelize','transaction','mode','files','join','root','server/files/moh','mkdirSync','directory','0777','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','readdirSync','forEach','unlinkSync','Sequelize','ValidationError','message','addSound','findOne','save_name','converted_format','createdAt','format','basename','extname','%s.%s','symlinkSync','removeSound','Sound','id2','getSounds','order','eml-format','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox'];(function(_0x1ac595,_0x5d2081){var _0x455fff=function(_0x3043ee){while(--_0x3043ee){_0x1ac595['push'](_0x1ac595['shift']());}};_0x455fff(++_0x5d2081);}(_0xb0b0,0x6a));var _0x0b0b=function(_0x1cabc0,_0x50dbc7){_0x1cabc0=_0x1cabc0-0x0;var _0x39fa24=_0xb0b0[_0x1cabc0];return _0x39fa24;};'use strict';var emlformat=require(_0x0b0b('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x0b0b('0x1'));var jsonpatch=require(_0x0b0b('0x2'));var rp=require('request-promise');var moment=require(_0x0b0b('0x3'));var BPromise=require(_0x0b0b('0x4'));var Mustache=require(_0x0b0b('0x5'));var util=require(_0x0b0b('0x6'));var path=require(_0x0b0b('0x7'));var sox=require(_0x0b0b('0x8'));var csv=require(_0x0b0b('0x9'));var ejs=require(_0x0b0b('0xa'));var fs=require('fs');var fs_extra=require(_0x0b0b('0xb'));var _=require(_0x0b0b('0xc'));var squel=require(_0x0b0b('0xd'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x0b0b('0xe'));var toCsv=require(_0x0b0b('0x9'));var querystring=require(_0x0b0b('0xf'));var Papa=require(_0x0b0b('0x10'));var Redis=require(_0x0b0b('0x11'));var authService=require(_0x0b0b('0x12'));var qs=require(_0x0b0b('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x0b0b('0x14'));var utils=require(_0x0b0b('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x0b0b('0x16'));var db=require(_0x0b0b('0x17'))['db'];function respondWithStatusCode(_0x1253d8,_0x204f87){_0x204f87=_0x204f87||0xcc;return function(_0x2cd600){if(_0x2cd600){return _0x1253d8[_0x0b0b('0x18')](_0x204f87);}return _0x1253d8[_0x0b0b('0x19')](_0x204f87)['end']();};}function respondWithResult(_0x4b98a7,_0x50a10d){_0x50a10d=_0x50a10d||0xc8;return function(_0x7811d5){if(_0x7811d5){return _0x4b98a7[_0x0b0b('0x19')](_0x50a10d)['json'](_0x7811d5);}};}function respondWithFilteredResult(_0x3986c3,_0x19b67a){return function(_0x186270){if(_0x186270){var _0x46784a=typeof _0x19b67a[_0x0b0b('0x1a')]===_0x0b0b('0x1b')&&typeof _0x19b67a[_0x0b0b('0x1c')]===_0x0b0b('0x1b');var _0x1e9fb7=_0x186270['count'];var _0x550d57=_0x46784a?0x0:_0x19b67a[_0x0b0b('0x1a')];var _0x2f71a2=_0x46784a?_0x186270['count']:_0x19b67a[_0x0b0b('0x1a')]+_0x19b67a[_0x0b0b('0x1c')];var _0x13529c;if(_0x2f71a2>=_0x1e9fb7){_0x2f71a2=_0x1e9fb7;_0x13529c=0xc8;}else{_0x13529c=0xce;}_0x3986c3[_0x0b0b('0x19')](_0x13529c);return _0x3986c3[_0x0b0b('0x1d')](_0x0b0b('0x1e'),_0x550d57+'-'+_0x2f71a2+'/'+_0x1e9fb7)[_0x0b0b('0x1f')](_0x186270);}return null;};}function patchUpdates(_0x5b2382){return function(_0x62fb8){try{jsonpatch['apply'](_0x62fb8,_0x5b2382,!![]);}catch(_0x187c23){return BPromise['reject'](_0x187c23);}return _0x62fb8[_0x0b0b('0x20')]();};}function saveUpdates(_0x20b863,_0x125de9){return function(_0x2e050a){if(_0x2e050a){return _0x2e050a[_0x0b0b('0x21')](_0x20b863)[_0x0b0b('0x22')](function(_0x32a35f){return _0x32a35f;});}return null;};}function removeEntity(_0x47e42a,_0x5e08ae){return function(_0x4378c3){if(_0x4378c3){return _0x4378c3[_0x0b0b('0x23')]()[_0x0b0b('0x22')](function(){var _0x22496c=_0x4378c3[_0x0b0b('0x24')]({'plain':!![]});var _0x286216=_0x0b0b('0x25');return db[_0x0b0b('0x26')]['destroy']({'where':{'type':_0x286216,'resourceId':_0x22496c['id']}})[_0x0b0b('0x22')](function(){return _0x4378c3;});})[_0x0b0b('0x22')](function(){_0x47e42a[_0x0b0b('0x19')](0xcc)[_0x0b0b('0x27')]();});}};}function handleEntityNotFound(_0x58aa8d,_0x4157a1){return function(_0x417809){if(!_0x417809){_0x58aa8d[_0x0b0b('0x18')](0x194);}return _0x417809;};}function handleError(_0x261247,_0x19c80c){_0x19c80c=_0x19c80c||0x1f4;return function(_0xc071a0){logger['error'](_0xc071a0[_0x0b0b('0x28')]);if(_0xc071a0[_0x0b0b('0x29')]){delete _0xc071a0[_0x0b0b('0x29')];}_0x261247[_0x0b0b('0x19')](_0x19c80c)[_0x0b0b('0x2a')](_0xc071a0);};}exports[_0x0b0b('0x2b')]=function(_0x1d6e2b,_0x3fb3e4){var _0x349f3a={},_0x298f82={},_0xf9b690={'count':0x0,'rows':[]};var _0x56ef84=_[_0x0b0b('0x2c')](db[_0x0b0b('0x2d')][_0x0b0b('0x2e')],function(_0x5d391a){return{'name':_0x5d391a[_0x0b0b('0x2f')],'type':_0x5d391a[_0x0b0b('0x30')]['key']};});_0x298f82['model']=_[_0x0b0b('0x2c')](_0x56ef84,_0x0b0b('0x29'));_0x298f82[_0x0b0b('0x31')]=_[_0x0b0b('0x32')](_0x1d6e2b[_0x0b0b('0x31')]);_0x298f82[_0x0b0b('0x33')]=_[_0x0b0b('0x34')](_0x298f82[_0x0b0b('0x35')],_0x298f82['query']);_0x349f3a[_0x0b0b('0x36')]=_['intersection'](_0x298f82[_0x0b0b('0x35')],qs['fields'](_0x1d6e2b[_0x0b0b('0x31')][_0x0b0b('0x37')]));_0x349f3a['attributes']=_0x349f3a[_0x0b0b('0x36')][_0x0b0b('0x38')]?_0x349f3a[_0x0b0b('0x36')]:_0x298f82[_0x0b0b('0x35')];if(!_0x1d6e2b[_0x0b0b('0x31')]['hasOwnProperty'](_0x0b0b('0x39'))){_0x349f3a[_0x0b0b('0x1c')]=qs[_0x0b0b('0x1c')](_0x1d6e2b[_0x0b0b('0x31')]['limit']);_0x349f3a['offset']=qs['offset'](_0x1d6e2b[_0x0b0b('0x31')][_0x0b0b('0x1a')]);}_0x349f3a['order']=qs[_0x0b0b('0x3a')](_0x1d6e2b['query'][_0x0b0b('0x3a')]);delete _0x1d6e2b['query'][_0x0b0b('0x3a')];_0x349f3a[_0x0b0b('0x3b')]=qs[_0x0b0b('0x33')](_[_0x0b0b('0x3c')](_0x1d6e2b['query'],_0x298f82[_0x0b0b('0x33')]),_0x56ef84);if(_0x1d6e2b[_0x0b0b('0x31')][_0x0b0b('0x3d')]){_0x349f3a[_0x0b0b('0x3b')]=_[_0x0b0b('0x3e')](_0x349f3a['where'],{'$or':_[_0x0b0b('0x2c')](_0x56ef84,function(_0x3ad194){if(_0x3ad194[_0x0b0b('0x30')]!==_0x0b0b('0x3f')){var _0x12de3f={};_0x12de3f[_0x3ad194[_0x0b0b('0x29')]]={'$like':'%'+_0x1d6e2b[_0x0b0b('0x31')]['filter']+'%'};return _0x12de3f;}})});}_0x349f3a=_[_0x0b0b('0x3e')]({},_0x349f3a,_0x1d6e2b[_0x0b0b('0x40')]);var _0x155db5={'where':_0x349f3a['where']};return db[_0x0b0b('0x2d')][_0x0b0b('0x41')](_0x155db5)[_0x0b0b('0x22')](function(_0x1e5fce){_0xf9b690[_0x0b0b('0x41')]=_0x1e5fce;if(_0x1d6e2b[_0x0b0b('0x31')]['includeAll']){_0x349f3a[_0x0b0b('0x42')]=[{'all':!![]}];}return db['VoiceMusicOnHold'][_0x0b0b('0x43')](_0x349f3a);})[_0x0b0b('0x22')](function(_0x249372){_0xf9b690[_0x0b0b('0x44')]=_0x249372;return _0xf9b690;})[_0x0b0b('0x22')](respondWithFilteredResult(_0x3fb3e4,_0x349f3a))[_0x0b0b('0x45')](handleError(_0x3fb3e4,null));};exports[_0x0b0b('0x46')]=function(_0x672887,_0x2935d7){var _0x4b7c74={'raw':![],'where':{'id':_0x672887[_0x0b0b('0x47')]['id']}},_0xebb972={};_0xebb972['model']=_['keys'](db[_0x0b0b('0x2d')][_0x0b0b('0x2e')]);_0xebb972[_0x0b0b('0x31')]=_[_0x0b0b('0x32')](_0x672887[_0x0b0b('0x31')]);_0xebb972[_0x0b0b('0x33')]=_[_0x0b0b('0x34')](_0xebb972[_0x0b0b('0x35')],_0xebb972[_0x0b0b('0x31')]);_0x4b7c74['attributes']=_[_0x0b0b('0x34')](_0xebb972[_0x0b0b('0x35')],qs['fields'](_0x672887[_0x0b0b('0x31')]['fields']));_0x4b7c74[_0x0b0b('0x36')]=_0x4b7c74[_0x0b0b('0x36')][_0x0b0b('0x38')]?_0x4b7c74[_0x0b0b('0x36')]:_0xebb972['model'];if(_0x672887[_0x0b0b('0x31')][_0x0b0b('0x48')]){_0x4b7c74[_0x0b0b('0x42')]=[{'all':!![]}];}_0x4b7c74=_[_0x0b0b('0x3e')]({},_0x4b7c74,_0x672887[_0x0b0b('0x40')]);return db[_0x0b0b('0x2d')]['find'](_0x4b7c74)[_0x0b0b('0x22')](handleEntityNotFound(_0x2935d7,null))[_0x0b0b('0x22')](respondWithResult(_0x2935d7,null))[_0x0b0b('0x45')](handleError(_0x2935d7,null));};exports[_0x0b0b('0x21')]=function(_0x361bee,_0x1cc341){if(_0x361bee[_0x0b0b('0x49')]['id']){delete _0x361bee['body']['id'];}return db[_0x0b0b('0x2d')]['find']({'where':{'id':_0x361bee[_0x0b0b('0x47')]['id']}})[_0x0b0b('0x22')](handleEntityNotFound(_0x1cc341,null))[_0x0b0b('0x22')](saveUpdates(_0x361bee[_0x0b0b('0x49')],null))[_0x0b0b('0x22')](respondWithResult(_0x1cc341,null))['catch'](handleError(_0x1cc341,null));};exports[_0x0b0b('0x4a')]=function(_0x2e431b,_0x2e27e3,_0x39c33c){return db[_0x0b0b('0x4b')][_0x0b0b('0x4c')](function(_0x30d103){if(_0x2e431b[_0x0b0b('0x49')][_0x0b0b('0x4d')]===_0x0b0b('0x4e')){_0x2e431b['body']['directory']=path[_0x0b0b('0x4f')](config[_0x0b0b('0x50')],_0x0b0b('0x51'),_0x2e431b[_0x0b0b('0x49')]['name']);}return db[_0x0b0b('0x2d')][_0x0b0b('0x4a')](_0x2e431b[_0x0b0b('0x49')],{'transaction':_0x30d103})[_0x0b0b('0x22')](function(_0x36b337){if(_0x2e431b[_0x0b0b('0x49')][_0x0b0b('0x4d')]===_0x0b0b('0x4e')){fs[_0x0b0b('0x52')](_0x36b337[_0x0b0b('0x53')],parseInt(_0x0b0b('0x54'),0x8));}var _0x333091=_0x2e431b[_0x0b0b('0x55')][_0x0b0b('0x24')]({'plain':!![]});if(!_0x333091)throw new Error(_0x0b0b('0x56'));if(_0x333091[_0x0b0b('0x57')]==='user'){var _0x13c591=_0x36b337[_0x0b0b('0x24')]({'plain':!![]});return db[_0x0b0b('0x58')][_0x0b0b('0x59')]({'where':{'name':_0x0b0b('0x25'),'userProfileId':_0x333091[_0x0b0b('0x5a')]},'raw':!![]})['then'](function(_0x3a8be7){if(_0x3a8be7&&_0x3a8be7[_0x0b0b('0x5b')]===0x0){return db[_0x0b0b('0x26')][_0x0b0b('0x4a')]({'name':_0x13c591['name'],'resourceId':_0x13c591['id'],'type':_0x3a8be7[_0x0b0b('0x29')],'sectionId':_0x3a8be7['id']},{})[_0x0b0b('0x22')](function(){return _0x36b337;});}else{return _0x36b337;}})[_0x0b0b('0x45')](function(_0x3400fe){logger[_0x0b0b('0x5c')](_0x0b0b('0x5d'),_0x3400fe);});}return _0x36b337;});})[_0x0b0b('0x22')](respondWithResult(_0x2e27e3,0xc9))[_0x0b0b('0x45')](handleError(_0x2e27e3,null));};exports[_0x0b0b('0x23')]=function(_0x1de337,_0x4709c4,_0x3488ff){var _0x1658e7;return db[_0x0b0b('0x2d')][_0x0b0b('0x59')]({'where':{'id':_0x1de337['params']['id']}})[_0x0b0b('0x22')](function(_0x196de9){if(_0x196de9){return db[_0x0b0b('0x4b')]['transaction'](function(_0x1f7d2a){return _0x196de9[_0x0b0b('0x23')]({'transaction':_0x1f7d2a,'raw':!![]})[_0x0b0b('0x22')](function(_0x4f547d){if(_0x4f547d['directory']){fs[_0x0b0b('0x5e')](_0x4f547d['directory'])[_0x0b0b('0x5f')](function(_0x1b1a56){fs[_0x0b0b('0x60')](path[_0x0b0b('0x4f')](_0x4f547d['directory'],_0x1b1a56));});fs['rmdirSync'](_0x4f547d[_0x0b0b('0x53')]);}return _0x4f547d;});})[_0x0b0b('0x45')](function(_0x326e2a){throw new db[(_0x0b0b('0x61'))][(_0x0b0b('0x62'))](_0x326e2a[_0x0b0b('0x63')]);});}})['then'](handleEntityNotFound(_0x4709c4,null))[_0x0b0b('0x22')](removeEntity(_0x4709c4,null))[_0x0b0b('0x45')](handleError(_0x4709c4,null));};exports['addSound']=function(_0x22d366,_0x1c8425,_0x4bc773){return db['sequelize'][_0x0b0b('0x4c')](function(_0x2db891){var _0xe1bcb7;return db[_0x0b0b('0x2d')]['find']({'where':{'id':_0x22d366[_0x0b0b('0x47')]['id']}})[_0x0b0b('0x22')](function(_0x465bd9){if(_0x465bd9){_0xe1bcb7=_0x465bd9;return _0x465bd9[_0x0b0b('0x64')](_0x22d366['body']['id'],{'transaction':_0x2db891});}})[_0x0b0b('0x22')](function(_0x5c4d71){if(_0x5c4d71){return db['Sound'][_0x0b0b('0x65')]({'where':{'id':_0x22d366['body']['id']},'attributes':['id',_0x0b0b('0x29'),_0x0b0b('0x66'),_0x0b0b('0x67'),_0x0b0b('0x68')],'raw':!![]});}})[_0x0b0b('0x22')](function(_0x8fffa3){if(_0x8fffa3){var _0x560e71=path[_0x0b0b('0x4f')](config[_0x0b0b('0x50')],'server/files/sounds/converted',util[_0x0b0b('0x69')]('%s.%s',path[_0x0b0b('0x6a')](_0x8fffa3[_0x0b0b('0x66')],path[_0x0b0b('0x6b')](_0x8fffa3[_0x0b0b('0x66')])),_0x8fffa3[_0x0b0b('0x67')]));var _0x1e7244=path[_0x0b0b('0x4f')](config[_0x0b0b('0x50')],_0x0b0b('0x51'),_0xe1bcb7[_0x0b0b('0x29')],util['format'](_0x0b0b('0x6c'),_0x8fffa3[_0x0b0b('0x29')],_0x8fffa3[_0x0b0b('0x67')]));fs[_0x0b0b('0x6d')](_0x560e71,_0x1e7244);return _0x8fffa3;}})[_0x0b0b('0x45')](function(_0x590d3c){throw new db[(_0x0b0b('0x61'))][(_0x0b0b('0x62'))](_0x590d3c[_0x0b0b('0x63')]);});})[_0x0b0b('0x22')](handleEntityNotFound(_0x1c8425,null))[_0x0b0b('0x22')](respondWithResult(_0x1c8425,0xc9))[_0x0b0b('0x45')](handleError(_0x1c8425,null));};exports['removeSound']=function(_0x105e9e,_0x54008b,_0x1cf066){return db['sequelize'][_0x0b0b('0x4c')](function(_0x50e821){var _0x3236d9;return db[_0x0b0b('0x2d')][_0x0b0b('0x65')]({'where':{'id':_0x105e9e[_0x0b0b('0x47')]['id']}})[_0x0b0b('0x22')](handleEntityNotFound(_0x54008b,null))[_0x0b0b('0x22')](function(_0x493fb9){if(_0x493fb9){_0x3236d9=_0x493fb9;return _0x493fb9[_0x0b0b('0x6e')](_0x105e9e[_0x0b0b('0x47')]['id2']);}})[_0x0b0b('0x22')](function(_0x57520b){if(_0x57520b){return db[_0x0b0b('0x6f')][_0x0b0b('0x65')]({'where':{'id':_0x105e9e[_0x0b0b('0x47')][_0x0b0b('0x70')]},'attributes':['id',_0x0b0b('0x29'),_0x0b0b('0x66'),'converted_format','createdAt'],'raw':!![]});}})['then'](function(_0x232288){if(_0x232288){fs['unlinkSync'](path[_0x0b0b('0x4f')](_0x3236d9['directory'],util[_0x0b0b('0x69')](_0x0b0b('0x6c'),_0x232288['name'],_0x232288[_0x0b0b('0x67')])));return _0x232288;}})['catch'](function(_0x2ebf48){throw new db[(_0x0b0b('0x61'))]['ValidationError'](_0x2ebf48['message']);});})['then'](handleEntityNotFound(_0x54008b,null))['then'](respondWithStatusCode(_0x54008b,0xcc))[_0x0b0b('0x45')](handleError(_0x54008b,null));};exports[_0x0b0b('0x71')]=function(_0x161dde,_0x59b534,_0x245454){var _0x5612c1={};var _0x565a55={};var _0x12825a;var _0x87d865;return db['VoiceMusicOnHold'][_0x0b0b('0x65')]({'where':{'id':_0x161dde[_0x0b0b('0x47')]['id']}})['then'](handleEntityNotFound(_0x59b534,null))[_0x0b0b('0x22')](function(_0x2cc68f){if(_0x2cc68f){_0x12825a=_0x2cc68f;_0x565a55[_0x0b0b('0x35')]=_[_0x0b0b('0x32')](db[_0x0b0b('0x6f')][_0x0b0b('0x2e')]);_0x565a55[_0x0b0b('0x31')]=_[_0x0b0b('0x32')](_0x161dde[_0x0b0b('0x31')]);_0x565a55[_0x0b0b('0x33')]=_[_0x0b0b('0x34')](_0x565a55[_0x0b0b('0x35')],_0x565a55[_0x0b0b('0x31')]);_0x5612c1[_0x0b0b('0x36')]=_[_0x0b0b('0x34')](_0x565a55[_0x0b0b('0x35')],qs[_0x0b0b('0x37')](_0x161dde[_0x0b0b('0x31')][_0x0b0b('0x37')]));_0x5612c1['attributes']=_0x5612c1['attributes']['length']?_0x5612c1[_0x0b0b('0x36')]:_0x565a55[_0x0b0b('0x35')];_0x5612c1[_0x0b0b('0x72')]=qs[_0x0b0b('0x3a')](_0x161dde[_0x0b0b('0x31')][_0x0b0b('0x3a')]);_0x5612c1[_0x0b0b('0x3b')]=qs['filters'](_[_0x0b0b('0x3c')](_0x161dde[_0x0b0b('0x31')],_0x565a55[_0x0b0b('0x33')]));if(_0x161dde[_0x0b0b('0x31')][_0x0b0b('0x3d')]){_0x5612c1[_0x0b0b('0x3b')]=_[_0x0b0b('0x3e')](_0x5612c1['where'],{'$or':_[_0x0b0b('0x2c')](_0x5612c1['attributes'],function(_0x5dd840){var _0x81735b={};_0x81735b[_0x5dd840]={'$like':'%'+_0x161dde[_0x0b0b('0x31')]['filter']+'%'};return _0x81735b;})});}_0x5612c1=_[_0x0b0b('0x3e')]({},_0x5612c1,_0x161dde['options']);return _0x12825a[_0x0b0b('0x71')](_0x5612c1);}})[_0x0b0b('0x22')](function(_0xaf1450){if(_0xaf1450){_0x87d865=_0xaf1450[_0x0b0b('0x38')];if(!_0x161dde[_0x0b0b('0x31')]['hasOwnProperty'](_0x0b0b('0x39'))){_0x5612c1[_0x0b0b('0x1c')]=qs[_0x0b0b('0x1c')](_0x161dde[_0x0b0b('0x31')][_0x0b0b('0x1c')]);_0x5612c1[_0x0b0b('0x1a')]=qs[_0x0b0b('0x1a')](_0x161dde[_0x0b0b('0x31')]['offset']);}return _0x12825a['getSounds'](_0x5612c1);}})[_0x0b0b('0x22')](function(_0x447e1e){if(_0x447e1e){return _0x447e1e?{'count':_0x87d865,'rows':_0x447e1e}:null;}})['then'](respondWithResult(_0x59b534,null))['catch'](handleError(_0x59b534,null));};
\ No newline at end of file