Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / voiceQueuesLog / voiceQueuesLog.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 _0xc69b=['../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','undefined','limit','count','offset','set','Content-Range','reject','save','update','then','destroy','sendStatus','error','stack','send','index','VoiceQueuesLog','rawAttributes','fieldName','key','model','map','name','query','keys','intersection','attributes','fields','hasOwnProperty','order','sort','where','filters','pick','filter','merge','type','VIRTUAL','includeAll','findAll','rows','show','params','length','include','options','find','create','body','catch','eml-format','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch'];(function(_0x1e5cb6,_0x1314d6){var _0x408f84=function(_0x120da5){while(--_0x120da5){_0x1e5cb6['push'](_0x1e5cb6['shift']());}};_0x408f84(++_0x1314d6);}(_0xc69b,0x8d));var _0xbc69=function(_0x20c9b2,_0x55d7b1){_0x20c9b2=_0x20c9b2-0x0;var _0x2c6030=_0xc69b[_0x20c9b2];return _0x2c6030;};'use strict';var emlformat=require(_0xbc69('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xbc69('0x1'));var jsonpatch=require(_0xbc69('0x2'));var rp=require('request-promise');var moment=require(_0xbc69('0x3'));var BPromise=require(_0xbc69('0x4'));var Mustache=require(_0xbc69('0x5'));var util=require(_0xbc69('0x6'));var path=require(_0xbc69('0x7'));var sox=require(_0xbc69('0x8'));var csv=require(_0xbc69('0x9'));var ejs=require(_0xbc69('0xa'));var fs=require('fs');var fs_extra=require(_0xbc69('0xb'));var _=require(_0xbc69('0xc'));var squel=require(_0xbc69('0xd'));var crypto=require(_0xbc69('0xe'));var jsforce=require(_0xbc69('0xf'));var deskjs=require(_0xbc69('0x10'));var toCsv=require('to-csv');var querystring=require(_0xbc69('0x11'));var Papa=require(_0xbc69('0x12'));var Redis=require(_0xbc69('0x13'));var authService=require(_0xbc69('0x14'));var qs=require(_0xbc69('0x15'));var as=require(_0xbc69('0x16'));var hardwareService=require(_0xbc69('0x17'));var logger=require('../../config/logger')(_0xbc69('0x18'));var utils=require(_0xbc69('0x19'));var config=require(_0xbc69('0x1a'));var licenseUtil=require(_0xbc69('0x1b'));var db=require(_0xbc69('0x1c'))['db'];function respondWithStatusCode(_0x29895a,_0x7e1023){_0x7e1023=_0x7e1023||0xcc;return function(_0x6efa7b){if(_0x6efa7b){return _0x29895a['sendStatus'](_0x7e1023);}return _0x29895a[_0xbc69('0x1d')](_0x7e1023)[_0xbc69('0x1e')]();};}function respondWithResult(_0xe8bff4,_0x58b346){_0x58b346=_0x58b346||0xc8;return function(_0x3b43f6){if(_0x3b43f6){return _0xe8bff4[_0xbc69('0x1d')](_0x58b346)[_0xbc69('0x1f')](_0x3b43f6);}};}function respondWithFilteredResult(_0x5e1049,_0x3fce0f){return function(_0x4b0927){if(_0x4b0927){var _0x1607fd=typeof _0x3fce0f['offset']===_0xbc69('0x20')&&typeof _0x3fce0f[_0xbc69('0x21')]==='undefined';var _0x414de9=_0x4b0927[_0xbc69('0x22')];var _0x444cfd=_0x1607fd?0x0:_0x3fce0f['offset'];var _0x26f17c=_0x1607fd?_0x4b0927[_0xbc69('0x22')]:_0x3fce0f[_0xbc69('0x23')]+_0x3fce0f[_0xbc69('0x21')];var _0x50680d;if(_0x26f17c>=_0x414de9){_0x26f17c=_0x414de9;_0x50680d=0xc8;}else{_0x50680d=0xce;}_0x5e1049[_0xbc69('0x1d')](_0x50680d);return _0x5e1049[_0xbc69('0x24')](_0xbc69('0x25'),_0x444cfd+'-'+_0x26f17c+'/'+_0x414de9)[_0xbc69('0x1f')](_0x4b0927);}return null;};}function patchUpdates(_0x48d323){return function(_0x5cc135){try{jsonpatch['apply'](_0x5cc135,_0x48d323,!![]);}catch(_0x3e3b1a){return BPromise[_0xbc69('0x26')](_0x3e3b1a);}return _0x5cc135[_0xbc69('0x27')]();};}function saveUpdates(_0x19654f,_0x31009c){return function(_0x46c026){if(_0x46c026){return _0x46c026[_0xbc69('0x28')](_0x19654f)[_0xbc69('0x29')](function(_0x2a7262){return _0x2a7262;});}return null;};}function removeEntity(_0x3bfd80,_0x3e562a){return function(_0x53629e){if(_0x53629e){return _0x53629e[_0xbc69('0x2a')]()['then'](function(){_0x3bfd80['status'](0xcc)[_0xbc69('0x1e')]();});}};}function handleEntityNotFound(_0x5caea9,_0x19be9c){return function(_0x3eda90){if(!_0x3eda90){_0x5caea9[_0xbc69('0x2b')](0x194);}return _0x3eda90;};}function handleError(_0x45a54b,_0x72147d){_0x72147d=_0x72147d||0x1f4;return function(_0x39b3e6){logger[_0xbc69('0x2c')](_0x39b3e6[_0xbc69('0x2d')]);if(_0x39b3e6['name']){delete _0x39b3e6['name'];}_0x45a54b[_0xbc69('0x1d')](_0x72147d)[_0xbc69('0x2e')](_0x39b3e6);};}exports[_0xbc69('0x2f')]=function(_0x523f77,_0x15dd41){var _0x4b77bd={},_0x55542e={},_0x3654d6={'count':0x0,'rows':[]};var _0x5ee9a8=_['map'](db[_0xbc69('0x30')][_0xbc69('0x31')],function(_0x3f92f1){return{'name':_0x3f92f1[_0xbc69('0x32')],'type':_0x3f92f1['type'][_0xbc69('0x33')]};});_0x55542e[_0xbc69('0x34')]=_[_0xbc69('0x35')](_0x5ee9a8,_0xbc69('0x36'));_0x55542e[_0xbc69('0x37')]=_[_0xbc69('0x38')](_0x523f77[_0xbc69('0x37')]);_0x55542e['filters']=_[_0xbc69('0x39')](_0x55542e[_0xbc69('0x34')],_0x55542e[_0xbc69('0x37')]);_0x4b77bd[_0xbc69('0x3a')]=_[_0xbc69('0x39')](_0x55542e['model'],qs['fields'](_0x523f77[_0xbc69('0x37')][_0xbc69('0x3b')]));_0x4b77bd['attributes']=_0x4b77bd[_0xbc69('0x3a')]['length']?_0x4b77bd[_0xbc69('0x3a')]:_0x55542e[_0xbc69('0x34')];if(!_0x523f77['query'][_0xbc69('0x3c')]('nolimit')){_0x4b77bd[_0xbc69('0x21')]=qs[_0xbc69('0x21')](_0x523f77[_0xbc69('0x37')][_0xbc69('0x21')]);_0x4b77bd[_0xbc69('0x23')]=qs['offset'](_0x523f77['query'][_0xbc69('0x23')]);}_0x4b77bd[_0xbc69('0x3d')]=qs[_0xbc69('0x3e')](_0x523f77[_0xbc69('0x37')][_0xbc69('0x3e')]);_0x4b77bd[_0xbc69('0x3f')]=qs[_0xbc69('0x40')](_[_0xbc69('0x41')](_0x523f77[_0xbc69('0x37')],_0x55542e[_0xbc69('0x40')]),_0x5ee9a8);if(_0x523f77['query'][_0xbc69('0x42')]){_0x4b77bd['where']=_[_0xbc69('0x43')](_0x4b77bd[_0xbc69('0x3f')],{'$or':_['map'](_0x5ee9a8,function(_0x6c64d6){if(_0x6c64d6[_0xbc69('0x44')]!==_0xbc69('0x45')){var _0xd345e8={};_0xd345e8[_0x6c64d6[_0xbc69('0x36')]]={'$like':'%'+_0x523f77[_0xbc69('0x37')][_0xbc69('0x42')]+'%'};return _0xd345e8;}})});}_0x4b77bd=_['merge']({},_0x4b77bd,_0x523f77['options']);var _0x86dff={'where':_0x4b77bd[_0xbc69('0x3f')]};return db[_0xbc69('0x30')][_0xbc69('0x22')](_0x86dff)[_0xbc69('0x29')](function(_0x1d16d8){_0x3654d6[_0xbc69('0x22')]=_0x1d16d8;if(_0x523f77[_0xbc69('0x37')][_0xbc69('0x46')]){_0x4b77bd['include']=[{'all':!![]}];}return db[_0xbc69('0x30')][_0xbc69('0x47')](_0x4b77bd);})['then'](function(_0x58f462){_0x3654d6[_0xbc69('0x48')]=_0x58f462;return _0x3654d6;})[_0xbc69('0x29')](respondWithFilteredResult(_0x15dd41,_0x4b77bd))['catch'](handleError(_0x15dd41,null));};exports[_0xbc69('0x49')]=function(_0x4288fc,_0x2d3df2){var _0x446111={'raw':!![],'where':{'id':_0x4288fc[_0xbc69('0x4a')]['id']}},_0x6282cd={};_0x6282cd[_0xbc69('0x34')]=_[_0xbc69('0x38')](db[_0xbc69('0x30')]['rawAttributes']);_0x6282cd['query']=_[_0xbc69('0x38')](_0x4288fc['query']);_0x6282cd[_0xbc69('0x40')]=_['intersection'](_0x6282cd[_0xbc69('0x34')],_0x6282cd[_0xbc69('0x37')]);_0x446111[_0xbc69('0x3a')]=_[_0xbc69('0x39')](_0x6282cd[_0xbc69('0x34')],qs['fields'](_0x4288fc[_0xbc69('0x37')][_0xbc69('0x3b')]));_0x446111[_0xbc69('0x3a')]=_0x446111[_0xbc69('0x3a')][_0xbc69('0x4b')]?_0x446111[_0xbc69('0x3a')]:_0x6282cd[_0xbc69('0x34')];if(_0x4288fc[_0xbc69('0x37')][_0xbc69('0x46')]){_0x446111[_0xbc69('0x4c')]=[{'all':!![]}];}_0x446111=_['merge']({},_0x446111,_0x4288fc[_0xbc69('0x4d')]);return db['VoiceQueuesLog'][_0xbc69('0x4e')](_0x446111)[_0xbc69('0x29')](handleEntityNotFound(_0x2d3df2,null))[_0xbc69('0x29')](respondWithResult(_0x2d3df2,null))['catch'](handleError(_0x2d3df2,null));};exports[_0xbc69('0x4f')]=function(_0x1f579d,_0x3d675a){return db['VoiceQueuesLog']['create'](_0x1f579d[_0xbc69('0x50')],{})['then'](respondWithResult(_0x3d675a,0xc9))[_0xbc69('0x51')](handleError(_0x3d675a,null));};exports[_0xbc69('0x28')]=function(_0x295789,_0x20296e){if(_0x295789['body']['id']){delete _0x295789['body']['id'];}return db[_0xbc69('0x30')]['find']({'where':{'id':_0x295789[_0xbc69('0x4a')]['id']}})[_0xbc69('0x29')](handleEntityNotFound(_0x20296e,null))[_0xbc69('0x29')](saveUpdates(_0x295789[_0xbc69('0x50')],null))[_0xbc69('0x29')](respondWithResult(_0x20296e,null))['catch'](handleError(_0x20296e,null));};exports[_0xbc69('0x2a')]=function(_0x2dcdef,_0x114a72){return db[_0xbc69('0x30')][_0xbc69('0x4e')]({'where':{'id':_0x2dcdef[_0xbc69('0x4a')]['id']}})[_0xbc69('0x29')](handleEntityNotFound(_0x114a72,null))[_0xbc69('0x29')](removeEntity(_0x114a72,null))['catch'](handleError(_0x114a72,null));};