Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / openchannelQueueReport / openchannelQueueReport.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 _0x303a=['destroy','describe','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','querystring','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','status','end','json','count','offset','Content-Range','apply','reject','save','update','then','sendStatus','send','index','map','OpenchannelQueueReport','rawAttributes','fieldName','type','key','model','name','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','limit','order','sort','where','filter','merge','includeAll','include','rows','params','catch','create','body','find'];(function(_0x237ffb,_0x568db7){var _0x2141ca=function(_0x568f13){while(--_0x568f13){_0x237ffb['push'](_0x237ffb['shift']());}};_0x2141ca(++_0x568db7);}(_0x303a,0x1a0));var _0xa303=function(_0x288d33,_0x58ee36){_0x288d33=_0x288d33-0x0;var _0x1033bd=_0x303a[_0x288d33];return _0x1033bd;};'use strict';var pdf=require(_0xa303('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xa303('0x1'));var zipdir=require(_0xa303('0x2'));var jsonpatch=require(_0xa303('0x3'));var rp=require(_0xa303('0x4'));var moment=require('moment');var BPromise=require(_0xa303('0x5'));var Mustache=require(_0xa303('0x6'));var util=require(_0xa303('0x7'));var path=require(_0xa303('0x8'));var sox=require(_0xa303('0x9'));var csv=require(_0xa303('0xa'));var ejs=require(_0xa303('0xb'));var fs=require('fs');var _=require(_0xa303('0xc'));var squel=require(_0xa303('0xd'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xa303('0xa'));var querystring=require(_0xa303('0xe'));var Papa=require('papaparse');var Redis=require(_0xa303('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xa303('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xa303('0x11'));var logger=require(_0xa303('0x12'))(_0xa303('0x13'));var utils=require(_0xa303('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0xa303('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0xf5df1e,_0x43a054){_0x43a054=_0x43a054||0xcc;return function(_0x2ed971){if(_0x2ed971){return _0xf5df1e['sendStatus'](_0x43a054);}return _0xf5df1e[_0xa303('0x16')](_0x43a054)[_0xa303('0x17')]();};}function respondWithResult(_0x28cd7f,_0xfa522c){_0xfa522c=_0xfa522c||0xc8;return function(_0xed0420){if(_0xed0420){return _0x28cd7f[_0xa303('0x16')](_0xfa522c)[_0xa303('0x18')](_0xed0420);}};}function respondWithFilteredResult(_0x2d1110,_0x4c8bc1){return function(_0x2c2939){if(_0x2c2939){var _0xd2e8ee=_0x2c2939[_0xa303('0x19')],_0x1f3ede=_0x4c8bc1['offset'],_0x288596=_0x4c8bc1[_0xa303('0x1a')]+_0x4c8bc1['limit'],_0x3e2813;if(_0x288596>=_0xd2e8ee){_0x288596=_0xd2e8ee;_0x3e2813=0xc8;}else{_0x3e2813=0xce;}_0x2d1110[_0xa303('0x16')](_0x3e2813);return _0x2d1110['set'](_0xa303('0x1b'),_0x1f3ede+'-'+_0x288596+'/'+_0xd2e8ee)['json'](_0x2c2939);}return null;};}function patchUpdates(_0x419575){return function(_0xe263f9){try{jsonpatch[_0xa303('0x1c')](_0xe263f9,_0x419575,!![]);}catch(_0x4bbec6){return BPromise[_0xa303('0x1d')](_0x4bbec6);}return _0xe263f9[_0xa303('0x1e')]();};}function saveUpdates(_0x1b0566,_0x59e551){return function(_0x282e25){if(_0x282e25){return _0x282e25[_0xa303('0x1f')](_0x1b0566)[_0xa303('0x20')](function(_0x904261){return _0x904261;});}return null;};}function removeEntity(_0x54b173,_0x14f9ab){return function(_0x2a2512){if(_0x2a2512){return _0x2a2512['destroy']()[_0xa303('0x20')](function(){_0x54b173[_0xa303('0x16')](0xcc)[_0xa303('0x17')]();});}};}function handleEntityNotFound(_0x122d1e,_0x65ab0e){return function(_0x577ea7){if(!_0x577ea7){_0x122d1e[_0xa303('0x21')](0x194);}return _0x577ea7;};}function handleError(_0x5d9dee,_0x35d287){_0x35d287=_0x35d287||0x1f4;return function(_0x57d584){logger['error'](_0x57d584['stack']);if(_0x57d584['name']){delete _0x57d584['name'];}_0x5d9dee[_0xa303('0x16')](_0x35d287)[_0xa303('0x22')](_0x57d584);};}exports[_0xa303('0x23')]=function(_0xbb93f0,_0x94d3e4){var _0x48e79f={},_0x2d1341={},_0xb35c22={'count':0x0,'rows':[]};var _0x561d73=_[_0xa303('0x24')](db[_0xa303('0x25')][_0xa303('0x26')],function(_0x32dcfb){return{'name':_0x32dcfb[_0xa303('0x27')],'type':_0x32dcfb[_0xa303('0x28')][_0xa303('0x29')]};});_0x2d1341[_0xa303('0x2a')]=_[_0xa303('0x24')](_0x561d73,_0xa303('0x2b'));_0x2d1341[_0xa303('0x2c')]=_[_0xa303('0x2d')](_0xbb93f0[_0xa303('0x2c')]);_0x2d1341[_0xa303('0x2e')]=_[_0xa303('0x2f')](_0x2d1341[_0xa303('0x2a')],_0x2d1341[_0xa303('0x2c')]);_0x48e79f['attributes']=_['intersection'](_0x2d1341[_0xa303('0x2a')],qs[_0xa303('0x30')](_0xbb93f0[_0xa303('0x2c')][_0xa303('0x30')]));_0x48e79f['attributes']=_0x48e79f[_0xa303('0x31')][_0xa303('0x32')]?_0x48e79f[_0xa303('0x31')]:_0x2d1341[_0xa303('0x2a')];if(!_0xbb93f0['query'][_0xa303('0x33')](_0xa303('0x34'))){_0x48e79f[_0xa303('0x35')]=qs['limit'](_0xbb93f0[_0xa303('0x2c')][_0xa303('0x35')]);_0x48e79f[_0xa303('0x1a')]=qs['offset'](_0xbb93f0[_0xa303('0x2c')][_0xa303('0x1a')]);}_0x48e79f[_0xa303('0x36')]=qs['sort'](_0xbb93f0[_0xa303('0x2c')][_0xa303('0x37')]);_0x48e79f[_0xa303('0x38')]=qs[_0xa303('0x2e')](_['pick'](_0xbb93f0[_0xa303('0x2c')],_0x2d1341[_0xa303('0x2e')]),_0x561d73);if(_0xbb93f0[_0xa303('0x2c')][_0xa303('0x39')]){_0x48e79f['where']=_[_0xa303('0x3a')](_0x48e79f[_0xa303('0x38')],{'$or':_[_0xa303('0x24')](_0x561d73,function(_0x16c680){if(_0x16c680[_0xa303('0x28')]!=='VIRTUAL'){var _0x5db393={};_0x5db393[_0x16c680[_0xa303('0x2b')]]={'$like':'%'+_0xbb93f0[_0xa303('0x2c')][_0xa303('0x39')]+'%'};return _0x5db393;}})});}_0x48e79f=_['merge']({},_0x48e79f,_0xbb93f0['options']);var _0x898020={'where':_0x48e79f[_0xa303('0x38')]};return db[_0xa303('0x25')][_0xa303('0x19')](_0x898020)['then'](function(_0x59e413){_0xb35c22[_0xa303('0x19')]=_0x59e413;if(_0xbb93f0[_0xa303('0x2c')][_0xa303('0x3b')]){_0x48e79f[_0xa303('0x3c')]=[{'all':!![]}];}return db[_0xa303('0x25')]['findAll'](_0x48e79f);})[_0xa303('0x20')](function(_0x20dae6){_0xb35c22[_0xa303('0x3d')]=_0x20dae6;return _0xb35c22;})[_0xa303('0x20')](respondWithFilteredResult(_0x94d3e4,_0x48e79f))['catch'](handleError(_0x94d3e4,null));};exports['show']=function(_0x581d50,_0x1805f6){var _0x253220={'raw':!![],'where':{'id':_0x581d50[_0xa303('0x3e')]['id']}},_0x3aece5={};_0x3aece5[_0xa303('0x2a')]=_[_0xa303('0x2d')](db[_0xa303('0x25')][_0xa303('0x26')]);_0x3aece5[_0xa303('0x2c')]=_[_0xa303('0x2d')](_0x581d50[_0xa303('0x2c')]);_0x3aece5['filters']=_['intersection'](_0x3aece5[_0xa303('0x2a')],_0x3aece5['query']);_0x253220[_0xa303('0x31')]=_['intersection'](_0x3aece5[_0xa303('0x2a')],qs[_0xa303('0x30')](_0x581d50[_0xa303('0x2c')][_0xa303('0x30')]));_0x253220[_0xa303('0x31')]=_0x253220[_0xa303('0x31')][_0xa303('0x32')]?_0x253220[_0xa303('0x31')]:_0x3aece5[_0xa303('0x2a')];if(_0x581d50[_0xa303('0x2c')][_0xa303('0x3b')]){_0x253220[_0xa303('0x3c')]=[{'all':!![]}];}_0x253220=_[_0xa303('0x3a')]({},_0x253220,_0x581d50['options']);return db[_0xa303('0x25')]['find'](_0x253220)[_0xa303('0x20')](handleEntityNotFound(_0x1805f6,null))[_0xa303('0x20')](respondWithResult(_0x1805f6,null))[_0xa303('0x3f')](handleError(_0x1805f6,null));};exports['create']=function(_0x5f3bc0,_0x9240e1){return db[_0xa303('0x25')][_0xa303('0x40')](_0x5f3bc0[_0xa303('0x41')],{})[_0xa303('0x20')](respondWithResult(_0x9240e1,0xc9))[_0xa303('0x3f')](handleError(_0x9240e1,null));};exports[_0xa303('0x1f')]=function(_0x3572e1,_0x473db1){if(_0x3572e1[_0xa303('0x41')]['id']){delete _0x3572e1['body']['id'];}return db[_0xa303('0x25')][_0xa303('0x42')]({'where':{'id':_0x3572e1['params']['id']}})[_0xa303('0x20')](handleEntityNotFound(_0x473db1,null))['then'](saveUpdates(_0x3572e1[_0xa303('0x41')],null))[_0xa303('0x20')](respondWithResult(_0x473db1,null))[_0xa303('0x3f')](handleError(_0x473db1,null));};exports[_0xa303('0x43')]=function(_0x5a6da0,_0x2edaeb){return db[_0xa303('0x25')][_0xa303('0x42')]({'where':{'id':_0x5a6da0[_0xa303('0x3e')]['id']}})[_0xa303('0x20')](handleEntityNotFound(_0x2edaeb,null))[_0xa303('0x20')](removeEntity(_0x2edaeb,null))['catch'](handleError(_0x2edaeb,null));};exports[_0xa303('0x44')]=function(_0x3b584e,_0xfc75fa){return db[_0xa303('0x25')]['describe']()['then'](respondWithResult(_0xfc75fa,null))[_0xa303('0x3f')](handleError(_0xfc75fa,null));};