Built motion from commit (unavailable).|2.5.25
[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 _0xfcf9=['../../config/license/util','../../mysqldb','sendStatus','status','end','json','count','offset','set','Content-Range','reject','save','update','then','destroy','name','index','VoiceQueuesLog','rawAttributes','type','key','model','query','keys','filters','intersection','fields','attributes','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','map','VIRTUAL','options','includeAll','include','catch','body','find','params','html-pdf','eml-format','rimraf','request-promise','bluebird','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/parsers/advancedSearch','api'];(function(_0x28da54,_0x92c496){var _0x3eddc1=function(_0x4b099b){while(--_0x4b099b){_0x28da54['push'](_0x28da54['shift']());}};_0x3eddc1(++_0x92c496);}(_0xfcf9,0x1ae));var _0x9fcf=function(_0x48bce7,_0x2fb44c){_0x48bce7=_0x48bce7-0x0;var _0x3925a6=_0xfcf9[_0x48bce7];return _0x3925a6;};'use strict';var pdf=require(_0x9fcf('0x0'));var emlformat=require(_0x9fcf('0x1'));var rimraf=require(_0x9fcf('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x9fcf('0x3'));var moment=require('moment');var BPromise=require(_0x9fcf('0x4'));var Mustache=require('mustache');var util=require(_0x9fcf('0x5'));var path=require(_0x9fcf('0x6'));var sox=require(_0x9fcf('0x7'));var csv=require(_0x9fcf('0x8'));var ejs=require(_0x9fcf('0x9'));var fs=require('fs');var _=require(_0x9fcf('0xa'));var squel=require(_0x9fcf('0xb'));var crypto=require('crypto');var jsforce=require(_0x9fcf('0xc'));var deskjs=require(_0x9fcf('0xd'));var toCsv=require(_0x9fcf('0x8'));var querystring=require('querystring');var Papa=require(_0x9fcf('0xe'));var Redis=require(_0x9fcf('0xf'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x9fcf('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x9fcf('0x11'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x9fcf('0x12'));var db=require(_0x9fcf('0x13'))['db'];function respondWithStatusCode(_0x5618a0,_0x1f092b){_0x1f092b=_0x1f092b||0xcc;return function(_0x4dd6ba){if(_0x4dd6ba){return _0x5618a0[_0x9fcf('0x14')](_0x1f092b);}return _0x5618a0[_0x9fcf('0x15')](_0x1f092b)[_0x9fcf('0x16')]();};}function respondWithResult(_0x33dcc4,_0x4a51d6){_0x4a51d6=_0x4a51d6||0xc8;return function(_0x27d5fd){if(_0x27d5fd){return _0x33dcc4[_0x9fcf('0x15')](_0x4a51d6)[_0x9fcf('0x17')](_0x27d5fd);}};}function respondWithFilteredResult(_0x3770de,_0x421b09){return function(_0x2098ba){if(_0x2098ba){var _0x326bab=_0x2098ba[_0x9fcf('0x18')],_0x16361e=_0x421b09[_0x9fcf('0x19')],_0x1629f0=_0x421b09['offset']+_0x421b09['limit'],_0x8c9f32;if(_0x1629f0>=_0x326bab){_0x1629f0=_0x326bab;_0x8c9f32=0xc8;}else{_0x8c9f32=0xce;}_0x3770de[_0x9fcf('0x15')](_0x8c9f32);return _0x3770de[_0x9fcf('0x1a')](_0x9fcf('0x1b'),_0x16361e+'-'+_0x1629f0+'/'+_0x326bab)['json'](_0x2098ba);}return null;};}function patchUpdates(_0x586720){return function(_0x5c86d2){try{jsonpatch['apply'](_0x5c86d2,_0x586720,!![]);}catch(_0x4d7831){return BPromise[_0x9fcf('0x1c')](_0x4d7831);}return _0x5c86d2[_0x9fcf('0x1d')]();};}function saveUpdates(_0x561e83,_0x2e510e){return function(_0x17c08b){if(_0x17c08b){return _0x17c08b[_0x9fcf('0x1e')](_0x561e83)[_0x9fcf('0x1f')](function(_0x49a2e1){return _0x49a2e1;});}return null;};}function removeEntity(_0x17b4a2,_0x299388){return function(_0x3f120d){if(_0x3f120d){return _0x3f120d[_0x9fcf('0x20')]()[_0x9fcf('0x1f')](function(){_0x17b4a2[_0x9fcf('0x15')](0xcc)[_0x9fcf('0x16')]();});}};}function handleEntityNotFound(_0x1cb7e8,_0xe210d1){return function(_0x569be8){if(!_0x569be8){_0x1cb7e8[_0x9fcf('0x14')](0x194);}return _0x569be8;};}function handleError(_0x4b0d30,_0x2ed827){_0x2ed827=_0x2ed827||0x1f4;return function(_0x4c3df2){logger['error'](_0x4c3df2['stack']);if(_0x4c3df2[_0x9fcf('0x21')]){delete _0x4c3df2[_0x9fcf('0x21')];}_0x4b0d30[_0x9fcf('0x15')](_0x2ed827)['send'](_0x4c3df2);};}exports[_0x9fcf('0x22')]=function(_0x208318,_0x349c93){var _0xfae4db={},_0x53426b={},_0x37c3f3={'count':0x0,'rows':[]};var _0x4ecee8=_['map'](db[_0x9fcf('0x23')][_0x9fcf('0x24')],function(_0x397ac3){return{'name':_0x397ac3['fieldName'],'type':_0x397ac3[_0x9fcf('0x25')][_0x9fcf('0x26')]};});_0x53426b[_0x9fcf('0x27')]=_['map'](_0x4ecee8,_0x9fcf('0x21'));_0x53426b[_0x9fcf('0x28')]=_[_0x9fcf('0x29')](_0x208318['query']);_0x53426b[_0x9fcf('0x2a')]=_['intersection'](_0x53426b[_0x9fcf('0x27')],_0x53426b[_0x9fcf('0x28')]);_0xfae4db['attributes']=_[_0x9fcf('0x2b')](_0x53426b[_0x9fcf('0x27')],qs[_0x9fcf('0x2c')](_0x208318[_0x9fcf('0x28')]['fields']));_0xfae4db[_0x9fcf('0x2d')]=_0xfae4db[_0x9fcf('0x2d')]['length']?_0xfae4db['attributes']:_0x53426b[_0x9fcf('0x27')];if(!_0x208318[_0x9fcf('0x28')][_0x9fcf('0x2e')](_0x9fcf('0x2f'))){_0xfae4db['limit']=qs[_0x9fcf('0x30')](_0x208318[_0x9fcf('0x28')][_0x9fcf('0x30')]);_0xfae4db[_0x9fcf('0x19')]=qs['offset'](_0x208318[_0x9fcf('0x28')][_0x9fcf('0x19')]);}_0xfae4db[_0x9fcf('0x31')]=qs['sort'](_0x208318[_0x9fcf('0x28')][_0x9fcf('0x32')]);_0xfae4db[_0x9fcf('0x33')]=qs[_0x9fcf('0x2a')](_[_0x9fcf('0x34')](_0x208318[_0x9fcf('0x28')],_0x53426b[_0x9fcf('0x2a')]),_0x4ecee8);if(_0x208318[_0x9fcf('0x28')][_0x9fcf('0x35')]){_0xfae4db['where']=_[_0x9fcf('0x36')](_0xfae4db[_0x9fcf('0x33')],{'$or':_[_0x9fcf('0x37')](_0x4ecee8,function(_0x2535ac){if(_0x2535ac[_0x9fcf('0x25')]!==_0x9fcf('0x38')){var _0x4e9da0={};_0x4e9da0[_0x2535ac[_0x9fcf('0x21')]]={'$like':'%'+_0x208318[_0x9fcf('0x28')][_0x9fcf('0x35')]+'%'};return _0x4e9da0;}})});}_0xfae4db=_[_0x9fcf('0x36')]({},_0xfae4db,_0x208318[_0x9fcf('0x39')]);var _0x3fec31={'where':_0xfae4db[_0x9fcf('0x33')]};return db[_0x9fcf('0x23')][_0x9fcf('0x18')](_0x3fec31)[_0x9fcf('0x1f')](function(_0x50404e){_0x37c3f3[_0x9fcf('0x18')]=_0x50404e;if(_0x208318[_0x9fcf('0x28')][_0x9fcf('0x3a')]){_0xfae4db[_0x9fcf('0x3b')]=[{'all':!![]}];}return db[_0x9fcf('0x23')]['findAll'](_0xfae4db);})[_0x9fcf('0x1f')](function(_0x53e5d3){_0x37c3f3['rows']=_0x53e5d3;return _0x37c3f3;})[_0x9fcf('0x1f')](respondWithFilteredResult(_0x349c93,_0xfae4db))[_0x9fcf('0x3c')](handleError(_0x349c93,null));};exports['show']=function(_0x341ec6,_0x4197a9){var _0x8fc2b5={'raw':!![],'where':{'id':_0x341ec6['params']['id']}},_0x33e171={};_0x33e171['model']=_[_0x9fcf('0x29')](db['VoiceQueuesLog']['rawAttributes']);_0x33e171['query']=_[_0x9fcf('0x29')](_0x341ec6[_0x9fcf('0x28')]);_0x33e171[_0x9fcf('0x2a')]=_[_0x9fcf('0x2b')](_0x33e171[_0x9fcf('0x27')],_0x33e171[_0x9fcf('0x28')]);_0x8fc2b5[_0x9fcf('0x2d')]=_[_0x9fcf('0x2b')](_0x33e171['model'],qs[_0x9fcf('0x2c')](_0x341ec6[_0x9fcf('0x28')][_0x9fcf('0x2c')]));_0x8fc2b5['attributes']=_0x8fc2b5['attributes']['length']?_0x8fc2b5[_0x9fcf('0x2d')]:_0x33e171[_0x9fcf('0x27')];if(_0x341ec6[_0x9fcf('0x28')][_0x9fcf('0x3a')]){_0x8fc2b5[_0x9fcf('0x3b')]=[{'all':!![]}];}_0x8fc2b5=_[_0x9fcf('0x36')]({},_0x8fc2b5,_0x341ec6[_0x9fcf('0x39')]);return db['VoiceQueuesLog']['find'](_0x8fc2b5)[_0x9fcf('0x1f')](handleEntityNotFound(_0x4197a9,null))[_0x9fcf('0x1f')](respondWithResult(_0x4197a9,null))['catch'](handleError(_0x4197a9,null));};exports['create']=function(_0x198f89,_0x224280){return db[_0x9fcf('0x23')]['create'](_0x198f89[_0x9fcf('0x3d')],{})[_0x9fcf('0x1f')](respondWithResult(_0x224280,0xc9))[_0x9fcf('0x3c')](handleError(_0x224280,null));};exports[_0x9fcf('0x1e')]=function(_0x45b4ea,_0x370d75){if(_0x45b4ea[_0x9fcf('0x3d')]['id']){delete _0x45b4ea['body']['id'];}return db[_0x9fcf('0x23')][_0x9fcf('0x3e')]({'where':{'id':_0x45b4ea[_0x9fcf('0x3f')]['id']}})[_0x9fcf('0x1f')](handleEntityNotFound(_0x370d75,null))[_0x9fcf('0x1f')](saveUpdates(_0x45b4ea[_0x9fcf('0x3d')],null))[_0x9fcf('0x1f')](respondWithResult(_0x370d75,null))[_0x9fcf('0x3c')](handleError(_0x370d75,null));};exports[_0x9fcf('0x20')]=function(_0x11ed57,_0x243f87){return db[_0x9fcf('0x23')][_0x9fcf('0x3e')]({'where':{'id':_0x11ed57[_0x9fcf('0x3f')]['id']}})[_0x9fcf('0x1f')](handleEntityNotFound(_0x243f87,null))['then'](removeEntity(_0x243f87,null))['catch'](handleError(_0x243f87,null));};