Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / api / voiceDialReport / voiceDialReport.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 _0x3817=['../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','offset','undefined','limit','count','set','Content-Range','save','update','then','destroy','error','stack','name','send','map','rawAttributes','fieldName','type','key','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','findAll','rows','catch','show','params','keys','VoiceDialReport','includeAll','include','find','create','body','describe','rimraf','zip-dir','fast-json-patch','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger'];(function(_0x254ff5,_0x336dfc){var _0x382224=function(_0x5b20a0){while(--_0x5b20a0){_0x254ff5['push'](_0x254ff5['shift']());}};_0x382224(++_0x336dfc);}(_0x3817,0x163));var _0x7381=function(_0x1c619e,_0x5823a2){_0x1c619e=_0x1c619e-0x0;var _0x36f09b=_0x3817[_0x1c619e];return _0x36f09b;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x7381('0x0'));var zipdir=require(_0x7381('0x1'));var jsonpatch=require(_0x7381('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x7381('0x3'));var Mustache=require('mustache');var util=require(_0x7381('0x4'));var path=require(_0x7381('0x5'));var sox=require(_0x7381('0x6'));var csv=require(_0x7381('0x7'));var ejs=require(_0x7381('0x8'));var fs=require('fs');var fs_extra=require(_0x7381('0x9'));var _=require(_0x7381('0xa'));var squel=require(_0x7381('0xb'));var crypto=require(_0x7381('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x7381('0xd'));var toCsv=require(_0x7381('0x7'));var querystring=require(_0x7381('0xe'));var Papa=require(_0x7381('0xf'));var Redis=require(_0x7381('0x10'));var authService=require(_0x7381('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x7381('0x12'));var logger=require(_0x7381('0x13'))('api');var utils=require(_0x7381('0x14'));var config=require(_0x7381('0x15'));var licenseUtil=require(_0x7381('0x16'));var db=require(_0x7381('0x17'))['db'];function respondWithStatusCode(_0x55ebb9,_0x2af0b7){_0x2af0b7=_0x2af0b7||0xcc;return function(_0x4cbdbd){if(_0x4cbdbd){return _0x55ebb9[_0x7381('0x18')](_0x2af0b7);}return _0x55ebb9['status'](_0x2af0b7)[_0x7381('0x19')]();};}function respondWithResult(_0x4e4224,_0x3e4824){_0x3e4824=_0x3e4824||0xc8;return function(_0x2b0eb1){if(_0x2b0eb1){return _0x4e4224[_0x7381('0x1a')](_0x3e4824)['json'](_0x2b0eb1);}};}function respondWithFilteredResult(_0x38a970,_0x12640){return function(_0x51a2b6){if(_0x51a2b6){var _0x34122f=typeof _0x12640[_0x7381('0x1b')]===_0x7381('0x1c')&&typeof _0x12640[_0x7381('0x1d')]==='undefined';var _0x58a4a2=_0x51a2b6[_0x7381('0x1e')];var _0x4e3c5d=_0x34122f?0x0:_0x12640['offset'];var _0x13a959=_0x34122f?_0x51a2b6[_0x7381('0x1e')]:_0x12640['offset']+_0x12640[_0x7381('0x1d')];var _0xa45a34;if(_0x13a959>=_0x58a4a2){_0x13a959=_0x58a4a2;_0xa45a34=0xc8;}else{_0xa45a34=0xce;}_0x38a970[_0x7381('0x1a')](_0xa45a34);return _0x38a970[_0x7381('0x1f')](_0x7381('0x20'),_0x4e3c5d+'-'+_0x13a959+'/'+_0x58a4a2)['json'](_0x51a2b6);}return null;};}function patchUpdates(_0xab3d5d){return function(_0x2cc0e4){try{jsonpatch['apply'](_0x2cc0e4,_0xab3d5d,!![]);}catch(_0x4fed72){return BPromise['reject'](_0x4fed72);}return _0x2cc0e4[_0x7381('0x21')]();};}function saveUpdates(_0x10ad4b,_0x3bc9b9){return function(_0x2aa096){if(_0x2aa096){return _0x2aa096[_0x7381('0x22')](_0x10ad4b)[_0x7381('0x23')](function(_0x521aaa){return _0x521aaa;});}return null;};}function removeEntity(_0x27b546,_0x44add5){return function(_0xa689d4){if(_0xa689d4){return _0xa689d4[_0x7381('0x24')]()[_0x7381('0x23')](function(){_0x27b546['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x127671,_0xdb701f){return function(_0x28b98c){if(!_0x28b98c){_0x127671[_0x7381('0x18')](0x194);}return _0x28b98c;};}function handleError(_0x1ec642,_0x586af4){_0x586af4=_0x586af4||0x1f4;return function(_0x7bdfd4){logger[_0x7381('0x25')](_0x7bdfd4[_0x7381('0x26')]);if(_0x7bdfd4[_0x7381('0x27')]){delete _0x7bdfd4[_0x7381('0x27')];}_0x1ec642[_0x7381('0x1a')](_0x586af4)[_0x7381('0x28')](_0x7bdfd4);};}exports['index']=function(_0x45dc0e,_0x340cce){var _0x233784={},_0x82b2a1={},_0x245289={'count':0x0,'rows':[]};var _0xb605b8=_[_0x7381('0x29')](db['VoiceDialReport'][_0x7381('0x2a')],function(_0x1332ca){return{'name':_0x1332ca[_0x7381('0x2b')],'type':_0x1332ca[_0x7381('0x2c')][_0x7381('0x2d')]};});_0x82b2a1[_0x7381('0x2e')]=_[_0x7381('0x29')](_0xb605b8,_0x7381('0x27'));_0x82b2a1[_0x7381('0x2f')]=_['keys'](_0x45dc0e[_0x7381('0x2f')]);_0x82b2a1[_0x7381('0x30')]=_[_0x7381('0x31')](_0x82b2a1[_0x7381('0x2e')],_0x82b2a1[_0x7381('0x2f')]);_0x233784['attributes']=_[_0x7381('0x31')](_0x82b2a1[_0x7381('0x2e')],qs[_0x7381('0x32')](_0x45dc0e[_0x7381('0x2f')]['fields']));_0x233784[_0x7381('0x33')]=_0x233784[_0x7381('0x33')][_0x7381('0x34')]?_0x233784[_0x7381('0x33')]:_0x82b2a1['model'];if(!_0x45dc0e[_0x7381('0x2f')][_0x7381('0x35')](_0x7381('0x36'))){_0x233784[_0x7381('0x1d')]=qs['limit'](_0x45dc0e[_0x7381('0x2f')][_0x7381('0x1d')]);_0x233784[_0x7381('0x1b')]=qs[_0x7381('0x1b')](_0x45dc0e[_0x7381('0x2f')][_0x7381('0x1b')]);}_0x233784[_0x7381('0x37')]=qs[_0x7381('0x38')](_0x45dc0e[_0x7381('0x2f')][_0x7381('0x38')]);_0x233784[_0x7381('0x39')]=qs[_0x7381('0x30')](_['pick'](_0x45dc0e[_0x7381('0x2f')],_0x82b2a1[_0x7381('0x30')]),_0xb605b8);if(_0x45dc0e['query'][_0x7381('0x3a')]){_0x233784[_0x7381('0x39')]=_[_0x7381('0x3b')](_0x233784[_0x7381('0x39')],{'$or':_[_0x7381('0x29')](_0xb605b8,function(_0x3a56b4){if(_0x3a56b4[_0x7381('0x2c')]!==_0x7381('0x3c')){var _0x50419d={};_0x50419d[_0x3a56b4[_0x7381('0x27')]]={'$like':'%'+_0x45dc0e[_0x7381('0x2f')][_0x7381('0x3a')]+'%'};return _0x50419d;}})});}_0x233784=_[_0x7381('0x3b')]({},_0x233784,_0x45dc0e[_0x7381('0x3d')]);var _0x497002={'where':_0x233784[_0x7381('0x39')]};return db['VoiceDialReport'][_0x7381('0x1e')](_0x497002)['then'](function(_0x121af1){_0x245289[_0x7381('0x1e')]=_0x121af1;if(_0x45dc0e[_0x7381('0x2f')]['includeAll']){_0x233784['include']=[{'all':!![]}];}return db['VoiceDialReport'][_0x7381('0x3e')](_0x233784);})[_0x7381('0x23')](function(_0x5b2092){_0x245289[_0x7381('0x3f')]=_0x5b2092;return _0x245289;})[_0x7381('0x23')](respondWithFilteredResult(_0x340cce,_0x233784))[_0x7381('0x40')](handleError(_0x340cce,null));};exports[_0x7381('0x41')]=function(_0x16baf5,_0x556701){var _0x198955={'raw':!![],'where':{'id':_0x16baf5[_0x7381('0x42')]['id']}},_0xf42656={};_0xf42656[_0x7381('0x2e')]=_[_0x7381('0x43')](db[_0x7381('0x44')][_0x7381('0x2a')]);_0xf42656[_0x7381('0x2f')]=_['keys'](_0x16baf5[_0x7381('0x2f')]);_0xf42656[_0x7381('0x30')]=_['intersection'](_0xf42656[_0x7381('0x2e')],_0xf42656[_0x7381('0x2f')]);_0x198955[_0x7381('0x33')]=_[_0x7381('0x31')](_0xf42656[_0x7381('0x2e')],qs[_0x7381('0x32')](_0x16baf5[_0x7381('0x2f')][_0x7381('0x32')]));_0x198955[_0x7381('0x33')]=_0x198955['attributes'][_0x7381('0x34')]?_0x198955[_0x7381('0x33')]:_0xf42656['model'];if(_0x16baf5[_0x7381('0x2f')][_0x7381('0x45')]){_0x198955[_0x7381('0x46')]=[{'all':!![]}];}_0x198955=_[_0x7381('0x3b')]({},_0x198955,_0x16baf5[_0x7381('0x3d')]);return db[_0x7381('0x44')][_0x7381('0x47')](_0x198955)[_0x7381('0x23')](handleEntityNotFound(_0x556701,null))[_0x7381('0x23')](respondWithResult(_0x556701,null))[_0x7381('0x40')](handleError(_0x556701,null));};exports[_0x7381('0x48')]=function(_0x21ba71,_0xc210cf){return db[_0x7381('0x44')][_0x7381('0x48')](_0x21ba71['body'],{})[_0x7381('0x23')](respondWithResult(_0xc210cf,0xc9))[_0x7381('0x40')](handleError(_0xc210cf,null));};exports[_0x7381('0x22')]=function(_0x4a1d41,_0x54b947){if(_0x4a1d41[_0x7381('0x49')]['id']){delete _0x4a1d41[_0x7381('0x49')]['id'];}return db[_0x7381('0x44')][_0x7381('0x47')]({'where':{'id':_0x4a1d41[_0x7381('0x42')]['id']}})[_0x7381('0x23')](handleEntityNotFound(_0x54b947,null))['then'](saveUpdates(_0x4a1d41[_0x7381('0x49')],null))['then'](respondWithResult(_0x54b947,null))[_0x7381('0x40')](handleError(_0x54b947,null));};exports[_0x7381('0x24')]=function(_0x3f3401,_0x2e2c56){return db[_0x7381('0x44')][_0x7381('0x47')]({'where':{'id':_0x3f3401[_0x7381('0x42')]['id']}})[_0x7381('0x23')](handleEntityNotFound(_0x2e2c56,null))[_0x7381('0x23')](removeEntity(_0x2e2c56,null))[_0x7381('0x40')](handleError(_0x2e2c56,null));};exports[_0x7381('0x4a')]=function(_0x24897d,_0x5630e0){return db[_0x7381('0x44')][_0x7381('0x4a')]()[_0x7381('0x23')](respondWithResult(_0x5630e0,null))[_0x7381('0x40')](handleError(_0x5630e0,null));};