Built motion from commit 911eb874.|2.6.31
[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 _0xf15f=['../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','limit','count','set','save','then','sendStatus','error','name','index','VoiceQueuesLog','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','filter','merge','VIRTUAL','includeAll','findAll','rows','catch','show','params','include','options','find','update','body','destroy','eml-format','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','crypto','jsforce','desk.js','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api'];(function(_0x3eb932,_0x332c06){var _0x1ee879=function(_0x58e991){while(--_0x58e991){_0x3eb932['push'](_0x3eb932['shift']());}};_0x1ee879(++_0x332c06);}(_0xf15f,0x10b));var _0xff15=function(_0x580576,_0x2f107d){_0x580576=_0x580576-0x0;var _0x3f55a0=_0xf15f[_0x580576];return _0x3f55a0;};'use strict';var emlformat=require(_0xff15('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xff15('0x1'));var jsonpatch=require(_0xff15('0x2'));var rp=require('request-promise');var moment=require(_0xff15('0x3'));var BPromise=require(_0xff15('0x4'));var Mustache=require(_0xff15('0x5'));var util=require(_0xff15('0x6'));var path=require(_0xff15('0x7'));var sox=require(_0xff15('0x8'));var csv=require(_0xff15('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xff15('0xa'));var _=require(_0xff15('0xb'));var squel=require('squel');var crypto=require(_0xff15('0xc'));var jsforce=require(_0xff15('0xd'));var deskjs=require(_0xff15('0xe'));var toCsv=require(_0xff15('0x9'));var querystring=require(_0xff15('0xf'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xff15('0x10'));var qs=require(_0xff15('0x11'));var as=require(_0xff15('0x12'));var hardwareService=require(_0xff15('0x13'));var logger=require('../../config/logger')(_0xff15('0x14'));var utils=require(_0xff15('0x15'));var config=require(_0xff15('0x16'));var licenseUtil=require(_0xff15('0x17'));var db=require(_0xff15('0x18'))['db'];function respondWithStatusCode(_0x43b344,_0x265134){_0x265134=_0x265134||0xcc;return function(_0x1afc02){if(_0x1afc02){return _0x43b344['sendStatus'](_0x265134);}return _0x43b344[_0xff15('0x19')](_0x265134)[_0xff15('0x1a')]();};}function respondWithResult(_0x20be72,_0x471f1a){_0x471f1a=_0x471f1a||0xc8;return function(_0x79d156){if(_0x79d156){return _0x20be72[_0xff15('0x19')](_0x471f1a)[_0xff15('0x1b')](_0x79d156);}};}function respondWithFilteredResult(_0x37bc6a,_0x2568fd){return function(_0x5bec5f){if(_0x5bec5f){var _0x465c07=typeof _0x2568fd[_0xff15('0x1c')]===_0xff15('0x1d')&&typeof _0x2568fd[_0xff15('0x1e')]==='undefined';var _0x2dc0c7=_0x5bec5f[_0xff15('0x1f')];var _0x3a0fd4=_0x465c07?0x0:_0x2568fd[_0xff15('0x1c')];var _0x3592c3=_0x465c07?_0x5bec5f[_0xff15('0x1f')]:_0x2568fd[_0xff15('0x1c')]+_0x2568fd[_0xff15('0x1e')];var _0x5f4d59;if(_0x3592c3>=_0x2dc0c7){_0x3592c3=_0x2dc0c7;_0x5f4d59=0xc8;}else{_0x5f4d59=0xce;}_0x37bc6a[_0xff15('0x19')](_0x5f4d59);return _0x37bc6a[_0xff15('0x20')]('Content-Range',_0x3a0fd4+'-'+_0x3592c3+'/'+_0x2dc0c7)['json'](_0x5bec5f);}return null;};}function patchUpdates(_0x1eb880){return function(_0x279918){try{jsonpatch['apply'](_0x279918,_0x1eb880,!![]);}catch(_0x502ffd){return BPromise['reject'](_0x502ffd);}return _0x279918[_0xff15('0x21')]();};}function saveUpdates(_0x3c09c1,_0x35df8){return function(_0xf4fbfa){if(_0xf4fbfa){return _0xf4fbfa['update'](_0x3c09c1)[_0xff15('0x22')](function(_0x11ed45){return _0x11ed45;});}return null;};}function removeEntity(_0x2f0db2,_0xc6b980){return function(_0x227ead){if(_0x227ead){return _0x227ead['destroy']()[_0xff15('0x22')](function(){_0x2f0db2[_0xff15('0x19')](0xcc)[_0xff15('0x1a')]();});}};}function handleEntityNotFound(_0x365e77,_0x50a988){return function(_0x431252){if(!_0x431252){_0x365e77[_0xff15('0x23')](0x194);}return _0x431252;};}function handleError(_0x33913e,_0x11fa7d){_0x11fa7d=_0x11fa7d||0x1f4;return function(_0xf4b9b2){logger[_0xff15('0x24')](_0xf4b9b2['stack']);if(_0xf4b9b2[_0xff15('0x25')]){delete _0xf4b9b2['name'];}_0x33913e['status'](_0x11fa7d)['send'](_0xf4b9b2);};}exports[_0xff15('0x26')]=function(_0x338281,_0x224b7e){var _0x1beae2={},_0x17e00a={},_0xdb6bcb={'count':0x0,'rows':[]};var _0x585c66=_['map'](db[_0xff15('0x27')][_0xff15('0x28')],function(_0x2562c6){return{'name':_0x2562c6[_0xff15('0x29')],'type':_0x2562c6[_0xff15('0x2a')][_0xff15('0x2b')]};});_0x17e00a[_0xff15('0x2c')]=_[_0xff15('0x2d')](_0x585c66,_0xff15('0x25'));_0x17e00a[_0xff15('0x2e')]=_[_0xff15('0x2f')](_0x338281[_0xff15('0x2e')]);_0x17e00a[_0xff15('0x30')]=_[_0xff15('0x31')](_0x17e00a[_0xff15('0x2c')],_0x17e00a[_0xff15('0x2e')]);_0x1beae2[_0xff15('0x32')]=_[_0xff15('0x31')](_0x17e00a[_0xff15('0x2c')],qs[_0xff15('0x33')](_0x338281[_0xff15('0x2e')][_0xff15('0x33')]));_0x1beae2[_0xff15('0x32')]=_0x1beae2[_0xff15('0x32')][_0xff15('0x34')]?_0x1beae2[_0xff15('0x32')]:_0x17e00a[_0xff15('0x2c')];if(!_0x338281[_0xff15('0x2e')][_0xff15('0x35')]('nolimit')){_0x1beae2[_0xff15('0x1e')]=qs[_0xff15('0x1e')](_0x338281[_0xff15('0x2e')][_0xff15('0x1e')]);_0x1beae2[_0xff15('0x1c')]=qs[_0xff15('0x1c')](_0x338281[_0xff15('0x2e')][_0xff15('0x1c')]);}_0x1beae2[_0xff15('0x36')]=qs['sort'](_0x338281[_0xff15('0x2e')][_0xff15('0x37')]);_0x1beae2[_0xff15('0x38')]=qs[_0xff15('0x30')](_['pick'](_0x338281[_0xff15('0x2e')],_0x17e00a['filters']),_0x585c66);if(_0x338281[_0xff15('0x2e')][_0xff15('0x39')]){_0x1beae2[_0xff15('0x38')]=_[_0xff15('0x3a')](_0x1beae2[_0xff15('0x38')],{'$or':_[_0xff15('0x2d')](_0x585c66,function(_0x2ff375){if(_0x2ff375[_0xff15('0x2a')]!==_0xff15('0x3b')){var _0x572760={};_0x572760[_0x2ff375[_0xff15('0x25')]]={'$like':'%'+_0x338281[_0xff15('0x2e')][_0xff15('0x39')]+'%'};return _0x572760;}})});}_0x1beae2=_[_0xff15('0x3a')]({},_0x1beae2,_0x338281['options']);var _0x14b04b={'where':_0x1beae2['where']};return db[_0xff15('0x27')][_0xff15('0x1f')](_0x14b04b)[_0xff15('0x22')](function(_0xa61448){_0xdb6bcb[_0xff15('0x1f')]=_0xa61448;if(_0x338281['query'][_0xff15('0x3c')]){_0x1beae2['include']=[{'all':!![]}];}return db[_0xff15('0x27')][_0xff15('0x3d')](_0x1beae2);})[_0xff15('0x22')](function(_0x1d5732){_0xdb6bcb[_0xff15('0x3e')]=_0x1d5732;return _0xdb6bcb;})[_0xff15('0x22')](respondWithFilteredResult(_0x224b7e,_0x1beae2))[_0xff15('0x3f')](handleError(_0x224b7e,null));};exports[_0xff15('0x40')]=function(_0x5761fa,_0x418713){var _0xfe5847={'raw':!![],'where':{'id':_0x5761fa[_0xff15('0x41')]['id']}},_0x4c1fa1={};_0x4c1fa1[_0xff15('0x2c')]=_[_0xff15('0x2f')](db[_0xff15('0x27')][_0xff15('0x28')]);_0x4c1fa1[_0xff15('0x2e')]=_[_0xff15('0x2f')](_0x5761fa[_0xff15('0x2e')]);_0x4c1fa1[_0xff15('0x30')]=_['intersection'](_0x4c1fa1['model'],_0x4c1fa1[_0xff15('0x2e')]);_0xfe5847[_0xff15('0x32')]=_[_0xff15('0x31')](_0x4c1fa1[_0xff15('0x2c')],qs['fields'](_0x5761fa[_0xff15('0x2e')][_0xff15('0x33')]));_0xfe5847[_0xff15('0x32')]=_0xfe5847[_0xff15('0x32')][_0xff15('0x34')]?_0xfe5847[_0xff15('0x32')]:_0x4c1fa1[_0xff15('0x2c')];if(_0x5761fa['query'][_0xff15('0x3c')]){_0xfe5847[_0xff15('0x42')]=[{'all':!![]}];}_0xfe5847=_[_0xff15('0x3a')]({},_0xfe5847,_0x5761fa[_0xff15('0x43')]);return db['VoiceQueuesLog'][_0xff15('0x44')](_0xfe5847)[_0xff15('0x22')](handleEntityNotFound(_0x418713,null))[_0xff15('0x22')](respondWithResult(_0x418713,null))['catch'](handleError(_0x418713,null));};exports['create']=function(_0x4ca435,_0x3e7818){return db['VoiceQueuesLog']['create'](_0x4ca435['body'],{})[_0xff15('0x22')](respondWithResult(_0x3e7818,0xc9))['catch'](handleError(_0x3e7818,null));};exports[_0xff15('0x45')]=function(_0x452a87,_0x317c0a){if(_0x452a87[_0xff15('0x46')]['id']){delete _0x452a87[_0xff15('0x46')]['id'];}return db['VoiceQueuesLog'][_0xff15('0x44')]({'where':{'id':_0x452a87[_0xff15('0x41')]['id']}})[_0xff15('0x22')](handleEntityNotFound(_0x317c0a,null))[_0xff15('0x22')](saveUpdates(_0x452a87[_0xff15('0x46')],null))[_0xff15('0x22')](respondWithResult(_0x317c0a,null))['catch'](handleError(_0x317c0a,null));};exports[_0xff15('0x47')]=function(_0x15f0f2,_0x17fc47){return db[_0xff15('0x27')][_0xff15('0x44')]({'where':{'id':_0x15f0f2[_0xff15('0x41')]['id']}})[_0xff15('0x22')](handleEntityNotFound(_0x17fc47,null))[_0xff15('0x22')](removeEntity(_0x17fc47,null))['catch'](handleError(_0x17fc47,null));};