Built motion from commit (unavailable).|2.5.26
[motion2.git] / server / api / cmHopperHistory / cmHopperHistory.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 _0x36bb=['sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','then','destroy','error','stack','name','index','map','CmHopperHistory','rawAttributes','fieldName','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','type','includeAll','rows','catch','params','include','options','find','create','describe','update','body','uniqueid','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','util','path'];(function(_0x46c690,_0x20167f){var _0x10b408=function(_0x156f6a){while(--_0x156f6a){_0x46c690['push'](_0x46c690['shift']());}};_0x10b408(++_0x20167f);}(_0x36bb,0xdf));var _0xb36b=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x36bb[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0xb36b('0x0'));var rimraf=require(_0xb36b('0x1'));var zipdir=require(_0xb36b('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xb36b('0x3'));var moment=require(_0xb36b('0x4'));var BPromise=require(_0xb36b('0x5'));var Mustache=require('mustache');var util=require(_0xb36b('0x6'));var path=require(_0xb36b('0x7'));var sox=require(_0xb36b('0x8'));var csv=require(_0xb36b('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xb36b('0xa'));var _=require(_0xb36b('0xb'));var squel=require(_0xb36b('0xc'));var crypto=require(_0xb36b('0xd'));var jsforce=require(_0xb36b('0xe'));var deskjs=require(_0xb36b('0xf'));var toCsv=require(_0xb36b('0x9'));var querystring=require(_0xb36b('0x10'));var Papa=require(_0xb36b('0x11'));var Redis=require('ioredis');var authService=require(_0xb36b('0x12'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xb36b('0x13'));var logger=require(_0xb36b('0x14'))(_0xb36b('0x15'));var utils=require(_0xb36b('0x16'));var config=require(_0xb36b('0x17'));var licenseUtil=require(_0xb36b('0x18'));var db=require(_0xb36b('0x19'))['db'];function respondWithStatusCode(_0x5b1862,_0x5de220){_0x5de220=_0x5de220||0xcc;return function(_0x35efb8){if(_0x35efb8){return _0x5b1862[_0xb36b('0x1a')](_0x5de220);}return _0x5b1862[_0xb36b('0x1b')](_0x5de220)[_0xb36b('0x1c')]();};}function respondWithResult(_0x52bbd5,_0x398365){_0x398365=_0x398365||0xc8;return function(_0x39a500){if(_0x39a500){return _0x52bbd5[_0xb36b('0x1b')](_0x398365)[_0xb36b('0x1d')](_0x39a500);}};}function respondWithFilteredResult(_0x502900,_0x10aea4){return function(_0x1d8019){if(_0x1d8019){var _0xb75a11=_0x1d8019[_0xb36b('0x1e')],_0x5b11a1=_0x10aea4[_0xb36b('0x1f')],_0x101fdb=_0x10aea4[_0xb36b('0x1f')]+_0x10aea4[_0xb36b('0x20')],_0x174960;if(_0x101fdb>=_0xb75a11){_0x101fdb=_0xb75a11;_0x174960=0xc8;}else{_0x174960=0xce;}_0x502900[_0xb36b('0x1b')](_0x174960);return _0x502900[_0xb36b('0x21')](_0xb36b('0x22'),_0x5b11a1+'-'+_0x101fdb+'/'+_0xb75a11)[_0xb36b('0x1d')](_0x1d8019);}return null;};}function patchUpdates(_0x135bf9){return function(_0x126d50){try{jsonpatch[_0xb36b('0x23')](_0x126d50,_0x135bf9,!![]);}catch(_0x1022e9){return BPromise[_0xb36b('0x24')](_0x1022e9);}return _0x126d50[_0xb36b('0x25')]();};}function saveUpdates(_0x2dcc4c,_0x3bbf76){return function(_0x4e0e5a){if(_0x4e0e5a){return _0x4e0e5a['update'](_0x2dcc4c)[_0xb36b('0x26')](function(_0x1822c0){return _0x1822c0;});}return null;};}function removeEntity(_0x2358ef,_0x437aab){return function(_0x3f41c6){if(_0x3f41c6){return _0x3f41c6[_0xb36b('0x27')]()[_0xb36b('0x26')](function(){_0x2358ef[_0xb36b('0x1b')](0xcc)[_0xb36b('0x1c')]();});}};}function handleEntityNotFound(_0x2be82f,_0x651de5){return function(_0x338ee8){if(!_0x338ee8){_0x2be82f['sendStatus'](0x194);}return _0x338ee8;};}function handleError(_0x15074c,_0x1a743d){_0x1a743d=_0x1a743d||0x1f4;return function(_0x11fc07){logger[_0xb36b('0x28')](_0x11fc07[_0xb36b('0x29')]);if(_0x11fc07[_0xb36b('0x2a')]){delete _0x11fc07['name'];}_0x15074c['status'](_0x1a743d)['send'](_0x11fc07);};}exports[_0xb36b('0x2b')]=function(_0x29a4aa,_0x4e2910){var _0x33514b={},_0xc457df={},_0x40b5b4={'count':0x0,'rows':[]};var _0x2d5467=_[_0xb36b('0x2c')](db[_0xb36b('0x2d')][_0xb36b('0x2e')],function(_0x29406c){return{'name':_0x29406c[_0xb36b('0x2f')],'type':_0x29406c['type'][_0xb36b('0x30')]};});_0xc457df[_0xb36b('0x31')]=_[_0xb36b('0x2c')](_0x2d5467,'name');_0xc457df['query']=_[_0xb36b('0x32')](_0x29a4aa[_0xb36b('0x33')]);_0xc457df[_0xb36b('0x34')]=_[_0xb36b('0x35')](_0xc457df[_0xb36b('0x31')],_0xc457df['query']);_0x33514b[_0xb36b('0x36')]=_[_0xb36b('0x35')](_0xc457df[_0xb36b('0x31')],qs['fields'](_0x29a4aa[_0xb36b('0x33')][_0xb36b('0x37')]));_0x33514b['attributes']=_0x33514b[_0xb36b('0x36')][_0xb36b('0x38')]?_0x33514b[_0xb36b('0x36')]:_0xc457df[_0xb36b('0x31')];if(!_0x29a4aa[_0xb36b('0x33')][_0xb36b('0x39')]('nolimit')){_0x33514b['limit']=qs[_0xb36b('0x20')](_0x29a4aa[_0xb36b('0x33')]['limit']);_0x33514b[_0xb36b('0x1f')]=qs[_0xb36b('0x1f')](_0x29a4aa[_0xb36b('0x33')][_0xb36b('0x1f')]);}_0x33514b[_0xb36b('0x3a')]=qs[_0xb36b('0x3b')](_0x29a4aa[_0xb36b('0x33')][_0xb36b('0x3b')]);_0x33514b[_0xb36b('0x3c')]=qs[_0xb36b('0x34')](_[_0xb36b('0x3d')](_0x29a4aa[_0xb36b('0x33')],_0xc457df[_0xb36b('0x34')]),_0x2d5467);if(_0x29a4aa['query'][_0xb36b('0x3e')]){_0x33514b[_0xb36b('0x3c')]=_[_0xb36b('0x3f')](_0x33514b[_0xb36b('0x3c')],{'$or':_[_0xb36b('0x2c')](_0x2d5467,function(_0x4b3cb9){if(_0x4b3cb9[_0xb36b('0x40')]!=='VIRTUAL'){var _0x26d76b={};_0x26d76b[_0x4b3cb9['name']]={'$like':'%'+_0x29a4aa[_0xb36b('0x33')][_0xb36b('0x3e')]+'%'};return _0x26d76b;}})});}_0x33514b=_[_0xb36b('0x3f')]({},_0x33514b,_0x29a4aa['options']);var _0x52b43c={'where':_0x33514b[_0xb36b('0x3c')]};return db[_0xb36b('0x2d')][_0xb36b('0x1e')](_0x52b43c)[_0xb36b('0x26')](function(_0x5a2b7c){_0x40b5b4['count']=_0x5a2b7c;if(_0x29a4aa['query'][_0xb36b('0x41')]){_0x33514b['include']=[{'all':!![]}];}return db[_0xb36b('0x2d')]['findAll'](_0x33514b);})[_0xb36b('0x26')](function(_0x5ec109){_0x40b5b4[_0xb36b('0x42')]=_0x5ec109;return _0x40b5b4;})[_0xb36b('0x26')](respondWithFilteredResult(_0x4e2910,_0x33514b))[_0xb36b('0x43')](handleError(_0x4e2910,null));};exports['show']=function(_0x2ad93e,_0x42678e){var _0x2b550e={'raw':!![],'where':{'id':_0x2ad93e[_0xb36b('0x44')]['id']}},_0x2ea122={};_0x2ea122[_0xb36b('0x31')]=_[_0xb36b('0x32')](db['CmHopperHistory'][_0xb36b('0x2e')]);_0x2ea122[_0xb36b('0x33')]=_[_0xb36b('0x32')](_0x2ad93e[_0xb36b('0x33')]);_0x2ea122['filters']=_[_0xb36b('0x35')](_0x2ea122[_0xb36b('0x31')],_0x2ea122[_0xb36b('0x33')]);_0x2b550e['attributes']=_[_0xb36b('0x35')](_0x2ea122['model'],qs[_0xb36b('0x37')](_0x2ad93e[_0xb36b('0x33')]['fields']));_0x2b550e[_0xb36b('0x36')]=_0x2b550e[_0xb36b('0x36')][_0xb36b('0x38')]?_0x2b550e[_0xb36b('0x36')]:_0x2ea122['model'];if(_0x2ad93e[_0xb36b('0x33')][_0xb36b('0x41')]){_0x2b550e[_0xb36b('0x45')]=[{'all':!![]}];}_0x2b550e=_[_0xb36b('0x3f')]({},_0x2b550e,_0x2ad93e[_0xb36b('0x46')]);return db[_0xb36b('0x2d')][_0xb36b('0x47')](_0x2b550e)[_0xb36b('0x26')](handleEntityNotFound(_0x42678e,null))['then'](respondWithResult(_0x42678e,null))[_0xb36b('0x43')](handleError(_0x42678e,null));};exports[_0xb36b('0x48')]=function(_0x227f09,_0x3e215d){return db[_0xb36b('0x2d')][_0xb36b('0x48')](_0x227f09['body'],{})[_0xb36b('0x26')](respondWithResult(_0x3e215d,0xc9))[_0xb36b('0x43')](handleError(_0x3e215d,null));};exports[_0xb36b('0x49')]=function(_0x47e553,_0x166fa9){return db[_0xb36b('0x2d')][_0xb36b('0x49')]()[_0xb36b('0x26')](respondWithResult(_0x166fa9,null))[_0xb36b('0x43')](handleError(_0x166fa9,null));};exports[_0xb36b('0x4a')]=function(_0x50df32,_0x2f44cc){if(_0x50df32[_0xb36b('0x4b')][_0xb36b('0x4c')]){delete _0x50df32['body'][_0xb36b('0x4c')];}return db[_0xb36b('0x2d')]['find']({'where':{'uniqueid':_0x50df32['params']['id']}})[_0xb36b('0x26')](handleEntityNotFound(_0x2f44cc,null))['then'](saveUpdates(_0x50df32['body'],null))[_0xb36b('0x26')](respondWithResult(_0x2f44cc,null))[_0xb36b('0x43')](handleError(_0x2f44cc,null));};