10ab9c87e96e26fa6eab71cba287e0c74e60a019
[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 _0x60e5=['stack','name','send','index','map','VoiceQueuesLog','rawAttributes','fieldName','type','key','model','keys','filters','intersection','query','attributes','fields','length','nolimit','order','sort','where','pick','merge','filter','options','include','rows','catch','show','params','find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','limit','undefined','count','set','Content-Range','apply','save','update','destroy','then','sendStatus','error'];(function(_0x370032,_0x4406c6){var _0x5cd605=function(_0x838862){while(--_0x838862){_0x370032['push'](_0x370032['shift']());}};_0x5cd605(++_0x4406c6);}(_0x60e5,0x1a3));var _0x560e=function(_0x5774be,_0x2259d3){_0x5774be=_0x5774be-0x0;var _0x4914b4=_0x60e5[_0x5774be];return _0x4914b4;};'use strict';var emlformat=require(_0x560e('0x0'));var rimraf=require(_0x560e('0x1'));var zipdir=require(_0x560e('0x2'));var jsonpatch=require(_0x560e('0x3'));var rp=require(_0x560e('0x4'));var moment=require(_0x560e('0x5'));var BPromise=require(_0x560e('0x6'));var Mustache=require('mustache');var util=require(_0x560e('0x7'));var path=require('path');var sox=require(_0x560e('0x8'));var csv=require(_0x560e('0x9'));var ejs=require(_0x560e('0xa'));var fs=require('fs');var fs_extra=require(_0x560e('0xb'));var _=require('lodash');var squel=require(_0x560e('0xc'));var crypto=require(_0x560e('0xd'));var jsforce=require(_0x560e('0xe'));var deskjs=require(_0x560e('0xf'));var toCsv=require(_0x560e('0x9'));var querystring=require('querystring');var Papa=require(_0x560e('0x10'));var Redis=require(_0x560e('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x560e('0x12'));var as=require(_0x560e('0x13'));var hardwareService=require(_0x560e('0x14'));var logger=require(_0x560e('0x15'))(_0x560e('0x16'));var utils=require(_0x560e('0x17'));var config=require(_0x560e('0x18'));var licenseUtil=require(_0x560e('0x19'));var db=require(_0x560e('0x1a'))['db'];function respondWithStatusCode(_0x50b3d8,_0x36ef3e){_0x36ef3e=_0x36ef3e||0xcc;return function(_0x3b984b){if(_0x3b984b){return _0x50b3d8['sendStatus'](_0x36ef3e);}return _0x50b3d8[_0x560e('0x1b')](_0x36ef3e)[_0x560e('0x1c')]();};}function respondWithResult(_0xbc55b5,_0x107c58){_0x107c58=_0x107c58||0xc8;return function(_0x1805ea){if(_0x1805ea){return _0xbc55b5[_0x560e('0x1b')](_0x107c58)[_0x560e('0x1d')](_0x1805ea);}};}function respondWithFilteredResult(_0x3d2ab6,_0x4b7c77){return function(_0x4dfc14){if(_0x4dfc14){var _0x165edb=typeof _0x4b7c77[_0x560e('0x1e')]==='undefined'&&typeof _0x4b7c77[_0x560e('0x1f')]===_0x560e('0x20');var _0x50bb06=_0x4dfc14[_0x560e('0x21')];var _0x2d4741=_0x165edb?0x0:_0x4b7c77[_0x560e('0x1e')];var _0x78828c=_0x165edb?_0x4dfc14[_0x560e('0x21')]:_0x4b7c77[_0x560e('0x1e')]+_0x4b7c77['limit'];var _0x232fa2;if(_0x78828c>=_0x50bb06){_0x78828c=_0x50bb06;_0x232fa2=0xc8;}else{_0x232fa2=0xce;}_0x3d2ab6[_0x560e('0x1b')](_0x232fa2);return _0x3d2ab6[_0x560e('0x22')](_0x560e('0x23'),_0x2d4741+'-'+_0x78828c+'/'+_0x50bb06)['json'](_0x4dfc14);}return null;};}function patchUpdates(_0x48ffa9){return function(_0x4eb3b7){try{jsonpatch[_0x560e('0x24')](_0x4eb3b7,_0x48ffa9,!![]);}catch(_0x22af52){return BPromise['reject'](_0x22af52);}return _0x4eb3b7[_0x560e('0x25')]();};}function saveUpdates(_0x53937c,_0x3630fb){return function(_0x43f6ef){if(_0x43f6ef){return _0x43f6ef[_0x560e('0x26')](_0x53937c)['then'](function(_0x3356e8){return _0x3356e8;});}return null;};}function removeEntity(_0x1fe014,_0x55a4de){return function(_0x3bbcd0){if(_0x3bbcd0){return _0x3bbcd0[_0x560e('0x27')]()[_0x560e('0x28')](function(){_0x1fe014['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x1ac0bb,_0xffcce3){return function(_0x585bcd){if(!_0x585bcd){_0x1ac0bb[_0x560e('0x29')](0x194);}return _0x585bcd;};}function handleError(_0x28e382,_0x5da4ac){_0x5da4ac=_0x5da4ac||0x1f4;return function(_0x1c92bc){logger[_0x560e('0x2a')](_0x1c92bc[_0x560e('0x2b')]);if(_0x1c92bc[_0x560e('0x2c')]){delete _0x1c92bc['name'];}_0x28e382[_0x560e('0x1b')](_0x5da4ac)[_0x560e('0x2d')](_0x1c92bc);};}exports[_0x560e('0x2e')]=function(_0x2ebb99,_0x5e9492){var _0x5145b3={},_0x2c17be={},_0x2df3de={'count':0x0,'rows':[]};var _0x4d0c9a=_[_0x560e('0x2f')](db[_0x560e('0x30')][_0x560e('0x31')],function(_0x2f3dac){return{'name':_0x2f3dac[_0x560e('0x32')],'type':_0x2f3dac[_0x560e('0x33')][_0x560e('0x34')]};});_0x2c17be[_0x560e('0x35')]=_[_0x560e('0x2f')](_0x4d0c9a,'name');_0x2c17be['query']=_[_0x560e('0x36')](_0x2ebb99['query']);_0x2c17be[_0x560e('0x37')]=_[_0x560e('0x38')](_0x2c17be[_0x560e('0x35')],_0x2c17be[_0x560e('0x39')]);_0x5145b3[_0x560e('0x3a')]=_['intersection'](_0x2c17be[_0x560e('0x35')],qs[_0x560e('0x3b')](_0x2ebb99[_0x560e('0x39')]['fields']));_0x5145b3[_0x560e('0x3a')]=_0x5145b3[_0x560e('0x3a')][_0x560e('0x3c')]?_0x5145b3['attributes']:_0x2c17be[_0x560e('0x35')];if(!_0x2ebb99[_0x560e('0x39')]['hasOwnProperty'](_0x560e('0x3d'))){_0x5145b3['limit']=qs['limit'](_0x2ebb99[_0x560e('0x39')][_0x560e('0x1f')]);_0x5145b3[_0x560e('0x1e')]=qs[_0x560e('0x1e')](_0x2ebb99['query'][_0x560e('0x1e')]);}_0x5145b3[_0x560e('0x3e')]=qs[_0x560e('0x3f')](_0x2ebb99[_0x560e('0x39')]['sort']);_0x5145b3[_0x560e('0x40')]=qs[_0x560e('0x37')](_[_0x560e('0x41')](_0x2ebb99[_0x560e('0x39')],_0x2c17be[_0x560e('0x37')]),_0x4d0c9a);if(_0x2ebb99[_0x560e('0x39')]['filter']){_0x5145b3[_0x560e('0x40')]=_[_0x560e('0x42')](_0x5145b3[_0x560e('0x40')],{'$or':_[_0x560e('0x2f')](_0x4d0c9a,function(_0x1a5cbb){if(_0x1a5cbb[_0x560e('0x33')]!=='VIRTUAL'){var _0x735ab0={};_0x735ab0[_0x1a5cbb[_0x560e('0x2c')]]={'$like':'%'+_0x2ebb99[_0x560e('0x39')][_0x560e('0x43')]+'%'};return _0x735ab0;}})});}_0x5145b3=_[_0x560e('0x42')]({},_0x5145b3,_0x2ebb99[_0x560e('0x44')]);var _0x38b0c8={'where':_0x5145b3[_0x560e('0x40')]};return db[_0x560e('0x30')][_0x560e('0x21')](_0x38b0c8)[_0x560e('0x28')](function(_0x5a13d9){_0x2df3de[_0x560e('0x21')]=_0x5a13d9;if(_0x2ebb99[_0x560e('0x39')]['includeAll']){_0x5145b3[_0x560e('0x45')]=[{'all':!![]}];}return db[_0x560e('0x30')]['findAll'](_0x5145b3);})['then'](function(_0x5b4c08){_0x2df3de[_0x560e('0x46')]=_0x5b4c08;return _0x2df3de;})['then'](respondWithFilteredResult(_0x5e9492,_0x5145b3))[_0x560e('0x47')](handleError(_0x5e9492,null));};exports[_0x560e('0x48')]=function(_0x1a282e,_0x490f66){var _0xd98625={'raw':!![],'where':{'id':_0x1a282e[_0x560e('0x49')]['id']}},_0x43af41={};_0x43af41[_0x560e('0x35')]=_[_0x560e('0x36')](db['VoiceQueuesLog'][_0x560e('0x31')]);_0x43af41[_0x560e('0x39')]=_['keys'](_0x1a282e['query']);_0x43af41['filters']=_['intersection'](_0x43af41['model'],_0x43af41[_0x560e('0x39')]);_0xd98625[_0x560e('0x3a')]=_['intersection'](_0x43af41[_0x560e('0x35')],qs[_0x560e('0x3b')](_0x1a282e['query']['fields']));_0xd98625[_0x560e('0x3a')]=_0xd98625['attributes'][_0x560e('0x3c')]?_0xd98625[_0x560e('0x3a')]:_0x43af41[_0x560e('0x35')];if(_0x1a282e['query']['includeAll']){_0xd98625[_0x560e('0x45')]=[{'all':!![]}];}_0xd98625=_[_0x560e('0x42')]({},_0xd98625,_0x1a282e['options']);return db[_0x560e('0x30')][_0x560e('0x4a')](_0xd98625)[_0x560e('0x28')](handleEntityNotFound(_0x490f66,null))[_0x560e('0x28')](respondWithResult(_0x490f66,null))[_0x560e('0x47')](handleError(_0x490f66,null));};exports[_0x560e('0x4b')]=function(_0xb1761,_0x17101c){return db[_0x560e('0x30')]['create'](_0xb1761[_0x560e('0x4c')],{})[_0x560e('0x28')](respondWithResult(_0x17101c,0xc9))[_0x560e('0x47')](handleError(_0x17101c,null));};exports[_0x560e('0x26')]=function(_0x4e0de1,_0x3162b7){if(_0x4e0de1[_0x560e('0x4c')]['id']){delete _0x4e0de1[_0x560e('0x4c')]['id'];}return db[_0x560e('0x30')]['find']({'where':{'id':_0x4e0de1[_0x560e('0x49')]['id']}})['then'](handleEntityNotFound(_0x3162b7,null))[_0x560e('0x28')](saveUpdates(_0x4e0de1[_0x560e('0x4c')],null))[_0x560e('0x28')](respondWithResult(_0x3162b7,null))['catch'](handleError(_0x3162b7,null));};exports[_0x560e('0x27')]=function(_0x553298,_0x359ecf){return db['VoiceQueuesLog'][_0x560e('0x4a')]({'where':{'id':_0x553298['params']['id']}})['then'](handleEntityNotFound(_0x359ecf,null))['then'](removeEntity(_0x359ecf,null))['catch'](handleError(_0x359ecf,null));};