Built motion from commit (unavailable).|2.3.93
[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 _0x20b1=['reject','save','update','destroy','stack','name','send','VoiceQueuesLog','rawAttributes','keys','query','filters','intersection','model','attributes','length','hasOwnProperty','limit','order','sort','pick','filter','where','merge','map','type','key','VIRTUAL','field','options','count','then','includeAll','include','findAll','rows','catch','show','fields','find','create','body','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','util','sox','to-csv','ejs','lodash','squel','crypto','desk.js','papaparse','../../components/auth/service','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','set','Content-Range','apply'];(function(_0x250071,_0x301941){var _0x34e574=function(_0x567186){while(--_0x567186){_0x250071['push'](_0x250071['shift']());}};_0x34e574(++_0x301941);}(_0x20b1,0x197));var _0x120b=function(_0xc02d2c,_0x315be4){_0xc02d2c=_0xc02d2c-0x0;var _0x4b6557=_0x20b1[_0xc02d2c];return _0x4b6557;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x120b('0x0'));var rimraf=require(_0x120b('0x1'));var zipdir=require(_0x120b('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x120b('0x3'));var moment=require(_0x120b('0x4'));var BPromise=require(_0x120b('0x5'));var Mustache=require('mustache');var util=require(_0x120b('0x6'));var path=require('path');var sox=require(_0x120b('0x7'));var csv=require(_0x120b('0x8'));var ejs=require(_0x120b('0x9'));var fs=require('fs');var _=require(_0x120b('0xa'));var squel=require(_0x120b('0xb'));var crypto=require(_0x120b('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x120b('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x120b('0xe'));var authService=require(_0x120b('0xf'));var hardwareService=require('../../config/license/hardware');var Redis=require(_0x120b('0x10'));var qs=require(_0x120b('0x11'));var logger=require(_0x120b('0x12'))(_0x120b('0x13'));var utils=require(_0x120b('0x14'));var config=require(_0x120b('0x15'));var db=require(_0x120b('0x16'))['db'];function respondWithStatusCode(_0x19f268,_0x14ae8e){_0x14ae8e=_0x14ae8e||0xcc;return function(_0x477120){if(_0x477120){return _0x19f268[_0x120b('0x17')](_0x14ae8e);}return _0x19f268[_0x120b('0x18')](_0x14ae8e)[_0x120b('0x19')]();};}function respondWithResult(_0x2d8509,_0x45a08c){_0x45a08c=_0x45a08c||0xc8;return function(_0x21b897){if(_0x21b897){return _0x2d8509[_0x120b('0x18')](_0x45a08c)[_0x120b('0x1a')](_0x21b897);}};}function respondWithFilteredResult(_0x57c317,_0x36cc22){return function(_0x3e0e6c){if(_0x3e0e6c){var _0xca4be5=_0x3e0e6c['count'],_0x3b5da7=_0x36cc22[_0x120b('0x1b')],_0x4e574a=_0x36cc22[_0x120b('0x1b')]+_0x36cc22['limit'],_0x2ea4ba;if(_0x4e574a>=_0xca4be5){_0x4e574a=_0xca4be5;_0x2ea4ba=0xc8;}else{_0x2ea4ba=0xce;}_0x57c317['status'](_0x2ea4ba);return _0x57c317[_0x120b('0x1c')](_0x120b('0x1d'),_0x3b5da7+'-'+_0x4e574a+'/'+_0xca4be5)[_0x120b('0x1a')](_0x3e0e6c);}return null;};}function patchUpdates(_0xae20b0){return function(_0x745484){try{jsonpatch[_0x120b('0x1e')](_0x745484,_0xae20b0,!![]);}catch(_0x25a597){return BPromise[_0x120b('0x1f')](_0x25a597);}return _0x745484[_0x120b('0x20')]();};}function saveUpdates(_0x83cf87,_0x17f5c0){return function(_0x595e78){if(_0x595e78){return _0x595e78[_0x120b('0x21')](_0x83cf87)['then'](function(_0xb82cc9){return _0xb82cc9;});}return null;};}function removeEntity(_0x4a0447,_0x160ee4){return function(_0x12fc85){if(_0x12fc85){return _0x12fc85[_0x120b('0x22')]()['then'](function(){_0x4a0447['status'](0xcc)[_0x120b('0x19')]();});}};}function handleEntityNotFound(_0x3a93b3,_0xfed6c9){return function(_0x4ca45b){if(!_0x4ca45b){_0x3a93b3[_0x120b('0x17')](0x194);}return _0x4ca45b;};}function handleError(_0x29a2e1,_0x20048c){_0x20048c=_0x20048c||0x1f4;return function(_0x25bb91){logger['error'](_0x25bb91[_0x120b('0x23')]);if(_0x25bb91[_0x120b('0x24')]){delete _0x25bb91[_0x120b('0x24')];}_0x29a2e1[_0x120b('0x18')](_0x20048c)[_0x120b('0x25')](_0x25bb91);};}exports['index']=function(_0x3d12c4,_0x3cbe90){var _0x4df986={},_0x59a042={},_0x1266a7={'count':0x0,'rows':[]};var _0x3c8d37=db[_0x120b('0x26')][_0x120b('0x27')];_0x59a042['model']=_[_0x120b('0x28')](_0x3c8d37);_0x59a042[_0x120b('0x29')]=_[_0x120b('0x28')](_0x3d12c4['query']);_0x59a042[_0x120b('0x2a')]=_[_0x120b('0x2b')](_0x59a042[_0x120b('0x2c')],_0x59a042[_0x120b('0x29')]);_0x4df986['attributes']=_['intersection'](_0x59a042[_0x120b('0x2c')],qs['fields'](_0x3d12c4[_0x120b('0x29')]['fields']));_0x4df986[_0x120b('0x2d')]=_0x4df986[_0x120b('0x2d')][_0x120b('0x2e')]?_0x4df986[_0x120b('0x2d')]:_0x59a042['model'];if(!_0x3d12c4[_0x120b('0x29')][_0x120b('0x2f')]('nolimit')){_0x4df986[_0x120b('0x30')]=qs[_0x120b('0x30')](_0x3d12c4[_0x120b('0x29')][_0x120b('0x30')]);_0x4df986[_0x120b('0x1b')]=qs['offset'](_0x3d12c4[_0x120b('0x29')][_0x120b('0x1b')]);}_0x4df986[_0x120b('0x31')]=qs[_0x120b('0x32')](_0x3d12c4[_0x120b('0x29')][_0x120b('0x32')]);_0x4df986['where']=qs[_0x120b('0x2a')](_[_0x120b('0x33')](_0x3d12c4[_0x120b('0x29')],_0x59a042[_0x120b('0x2a')]));if(_0x3d12c4['query'][_0x120b('0x34')]){_0x4df986[_0x120b('0x35')]=_[_0x120b('0x36')](_0x4df986[_0x120b('0x35')],{'$or':_[_0x120b('0x37')](_0x3c8d37,function(_0x16c2f1){if(_0x16c2f1[_0x120b('0x38')][_0x120b('0x39')]!==_0x120b('0x3a')){var _0x324796={};_0x324796[_0x16c2f1[_0x120b('0x3b')]]={'$like':'%'+_0x3d12c4[_0x120b('0x29')][_0x120b('0x34')]+'%'};return _0x324796;}})});}_0x4df986=_[_0x120b('0x36')]({},_0x4df986,_0x3d12c4[_0x120b('0x3c')]);var _0x347361={'where':_0x4df986[_0x120b('0x35')]};return db[_0x120b('0x26')][_0x120b('0x3d')](_0x347361)[_0x120b('0x3e')](function(_0xe8ab64){_0x1266a7[_0x120b('0x3d')]=_0xe8ab64;if(_0x3d12c4['query'][_0x120b('0x3f')]){_0x4df986[_0x120b('0x40')]=[{'all':!![]}];}return db[_0x120b('0x26')][_0x120b('0x41')](_0x4df986);})[_0x120b('0x3e')](function(_0xf62a37){_0x1266a7[_0x120b('0x42')]=_0xf62a37;return _0x1266a7;})['then'](respondWithFilteredResult(_0x3cbe90,_0x4df986))[_0x120b('0x43')](handleError(_0x3cbe90,null));};exports[_0x120b('0x44')]=function(_0x5da08b,_0x371b4f){var _0x3f69f2={'raw':!![],'where':{'id':_0x5da08b['params']['id']}},_0x2c137c={};_0x2c137c[_0x120b('0x2c')]=_[_0x120b('0x28')](db[_0x120b('0x26')][_0x120b('0x27')]);_0x2c137c['query']=_[_0x120b('0x28')](_0x5da08b[_0x120b('0x29')]);_0x2c137c[_0x120b('0x2a')]=_[_0x120b('0x2b')](_0x2c137c['model'],_0x2c137c[_0x120b('0x29')]);_0x3f69f2[_0x120b('0x2d')]=_[_0x120b('0x2b')](_0x2c137c[_0x120b('0x2c')],qs[_0x120b('0x45')](_0x5da08b[_0x120b('0x29')][_0x120b('0x45')]));_0x3f69f2[_0x120b('0x2d')]=_0x3f69f2['attributes'][_0x120b('0x2e')]?_0x3f69f2['attributes']:_0x2c137c[_0x120b('0x2c')];if(_0x5da08b[_0x120b('0x29')][_0x120b('0x3f')]){_0x3f69f2[_0x120b('0x40')]=[{'all':!![]}];}_0x3f69f2=_[_0x120b('0x36')]({},_0x3f69f2,_0x5da08b[_0x120b('0x3c')]);return db[_0x120b('0x26')][_0x120b('0x46')](_0x3f69f2)[_0x120b('0x3e')](handleEntityNotFound(_0x371b4f,null))['then'](respondWithResult(_0x371b4f,null))[_0x120b('0x43')](handleError(_0x371b4f,null));};exports[_0x120b('0x47')]=function(_0x4f7687,_0x439b8e){return db[_0x120b('0x26')][_0x120b('0x47')](_0x4f7687[_0x120b('0x48')],{})[_0x120b('0x3e')](respondWithResult(_0x439b8e,0xc9))[_0x120b('0x43')](handleError(_0x439b8e,null));};exports['update']=function(_0x41b801,_0x3118e0){if(_0x41b801[_0x120b('0x48')]['id']){delete _0x41b801[_0x120b('0x48')]['id'];}return db['VoiceQueuesLog'][_0x120b('0x46')]({'where':{'id':_0x41b801['params']['id']}})[_0x120b('0x3e')](handleEntityNotFound(_0x3118e0,null))[_0x120b('0x3e')](saveUpdates(_0x41b801[_0x120b('0x48')],null))[_0x120b('0x3e')](respondWithResult(_0x3118e0,null))[_0x120b('0x43')](handleError(_0x3118e0,null));};exports['destroy']=function(_0x4729dc,_0x170d94){return db[_0x120b('0x26')][_0x120b('0x46')]({'where':{'id':_0x4729dc['params']['id']}})[_0x120b('0x3e')](handleEntityNotFound(_0x170d94,null))[_0x120b('0x3e')](removeEntity(_0x170d94,null))[_0x120b('0x43')](handleError(_0x170d94,null));};