Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / voiceTransferReport / voiceTransferReport.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 _0x2340=['catch','show','rawAttributes','body','find','params','describe','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','lodash','squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','json','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','VoiceTransferReport','fieldName','type','key','model','keys','filters','query','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','VIRTUAL','filter','merge','options','includeAll','include','findAll','rows'];(function(_0x485342,_0xe19f6f){var _0x54e30c=function(_0x5048a7){while(--_0x5048a7){_0x485342['push'](_0x485342['shift']());}};_0x54e30c(++_0xe19f6f);}(_0x2340,0x157));var _0x0234=function(_0x529aff,_0x7b99af){_0x529aff=_0x529aff-0x0;var _0x1a1e64=_0x2340[_0x529aff];return _0x1a1e64;};'use strict';var emlformat=require(_0x0234('0x0'));var rimraf=require(_0x0234('0x1'));var zipdir=require(_0x0234('0x2'));var jsonpatch=require(_0x0234('0x3'));var rp=require(_0x0234('0x4'));var moment=require(_0x0234('0x5'));var BPromise=require(_0x0234('0x6'));var Mustache=require(_0x0234('0x7'));var util=require(_0x0234('0x8'));var path=require(_0x0234('0x9'));var sox=require(_0x0234('0xa'));var csv=require('to-csv');var ejs=require(_0x0234('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x0234('0xc'));var squel=require(_0x0234('0xd'));var crypto=require('crypto');var jsforce=require(_0x0234('0xe'));var deskjs=require(_0x0234('0xf'));var toCsv=require(_0x0234('0x10'));var querystring=require(_0x0234('0x11'));var Papa=require(_0x0234('0x12'));var Redis=require(_0x0234('0x13'));var authService=require(_0x0234('0x14'));var qs=require(_0x0234('0x15'));var as=require(_0x0234('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x0234('0x17'))(_0x0234('0x18'));var utils=require(_0x0234('0x19'));var config=require(_0x0234('0x1a'));var licenseUtil=require(_0x0234('0x1b'));var db=require(_0x0234('0x1c'))['db'];function respondWithStatusCode(_0x472a1d,_0x724e5){_0x724e5=_0x724e5||0xcc;return function(_0x2757ff){if(_0x2757ff){return _0x472a1d[_0x0234('0x1d')](_0x724e5);}return _0x472a1d[_0x0234('0x1e')](_0x724e5)[_0x0234('0x1f')]();};}function respondWithResult(_0x543451,_0x1d5e34){_0x1d5e34=_0x1d5e34||0xc8;return function(_0x4e07aa){if(_0x4e07aa){return _0x543451[_0x0234('0x1e')](_0x1d5e34)['json'](_0x4e07aa);}};}function respondWithFilteredResult(_0xb65369,_0x5ba3cf){return function(_0x2c9933){if(_0x2c9933){var _0x234914=typeof _0x5ba3cf[_0x0234('0x20')]===_0x0234('0x21')&&typeof _0x5ba3cf[_0x0234('0x22')]===_0x0234('0x21');var _0x4477b6=_0x2c9933[_0x0234('0x23')];var _0x502faa=_0x234914?0x0:_0x5ba3cf[_0x0234('0x20')];var _0x7b944d=_0x234914?_0x2c9933[_0x0234('0x23')]:_0x5ba3cf['offset']+_0x5ba3cf[_0x0234('0x22')];var _0x28ec08;if(_0x7b944d>=_0x4477b6){_0x7b944d=_0x4477b6;_0x28ec08=0xc8;}else{_0x28ec08=0xce;}_0xb65369[_0x0234('0x1e')](_0x28ec08);return _0xb65369[_0x0234('0x24')](_0x0234('0x25'),_0x502faa+'-'+_0x7b944d+'/'+_0x4477b6)[_0x0234('0x26')](_0x2c9933);}return null;};}function patchUpdates(_0x1d9273){return function(_0x5ea19a){try{jsonpatch[_0x0234('0x27')](_0x5ea19a,_0x1d9273,!![]);}catch(_0x49359b){return BPromise[_0x0234('0x28')](_0x49359b);}return _0x5ea19a[_0x0234('0x29')]();};}function saveUpdates(_0x2216b2,_0xf04751){return function(_0x28ae3b){if(_0x28ae3b){return _0x28ae3b[_0x0234('0x2a')](_0x2216b2)[_0x0234('0x2b')](function(_0x1c0bbb){return _0x1c0bbb;});}return null;};}function removeEntity(_0x2bf55b,_0x50f829){return function(_0x3a3b78){if(_0x3a3b78){return _0x3a3b78[_0x0234('0x2c')]()['then'](function(){_0x2bf55b[_0x0234('0x1e')](0xcc)[_0x0234('0x1f')]();});}};}function handleEntityNotFound(_0x59fe79,_0x30d7de){return function(_0x48d5e0){if(!_0x48d5e0){_0x59fe79[_0x0234('0x1d')](0x194);}return _0x48d5e0;};}function handleError(_0x222dbd,_0x8e1362){_0x8e1362=_0x8e1362||0x1f4;return function(_0x5e46fa){logger[_0x0234('0x2d')](_0x5e46fa[_0x0234('0x2e')]);if(_0x5e46fa[_0x0234('0x2f')]){delete _0x5e46fa[_0x0234('0x2f')];}_0x222dbd[_0x0234('0x1e')](_0x8e1362)[_0x0234('0x30')](_0x5e46fa);};}exports[_0x0234('0x31')]=function(_0xf1371a,_0x415bf6){var _0x535e5d={},_0x1d7cdd={},_0x3130c0={'count':0x0,'rows':[]};var _0x2c7b3b=_[_0x0234('0x32')](db[_0x0234('0x33')]['rawAttributes'],function(_0x5568ef){return{'name':_0x5568ef[_0x0234('0x34')],'type':_0x5568ef[_0x0234('0x35')][_0x0234('0x36')]};});_0x1d7cdd[_0x0234('0x37')]=_[_0x0234('0x32')](_0x2c7b3b,_0x0234('0x2f'));_0x1d7cdd['query']=_[_0x0234('0x38')](_0xf1371a['query']);_0x1d7cdd[_0x0234('0x39')]=_['intersection'](_0x1d7cdd['model'],_0x1d7cdd[_0x0234('0x3a')]);_0x535e5d[_0x0234('0x3b')]=_[_0x0234('0x3c')](_0x1d7cdd['model'],qs[_0x0234('0x3d')](_0xf1371a[_0x0234('0x3a')]['fields']));_0x535e5d[_0x0234('0x3b')]=_0x535e5d['attributes'][_0x0234('0x3e')]?_0x535e5d[_0x0234('0x3b')]:_0x1d7cdd[_0x0234('0x37')];if(!_0xf1371a[_0x0234('0x3a')][_0x0234('0x3f')](_0x0234('0x40'))){_0x535e5d[_0x0234('0x22')]=qs[_0x0234('0x22')](_0xf1371a[_0x0234('0x3a')][_0x0234('0x22')]);_0x535e5d[_0x0234('0x20')]=qs['offset'](_0xf1371a[_0x0234('0x3a')][_0x0234('0x20')]);}_0x535e5d[_0x0234('0x41')]=qs[_0x0234('0x42')](_0xf1371a[_0x0234('0x3a')][_0x0234('0x42')]);_0x535e5d[_0x0234('0x43')]=qs[_0x0234('0x39')](_[_0x0234('0x44')](_0xf1371a[_0x0234('0x3a')],_0x1d7cdd[_0x0234('0x39')]),_0x2c7b3b);if(_0xf1371a['query']['filter']){_0x535e5d['where']=_['merge'](_0x535e5d[_0x0234('0x43')],{'$or':_[_0x0234('0x32')](_0x2c7b3b,function(_0x5c3e51){if(_0x5c3e51[_0x0234('0x35')]!==_0x0234('0x45')){var _0x2eecbc={};_0x2eecbc[_0x5c3e51[_0x0234('0x2f')]]={'$like':'%'+_0xf1371a[_0x0234('0x3a')][_0x0234('0x46')]+'%'};return _0x2eecbc;}})});}_0x535e5d=_[_0x0234('0x47')]({},_0x535e5d,_0xf1371a[_0x0234('0x48')]);var _0x3d45ce={'where':_0x535e5d[_0x0234('0x43')]};return db[_0x0234('0x33')][_0x0234('0x23')](_0x3d45ce)[_0x0234('0x2b')](function(_0x3432cb){_0x3130c0[_0x0234('0x23')]=_0x3432cb;if(_0xf1371a['query'][_0x0234('0x49')]){_0x535e5d[_0x0234('0x4a')]=[{'all':!![]}];}return db[_0x0234('0x33')][_0x0234('0x4b')](_0x535e5d);})[_0x0234('0x2b')](function(_0xfb5854){_0x3130c0[_0x0234('0x4c')]=_0xfb5854;return _0x3130c0;})['then'](respondWithFilteredResult(_0x415bf6,_0x535e5d))[_0x0234('0x4d')](handleError(_0x415bf6,null));};exports[_0x0234('0x4e')]=function(_0x7b92c8,_0x35774b){var _0x32452b={'raw':!![],'where':{'id':_0x7b92c8['params']['id']}},_0x3edceb={};_0x3edceb[_0x0234('0x37')]=_['keys'](db[_0x0234('0x33')][_0x0234('0x4f')]);_0x3edceb[_0x0234('0x3a')]=_['keys'](_0x7b92c8[_0x0234('0x3a')]);_0x3edceb[_0x0234('0x39')]=_[_0x0234('0x3c')](_0x3edceb[_0x0234('0x37')],_0x3edceb[_0x0234('0x3a')]);_0x32452b[_0x0234('0x3b')]=_[_0x0234('0x3c')](_0x3edceb[_0x0234('0x37')],qs[_0x0234('0x3d')](_0x7b92c8[_0x0234('0x3a')][_0x0234('0x3d')]));_0x32452b[_0x0234('0x3b')]=_0x32452b[_0x0234('0x3b')][_0x0234('0x3e')]?_0x32452b['attributes']:_0x3edceb[_0x0234('0x37')];if(_0x7b92c8[_0x0234('0x3a')][_0x0234('0x49')]){_0x32452b['include']=[{'all':!![]}];}_0x32452b=_[_0x0234('0x47')]({},_0x32452b,_0x7b92c8[_0x0234('0x48')]);return db[_0x0234('0x33')]['find'](_0x32452b)[_0x0234('0x2b')](handleEntityNotFound(_0x35774b,null))[_0x0234('0x2b')](respondWithResult(_0x35774b,null))[_0x0234('0x4d')](handleError(_0x35774b,null));};exports['create']=function(_0x3900d8,_0x2e6848){return db[_0x0234('0x33')]['create'](_0x3900d8[_0x0234('0x50')],{})['then'](respondWithResult(_0x2e6848,0xc9))['catch'](handleError(_0x2e6848,null));};exports['update']=function(_0x1bedd4,_0x1cb75f){if(_0x1bedd4['body']['id']){delete _0x1bedd4[_0x0234('0x50')]['id'];}return db[_0x0234('0x33')][_0x0234('0x51')]({'where':{'id':_0x1bedd4[_0x0234('0x52')]['id']}})[_0x0234('0x2b')](handleEntityNotFound(_0x1cb75f,null))[_0x0234('0x2b')](saveUpdates(_0x1bedd4[_0x0234('0x50')],null))[_0x0234('0x2b')](respondWithResult(_0x1cb75f,null))[_0x0234('0x4d')](handleError(_0x1cb75f,null));};exports['destroy']=function(_0x30e2,_0x16c835){return db[_0x0234('0x33')][_0x0234('0x51')]({'where':{'id':_0x30e2[_0x0234('0x52')]['id']}})['then'](handleEntityNotFound(_0x16c835,null))[_0x0234('0x2b')](removeEntity(_0x16c835,null))[_0x0234('0x4d')](handleError(_0x16c835,null));};exports[_0x0234('0x53')]=function(_0x4dd92f,_0x1b0636){return db[_0x0234('0x33')][_0x0234('0x53')]()[_0x0234('0x2b')](respondWithResult(_0x1b0636,null))[_0x0234('0x4d')](handleError(_0x1b0636,null));};