Built motion from commit da617fac.|2.6.6
[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 _0xc09d=['keys','filters','intersection','attributes','model','fields','query','length','hasOwnProperty','nolimit','offset','order','sort','where','filter','merge','includeAll','include','VoiceQueuesLog','findAll','rows','catch','params','find','create','body','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','undefined','limit','count','Content-Range','apply','reject','save','update','then','error','stack','name','index','map','rawAttributes','fieldName','type','key'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xc09d,0xfe));var _0xdc09=function(_0x544b1f,_0x260880){_0x544b1f=_0x544b1f-0x0;var _0x20c4c6=_0xc09d[_0x544b1f];return _0x20c4c6;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xdc09('0x0'));var zipdir=require(_0xdc09('0x1'));var jsonpatch=require(_0xdc09('0x2'));var rp=require(_0xdc09('0x3'));var moment=require(_0xdc09('0x4'));var BPromise=require(_0xdc09('0x5'));var Mustache=require(_0xdc09('0x6'));var util=require(_0xdc09('0x7'));var path=require(_0xdc09('0x8'));var sox=require('sox');var csv=require(_0xdc09('0x9'));var ejs=require(_0xdc09('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xdc09('0xb'));var squel=require(_0xdc09('0xc'));var crypto=require(_0xdc09('0xd'));var jsforce=require(_0xdc09('0xe'));var deskjs=require(_0xdc09('0xf'));var toCsv=require('to-csv');var querystring=require(_0xdc09('0x10'));var Papa=require(_0xdc09('0x11'));var Redis=require(_0xdc09('0x12'));var authService=require(_0xdc09('0x13'));var qs=require(_0xdc09('0x14'));var as=require(_0xdc09('0x15'));var hardwareService=require(_0xdc09('0x16'));var logger=require(_0xdc09('0x17'))('api');var utils=require(_0xdc09('0x18'));var config=require(_0xdc09('0x19'));var licenseUtil=require(_0xdc09('0x1a'));var db=require(_0xdc09('0x1b'))['db'];function respondWithStatusCode(_0x516d46,_0x372218){_0x372218=_0x372218||0xcc;return function(_0x2bfcd3){if(_0x2bfcd3){return _0x516d46[_0xdc09('0x1c')](_0x372218);}return _0x516d46[_0xdc09('0x1d')](_0x372218)[_0xdc09('0x1e')]();};}function respondWithResult(_0x42d5b8,_0x360a3a){_0x360a3a=_0x360a3a||0xc8;return function(_0xf1601){if(_0xf1601){return _0x42d5b8['status'](_0x360a3a)[_0xdc09('0x1f')](_0xf1601);}};}function respondWithFilteredResult(_0xde7113,_0x457b80){return function(_0xd868c5){if(_0xd868c5){var _0x1d068e=typeof _0x457b80['offset']===_0xdc09('0x20')&&typeof _0x457b80[_0xdc09('0x21')]===_0xdc09('0x20');var _0x3a9141=_0xd868c5['count'];var _0x2656fb=_0x1d068e?0x0:_0x457b80['offset'];var _0xae9f72=_0x1d068e?_0xd868c5[_0xdc09('0x22')]:_0x457b80['offset']+_0x457b80[_0xdc09('0x21')];var _0x4bd473;if(_0xae9f72>=_0x3a9141){_0xae9f72=_0x3a9141;_0x4bd473=0xc8;}else{_0x4bd473=0xce;}_0xde7113[_0xdc09('0x1d')](_0x4bd473);return _0xde7113['set'](_0xdc09('0x23'),_0x2656fb+'-'+_0xae9f72+'/'+_0x3a9141)[_0xdc09('0x1f')](_0xd868c5);}return null;};}function patchUpdates(_0x53f714){return function(_0x1d2e53){try{jsonpatch[_0xdc09('0x24')](_0x1d2e53,_0x53f714,!![]);}catch(_0x31e132){return BPromise[_0xdc09('0x25')](_0x31e132);}return _0x1d2e53[_0xdc09('0x26')]();};}function saveUpdates(_0x3f4301,_0x25f5b2){return function(_0x184d67){if(_0x184d67){return _0x184d67[_0xdc09('0x27')](_0x3f4301)[_0xdc09('0x28')](function(_0x24b171){return _0x24b171;});}return null;};}function removeEntity(_0xe91317,_0x63f875){return function(_0x31f070){if(_0x31f070){return _0x31f070['destroy']()[_0xdc09('0x28')](function(){_0xe91317[_0xdc09('0x1d')](0xcc)[_0xdc09('0x1e')]();});}};}function handleEntityNotFound(_0x2fffaa,_0x3737f9){return function(_0x417075){if(!_0x417075){_0x2fffaa[_0xdc09('0x1c')](0x194);}return _0x417075;};}function handleError(_0x433a88,_0x27c6fb){_0x27c6fb=_0x27c6fb||0x1f4;return function(_0x1b6826){logger[_0xdc09('0x29')](_0x1b6826[_0xdc09('0x2a')]);if(_0x1b6826[_0xdc09('0x2b')]){delete _0x1b6826[_0xdc09('0x2b')];}_0x433a88[_0xdc09('0x1d')](_0x27c6fb)['send'](_0x1b6826);};}exports[_0xdc09('0x2c')]=function(_0x296367,_0x5f49eb){var _0x599dbd={},_0x2e5886={},_0x2e9486={'count':0x0,'rows':[]};var _0xd6be12=_[_0xdc09('0x2d')](db['VoiceQueuesLog'][_0xdc09('0x2e')],function(_0x1c7013){return{'name':_0x1c7013[_0xdc09('0x2f')],'type':_0x1c7013[_0xdc09('0x30')][_0xdc09('0x31')]};});_0x2e5886['model']=_['map'](_0xd6be12,_0xdc09('0x2b'));_0x2e5886['query']=_[_0xdc09('0x32')](_0x296367['query']);_0x2e5886[_0xdc09('0x33')]=_[_0xdc09('0x34')](_0x2e5886['model'],_0x2e5886['query']);_0x599dbd[_0xdc09('0x35')]=_[_0xdc09('0x34')](_0x2e5886[_0xdc09('0x36')],qs[_0xdc09('0x37')](_0x296367[_0xdc09('0x38')][_0xdc09('0x37')]));_0x599dbd['attributes']=_0x599dbd[_0xdc09('0x35')][_0xdc09('0x39')]?_0x599dbd[_0xdc09('0x35')]:_0x2e5886[_0xdc09('0x36')];if(!_0x296367['query'][_0xdc09('0x3a')](_0xdc09('0x3b'))){_0x599dbd['limit']=qs[_0xdc09('0x21')](_0x296367['query'][_0xdc09('0x21')]);_0x599dbd[_0xdc09('0x3c')]=qs[_0xdc09('0x3c')](_0x296367[_0xdc09('0x38')][_0xdc09('0x3c')]);}_0x599dbd[_0xdc09('0x3d')]=qs[_0xdc09('0x3e')](_0x296367[_0xdc09('0x38')][_0xdc09('0x3e')]);_0x599dbd[_0xdc09('0x3f')]=qs[_0xdc09('0x33')](_['pick'](_0x296367[_0xdc09('0x38')],_0x2e5886['filters']),_0xd6be12);if(_0x296367[_0xdc09('0x38')][_0xdc09('0x40')]){_0x599dbd[_0xdc09('0x3f')]=_['merge'](_0x599dbd[_0xdc09('0x3f')],{'$or':_['map'](_0xd6be12,function(_0x176b0b){if(_0x176b0b[_0xdc09('0x30')]!=='VIRTUAL'){var _0x49297b={};_0x49297b[_0x176b0b['name']]={'$like':'%'+_0x296367[_0xdc09('0x38')][_0xdc09('0x40')]+'%'};return _0x49297b;}})});}_0x599dbd=_[_0xdc09('0x41')]({},_0x599dbd,_0x296367['options']);var _0x4f2a0b={'where':_0x599dbd[_0xdc09('0x3f')]};return db['VoiceQueuesLog'][_0xdc09('0x22')](_0x4f2a0b)['then'](function(_0x52788c){_0x2e9486[_0xdc09('0x22')]=_0x52788c;if(_0x296367['query'][_0xdc09('0x42')]){_0x599dbd[_0xdc09('0x43')]=[{'all':!![]}];}return db[_0xdc09('0x44')][_0xdc09('0x45')](_0x599dbd);})[_0xdc09('0x28')](function(_0x4ef7c4){_0x2e9486[_0xdc09('0x46')]=_0x4ef7c4;return _0x2e9486;})[_0xdc09('0x28')](respondWithFilteredResult(_0x5f49eb,_0x599dbd))[_0xdc09('0x47')](handleError(_0x5f49eb,null));};exports['show']=function(_0x223ce1,_0x597d28){var _0x29de69={'raw':!![],'where':{'id':_0x223ce1[_0xdc09('0x48')]['id']}},_0x3b275b={};_0x3b275b['model']=_[_0xdc09('0x32')](db[_0xdc09('0x44')]['rawAttributes']);_0x3b275b[_0xdc09('0x38')]=_[_0xdc09('0x32')](_0x223ce1[_0xdc09('0x38')]);_0x3b275b[_0xdc09('0x33')]=_[_0xdc09('0x34')](_0x3b275b[_0xdc09('0x36')],_0x3b275b[_0xdc09('0x38')]);_0x29de69[_0xdc09('0x35')]=_['intersection'](_0x3b275b[_0xdc09('0x36')],qs[_0xdc09('0x37')](_0x223ce1[_0xdc09('0x38')]['fields']));_0x29de69[_0xdc09('0x35')]=_0x29de69[_0xdc09('0x35')]['length']?_0x29de69[_0xdc09('0x35')]:_0x3b275b['model'];if(_0x223ce1[_0xdc09('0x38')]['includeAll']){_0x29de69[_0xdc09('0x43')]=[{'all':!![]}];}_0x29de69=_['merge']({},_0x29de69,_0x223ce1['options']);return db[_0xdc09('0x44')][_0xdc09('0x49')](_0x29de69)[_0xdc09('0x28')](handleEntityNotFound(_0x597d28,null))['then'](respondWithResult(_0x597d28,null))['catch'](handleError(_0x597d28,null));};exports[_0xdc09('0x4a')]=function(_0x1d0e1f,_0x4d3a7c){return db[_0xdc09('0x44')][_0xdc09('0x4a')](_0x1d0e1f[_0xdc09('0x4b')],{})[_0xdc09('0x28')](respondWithResult(_0x4d3a7c,0xc9))[_0xdc09('0x47')](handleError(_0x4d3a7c,null));};exports[_0xdc09('0x27')]=function(_0x52d907,_0x141301){if(_0x52d907['body']['id']){delete _0x52d907[_0xdc09('0x4b')]['id'];}return db[_0xdc09('0x44')]['find']({'where':{'id':_0x52d907[_0xdc09('0x48')]['id']}})['then'](handleEntityNotFound(_0x141301,null))['then'](saveUpdates(_0x52d907[_0xdc09('0x4b')],null))['then'](respondWithResult(_0x141301,null))['catch'](handleError(_0x141301,null));};exports['destroy']=function(_0x11135d,_0x47996e){return db[_0xdc09('0x44')][_0xdc09('0x49')]({'where':{'id':_0x11135d['params']['id']}})[_0xdc09('0x28')](handleEntityNotFound(_0x47996e,null))[_0xdc09('0x28')](removeEntity(_0x47996e,null))[_0xdc09('0x47')](handleError(_0x47996e,null));};