Built motion from commit (unavailable).|2.5.15
[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 _0xb702=['sort','where','pick','filters','VIRTUAL','merge','options','CmHopperHistory','count','findAll','rows','catch','show','params','rawAttributes','length','include','find','create','describe','update','uniqueid','body','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','ejs','lodash','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','status','end','offset','set','Content-Range','json','apply','save','then','destroy','sendStatus','error','stack','name','send','index','fieldName','type','key','model','map','query','keys','attributes','intersection','fields','hasOwnProperty','limit','order'];(function(_0x3ccac6,_0xd6b81b){var _0x5da1e0=function(_0x34231a){while(--_0x34231a){_0x3ccac6['push'](_0x3ccac6['shift']());}};_0x5da1e0(++_0xd6b81b);}(_0xb702,0x13f));var _0x2b70=function(_0x4bd950,_0x184ed5){_0x4bd950=_0x4bd950-0x0;var _0x5dc59a=_0xb702[_0x4bd950];return _0x5dc59a;};'use strict';var pdf=require(_0x2b70('0x0'));var emlformat=require(_0x2b70('0x1'));var rimraf=require(_0x2b70('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x2b70('0x3'));var rp=require(_0x2b70('0x4'));var moment=require(_0x2b70('0x5'));var BPromise=require(_0x2b70('0x6'));var Mustache=require('mustache');var util=require(_0x2b70('0x7'));var path=require(_0x2b70('0x8'));var sox=require('sox');var csv=require(_0x2b70('0x9'));var ejs=require(_0x2b70('0xa'));var fs=require('fs');var _=require(_0x2b70('0xb'));var squel=require('squel');var crypto=require(_0x2b70('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x2b70('0xd'));var toCsv=require(_0x2b70('0x9'));var querystring=require(_0x2b70('0xe'));var Papa=require(_0x2b70('0xf'));var Redis=require(_0x2b70('0x10'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x2b70('0x11'));var hardwareService=require(_0x2b70('0x12'));var logger=require(_0x2b70('0x13'))('api');var utils=require('../../config/utils');var config=require(_0x2b70('0x14'));var licenseUtil=require(_0x2b70('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x4ca0a4,_0x43091b){_0x43091b=_0x43091b||0xcc;return function(_0x309135){if(_0x309135){return _0x4ca0a4['sendStatus'](_0x43091b);}return _0x4ca0a4[_0x2b70('0x16')](_0x43091b)[_0x2b70('0x17')]();};}function respondWithResult(_0x4e782b,_0x447685){_0x447685=_0x447685||0xc8;return function(_0x57d534){if(_0x57d534){return _0x4e782b[_0x2b70('0x16')](_0x447685)['json'](_0x57d534);}};}function respondWithFilteredResult(_0x26fb88,_0x48b866){return function(_0x1291b9){if(_0x1291b9){var _0x4b533b=_0x1291b9['count'],_0x56d952=_0x48b866[_0x2b70('0x18')],_0x389706=_0x48b866[_0x2b70('0x18')]+_0x48b866['limit'],_0x2c1f15;if(_0x389706>=_0x4b533b){_0x389706=_0x4b533b;_0x2c1f15=0xc8;}else{_0x2c1f15=0xce;}_0x26fb88['status'](_0x2c1f15);return _0x26fb88[_0x2b70('0x19')](_0x2b70('0x1a'),_0x56d952+'-'+_0x389706+'/'+_0x4b533b)[_0x2b70('0x1b')](_0x1291b9);}return null;};}function patchUpdates(_0x3ffcee){return function(_0x3112bf){try{jsonpatch[_0x2b70('0x1c')](_0x3112bf,_0x3ffcee,!![]);}catch(_0x4f14e9){return BPromise['reject'](_0x4f14e9);}return _0x3112bf[_0x2b70('0x1d')]();};}function saveUpdates(_0x5a5c10,_0x481b52){return function(_0x385dde){if(_0x385dde){return _0x385dde['update'](_0x5a5c10)[_0x2b70('0x1e')](function(_0x2d97d5){return _0x2d97d5;});}return null;};}function removeEntity(_0x55ebc3,_0x512a1b){return function(_0xf86405){if(_0xf86405){return _0xf86405[_0x2b70('0x1f')]()[_0x2b70('0x1e')](function(){_0x55ebc3[_0x2b70('0x16')](0xcc)[_0x2b70('0x17')]();});}};}function handleEntityNotFound(_0x252764,_0x145d17){return function(_0x1f0304){if(!_0x1f0304){_0x252764[_0x2b70('0x20')](0x194);}return _0x1f0304;};}function handleError(_0x2fb8f9,_0x3379ba){_0x3379ba=_0x3379ba||0x1f4;return function(_0x2452d1){logger[_0x2b70('0x21')](_0x2452d1[_0x2b70('0x22')]);if(_0x2452d1[_0x2b70('0x23')]){delete _0x2452d1[_0x2b70('0x23')];}_0x2fb8f9['status'](_0x3379ba)[_0x2b70('0x24')](_0x2452d1);};}exports[_0x2b70('0x25')]=function(_0x33518b,_0x3c7324){var _0x29b689={},_0x342630={},_0x35f9a6={'count':0x0,'rows':[]};var _0x4933c0=_['map'](db['CmHopperHistory']['rawAttributes'],function(_0x2a8441){return{'name':_0x2a8441[_0x2b70('0x26')],'type':_0x2a8441[_0x2b70('0x27')][_0x2b70('0x28')]};});_0x342630[_0x2b70('0x29')]=_[_0x2b70('0x2a')](_0x4933c0,_0x2b70('0x23'));_0x342630[_0x2b70('0x2b')]=_[_0x2b70('0x2c')](_0x33518b[_0x2b70('0x2b')]);_0x342630['filters']=_['intersection'](_0x342630[_0x2b70('0x29')],_0x342630[_0x2b70('0x2b')]);_0x29b689[_0x2b70('0x2d')]=_[_0x2b70('0x2e')](_0x342630['model'],qs['fields'](_0x33518b[_0x2b70('0x2b')][_0x2b70('0x2f')]));_0x29b689[_0x2b70('0x2d')]=_0x29b689[_0x2b70('0x2d')]['length']?_0x29b689[_0x2b70('0x2d')]:_0x342630[_0x2b70('0x29')];if(!_0x33518b[_0x2b70('0x2b')][_0x2b70('0x30')]('nolimit')){_0x29b689[_0x2b70('0x31')]=qs[_0x2b70('0x31')](_0x33518b[_0x2b70('0x2b')][_0x2b70('0x31')]);_0x29b689[_0x2b70('0x18')]=qs[_0x2b70('0x18')](_0x33518b[_0x2b70('0x2b')][_0x2b70('0x18')]);}_0x29b689[_0x2b70('0x32')]=qs[_0x2b70('0x33')](_0x33518b['query']['sort']);_0x29b689[_0x2b70('0x34')]=qs['filters'](_[_0x2b70('0x35')](_0x33518b[_0x2b70('0x2b')],_0x342630[_0x2b70('0x36')]),_0x4933c0);if(_0x33518b[_0x2b70('0x2b')]['filter']){_0x29b689[_0x2b70('0x34')]=_['merge'](_0x29b689['where'],{'$or':_[_0x2b70('0x2a')](_0x4933c0,function(_0x20fdb3){if(_0x20fdb3[_0x2b70('0x27')]!==_0x2b70('0x37')){var _0x6e1e17={};_0x6e1e17[_0x20fdb3[_0x2b70('0x23')]]={'$like':'%'+_0x33518b['query']['filter']+'%'};return _0x6e1e17;}})});}_0x29b689=_[_0x2b70('0x38')]({},_0x29b689,_0x33518b[_0x2b70('0x39')]);var _0x51477c={'where':_0x29b689[_0x2b70('0x34')]};return db[_0x2b70('0x3a')]['count'](_0x51477c)[_0x2b70('0x1e')](function(_0x26eb2f){_0x35f9a6[_0x2b70('0x3b')]=_0x26eb2f;if(_0x33518b['query']['includeAll']){_0x29b689['include']=[{'all':!![]}];}return db[_0x2b70('0x3a')][_0x2b70('0x3c')](_0x29b689);})[_0x2b70('0x1e')](function(_0x6dacaa){_0x35f9a6[_0x2b70('0x3d')]=_0x6dacaa;return _0x35f9a6;})['then'](respondWithFilteredResult(_0x3c7324,_0x29b689))[_0x2b70('0x3e')](handleError(_0x3c7324,null));};exports[_0x2b70('0x3f')]=function(_0x227e79,_0x273a5d){var _0x343146={'raw':!![],'where':{'id':_0x227e79[_0x2b70('0x40')]['id']}},_0x4b9895={};_0x4b9895[_0x2b70('0x29')]=_[_0x2b70('0x2c')](db['CmHopperHistory'][_0x2b70('0x41')]);_0x4b9895[_0x2b70('0x2b')]=_[_0x2b70('0x2c')](_0x227e79[_0x2b70('0x2b')]);_0x4b9895[_0x2b70('0x36')]=_[_0x2b70('0x2e')](_0x4b9895[_0x2b70('0x29')],_0x4b9895[_0x2b70('0x2b')]);_0x343146[_0x2b70('0x2d')]=_[_0x2b70('0x2e')](_0x4b9895['model'],qs['fields'](_0x227e79['query']['fields']));_0x343146[_0x2b70('0x2d')]=_0x343146[_0x2b70('0x2d')][_0x2b70('0x42')]?_0x343146[_0x2b70('0x2d')]:_0x4b9895[_0x2b70('0x29')];if(_0x227e79[_0x2b70('0x2b')]['includeAll']){_0x343146[_0x2b70('0x43')]=[{'all':!![]}];}_0x343146=_[_0x2b70('0x38')]({},_0x343146,_0x227e79[_0x2b70('0x39')]);return db[_0x2b70('0x3a')][_0x2b70('0x44')](_0x343146)['then'](handleEntityNotFound(_0x273a5d,null))[_0x2b70('0x1e')](respondWithResult(_0x273a5d,null))[_0x2b70('0x3e')](handleError(_0x273a5d,null));};exports[_0x2b70('0x45')]=function(_0xac8dc5,_0x5f13a2){return db['CmHopperHistory'][_0x2b70('0x45')](_0xac8dc5['body'],{})[_0x2b70('0x1e')](respondWithResult(_0x5f13a2,0xc9))[_0x2b70('0x3e')](handleError(_0x5f13a2,null));};exports[_0x2b70('0x46')]=function(_0x2cb670,_0xa89bb7){return db[_0x2b70('0x3a')]['describe']()[_0x2b70('0x1e')](respondWithResult(_0xa89bb7,null))[_0x2b70('0x3e')](handleError(_0xa89bb7,null));};exports[_0x2b70('0x47')]=function(_0x18d747,_0x52e564){if(_0x18d747['body'][_0x2b70('0x48')]){delete _0x18d747[_0x2b70('0x49')]['uniqueid'];}return db['CmHopperHistory'][_0x2b70('0x44')]({'where':{'uniqueid':_0x18d747[_0x2b70('0x40')]['id']}})[_0x2b70('0x1e')](handleEntityNotFound(_0x52e564,null))[_0x2b70('0x1e')](saveUpdates(_0x18d747[_0x2b70('0x49')],null))[_0x2b70('0x1e')](respondWithResult(_0x52e564,null))[_0x2b70('0x3e')](handleError(_0x52e564,null));};