Built motion from commit (unavailable).|2.5.4
[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 _0x5cf6=['where','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','keys','length','find','create','body','describe','uniqueid','params','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','count','limit','set','Content-Range','apply','reject','update','destroy','then','stack','name','send','index','map','CmHopperHistory','rawAttributes','type','key','query','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','offset','order','sort','filter'];(function(_0x4565bf,_0x5ad9d6){var _0x5610ba=function(_0x170988){while(--_0x170988){_0x4565bf['push'](_0x4565bf['shift']());}};_0x5610ba(++_0x5ad9d6);}(_0x5cf6,0x1df));var _0x65cf=function(_0x13d07a,_0x41efc3){_0x13d07a=_0x13d07a-0x0;var _0x5ee0ee=_0x5cf6[_0x13d07a];return _0x5ee0ee;};'use strict';var pdf=require(_0x65cf('0x0'));var emlformat=require(_0x65cf('0x1'));var rimraf=require(_0x65cf('0x2'));var zipdir=require(_0x65cf('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x65cf('0x4'));var moment=require(_0x65cf('0x5'));var BPromise=require(_0x65cf('0x6'));var Mustache=require('mustache');var util=require(_0x65cf('0x7'));var path=require(_0x65cf('0x8'));var sox=require(_0x65cf('0x9'));var csv=require(_0x65cf('0xa'));var ejs=require(_0x65cf('0xb'));var fs=require('fs');var _=require(_0x65cf('0xc'));var squel=require(_0x65cf('0xd'));var crypto=require(_0x65cf('0xe'));var jsforce=require(_0x65cf('0xf'));var deskjs=require(_0x65cf('0x10'));var toCsv=require(_0x65cf('0xa'));var querystring=require(_0x65cf('0x11'));var Papa=require(_0x65cf('0x12'));var Redis=require('ioredis');var authService=require(_0x65cf('0x13'));var qs=require(_0x65cf('0x14'));var as=require(_0x65cf('0x15'));var hardwareService=require(_0x65cf('0x16'));var logger=require(_0x65cf('0x17'))('api');var utils=require(_0x65cf('0x18'));var config=require(_0x65cf('0x19'));var db=require(_0x65cf('0x1a'))['db'];function respondWithStatusCode(_0x563453,_0x288f81){_0x288f81=_0x288f81||0xcc;return function(_0x26151a){if(_0x26151a){return _0x563453[_0x65cf('0x1b')](_0x288f81);}return _0x563453[_0x65cf('0x1c')](_0x288f81)[_0x65cf('0x1d')]();};}function respondWithResult(_0x4f9e37,_0x6571f7){_0x6571f7=_0x6571f7||0xc8;return function(_0x247996){if(_0x247996){return _0x4f9e37[_0x65cf('0x1c')](_0x6571f7)['json'](_0x247996);}};}function respondWithFilteredResult(_0x423c98,_0xb2e89a){return function(_0x3e32c1){if(_0x3e32c1){var _0x5b61d2=_0x3e32c1[_0x65cf('0x1e')],_0x45a35a=_0xb2e89a['offset'],_0x281346=_0xb2e89a['offset']+_0xb2e89a[_0x65cf('0x1f')],_0x869f83;if(_0x281346>=_0x5b61d2){_0x281346=_0x5b61d2;_0x869f83=0xc8;}else{_0x869f83=0xce;}_0x423c98[_0x65cf('0x1c')](_0x869f83);return _0x423c98[_0x65cf('0x20')](_0x65cf('0x21'),_0x45a35a+'-'+_0x281346+'/'+_0x5b61d2)['json'](_0x3e32c1);}return null;};}function patchUpdates(_0x1e5f2f){return function(_0x275a5e){try{jsonpatch[_0x65cf('0x22')](_0x275a5e,_0x1e5f2f,!![]);}catch(_0x203cd9){return BPromise[_0x65cf('0x23')](_0x203cd9);}return _0x275a5e['save']();};}function saveUpdates(_0x5826a7,_0x26635f){return function(_0xa14773){if(_0xa14773){return _0xa14773[_0x65cf('0x24')](_0x5826a7)['then'](function(_0xa9b146){return _0xa9b146;});}return null;};}function removeEntity(_0x57fe4b,_0x1cf691){return function(_0x5e978f){if(_0x5e978f){return _0x5e978f[_0x65cf('0x25')]()[_0x65cf('0x26')](function(){_0x57fe4b[_0x65cf('0x1c')](0xcc)[_0x65cf('0x1d')]();});}};}function handleEntityNotFound(_0x1f41ec,_0x28485b){return function(_0x5c97c5){if(!_0x5c97c5){_0x1f41ec['sendStatus'](0x194);}return _0x5c97c5;};}function handleError(_0x1c1a39,_0x3c1c8d){_0x3c1c8d=_0x3c1c8d||0x1f4;return function(_0x113c67){logger['error'](_0x113c67[_0x65cf('0x27')]);if(_0x113c67[_0x65cf('0x28')]){delete _0x113c67[_0x65cf('0x28')];}_0x1c1a39[_0x65cf('0x1c')](_0x3c1c8d)[_0x65cf('0x29')](_0x113c67);};}exports[_0x65cf('0x2a')]=function(_0x262ed8,_0x4c1d2f){var _0xf240d5={},_0x5da90b={},_0x361683={'count':0x0,'rows':[]};var _0x225db7=_[_0x65cf('0x2b')](db[_0x65cf('0x2c')][_0x65cf('0x2d')],function(_0x54b2fa){return{'name':_0x54b2fa['fieldName'],'type':_0x54b2fa[_0x65cf('0x2e')][_0x65cf('0x2f')]};});_0x5da90b['model']=_[_0x65cf('0x2b')](_0x225db7,_0x65cf('0x28'));_0x5da90b[_0x65cf('0x30')]=_['keys'](_0x262ed8['query']);_0x5da90b[_0x65cf('0x31')]=_[_0x65cf('0x32')](_0x5da90b[_0x65cf('0x33')],_0x5da90b[_0x65cf('0x30')]);_0xf240d5[_0x65cf('0x34')]=_[_0x65cf('0x32')](_0x5da90b[_0x65cf('0x33')],qs[_0x65cf('0x35')](_0x262ed8[_0x65cf('0x30')][_0x65cf('0x35')]));_0xf240d5[_0x65cf('0x34')]=_0xf240d5[_0x65cf('0x34')]['length']?_0xf240d5['attributes']:_0x5da90b[_0x65cf('0x33')];if(!_0x262ed8['query'][_0x65cf('0x36')](_0x65cf('0x37'))){_0xf240d5[_0x65cf('0x1f')]=qs[_0x65cf('0x1f')](_0x262ed8[_0x65cf('0x30')][_0x65cf('0x1f')]);_0xf240d5[_0x65cf('0x38')]=qs[_0x65cf('0x38')](_0x262ed8[_0x65cf('0x30')]['offset']);}_0xf240d5[_0x65cf('0x39')]=qs[_0x65cf('0x3a')](_0x262ed8['query'][_0x65cf('0x3a')]);_0xf240d5['where']=qs[_0x65cf('0x31')](_['pick'](_0x262ed8['query'],_0x5da90b[_0x65cf('0x31')]),_0x225db7);if(_0x262ed8['query'][_0x65cf('0x3b')]){_0xf240d5[_0x65cf('0x3c')]=_[_0x65cf('0x3d')](_0xf240d5[_0x65cf('0x3c')],{'$or':_[_0x65cf('0x2b')](_0x225db7,function(_0x4be09b){if(_0x4be09b[_0x65cf('0x2e')]!==_0x65cf('0x3e')){var _0x3af7c3={};_0x3af7c3[_0x4be09b[_0x65cf('0x28')]]={'$like':'%'+_0x262ed8['query'][_0x65cf('0x3b')]+'%'};return _0x3af7c3;}})});}_0xf240d5=_['merge']({},_0xf240d5,_0x262ed8[_0x65cf('0x3f')]);var _0x1ff245={'where':_0xf240d5[_0x65cf('0x3c')]};return db['CmHopperHistory'][_0x65cf('0x1e')](_0x1ff245)[_0x65cf('0x26')](function(_0x2b7a14){_0x361683[_0x65cf('0x1e')]=_0x2b7a14;if(_0x262ed8['query'][_0x65cf('0x40')]){_0xf240d5[_0x65cf('0x41')]=[{'all':!![]}];}return db[_0x65cf('0x2c')][_0x65cf('0x42')](_0xf240d5);})['then'](function(_0x459f19){_0x361683[_0x65cf('0x43')]=_0x459f19;return _0x361683;})[_0x65cf('0x26')](respondWithFilteredResult(_0x4c1d2f,_0xf240d5))[_0x65cf('0x44')](handleError(_0x4c1d2f,null));};exports['show']=function(_0x342d9f,_0x25113e){var _0x470967={'raw':!![],'where':{'id':_0x342d9f['params']['id']}},_0xac7ad0={};_0xac7ad0[_0x65cf('0x33')]=_['keys'](db[_0x65cf('0x2c')][_0x65cf('0x2d')]);_0xac7ad0['query']=_[_0x65cf('0x45')](_0x342d9f[_0x65cf('0x30')]);_0xac7ad0[_0x65cf('0x31')]=_[_0x65cf('0x32')](_0xac7ad0['model'],_0xac7ad0['query']);_0x470967[_0x65cf('0x34')]=_[_0x65cf('0x32')](_0xac7ad0[_0x65cf('0x33')],qs[_0x65cf('0x35')](_0x342d9f[_0x65cf('0x30')][_0x65cf('0x35')]));_0x470967[_0x65cf('0x34')]=_0x470967[_0x65cf('0x34')][_0x65cf('0x46')]?_0x470967[_0x65cf('0x34')]:_0xac7ad0['model'];if(_0x342d9f[_0x65cf('0x30')]['includeAll']){_0x470967[_0x65cf('0x41')]=[{'all':!![]}];}_0x470967=_[_0x65cf('0x3d')]({},_0x470967,_0x342d9f['options']);return db[_0x65cf('0x2c')][_0x65cf('0x47')](_0x470967)[_0x65cf('0x26')](handleEntityNotFound(_0x25113e,null))['then'](respondWithResult(_0x25113e,null))[_0x65cf('0x44')](handleError(_0x25113e,null));};exports[_0x65cf('0x48')]=function(_0x32a63e,_0x15c795){return db[_0x65cf('0x2c')][_0x65cf('0x48')](_0x32a63e[_0x65cf('0x49')],{})[_0x65cf('0x26')](respondWithResult(_0x15c795,0xc9))['catch'](handleError(_0x15c795,null));};exports[_0x65cf('0x4a')]=function(_0x20bd6d,_0x2ba7bd){return db['CmHopperHistory'][_0x65cf('0x4a')]()['then'](respondWithResult(_0x2ba7bd,null))[_0x65cf('0x44')](handleError(_0x2ba7bd,null));};exports[_0x65cf('0x24')]=function(_0x8ef5d7,_0x4a728c){if(_0x8ef5d7[_0x65cf('0x49')]['uniqueid']){delete _0x8ef5d7['body'][_0x65cf('0x4b')];}return db[_0x65cf('0x2c')]['find']({'where':{'uniqueid':_0x8ef5d7[_0x65cf('0x4c')]['id']}})[_0x65cf('0x26')](handleEntityNotFound(_0x4a728c,null))[_0x65cf('0x26')](saveUpdates(_0x8ef5d7[_0x65cf('0x49')],null))['then'](respondWithResult(_0x4a728c,null))[_0x65cf('0x44')](handleError(_0x4a728c,null));};