Built motion from commit (unavailable).|2.3.10
[motion2.git] / server / api / voiceQueuesLog / voiceQueuesLog.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 _0x85f1=['count','offset','limit','Content-Range','apply','reject','save','then','destroy','sendStatus','error','stack','name','send','index','VoiceQueuesLog','rawAttributes','keys','query','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','map','type','key','field','options','includeAll','findAll','rows','catch','show','params','include','find','create','body','update','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv','ejs','lodash','jsforce','desk.js','papaparse','../../components/auth/service','ioredis','../../components/parsers/qs','api','../../config/utils','../../config/environment','../../mysqldb','status','end','json'];(function(_0x18c7cb,_0x3f176b){var _0x5cb1e6=function(_0x5d2719){while(--_0x5d2719){_0x18c7cb['push'](_0x18c7cb['shift']());}};_0x5cb1e6(++_0x3f176b);}(_0x85f1,0x1e1));var _0x185f=function(_0x28669c,_0x1f62c4){_0x28669c=_0x28669c-0x0;var _0x4a3af6=_0x85f1[_0x28669c];return _0x4a3af6;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x185f('0x0'));var jsonpatch=require(_0x185f('0x1'));var rp=require(_0x185f('0x2'));var moment=require(_0x185f('0x3'));var BPromise=require(_0x185f('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0x185f('0x5'));var sox=require(_0x185f('0x6'));var csv=require(_0x185f('0x7'));var ejs=require(_0x185f('0x8'));var fs=require('fs');var _=require(_0x185f('0x9'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x185f('0xa'));var deskjs=require(_0x185f('0xb'));var toCsv=require(_0x185f('0x7'));var querystring=require('querystring');var Papa=require(_0x185f('0xc'));var authService=require(_0x185f('0xd'));var hardwareService=require('../../config/license/hardware');var Redis=require(_0x185f('0xe'));var qs=require(_0x185f('0xf'));var logger=require('../../config/logger')(_0x185f('0x10'));var utils=require(_0x185f('0x11'));var config=require(_0x185f('0x12'));var db=require(_0x185f('0x13'))['db'];function respondWithStatusCode(_0x26a53f,_0x8ab7db){_0x8ab7db=_0x8ab7db||0xcc;return function(_0x32b921){if(_0x32b921){return _0x26a53f['sendStatus'](_0x8ab7db);}return _0x26a53f[_0x185f('0x14')](_0x8ab7db)[_0x185f('0x15')]();};}function respondWithResult(_0x4ac061,_0x3ce26c){_0x3ce26c=_0x3ce26c||0xc8;return function(_0x370e6c){if(_0x370e6c){return _0x4ac061[_0x185f('0x14')](_0x3ce26c)[_0x185f('0x16')](_0x370e6c);}};}function respondWithFilteredResult(_0x5e7a0b,_0xd455a4){return function(_0x28dbf){if(_0x28dbf){var _0x2d1ef7=_0x28dbf[_0x185f('0x17')],_0x31780e=_0xd455a4['offset'],_0x5c77cb=_0xd455a4[_0x185f('0x18')]+_0xd455a4[_0x185f('0x19')],_0x50f73a;if(_0x5c77cb>=_0x2d1ef7){_0x5c77cb=_0x2d1ef7;_0x50f73a=0xc8;}else{_0x50f73a=0xce;}_0x5e7a0b[_0x185f('0x14')](_0x50f73a);return _0x5e7a0b['set'](_0x185f('0x1a'),_0x31780e+'-'+_0x5c77cb+'/'+_0x2d1ef7)[_0x185f('0x16')](_0x28dbf);}return null;};}function patchUpdates(_0x5680b2){return function(_0x4e081f){try{jsonpatch[_0x185f('0x1b')](_0x4e081f,_0x5680b2,!![]);}catch(_0x583834){return BPromise[_0x185f('0x1c')](_0x583834);}return _0x4e081f[_0x185f('0x1d')]();};}function saveUpdates(_0x2146a5,_0x573e2a){return function(_0x5e9eac){if(_0x5e9eac){return _0x5e9eac['update'](_0x2146a5)[_0x185f('0x1e')](function(_0xe68406){return _0xe68406;});}return null;};}function removeEntity(_0x45bc99,_0x463cd0){return function(_0x541a7f){if(_0x541a7f){return _0x541a7f[_0x185f('0x1f')]()[_0x185f('0x1e')](function(){_0x45bc99[_0x185f('0x14')](0xcc)['end']();});}};}function handleEntityNotFound(_0x214614,_0x3f4367){return function(_0x46359b){if(!_0x46359b){_0x214614[_0x185f('0x20')](0x194);}return _0x46359b;};}function handleError(_0x2fffd1,_0x3b7c74){_0x3b7c74=_0x3b7c74||0x1f4;return function(_0x1755d3){logger[_0x185f('0x21')](_0x1755d3[_0x185f('0x22')]);if(_0x1755d3[_0x185f('0x23')]){delete _0x1755d3['name'];}_0x2fffd1['status'](_0x3b7c74)[_0x185f('0x24')](_0x1755d3);};}exports[_0x185f('0x25')]=function(_0x38f202,_0x152b48){var _0x595cc2={},_0x27f791={},_0x1b2f0c={'count':0x0,'rows':[]};var _0xe22a4d=db[_0x185f('0x26')][_0x185f('0x27')];_0x27f791['model']=_[_0x185f('0x28')](_0xe22a4d);_0x27f791[_0x185f('0x29')]=_[_0x185f('0x28')](_0x38f202[_0x185f('0x29')]);_0x27f791[_0x185f('0x2a')]=_[_0x185f('0x2b')](_0x27f791[_0x185f('0x2c')],_0x27f791['query']);_0x595cc2['attributes']=_[_0x185f('0x2b')](_0x27f791[_0x185f('0x2c')],qs[_0x185f('0x2d')](_0x38f202['query'][_0x185f('0x2d')]));_0x595cc2[_0x185f('0x2e')]=_0x595cc2['attributes'][_0x185f('0x2f')]?_0x595cc2[_0x185f('0x2e')]:_0x27f791[_0x185f('0x2c')];if(!_0x38f202[_0x185f('0x29')][_0x185f('0x30')](_0x185f('0x31'))){_0x595cc2[_0x185f('0x19')]=qs[_0x185f('0x19')](_0x38f202[_0x185f('0x29')][_0x185f('0x19')]);_0x595cc2[_0x185f('0x18')]=qs['offset'](_0x38f202[_0x185f('0x29')]['offset']);}_0x595cc2[_0x185f('0x32')]=qs[_0x185f('0x33')](_0x38f202[_0x185f('0x29')]['sort']);_0x595cc2[_0x185f('0x34')]=qs[_0x185f('0x2a')](_[_0x185f('0x35')](_0x38f202[_0x185f('0x29')],_0x27f791[_0x185f('0x2a')]));if(_0x38f202[_0x185f('0x29')][_0x185f('0x36')]){_0x595cc2['where']=_[_0x185f('0x37')](_0x595cc2[_0x185f('0x34')],{'$or':_[_0x185f('0x38')](_0xe22a4d,function(_0x589b15){if(_0x589b15[_0x185f('0x39')][_0x185f('0x3a')]!=='VIRTUAL'){var _0x194665={};_0x194665[_0x589b15[_0x185f('0x3b')]]={'$like':'%'+_0x38f202[_0x185f('0x29')][_0x185f('0x36')]+'%'};return _0x194665;}})});}_0x595cc2=_[_0x185f('0x37')]({},_0x595cc2,_0x38f202[_0x185f('0x3c')]);var _0x95fa16={'where':_0x595cc2[_0x185f('0x34')]};return db[_0x185f('0x26')][_0x185f('0x17')](_0x95fa16)[_0x185f('0x1e')](function(_0x81dd2f){_0x1b2f0c['count']=_0x81dd2f;if(_0x38f202[_0x185f('0x29')][_0x185f('0x3d')]){_0x595cc2['include']=[{'all':!![]}];}return db[_0x185f('0x26')][_0x185f('0x3e')](_0x595cc2);})[_0x185f('0x1e')](function(_0x40e1e2){_0x1b2f0c[_0x185f('0x3f')]=_0x40e1e2;return _0x1b2f0c;})[_0x185f('0x1e')](respondWithFilteredResult(_0x152b48,_0x595cc2))[_0x185f('0x40')](handleError(_0x152b48,null));};exports[_0x185f('0x41')]=function(_0x19c776,_0x158a1b){var _0x41e497={'raw':!![],'where':{'id':_0x19c776[_0x185f('0x42')]['id']}},_0x34c786={};_0x34c786['model']=_[_0x185f('0x28')](db['VoiceQueuesLog'][_0x185f('0x27')]);_0x34c786[_0x185f('0x29')]=_[_0x185f('0x28')](_0x19c776[_0x185f('0x29')]);_0x34c786[_0x185f('0x2a')]=_['intersection'](_0x34c786[_0x185f('0x2c')],_0x34c786[_0x185f('0x29')]);_0x41e497['attributes']=_['intersection'](_0x34c786[_0x185f('0x2c')],qs[_0x185f('0x2d')](_0x19c776[_0x185f('0x29')][_0x185f('0x2d')]));_0x41e497['attributes']=_0x41e497[_0x185f('0x2e')][_0x185f('0x2f')]?_0x41e497[_0x185f('0x2e')]:_0x34c786['model'];if(_0x19c776[_0x185f('0x29')]['includeAll']){_0x41e497[_0x185f('0x43')]=[{'all':!![]}];}_0x41e497=_[_0x185f('0x37')]({},_0x41e497,_0x19c776['options']);return db['VoiceQueuesLog'][_0x185f('0x44')](_0x41e497)[_0x185f('0x1e')](handleEntityNotFound(_0x158a1b,null))['then'](respondWithResult(_0x158a1b,null))[_0x185f('0x40')](handleError(_0x158a1b,null));};exports[_0x185f('0x45')]=function(_0x42b0aa,_0x100568){return db[_0x185f('0x26')]['create'](_0x42b0aa[_0x185f('0x46')],{})[_0x185f('0x1e')](respondWithResult(_0x100568,0xc9))['catch'](handleError(_0x100568,null));};exports[_0x185f('0x47')]=function(_0x1b6d4b,_0xed16d2){if(_0x1b6d4b['body']['id']){delete _0x1b6d4b[_0x185f('0x46')]['id'];}return db['VoiceQueuesLog'][_0x185f('0x44')]({'where':{'id':_0x1b6d4b[_0x185f('0x42')]['id']}})[_0x185f('0x1e')](handleEntityNotFound(_0xed16d2,null))['then'](saveUpdates(_0x1b6d4b['body'],null))[_0x185f('0x1e')](respondWithResult(_0xed16d2,null))['catch'](handleError(_0xed16d2,null));};exports[_0x185f('0x1f')]=function(_0x1a5a2b,_0x436261){return db[_0x185f('0x26')][_0x185f('0x44')]({'where':{'id':_0x1a5a2b[_0x185f('0x42')]['id']}})[_0x185f('0x1e')](handleEntityNotFound(_0x436261,null))[_0x185f('0x1e')](removeEntity(_0x436261,null))[_0x185f('0x40')](handleError(_0x436261,null));};