Built motion from commit (unavailable).|2.4.18
[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 _0xb65b=['rows','catch','show','params','keys','length','create','body','describe','uniqueid','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','status','end','count','offset','set','Content-Range','json','reject','save','update','then','error','stack','name','index','map','CmHopperHistory','rawAttributes','fieldName','type','key','model','query','intersection','fields','attributes','hasOwnProperty','limit','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','include'];(function(_0x167cc1,_0x56ef5a){var _0x10bc4b=function(_0xd6a255){while(--_0xd6a255){_0x167cc1['push'](_0x167cc1['shift']());}};_0x10bc4b(++_0x56ef5a);}(_0xb65b,0x1cc));var _0xbb65=function(_0x56ee42,_0x2d97ee){_0x56ee42=_0x56ee42-0x0;var _0x108a44=_0xb65b[_0x56ee42];return _0x108a44;};'use strict';var pdf=require(_0xbb65('0x0'));var emlformat=require(_0xbb65('0x1'));var rimraf=require(_0xbb65('0x2'));var zipdir=require(_0xbb65('0x3'));var jsonpatch=require(_0xbb65('0x4'));var rp=require(_0xbb65('0x5'));var moment=require(_0xbb65('0x6'));var BPromise=require(_0xbb65('0x7'));var Mustache=require('mustache');var util=require(_0xbb65('0x8'));var path=require(_0xbb65('0x9'));var sox=require(_0xbb65('0xa'));var csv=require('to-csv');var ejs=require(_0xbb65('0xb'));var fs=require('fs');var _=require(_0xbb65('0xc'));var squel=require(_0xbb65('0xd'));var crypto=require(_0xbb65('0xe'));var jsforce=require(_0xbb65('0xf'));var deskjs=require(_0xbb65('0x10'));var toCsv=require(_0xbb65('0x11'));var querystring=require(_0xbb65('0x12'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xbb65('0x13'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbb65('0x14'));var logger=require(_0xbb65('0x15'))(_0xbb65('0x16'));var utils=require(_0xbb65('0x17'));var config=require('../../config/environment');var db=require(_0xbb65('0x18'))['db'];function respondWithStatusCode(_0x30f56e,_0x5027dd){_0x5027dd=_0x5027dd||0xcc;return function(_0x1d3fee){if(_0x1d3fee){return _0x30f56e[_0xbb65('0x19')](_0x5027dd);}return _0x30f56e[_0xbb65('0x1a')](_0x5027dd)[_0xbb65('0x1b')]();};}function respondWithResult(_0x403909,_0x49fd1c){_0x49fd1c=_0x49fd1c||0xc8;return function(_0x4ba12d){if(_0x4ba12d){return _0x403909[_0xbb65('0x1a')](_0x49fd1c)['json'](_0x4ba12d);}};}function respondWithFilteredResult(_0x42412a,_0x5f54dc){return function(_0x38768e){if(_0x38768e){var _0x10c9f4=_0x38768e[_0xbb65('0x1c')],_0x1fe6c9=_0x5f54dc[_0xbb65('0x1d')],_0x4504c1=_0x5f54dc[_0xbb65('0x1d')]+_0x5f54dc['limit'],_0x54d0a1;if(_0x4504c1>=_0x10c9f4){_0x4504c1=_0x10c9f4;_0x54d0a1=0xc8;}else{_0x54d0a1=0xce;}_0x42412a[_0xbb65('0x1a')](_0x54d0a1);return _0x42412a[_0xbb65('0x1e')](_0xbb65('0x1f'),_0x1fe6c9+'-'+_0x4504c1+'/'+_0x10c9f4)[_0xbb65('0x20')](_0x38768e);}return null;};}function patchUpdates(_0x437fd7){return function(_0x3fdd11){try{jsonpatch['apply'](_0x3fdd11,_0x437fd7,!![]);}catch(_0x54244e){return BPromise[_0xbb65('0x21')](_0x54244e);}return _0x3fdd11[_0xbb65('0x22')]();};}function saveUpdates(_0x547220,_0x1e2b08){return function(_0x9db054){if(_0x9db054){return _0x9db054[_0xbb65('0x23')](_0x547220)[_0xbb65('0x24')](function(_0xc973c1){return _0xc973c1;});}return null;};}function removeEntity(_0x201f7a,_0x568026){return function(_0x14c9cd){if(_0x14c9cd){return _0x14c9cd['destroy']()['then'](function(){_0x201f7a[_0xbb65('0x1a')](0xcc)[_0xbb65('0x1b')]();});}};}function handleEntityNotFound(_0xcd7f6a,_0x3efad5){return function(_0xbf8003){if(!_0xbf8003){_0xcd7f6a[_0xbb65('0x19')](0x194);}return _0xbf8003;};}function handleError(_0x581068,_0x247c66){_0x247c66=_0x247c66||0x1f4;return function(_0x49c7f3){logger[_0xbb65('0x25')](_0x49c7f3[_0xbb65('0x26')]);if(_0x49c7f3[_0xbb65('0x27')]){delete _0x49c7f3[_0xbb65('0x27')];}_0x581068[_0xbb65('0x1a')](_0x247c66)['send'](_0x49c7f3);};}exports[_0xbb65('0x28')]=function(_0x402411,_0x27efcb){var _0x34002d={},_0x1e6542={},_0xa9e464={'count':0x0,'rows':[]};var _0x546057=_[_0xbb65('0x29')](db[_0xbb65('0x2a')][_0xbb65('0x2b')],function(_0x537b3b){return{'name':_0x537b3b[_0xbb65('0x2c')],'type':_0x537b3b[_0xbb65('0x2d')][_0xbb65('0x2e')]};});_0x1e6542[_0xbb65('0x2f')]=_['map'](_0x546057,_0xbb65('0x27'));_0x1e6542[_0xbb65('0x30')]=_['keys'](_0x402411[_0xbb65('0x30')]);_0x1e6542['filters']=_[_0xbb65('0x31')](_0x1e6542[_0xbb65('0x2f')],_0x1e6542[_0xbb65('0x30')]);_0x34002d['attributes']=_[_0xbb65('0x31')](_0x1e6542[_0xbb65('0x2f')],qs['fields'](_0x402411['query'][_0xbb65('0x32')]));_0x34002d[_0xbb65('0x33')]=_0x34002d[_0xbb65('0x33')]['length']?_0x34002d[_0xbb65('0x33')]:_0x1e6542[_0xbb65('0x2f')];if(!_0x402411['query'][_0xbb65('0x34')]('nolimit')){_0x34002d[_0xbb65('0x35')]=qs[_0xbb65('0x35')](_0x402411['query']['limit']);_0x34002d[_0xbb65('0x1d')]=qs[_0xbb65('0x1d')](_0x402411[_0xbb65('0x30')][_0xbb65('0x1d')]);}_0x34002d[_0xbb65('0x36')]=qs[_0xbb65('0x37')](_0x402411[_0xbb65('0x30')][_0xbb65('0x37')]);_0x34002d[_0xbb65('0x38')]=qs[_0xbb65('0x39')](_[_0xbb65('0x3a')](_0x402411[_0xbb65('0x30')],_0x1e6542[_0xbb65('0x39')]));if(_0x402411[_0xbb65('0x30')][_0xbb65('0x3b')]){_0x34002d['where']=_[_0xbb65('0x3c')](_0x34002d[_0xbb65('0x38')],{'$or':_[_0xbb65('0x29')](_0x546057,function(_0xeedf2f){if(_0xeedf2f[_0xbb65('0x2d')]!==_0xbb65('0x3d')){var _0x79b11b={};_0x79b11b[_0xeedf2f['name']]={'$like':'%'+_0x402411[_0xbb65('0x30')][_0xbb65('0x3b')]+'%'};return _0x79b11b;}})});}_0x34002d=_[_0xbb65('0x3c')]({},_0x34002d,_0x402411[_0xbb65('0x3e')]);var _0x2278aa={'where':_0x34002d[_0xbb65('0x38')]};return db[_0xbb65('0x2a')][_0xbb65('0x1c')](_0x2278aa)[_0xbb65('0x24')](function(_0x284589){_0xa9e464[_0xbb65('0x1c')]=_0x284589;if(_0x402411[_0xbb65('0x30')][_0xbb65('0x3f')]){_0x34002d[_0xbb65('0x40')]=[{'all':!![]}];}return db[_0xbb65('0x2a')]['findAll'](_0x34002d);})[_0xbb65('0x24')](function(_0xdb109f){_0xa9e464[_0xbb65('0x41')]=_0xdb109f;return _0xa9e464;})[_0xbb65('0x24')](respondWithFilteredResult(_0x27efcb,_0x34002d))[_0xbb65('0x42')](handleError(_0x27efcb,null));};exports[_0xbb65('0x43')]=function(_0x21a386,_0x49080e){var _0x4dea2a={'raw':!![],'where':{'id':_0x21a386[_0xbb65('0x44')]['id']}},_0x12780b={};_0x12780b[_0xbb65('0x2f')]=_[_0xbb65('0x45')](db[_0xbb65('0x2a')][_0xbb65('0x2b')]);_0x12780b['query']=_[_0xbb65('0x45')](_0x21a386[_0xbb65('0x30')]);_0x12780b[_0xbb65('0x39')]=_[_0xbb65('0x31')](_0x12780b[_0xbb65('0x2f')],_0x12780b[_0xbb65('0x30')]);_0x4dea2a[_0xbb65('0x33')]=_[_0xbb65('0x31')](_0x12780b[_0xbb65('0x2f')],qs[_0xbb65('0x32')](_0x21a386[_0xbb65('0x30')][_0xbb65('0x32')]));_0x4dea2a[_0xbb65('0x33')]=_0x4dea2a[_0xbb65('0x33')][_0xbb65('0x46')]?_0x4dea2a[_0xbb65('0x33')]:_0x12780b[_0xbb65('0x2f')];if(_0x21a386[_0xbb65('0x30')][_0xbb65('0x3f')]){_0x4dea2a[_0xbb65('0x40')]=[{'all':!![]}];}_0x4dea2a=_[_0xbb65('0x3c')]({},_0x4dea2a,_0x21a386[_0xbb65('0x3e')]);return db['CmHopperHistory']['find'](_0x4dea2a)[_0xbb65('0x24')](handleEntityNotFound(_0x49080e,null))[_0xbb65('0x24')](respondWithResult(_0x49080e,null))[_0xbb65('0x42')](handleError(_0x49080e,null));};exports['create']=function(_0x41ec87,_0x8a01b7){return db['CmHopperHistory'][_0xbb65('0x47')](_0x41ec87[_0xbb65('0x48')],{})[_0xbb65('0x24')](respondWithResult(_0x8a01b7,0xc9))[_0xbb65('0x42')](handleError(_0x8a01b7,null));};exports[_0xbb65('0x49')]=function(_0x5d7911,_0x18838){return db[_0xbb65('0x2a')]['describe']()[_0xbb65('0x24')](respondWithResult(_0x18838,null))[_0xbb65('0x42')](handleError(_0x18838,null));};exports[_0xbb65('0x23')]=function(_0x307d26,_0x160012){if(_0x307d26[_0xbb65('0x48')][_0xbb65('0x4a')]){delete _0x307d26[_0xbb65('0x48')][_0xbb65('0x4a')];}return db[_0xbb65('0x2a')]['find']({'where':{'uniqueid':_0x307d26[_0xbb65('0x44')]['id']}})[_0xbb65('0x24')](handleEntityNotFound(_0x160012,null))['then'](saveUpdates(_0x307d26['body'],null))[_0xbb65('0x24')](respondWithResult(_0x160012,null))[_0xbb65('0x42')](handleError(_0x160012,null));};