Built motion from commit (unavailable).|2.5.29
[motion2.git] / server / api / voiceMailMessage / voiceMailMessage.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x9b83=['length','includeAll','merge','options','catch','create','body','update','find','download','recording','msg_id','Sequelize','ValidationError','VoiceMailMessage\x20not\x20found','audio/wav','attachment','.wav\x22','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','then','error','stack','name','send','index','VoiceMailMessage','fieldName','key','model','differenceBy','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','map','type','include','rows','show','params','keys','rawAttributes'];(function(_0x110c17,_0x716d87){var _0x4ebc1e=function(_0xc5dd10){while(--_0xc5dd10){_0x110c17['push'](_0x110c17['shift']());}};_0x4ebc1e(++_0x716d87);}(_0x9b83,0x1cf));var _0x39b8=function(_0x1c8c28,_0x3ee093){_0x1c8c28=_0x1c8c28-0x0;var _0x1f59b4=_0x9b83[_0x1c8c28];return _0x1f59b4;};'use strict';var emlformat=require(_0x39b8('0x0'));var rimraf=require(_0x39b8('0x1'));var zipdir=require(_0x39b8('0x2'));var jsonpatch=require(_0x39b8('0x3'));var rp=require(_0x39b8('0x4'));var moment=require('moment');var BPromise=require(_0x39b8('0x5'));var Mustache=require(_0x39b8('0x6'));var util=require(_0x39b8('0x7'));var path=require(_0x39b8('0x8'));var sox=require(_0x39b8('0x9'));var csv=require(_0x39b8('0xa'));var ejs=require(_0x39b8('0xb'));var fs=require('fs');var fs_extra=require(_0x39b8('0xc'));var _=require(_0x39b8('0xd'));var squel=require('squel');var crypto=require(_0x39b8('0xe'));var jsforce=require(_0x39b8('0xf'));var deskjs=require(_0x39b8('0x10'));var toCsv=require(_0x39b8('0xa'));var querystring=require(_0x39b8('0x11'));var Papa=require(_0x39b8('0x12'));var Redis=require(_0x39b8('0x13'));var authService=require('../../components/auth/service');var qs=require(_0x39b8('0x14'));var as=require(_0x39b8('0x15'));var hardwareService=require(_0x39b8('0x16'));var logger=require('../../config/logger')(_0x39b8('0x17'));var utils=require(_0x39b8('0x18'));var config=require(_0x39b8('0x19'));var licenseUtil=require(_0x39b8('0x1a'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x372f49,_0x3b7b5b){_0x3b7b5b=_0x3b7b5b||0xcc;return function(_0x39255e){if(_0x39255e){return _0x372f49[_0x39b8('0x1b')](_0x3b7b5b);}return _0x372f49[_0x39b8('0x1c')](_0x3b7b5b)[_0x39b8('0x1d')]();};}function respondWithResult(_0x4ea9d2,_0x1fbab5){_0x1fbab5=_0x1fbab5||0xc8;return function(_0x3c5b4b){if(_0x3c5b4b){return _0x4ea9d2[_0x39b8('0x1c')](_0x1fbab5)[_0x39b8('0x1e')](_0x3c5b4b);}};}function respondWithFilteredResult(_0x3631b6,_0x49c700){return function(_0x1980c5){if(_0x1980c5){var _0x5b93f1=typeof _0x49c700['offset']===_0x39b8('0x1f')&&typeof _0x49c700[_0x39b8('0x20')]===_0x39b8('0x1f');var _0x13b537=_0x1980c5[_0x39b8('0x21')];var _0x35c95e=_0x5b93f1?0x0:_0x49c700['offset'];var _0x1f298e=_0x5b93f1?_0x1980c5[_0x39b8('0x21')]:_0x49c700[_0x39b8('0x22')]+_0x49c700[_0x39b8('0x20')];var _0x5cc0f8;if(_0x1f298e>=_0x13b537){_0x1f298e=_0x13b537;_0x5cc0f8=0xc8;}else{_0x5cc0f8=0xce;}_0x3631b6[_0x39b8('0x1c')](_0x5cc0f8);return _0x3631b6[_0x39b8('0x23')](_0x39b8('0x24'),_0x35c95e+'-'+_0x1f298e+'/'+_0x13b537)['json'](_0x1980c5);}return null;};}function patchUpdates(_0x30a5a9){return function(_0x136d50){try{jsonpatch[_0x39b8('0x25')](_0x136d50,_0x30a5a9,!![]);}catch(_0x549044){return BPromise[_0x39b8('0x26')](_0x549044);}return _0x136d50[_0x39b8('0x27')]();};}function saveUpdates(_0x7384f6,_0x315d17){return function(_0x135d9e){if(_0x135d9e){return _0x135d9e['update'](_0x7384f6)[_0x39b8('0x28')](function(_0x34e40d){return _0x34e40d;});}return null;};}function removeEntity(_0x204d20,_0x4aad7d){return function(_0x23a35d){if(_0x23a35d){return _0x23a35d['destroy']()[_0x39b8('0x28')](function(){_0x204d20[_0x39b8('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4f7a3b,_0x15f5f7){return function(_0x5bf1eb){if(!_0x5bf1eb){_0x4f7a3b[_0x39b8('0x1b')](0x194);}return _0x5bf1eb;};}function handleError(_0x541ac9,_0x260d73){_0x260d73=_0x260d73||0x1f4;return function(_0x47be51){logger[_0x39b8('0x29')](_0x47be51[_0x39b8('0x2a')]);if(_0x47be51[_0x39b8('0x2b')]){delete _0x47be51[_0x39b8('0x2b')];}_0x541ac9['status'](_0x260d73)[_0x39b8('0x2c')](_0x47be51);};}exports[_0x39b8('0x2d')]=function(_0x4adda9,_0x155818){var _0x2427cd={},_0x481321={},_0x26032f={'count':0x0,'rows':[]};var _0x1a93fc=_['map'](db[_0x39b8('0x2e')]['rawAttributes'],function(_0x2c86e4){return{'name':_0x2c86e4[_0x39b8('0x2f')],'type':_0x2c86e4['type'][_0x39b8('0x30')]};});_0x481321[_0x39b8('0x31')]=_[_0x39b8('0x32')](_['map'](_0x1a93fc,_0x39b8('0x2b')),[_0x39b8('0x2b')]);_0x481321[_0x39b8('0x33')]=_['keys'](_0x4adda9[_0x39b8('0x33')]);_0x481321[_0x39b8('0x34')]=_[_0x39b8('0x35')](_0x481321[_0x39b8('0x31')],_0x481321[_0x39b8('0x33')]);_0x2427cd[_0x39b8('0x36')]=_[_0x39b8('0x35')](_0x481321[_0x39b8('0x31')],qs[_0x39b8('0x37')](_0x4adda9['query']['fields']));_0x2427cd['attributes']=_0x2427cd[_0x39b8('0x36')]['length']?_0x2427cd[_0x39b8('0x36')]:_0x481321[_0x39b8('0x31')];if(!_0x4adda9['query'][_0x39b8('0x38')](_0x39b8('0x39'))){_0x2427cd[_0x39b8('0x20')]=qs[_0x39b8('0x20')](_0x4adda9[_0x39b8('0x33')]['limit']);_0x2427cd[_0x39b8('0x22')]=qs[_0x39b8('0x22')](_0x4adda9[_0x39b8('0x33')][_0x39b8('0x22')]);}_0x2427cd[_0x39b8('0x3a')]=qs['sort'](_0x4adda9[_0x39b8('0x33')][_0x39b8('0x3b')]);_0x2427cd[_0x39b8('0x3c')]=qs[_0x39b8('0x34')](_[_0x39b8('0x3d')](_0x4adda9[_0x39b8('0x33')],_0x481321[_0x39b8('0x34')]),_0x1a93fc);if(_0x4adda9['query'][_0x39b8('0x3e')]){_0x2427cd[_0x39b8('0x3c')]=_['merge'](_0x2427cd['where'],{'$or':_[_0x39b8('0x3f')](_0x1a93fc,function(_0x5d18cd){if(_0x5d18cd[_0x39b8('0x40')]!=='VIRTUAL'){var _0x596419={};_0x596419[_0x5d18cd[_0x39b8('0x2b')]]={'$like':'%'+_0x4adda9[_0x39b8('0x33')]['filter']+'%'};return _0x596419;}})});}_0x2427cd=_['merge']({},_0x2427cd,_0x4adda9['options']);var _0x2e9b51={'where':_0x2427cd[_0x39b8('0x3c')]};return db[_0x39b8('0x2e')][_0x39b8('0x21')](_0x2e9b51)[_0x39b8('0x28')](function(_0x25ac8b){_0x26032f[_0x39b8('0x21')]=_0x25ac8b;if(_0x4adda9[_0x39b8('0x33')]['includeAll']){_0x2427cd[_0x39b8('0x41')]=[{'all':!![]}];}return db[_0x39b8('0x2e')]['findAll'](_0x2427cd);})[_0x39b8('0x28')](function(_0x2d8cc2){_0x26032f[_0x39b8('0x42')]=_0x2d8cc2;return _0x26032f;})[_0x39b8('0x28')](respondWithFilteredResult(_0x155818,_0x2427cd))['catch'](handleError(_0x155818,null));};exports[_0x39b8('0x43')]=function(_0x35041d,_0x395064){var _0x23ac11={'raw':!![],'where':{'id':_0x35041d[_0x39b8('0x44')]['id']}},_0x5111d0={};_0x5111d0['model']=_[_0x39b8('0x45')](db[_0x39b8('0x2e')][_0x39b8('0x46')]);_0x5111d0[_0x39b8('0x33')]=_[_0x39b8('0x45')](_0x35041d['query']);_0x5111d0[_0x39b8('0x34')]=_[_0x39b8('0x35')](_0x5111d0[_0x39b8('0x31')],_0x5111d0[_0x39b8('0x33')]);_0x23ac11[_0x39b8('0x36')]=_['intersection'](_0x5111d0[_0x39b8('0x31')],qs[_0x39b8('0x37')](_0x35041d['query'][_0x39b8('0x37')]));_0x23ac11[_0x39b8('0x36')]=_0x23ac11[_0x39b8('0x36')][_0x39b8('0x47')]?_0x23ac11['attributes']:_0x5111d0[_0x39b8('0x31')];if(_0x35041d[_0x39b8('0x33')][_0x39b8('0x48')]){_0x23ac11[_0x39b8('0x41')]=[{'all':!![]}];}_0x23ac11=_[_0x39b8('0x49')]({},_0x23ac11,_0x35041d[_0x39b8('0x4a')]);return db[_0x39b8('0x2e')]['find'](_0x23ac11)[_0x39b8('0x28')](handleEntityNotFound(_0x395064,null))['then'](respondWithResult(_0x395064,null))[_0x39b8('0x4b')](handleError(_0x395064,null));};exports[_0x39b8('0x4c')]=function(_0x6dfe39,_0x30f470){return db['VoiceMailMessage'][_0x39b8('0x4c')](_0x6dfe39[_0x39b8('0x4d')],{})[_0x39b8('0x28')](respondWithResult(_0x30f470,0xc9))[_0x39b8('0x4b')](handleError(_0x30f470,null));};exports[_0x39b8('0x4e')]=function(_0x4e1699,_0xc51da4){if(_0x4e1699[_0x39b8('0x4d')]['id']){delete _0x4e1699[_0x39b8('0x4d')]['id'];}return db[_0x39b8('0x2e')][_0x39b8('0x4f')]({'where':{'id':_0x4e1699[_0x39b8('0x44')]['id']}})[_0x39b8('0x28')](handleEntityNotFound(_0xc51da4,null))['then'](saveUpdates(_0x4e1699[_0x39b8('0x4d')],null))['then'](respondWithResult(_0xc51da4,null))[_0x39b8('0x4b')](handleError(_0xc51da4,null));};exports['destroy']=function(_0x3a1697,_0x5b69bf){return db[_0x39b8('0x2e')][_0x39b8('0x4f')]({'where':{'id':_0x3a1697[_0x39b8('0x44')]['id']}})[_0x39b8('0x28')](handleEntityNotFound(_0x5b69bf,null))[_0x39b8('0x28')](removeEntity(_0x5b69bf,null))['catch'](handleError(_0x5b69bf,null));};exports[_0x39b8('0x50')]=function(_0x2eaa17,_0x4f4d25,_0xb0533){return db['VoiceMailMessage'][_0x39b8('0x4f')]({'where':{'id':_0x2eaa17[_0x39b8('0x44')]['id']},'attributes':['id',_0x39b8('0x51'),_0x39b8('0x52')]})[_0x39b8('0x28')](handleEntityNotFound(_0x4f4d25,null))[_0x39b8('0x28')](function(_0x3e2bfa){if(_0x3e2bfa){if(!_0x3e2bfa[_0x39b8('0x51')]){throw new db[(_0x39b8('0x53'))][(_0x39b8('0x54'))](_0x39b8('0x55'));}var _0x407686={'Content-Type':_0x39b8('0x56'),'Content-Disposition':_0x39b8('0x57')};if(_0x3e2bfa[_0x39b8('0x52')]){_0x407686['Content-Disposition']='attachment;\x20filename=\x22'+_0x3e2bfa[_0x39b8('0x52')]+_0x39b8('0x58');}_0x4f4d25['set'](_0x407686);return _0x4f4d25[_0x39b8('0x2c')](new Buffer(_0x3e2bfa[_0x39b8('0x51')]));}})['catch'](handleError(_0x4f4d25,null));};