Built motion from commit (unavailable).|2.5.20
[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 _0xc933=['map','CmHopperHistory','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','pick','filter','where','VIRTUAL','merge','options','includeAll','include','rows','catch','show','params','find','create','describe','uniqueid','body','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','to-csv','ejs','lodash','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','json','count','offset','limit','apply','reject','save','update','then','destroy','error','stack','name','send'];(function(_0x2ebd32,_0x14a52a){var _0xebdd6=function(_0x44e1e3){while(--_0x44e1e3){_0x2ebd32['push'](_0x2ebd32['shift']());}};_0xebdd6(++_0x14a52a);}(_0xc933,0x151));var _0x3c93=function(_0x1d8a63,_0x407d58){_0x1d8a63=_0x1d8a63-0x0;var _0x31d884=_0xc933[_0x1d8a63];return _0x31d884;};'use strict';var pdf=require(_0x3c93('0x0'));var emlformat=require(_0x3c93('0x1'));var rimraf=require(_0x3c93('0x2'));var zipdir=require(_0x3c93('0x3'));var jsonpatch=require(_0x3c93('0x4'));var rp=require(_0x3c93('0x5'));var moment=require('moment');var BPromise=require(_0x3c93('0x6'));var Mustache=require(_0x3c93('0x7'));var util=require(_0x3c93('0x8'));var path=require(_0x3c93('0x9'));var sox=require('sox');var csv=require(_0x3c93('0xa'));var ejs=require(_0x3c93('0xb'));var fs=require('fs');var _=require(_0x3c93('0xc'));var squel=require('squel');var crypto=require(_0x3c93('0xd'));var jsforce=require(_0x3c93('0xe'));var deskjs=require(_0x3c93('0xf'));var toCsv=require(_0x3c93('0xa'));var querystring=require(_0x3c93('0x10'));var Papa=require(_0x3c93('0x11'));var Redis=require('ioredis');var authService=require(_0x3c93('0x12'));var qs=require(_0x3c93('0x13'));var as=require(_0x3c93('0x14'));var hardwareService=require(_0x3c93('0x15'));var logger=require(_0x3c93('0x16'))('api');var utils=require(_0x3c93('0x17'));var config=require(_0x3c93('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0x3c93('0x19'))['db'];function respondWithStatusCode(_0x5aa9af,_0xb26c7b){_0xb26c7b=_0xb26c7b||0xcc;return function(_0x29cb81){if(_0x29cb81){return _0x5aa9af[_0x3c93('0x1a')](_0xb26c7b);}return _0x5aa9af[_0x3c93('0x1b')](_0xb26c7b)[_0x3c93('0x1c')]();};}function respondWithResult(_0x41d5f7,_0x22118e){_0x22118e=_0x22118e||0xc8;return function(_0x1cfc52){if(_0x1cfc52){return _0x41d5f7[_0x3c93('0x1b')](_0x22118e)[_0x3c93('0x1d')](_0x1cfc52);}};}function respondWithFilteredResult(_0x52bc47,_0x57d612){return function(_0x596cff){if(_0x596cff){var _0x54849e=_0x596cff[_0x3c93('0x1e')],_0x4caecf=_0x57d612[_0x3c93('0x1f')],_0x5255a0=_0x57d612[_0x3c93('0x1f')]+_0x57d612[_0x3c93('0x20')],_0x41f929;if(_0x5255a0>=_0x54849e){_0x5255a0=_0x54849e;_0x41f929=0xc8;}else{_0x41f929=0xce;}_0x52bc47[_0x3c93('0x1b')](_0x41f929);return _0x52bc47['set']('Content-Range',_0x4caecf+'-'+_0x5255a0+'/'+_0x54849e)[_0x3c93('0x1d')](_0x596cff);}return null;};}function patchUpdates(_0x41037a){return function(_0xb7ddda){try{jsonpatch[_0x3c93('0x21')](_0xb7ddda,_0x41037a,!![]);}catch(_0x557799){return BPromise[_0x3c93('0x22')](_0x557799);}return _0xb7ddda[_0x3c93('0x23')]();};}function saveUpdates(_0x519c52,_0x28985f){return function(_0x525537){if(_0x525537){return _0x525537[_0x3c93('0x24')](_0x519c52)[_0x3c93('0x25')](function(_0x2c23b2){return _0x2c23b2;});}return null;};}function removeEntity(_0x49bdf0,_0x108c33){return function(_0x48b2fd){if(_0x48b2fd){return _0x48b2fd[_0x3c93('0x26')]()[_0x3c93('0x25')](function(){_0x49bdf0[_0x3c93('0x1b')](0xcc)[_0x3c93('0x1c')]();});}};}function handleEntityNotFound(_0x578aef,_0x463bfc){return function(_0x501d32){if(!_0x501d32){_0x578aef[_0x3c93('0x1a')](0x194);}return _0x501d32;};}function handleError(_0x1d5c86,_0x552000){_0x552000=_0x552000||0x1f4;return function(_0xca1dc0){logger[_0x3c93('0x27')](_0xca1dc0[_0x3c93('0x28')]);if(_0xca1dc0[_0x3c93('0x29')]){delete _0xca1dc0[_0x3c93('0x29')];}_0x1d5c86[_0x3c93('0x1b')](_0x552000)[_0x3c93('0x2a')](_0xca1dc0);};}exports['index']=function(_0x3c61e6,_0x3fbc01){var _0x1f2284={},_0x132eb9={},_0x4cb230={'count':0x0,'rows':[]};var _0x413b18=_[_0x3c93('0x2b')](db[_0x3c93('0x2c')]['rawAttributes'],function(_0x2e27e3){return{'name':_0x2e27e3[_0x3c93('0x2d')],'type':_0x2e27e3[_0x3c93('0x2e')][_0x3c93('0x2f')]};});_0x132eb9[_0x3c93('0x30')]=_[_0x3c93('0x2b')](_0x413b18,_0x3c93('0x29'));_0x132eb9[_0x3c93('0x31')]=_[_0x3c93('0x32')](_0x3c61e6[_0x3c93('0x31')]);_0x132eb9[_0x3c93('0x33')]=_[_0x3c93('0x34')](_0x132eb9['model'],_0x132eb9[_0x3c93('0x31')]);_0x1f2284[_0x3c93('0x35')]=_[_0x3c93('0x34')](_0x132eb9[_0x3c93('0x30')],qs[_0x3c93('0x36')](_0x3c61e6[_0x3c93('0x31')][_0x3c93('0x36')]));_0x1f2284[_0x3c93('0x35')]=_0x1f2284[_0x3c93('0x35')][_0x3c93('0x37')]?_0x1f2284['attributes']:_0x132eb9['model'];if(!_0x3c61e6['query'][_0x3c93('0x38')](_0x3c93('0x39'))){_0x1f2284[_0x3c93('0x20')]=qs[_0x3c93('0x20')](_0x3c61e6[_0x3c93('0x31')][_0x3c93('0x20')]);_0x1f2284[_0x3c93('0x1f')]=qs[_0x3c93('0x1f')](_0x3c61e6[_0x3c93('0x31')][_0x3c93('0x1f')]);}_0x1f2284['order']=qs[_0x3c93('0x3a')](_0x3c61e6['query']['sort']);_0x1f2284['where']=qs['filters'](_[_0x3c93('0x3b')](_0x3c61e6[_0x3c93('0x31')],_0x132eb9[_0x3c93('0x33')]),_0x413b18);if(_0x3c61e6[_0x3c93('0x31')][_0x3c93('0x3c')]){_0x1f2284[_0x3c93('0x3d')]=_['merge'](_0x1f2284[_0x3c93('0x3d')],{'$or':_[_0x3c93('0x2b')](_0x413b18,function(_0x137c2e){if(_0x137c2e[_0x3c93('0x2e')]!==_0x3c93('0x3e')){var _0x3c9c30={};_0x3c9c30[_0x137c2e[_0x3c93('0x29')]]={'$like':'%'+_0x3c61e6[_0x3c93('0x31')][_0x3c93('0x3c')]+'%'};return _0x3c9c30;}})});}_0x1f2284=_[_0x3c93('0x3f')]({},_0x1f2284,_0x3c61e6[_0x3c93('0x40')]);var _0x52bec2={'where':_0x1f2284[_0x3c93('0x3d')]};return db['CmHopperHistory']['count'](_0x52bec2)[_0x3c93('0x25')](function(_0x1d610f){_0x4cb230['count']=_0x1d610f;if(_0x3c61e6['query'][_0x3c93('0x41')]){_0x1f2284[_0x3c93('0x42')]=[{'all':!![]}];}return db[_0x3c93('0x2c')]['findAll'](_0x1f2284);})[_0x3c93('0x25')](function(_0xfd034b){_0x4cb230[_0x3c93('0x43')]=_0xfd034b;return _0x4cb230;})['then'](respondWithFilteredResult(_0x3fbc01,_0x1f2284))[_0x3c93('0x44')](handleError(_0x3fbc01,null));};exports[_0x3c93('0x45')]=function(_0x35d6d9,_0x3950a6){var _0x3fc49f={'raw':!![],'where':{'id':_0x35d6d9[_0x3c93('0x46')]['id']}},_0x18ceeb={};_0x18ceeb[_0x3c93('0x30')]=_[_0x3c93('0x32')](db[_0x3c93('0x2c')]['rawAttributes']);_0x18ceeb[_0x3c93('0x31')]=_[_0x3c93('0x32')](_0x35d6d9[_0x3c93('0x31')]);_0x18ceeb[_0x3c93('0x33')]=_[_0x3c93('0x34')](_0x18ceeb[_0x3c93('0x30')],_0x18ceeb[_0x3c93('0x31')]);_0x3fc49f[_0x3c93('0x35')]=_['intersection'](_0x18ceeb[_0x3c93('0x30')],qs['fields'](_0x35d6d9[_0x3c93('0x31')]['fields']));_0x3fc49f[_0x3c93('0x35')]=_0x3fc49f[_0x3c93('0x35')][_0x3c93('0x37')]?_0x3fc49f[_0x3c93('0x35')]:_0x18ceeb[_0x3c93('0x30')];if(_0x35d6d9[_0x3c93('0x31')][_0x3c93('0x41')]){_0x3fc49f[_0x3c93('0x42')]=[{'all':!![]}];}_0x3fc49f=_[_0x3c93('0x3f')]({},_0x3fc49f,_0x35d6d9['options']);return db[_0x3c93('0x2c')][_0x3c93('0x47')](_0x3fc49f)[_0x3c93('0x25')](handleEntityNotFound(_0x3950a6,null))[_0x3c93('0x25')](respondWithResult(_0x3950a6,null))[_0x3c93('0x44')](handleError(_0x3950a6,null));};exports[_0x3c93('0x48')]=function(_0x2e679c,_0xc55b6e){return db[_0x3c93('0x2c')][_0x3c93('0x48')](_0x2e679c['body'],{})[_0x3c93('0x25')](respondWithResult(_0xc55b6e,0xc9))[_0x3c93('0x44')](handleError(_0xc55b6e,null));};exports[_0x3c93('0x49')]=function(_0x1f8b88,_0x153872){return db[_0x3c93('0x2c')][_0x3c93('0x49')]()['then'](respondWithResult(_0x153872,null))[_0x3c93('0x44')](handleError(_0x153872,null));};exports[_0x3c93('0x24')]=function(_0x45c842,_0x4ec4f1){if(_0x45c842['body'][_0x3c93('0x4a')]){delete _0x45c842[_0x3c93('0x4b')][_0x3c93('0x4a')];}return db[_0x3c93('0x2c')][_0x3c93('0x47')]({'where':{'uniqueid':_0x45c842[_0x3c93('0x46')]['id']}})['then'](handleEntityNotFound(_0x4ec4f1,null))[_0x3c93('0x25')](saveUpdates(_0x45c842['body'],null))[_0x3c93('0x25')](respondWithResult(_0x4ec4f1,null))[_0x3c93('0x44')](handleError(_0x4ec4f1,null));};