Built motion from commit (unavailable).|2.6.0
[motion2.git] / server / api / voiceAgentReport / voiceAgentReport.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 _0x53bb=['../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','sendStatus','status','end','json','undefined','limit','offset','set','Content-Range','save','update','then','destroy','error','name','send','index','map','rawAttributes','fieldName','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','merge','type','VIRTUAL','options','VoiceAgentReport','count','include','findAll','rows','catch','show','includeAll','find','create','body','params','describe','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service'];(function(_0x26b80e,_0x5c9333){var _0x84a8a8=function(_0x2e5b4a){while(--_0x2e5b4a){_0x26b80e['push'](_0x26b80e['shift']());}};_0x84a8a8(++_0x5c9333);}(_0x53bb,0x168));var _0xb53b=function(_0x1c1bcc,_0x171103){_0x1c1bcc=_0x1c1bcc-0x0;var _0x43f9c5=_0x53bb[_0x1c1bcc];return _0x43f9c5;};'use strict';var emlformat=require(_0xb53b('0x0'));var rimraf=require(_0xb53b('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb53b('0x2'));var rp=require(_0xb53b('0x3'));var moment=require(_0xb53b('0x4'));var BPromise=require(_0xb53b('0x5'));var Mustache=require(_0xb53b('0x6'));var util=require('util');var path=require('path');var sox=require(_0xb53b('0x7'));var csv=require(_0xb53b('0x8'));var ejs=require(_0xb53b('0x9'));var fs=require('fs');var fs_extra=require(_0xb53b('0xa'));var _=require(_0xb53b('0xb'));var squel=require(_0xb53b('0xc'));var crypto=require(_0xb53b('0xd'));var jsforce=require(_0xb53b('0xe'));var deskjs=require(_0xb53b('0xf'));var toCsv=require(_0xb53b('0x8'));var querystring=require(_0xb53b('0x10'));var Papa=require(_0xb53b('0x11'));var Redis=require(_0xb53b('0x12'));var authService=require(_0xb53b('0x13'));var qs=require('../../components/parsers/qs');var as=require(_0xb53b('0x14'));var hardwareService=require(_0xb53b('0x15'));var logger=require(_0xb53b('0x16'))(_0xb53b('0x17'));var utils=require(_0xb53b('0x18'));var config=require(_0xb53b('0x19'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x37a3db,_0x29db70){_0x29db70=_0x29db70||0xcc;return function(_0xb9ce49){if(_0xb9ce49){return _0x37a3db[_0xb53b('0x1a')](_0x29db70);}return _0x37a3db[_0xb53b('0x1b')](_0x29db70)[_0xb53b('0x1c')]();};}function respondWithResult(_0x37c432,_0x1ef5e2){_0x1ef5e2=_0x1ef5e2||0xc8;return function(_0x9dd158){if(_0x9dd158){return _0x37c432[_0xb53b('0x1b')](_0x1ef5e2)[_0xb53b('0x1d')](_0x9dd158);}};}function respondWithFilteredResult(_0x5c13d6,_0x446605){return function(_0x403850){if(_0x403850){var _0xcfcb3b=typeof _0x446605['offset']===_0xb53b('0x1e')&&typeof _0x446605[_0xb53b('0x1f')]===_0xb53b('0x1e');var _0x1ec4f9=_0x403850['count'];var _0x24c7be=_0xcfcb3b?0x0:_0x446605[_0xb53b('0x20')];var _0x427d85=_0xcfcb3b?_0x403850['count']:_0x446605[_0xb53b('0x20')]+_0x446605['limit'];var _0x227de3;if(_0x427d85>=_0x1ec4f9){_0x427d85=_0x1ec4f9;_0x227de3=0xc8;}else{_0x227de3=0xce;}_0x5c13d6['status'](_0x227de3);return _0x5c13d6[_0xb53b('0x21')](_0xb53b('0x22'),_0x24c7be+'-'+_0x427d85+'/'+_0x1ec4f9)['json'](_0x403850);}return null;};}function patchUpdates(_0x1a5352){return function(_0x296aae){try{jsonpatch['apply'](_0x296aae,_0x1a5352,!![]);}catch(_0x16c04e){return BPromise['reject'](_0x16c04e);}return _0x296aae[_0xb53b('0x23')]();};}function saveUpdates(_0x5d1164,_0x57e155){return function(_0x34b5d0){if(_0x34b5d0){return _0x34b5d0[_0xb53b('0x24')](_0x5d1164)[_0xb53b('0x25')](function(_0x34384d){return _0x34384d;});}return null;};}function removeEntity(_0xb08c49,_0x54c4fe){return function(_0x4f3c67){if(_0x4f3c67){return _0x4f3c67[_0xb53b('0x26')]()[_0xb53b('0x25')](function(){_0xb08c49[_0xb53b('0x1b')](0xcc)[_0xb53b('0x1c')]();});}};}function handleEntityNotFound(_0x50801c,_0x3e12ff){return function(_0x1e0341){if(!_0x1e0341){_0x50801c[_0xb53b('0x1a')](0x194);}return _0x1e0341;};}function handleError(_0x1e26dd,_0x5b4a75){_0x5b4a75=_0x5b4a75||0x1f4;return function(_0x1d0664){logger[_0xb53b('0x27')](_0x1d0664['stack']);if(_0x1d0664[_0xb53b('0x28')]){delete _0x1d0664['name'];}_0x1e26dd[_0xb53b('0x1b')](_0x5b4a75)[_0xb53b('0x29')](_0x1d0664);};}exports[_0xb53b('0x2a')]=function(_0x244f13,_0x5b89c1){var _0x19c926={},_0x28817b={},_0x3e77bf={'count':0x0,'rows':[]};var _0xf39fb2=_[_0xb53b('0x2b')](db['VoiceAgentReport'][_0xb53b('0x2c')],function(_0x83fec6){return{'name':_0x83fec6[_0xb53b('0x2d')],'type':_0x83fec6['type']['key']};});_0x28817b[_0xb53b('0x2e')]=_[_0xb53b('0x2b')](_0xf39fb2,_0xb53b('0x28'));_0x28817b[_0xb53b('0x2f')]=_[_0xb53b('0x30')](_0x244f13[_0xb53b('0x2f')]);_0x28817b[_0xb53b('0x31')]=_[_0xb53b('0x32')](_0x28817b[_0xb53b('0x2e')],_0x28817b[_0xb53b('0x2f')]);_0x19c926[_0xb53b('0x33')]=_['intersection'](_0x28817b[_0xb53b('0x2e')],qs[_0xb53b('0x34')](_0x244f13[_0xb53b('0x2f')][_0xb53b('0x34')]));_0x19c926[_0xb53b('0x33')]=_0x19c926[_0xb53b('0x33')][_0xb53b('0x35')]?_0x19c926[_0xb53b('0x33')]:_0x28817b[_0xb53b('0x2e')];if(!_0x244f13[_0xb53b('0x2f')]['hasOwnProperty'](_0xb53b('0x36'))){_0x19c926['limit']=qs['limit'](_0x244f13[_0xb53b('0x2f')][_0xb53b('0x1f')]);_0x19c926[_0xb53b('0x20')]=qs[_0xb53b('0x20')](_0x244f13[_0xb53b('0x2f')][_0xb53b('0x20')]);}_0x19c926[_0xb53b('0x37')]=qs[_0xb53b('0x38')](_0x244f13[_0xb53b('0x2f')]['sort']);_0x19c926[_0xb53b('0x39')]=qs[_0xb53b('0x31')](_[_0xb53b('0x3a')](_0x244f13[_0xb53b('0x2f')],_0x28817b[_0xb53b('0x31')]),_0xf39fb2);if(_0x244f13[_0xb53b('0x2f')]['filter']){_0x19c926[_0xb53b('0x39')]=_[_0xb53b('0x3b')](_0x19c926[_0xb53b('0x39')],{'$or':_[_0xb53b('0x2b')](_0xf39fb2,function(_0x3943dd){if(_0x3943dd[_0xb53b('0x3c')]!==_0xb53b('0x3d')){var _0x51e0dc={};_0x51e0dc[_0x3943dd[_0xb53b('0x28')]]={'$like':'%'+_0x244f13['query']['filter']+'%'};return _0x51e0dc;}})});}_0x19c926=_[_0xb53b('0x3b')]({},_0x19c926,_0x244f13[_0xb53b('0x3e')]);var _0x42535a={'where':_0x19c926['where']};return db[_0xb53b('0x3f')][_0xb53b('0x40')](_0x42535a)['then'](function(_0x332278){_0x3e77bf[_0xb53b('0x40')]=_0x332278;if(_0x244f13[_0xb53b('0x2f')]['includeAll']){_0x19c926[_0xb53b('0x41')]=[{'all':!![]}];}return db[_0xb53b('0x3f')][_0xb53b('0x42')](_0x19c926);})[_0xb53b('0x25')](function(_0xc249a0){_0x3e77bf[_0xb53b('0x43')]=_0xc249a0;return _0x3e77bf;})[_0xb53b('0x25')](respondWithFilteredResult(_0x5b89c1,_0x19c926))[_0xb53b('0x44')](handleError(_0x5b89c1,null));};exports[_0xb53b('0x45')]=function(_0x28e94a,_0x18782e){var _0xefe97d={'raw':![],'where':{'id':_0x28e94a['params']['id']}},_0x421147={};_0x421147[_0xb53b('0x2e')]=_[_0xb53b('0x30')](db['VoiceAgentReport']['rawAttributes']);_0x421147['query']=_['keys'](_0x28e94a[_0xb53b('0x2f')]);_0x421147[_0xb53b('0x31')]=_['intersection'](_0x421147[_0xb53b('0x2e')],_0x421147['query']);_0xefe97d[_0xb53b('0x33')]=_['intersection'](_0x421147[_0xb53b('0x2e')],qs[_0xb53b('0x34')](_0x28e94a[_0xb53b('0x2f')][_0xb53b('0x34')]));_0xefe97d['attributes']=_0xefe97d[_0xb53b('0x33')][_0xb53b('0x35')]?_0xefe97d[_0xb53b('0x33')]:_0x421147['model'];if(_0x28e94a['query'][_0xb53b('0x46')]){_0xefe97d['include']=[{'all':!![]}];}_0xefe97d=_[_0xb53b('0x3b')]({},_0xefe97d,_0x28e94a[_0xb53b('0x3e')]);return db[_0xb53b('0x3f')][_0xb53b('0x47')](_0xefe97d)[_0xb53b('0x25')](handleEntityNotFound(_0x18782e,null))[_0xb53b('0x25')](respondWithResult(_0x18782e,null))[_0xb53b('0x44')](handleError(_0x18782e,null));};exports[_0xb53b('0x48')]=function(_0x449621,_0x4b615){return db[_0xb53b('0x3f')][_0xb53b('0x48')](_0x449621['body'],{})[_0xb53b('0x25')](respondWithResult(_0x4b615,0xc9))[_0xb53b('0x44')](handleError(_0x4b615,null));};exports[_0xb53b('0x24')]=function(_0x5f3b63,_0x503a12){if(_0x5f3b63[_0xb53b('0x49')]['id']){delete _0x5f3b63[_0xb53b('0x49')]['id'];}return db[_0xb53b('0x3f')][_0xb53b('0x47')]({'where':{'id':_0x5f3b63[_0xb53b('0x4a')]['id']}})[_0xb53b('0x25')](handleEntityNotFound(_0x503a12,null))[_0xb53b('0x25')](saveUpdates(_0x5f3b63['body'],null))[_0xb53b('0x25')](respondWithResult(_0x503a12,null))[_0xb53b('0x44')](handleError(_0x503a12,null));};exports[_0xb53b('0x26')]=function(_0x34384a,_0x29963a){return db[_0xb53b('0x3f')][_0xb53b('0x47')]({'where':{'id':_0x34384a['params']['id']}})[_0xb53b('0x25')](handleEntityNotFound(_0x29963a,null))[_0xb53b('0x25')](removeEntity(_0x29963a,null))[_0xb53b('0x44')](handleError(_0x29963a,null));};exports[_0xb53b('0x4b')]=function(_0xe7b410,_0x42a5d5){return db[_0xb53b('0x3f')][_0xb53b('0x4b')]()[_0xb53b('0x25')](respondWithResult(_0x42a5d5,null))[_0xb53b('0x44')](handleError(_0x42a5d5,null));};