8c28adc6f0252b162cdb1cb05778da0a6bc029b7
[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 _0x28ff=['../../mysqldb','sendStatus','end','status','json','offset','undefined','count','limit','set','save','update','destroy','error','stack','name','send','index','VoiceQueuesLog','rawAttributes','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','pick','where','merge','map','type','VIRTUAL','filter','options','then','include','findAll','rows','show','params','find','create','body','catch','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment'];(function(_0x2f45ea,_0x15c656){var _0x485a84=function(_0x4a1fe3){while(--_0x4a1fe3){_0x2f45ea['push'](_0x2f45ea['shift']());}};_0x485a84(++_0x15c656);}(_0x28ff,0x112));var _0xf28f=function(_0x3b380d,_0x4bf247){_0x3b380d=_0x3b380d-0x0;var _0x54502b=_0x28ff[_0x3b380d];return _0x54502b;};'use strict';var emlformat=require(_0xf28f('0x0'));var rimraf=require(_0xf28f('0x1'));var zipdir=require(_0xf28f('0x2'));var jsonpatch=require(_0xf28f('0x3'));var rp=require(_0xf28f('0x4'));var moment=require(_0xf28f('0x5'));var BPromise=require(_0xf28f('0x6'));var Mustache=require('mustache');var util=require('util');var path=require(_0xf28f('0x7'));var sox=require('sox');var csv=require(_0xf28f('0x8'));var ejs=require(_0xf28f('0x9'));var fs=require('fs');var fs_extra=require(_0xf28f('0xa'));var _=require(_0xf28f('0xb'));var squel=require(_0xf28f('0xc'));var crypto=require(_0xf28f('0xd'));var jsforce=require(_0xf28f('0xe'));var deskjs=require(_0xf28f('0xf'));var toCsv=require('to-csv');var querystring=require(_0xf28f('0x10'));var Papa=require(_0xf28f('0x11'));var Redis=require(_0xf28f('0x12'));var authService=require('../../components/auth/service');var qs=require(_0xf28f('0x13'));var as=require(_0xf28f('0x14'));var hardwareService=require(_0xf28f('0x15'));var logger=require(_0xf28f('0x16'))(_0xf28f('0x17'));var utils=require(_0xf28f('0x18'));var config=require(_0xf28f('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0xf28f('0x1a'))['db'];function respondWithStatusCode(_0x5549e4,_0x18a801){_0x18a801=_0x18a801||0xcc;return function(_0x3b2459){if(_0x3b2459){return _0x5549e4[_0xf28f('0x1b')](_0x18a801);}return _0x5549e4['status'](_0x18a801)[_0xf28f('0x1c')]();};}function respondWithResult(_0x5aa1d0,_0x5b2361){_0x5b2361=_0x5b2361||0xc8;return function(_0x2e63a7){if(_0x2e63a7){return _0x5aa1d0[_0xf28f('0x1d')](_0x5b2361)[_0xf28f('0x1e')](_0x2e63a7);}};}function respondWithFilteredResult(_0xfcedeb,_0x15f37d){return function(_0x15f262){if(_0x15f262){var _0x5f494b=typeof _0x15f37d[_0xf28f('0x1f')]===_0xf28f('0x20')&&typeof _0x15f37d['limit']==='undefined';var _0x2c4f31=_0x15f262['count'];var _0x2d04dc=_0x5f494b?0x0:_0x15f37d['offset'];var _0xe6bb73=_0x5f494b?_0x15f262[_0xf28f('0x21')]:_0x15f37d[_0xf28f('0x1f')]+_0x15f37d[_0xf28f('0x22')];var _0x482d18;if(_0xe6bb73>=_0x2c4f31){_0xe6bb73=_0x2c4f31;_0x482d18=0xc8;}else{_0x482d18=0xce;}_0xfcedeb[_0xf28f('0x1d')](_0x482d18);return _0xfcedeb[_0xf28f('0x23')]('Content-Range',_0x2d04dc+'-'+_0xe6bb73+'/'+_0x2c4f31)[_0xf28f('0x1e')](_0x15f262);}return null;};}function patchUpdates(_0x1e0d64){return function(_0x2c28c7){try{jsonpatch['apply'](_0x2c28c7,_0x1e0d64,!![]);}catch(_0x16f090){return BPromise['reject'](_0x16f090);}return _0x2c28c7[_0xf28f('0x24')]();};}function saveUpdates(_0x4dd1dc,_0x11b39b){return function(_0x536e4d){if(_0x536e4d){return _0x536e4d[_0xf28f('0x25')](_0x4dd1dc)['then'](function(_0x508787){return _0x508787;});}return null;};}function removeEntity(_0x512c16,_0x18dd50){return function(_0x6ffce5){if(_0x6ffce5){return _0x6ffce5[_0xf28f('0x26')]()['then'](function(){_0x512c16[_0xf28f('0x1d')](0xcc)[_0xf28f('0x1c')]();});}};}function handleEntityNotFound(_0x510a8c,_0x435edf){return function(_0x3a8073){if(!_0x3a8073){_0x510a8c[_0xf28f('0x1b')](0x194);}return _0x3a8073;};}function handleError(_0x1b2a77,_0x23a31a){_0x23a31a=_0x23a31a||0x1f4;return function(_0x13aac9){logger[_0xf28f('0x27')](_0x13aac9[_0xf28f('0x28')]);if(_0x13aac9[_0xf28f('0x29')]){delete _0x13aac9[_0xf28f('0x29')];}_0x1b2a77[_0xf28f('0x1d')](_0x23a31a)[_0xf28f('0x2a')](_0x13aac9);};}exports[_0xf28f('0x2b')]=function(_0x3c6b67,_0xb24498){var _0x163631={},_0x1ff1c8={},_0x376042={'count':0x0,'rows':[]};var _0x38ca30=_['map'](db[_0xf28f('0x2c')][_0xf28f('0x2d')],function(_0xe28458){return{'name':_0xe28458['fieldName'],'type':_0xe28458['type'][_0xf28f('0x2e')]};});_0x1ff1c8[_0xf28f('0x2f')]=_['map'](_0x38ca30,_0xf28f('0x29'));_0x1ff1c8[_0xf28f('0x30')]=_[_0xf28f('0x31')](_0x3c6b67['query']);_0x1ff1c8[_0xf28f('0x32')]=_[_0xf28f('0x33')](_0x1ff1c8[_0xf28f('0x2f')],_0x1ff1c8[_0xf28f('0x30')]);_0x163631[_0xf28f('0x34')]=_[_0xf28f('0x33')](_0x1ff1c8['model'],qs['fields'](_0x3c6b67[_0xf28f('0x30')][_0xf28f('0x35')]));_0x163631['attributes']=_0x163631[_0xf28f('0x34')][_0xf28f('0x36')]?_0x163631[_0xf28f('0x34')]:_0x1ff1c8['model'];if(!_0x3c6b67[_0xf28f('0x30')]['hasOwnProperty'](_0xf28f('0x37'))){_0x163631['limit']=qs['limit'](_0x3c6b67['query'][_0xf28f('0x22')]);_0x163631[_0xf28f('0x1f')]=qs[_0xf28f('0x1f')](_0x3c6b67[_0xf28f('0x30')][_0xf28f('0x1f')]);}_0x163631[_0xf28f('0x38')]=qs['sort'](_0x3c6b67['query']['sort']);_0x163631['where']=qs[_0xf28f('0x32')](_[_0xf28f('0x39')](_0x3c6b67[_0xf28f('0x30')],_0x1ff1c8['filters']),_0x38ca30);if(_0x3c6b67['query']['filter']){_0x163631[_0xf28f('0x3a')]=_[_0xf28f('0x3b')](_0x163631['where'],{'$or':_[_0xf28f('0x3c')](_0x38ca30,function(_0x89195d){if(_0x89195d[_0xf28f('0x3d')]!==_0xf28f('0x3e')){var _0x1d8cc9={};_0x1d8cc9[_0x89195d[_0xf28f('0x29')]]={'$like':'%'+_0x3c6b67[_0xf28f('0x30')][_0xf28f('0x3f')]+'%'};return _0x1d8cc9;}})});}_0x163631=_['merge']({},_0x163631,_0x3c6b67[_0xf28f('0x40')]);var _0x3f829d={'where':_0x163631[_0xf28f('0x3a')]};return db['VoiceQueuesLog']['count'](_0x3f829d)[_0xf28f('0x41')](function(_0x493f4e){_0x376042['count']=_0x493f4e;if(_0x3c6b67[_0xf28f('0x30')]['includeAll']){_0x163631[_0xf28f('0x42')]=[{'all':!![]}];}return db[_0xf28f('0x2c')][_0xf28f('0x43')](_0x163631);})[_0xf28f('0x41')](function(_0x5680b5){_0x376042[_0xf28f('0x44')]=_0x5680b5;return _0x376042;})[_0xf28f('0x41')](respondWithFilteredResult(_0xb24498,_0x163631))['catch'](handleError(_0xb24498,null));};exports[_0xf28f('0x45')]=function(_0x57c4a0,_0x5276fc){var _0x5a2300={'raw':!![],'where':{'id':_0x57c4a0[_0xf28f('0x46')]['id']}},_0x4cd245={};_0x4cd245['model']=_[_0xf28f('0x31')](db[_0xf28f('0x2c')][_0xf28f('0x2d')]);_0x4cd245[_0xf28f('0x30')]=_[_0xf28f('0x31')](_0x57c4a0[_0xf28f('0x30')]);_0x4cd245[_0xf28f('0x32')]=_[_0xf28f('0x33')](_0x4cd245[_0xf28f('0x2f')],_0x4cd245['query']);_0x5a2300[_0xf28f('0x34')]=_[_0xf28f('0x33')](_0x4cd245[_0xf28f('0x2f')],qs[_0xf28f('0x35')](_0x57c4a0[_0xf28f('0x30')][_0xf28f('0x35')]));_0x5a2300['attributes']=_0x5a2300['attributes'][_0xf28f('0x36')]?_0x5a2300[_0xf28f('0x34')]:_0x4cd245[_0xf28f('0x2f')];if(_0x57c4a0[_0xf28f('0x30')]['includeAll']){_0x5a2300[_0xf28f('0x42')]=[{'all':!![]}];}_0x5a2300=_[_0xf28f('0x3b')]({},_0x5a2300,_0x57c4a0[_0xf28f('0x40')]);return db[_0xf28f('0x2c')][_0xf28f('0x47')](_0x5a2300)['then'](handleEntityNotFound(_0x5276fc,null))[_0xf28f('0x41')](respondWithResult(_0x5276fc,null))['catch'](handleError(_0x5276fc,null));};exports[_0xf28f('0x48')]=function(_0x2a4320,_0x21ee8c){return db['VoiceQueuesLog'][_0xf28f('0x48')](_0x2a4320[_0xf28f('0x49')],{})[_0xf28f('0x41')](respondWithResult(_0x21ee8c,0xc9))[_0xf28f('0x4a')](handleError(_0x21ee8c,null));};exports['update']=function(_0x12fea9,_0x5df393){if(_0x12fea9[_0xf28f('0x49')]['id']){delete _0x12fea9[_0xf28f('0x49')]['id'];}return db['VoiceQueuesLog'][_0xf28f('0x47')]({'where':{'id':_0x12fea9[_0xf28f('0x46')]['id']}})[_0xf28f('0x41')](handleEntityNotFound(_0x5df393,null))['then'](saveUpdates(_0x12fea9['body'],null))['then'](respondWithResult(_0x5df393,null))[_0xf28f('0x4a')](handleError(_0x5df393,null));};exports[_0xf28f('0x26')]=function(_0x17fe64,_0x379127){return db[_0xf28f('0x2c')][_0xf28f('0x47')]({'where':{'id':_0x17fe64[_0xf28f('0x46')]['id']}})['then'](handleEntityNotFound(_0x379127,null))['then'](removeEntity(_0x379127,null))['catch'](handleError(_0x379127,null));};