Built motion from commit 936e8062.|2.5.33
[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 _0x13c3=['index','VoiceQueuesLog','rawAttributes','fieldName','type','key','map','keys','query','intersection','model','fields','attributes','hasOwnProperty','order','sort','where','pick','filter','VIRTUAL','merge','include','findAll','catch','show','params','filters','length','includeAll','options','create','body','find','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','count','set','Content-Range','save','update','destroy','then','error','stack','name','send'];(function(_0x5f1219,_0x4ffb35){var _0x47b8bf=function(_0x1f8923){while(--_0x1f8923){_0x5f1219['push'](_0x5f1219['shift']());}};_0x47b8bf(++_0x4ffb35);}(_0x13c3,0xb9));var _0x313c=function(_0x316500,_0x5afc5e){_0x316500=_0x316500-0x0;var _0x142eea=_0x13c3[_0x316500];return _0x142eea;};'use strict';var emlformat=require(_0x313c('0x0'));var rimraf=require(_0x313c('0x1'));var zipdir=require(_0x313c('0x2'));var jsonpatch=require(_0x313c('0x3'));var rp=require(_0x313c('0x4'));var moment=require(_0x313c('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x313c('0x6'));var util=require(_0x313c('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0x313c('0x8'));var ejs=require(_0x313c('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x313c('0xa'));var squel=require('squel');var crypto=require(_0x313c('0xb'));var jsforce=require(_0x313c('0xc'));var deskjs=require(_0x313c('0xd'));var toCsv=require('to-csv');var querystring=require(_0x313c('0xe'));var Papa=require(_0x313c('0xf'));var Redis=require(_0x313c('0x10'));var authService=require(_0x313c('0x11'));var qs=require(_0x313c('0x12'));var as=require(_0x313c('0x13'));var hardwareService=require(_0x313c('0x14'));var logger=require('../../config/logger')(_0x313c('0x15'));var utils=require(_0x313c('0x16'));var config=require(_0x313c('0x17'));var licenseUtil=require(_0x313c('0x18'));var db=require(_0x313c('0x19'))['db'];function respondWithStatusCode(_0x55c06b,_0x19d08b){_0x19d08b=_0x19d08b||0xcc;return function(_0x322987){if(_0x322987){return _0x55c06b[_0x313c('0x1a')](_0x19d08b);}return _0x55c06b[_0x313c('0x1b')](_0x19d08b)[_0x313c('0x1c')]();};}function respondWithResult(_0x2fd1b6,_0x18bbd7){_0x18bbd7=_0x18bbd7||0xc8;return function(_0x56de52){if(_0x56de52){return _0x2fd1b6[_0x313c('0x1b')](_0x18bbd7)[_0x313c('0x1d')](_0x56de52);}};}function respondWithFilteredResult(_0x2c2b4c,_0x193412){return function(_0x50e53e){if(_0x50e53e){var _0x495317=typeof _0x193412[_0x313c('0x1e')]==='undefined'&&typeof _0x193412[_0x313c('0x1f')]==='undefined';var _0x118a1c=_0x50e53e[_0x313c('0x20')];var _0x24d032=_0x495317?0x0:_0x193412[_0x313c('0x1e')];var _0xcac2d9=_0x495317?_0x50e53e[_0x313c('0x20')]:_0x193412[_0x313c('0x1e')]+_0x193412['limit'];var _0x5e6435;if(_0xcac2d9>=_0x118a1c){_0xcac2d9=_0x118a1c;_0x5e6435=0xc8;}else{_0x5e6435=0xce;}_0x2c2b4c[_0x313c('0x1b')](_0x5e6435);return _0x2c2b4c[_0x313c('0x21')](_0x313c('0x22'),_0x24d032+'-'+_0xcac2d9+'/'+_0x118a1c)['json'](_0x50e53e);}return null;};}function patchUpdates(_0xe6c895){return function(_0x36a77c){try{jsonpatch['apply'](_0x36a77c,_0xe6c895,!![]);}catch(_0xe5ca0e){return BPromise['reject'](_0xe5ca0e);}return _0x36a77c[_0x313c('0x23')]();};}function saveUpdates(_0x22570f,_0x48304d){return function(_0x52d644){if(_0x52d644){return _0x52d644[_0x313c('0x24')](_0x22570f)['then'](function(_0x7bac1){return _0x7bac1;});}return null;};}function removeEntity(_0x28fa54,_0x47b8ef){return function(_0x5cdb2d){if(_0x5cdb2d){return _0x5cdb2d[_0x313c('0x25')]()[_0x313c('0x26')](function(){_0x28fa54['status'](0xcc)[_0x313c('0x1c')]();});}};}function handleEntityNotFound(_0x2475eb,_0x50add2){return function(_0x4538e3){if(!_0x4538e3){_0x2475eb[_0x313c('0x1a')](0x194);}return _0x4538e3;};}function handleError(_0x2e4289,_0x267a93){_0x267a93=_0x267a93||0x1f4;return function(_0x2facc2){logger[_0x313c('0x27')](_0x2facc2[_0x313c('0x28')]);if(_0x2facc2[_0x313c('0x29')]){delete _0x2facc2[_0x313c('0x29')];}_0x2e4289[_0x313c('0x1b')](_0x267a93)[_0x313c('0x2a')](_0x2facc2);};}exports[_0x313c('0x2b')]=function(_0x5e007f,_0x53c91f){var _0xe5be27={},_0x9477d3={},_0x44a2c2={'count':0x0,'rows':[]};var _0xa67036=_['map'](db[_0x313c('0x2c')][_0x313c('0x2d')],function(_0x28aa5a){return{'name':_0x28aa5a[_0x313c('0x2e')],'type':_0x28aa5a[_0x313c('0x2f')][_0x313c('0x30')]};});_0x9477d3['model']=_[_0x313c('0x31')](_0xa67036,_0x313c('0x29'));_0x9477d3['query']=_[_0x313c('0x32')](_0x5e007f[_0x313c('0x33')]);_0x9477d3['filters']=_[_0x313c('0x34')](_0x9477d3[_0x313c('0x35')],_0x9477d3[_0x313c('0x33')]);_0xe5be27['attributes']=_['intersection'](_0x9477d3[_0x313c('0x35')],qs[_0x313c('0x36')](_0x5e007f[_0x313c('0x33')][_0x313c('0x36')]));_0xe5be27[_0x313c('0x37')]=_0xe5be27[_0x313c('0x37')]['length']?_0xe5be27[_0x313c('0x37')]:_0x9477d3[_0x313c('0x35')];if(!_0x5e007f[_0x313c('0x33')][_0x313c('0x38')]('nolimit')){_0xe5be27[_0x313c('0x1f')]=qs[_0x313c('0x1f')](_0x5e007f['query'][_0x313c('0x1f')]);_0xe5be27[_0x313c('0x1e')]=qs[_0x313c('0x1e')](_0x5e007f[_0x313c('0x33')][_0x313c('0x1e')]);}_0xe5be27[_0x313c('0x39')]=qs[_0x313c('0x3a')](_0x5e007f[_0x313c('0x33')][_0x313c('0x3a')]);_0xe5be27[_0x313c('0x3b')]=qs['filters'](_[_0x313c('0x3c')](_0x5e007f[_0x313c('0x33')],_0x9477d3['filters']),_0xa67036);if(_0x5e007f[_0x313c('0x33')][_0x313c('0x3d')]){_0xe5be27['where']=_['merge'](_0xe5be27['where'],{'$or':_[_0x313c('0x31')](_0xa67036,function(_0x25db2d){if(_0x25db2d[_0x313c('0x2f')]!==_0x313c('0x3e')){var _0x2f0ab2={};_0x2f0ab2[_0x25db2d['name']]={'$like':'%'+_0x5e007f[_0x313c('0x33')][_0x313c('0x3d')]+'%'};return _0x2f0ab2;}})});}_0xe5be27=_[_0x313c('0x3f')]({},_0xe5be27,_0x5e007f['options']);var _0x3ed2ae={'where':_0xe5be27[_0x313c('0x3b')]};return db[_0x313c('0x2c')][_0x313c('0x20')](_0x3ed2ae)[_0x313c('0x26')](function(_0x490318){_0x44a2c2[_0x313c('0x20')]=_0x490318;if(_0x5e007f[_0x313c('0x33')]['includeAll']){_0xe5be27[_0x313c('0x40')]=[{'all':!![]}];}return db['VoiceQueuesLog'][_0x313c('0x41')](_0xe5be27);})[_0x313c('0x26')](function(_0x32f21b){_0x44a2c2['rows']=_0x32f21b;return _0x44a2c2;})['then'](respondWithFilteredResult(_0x53c91f,_0xe5be27))[_0x313c('0x42')](handleError(_0x53c91f,null));};exports[_0x313c('0x43')]=function(_0xad7401,_0x22e8c6){var _0x4f149f={'raw':!![],'where':{'id':_0xad7401[_0x313c('0x44')]['id']}},_0x41e6be={};_0x41e6be[_0x313c('0x35')]=_[_0x313c('0x32')](db[_0x313c('0x2c')][_0x313c('0x2d')]);_0x41e6be[_0x313c('0x33')]=_[_0x313c('0x32')](_0xad7401[_0x313c('0x33')]);_0x41e6be[_0x313c('0x45')]=_['intersection'](_0x41e6be[_0x313c('0x35')],_0x41e6be[_0x313c('0x33')]);_0x4f149f[_0x313c('0x37')]=_['intersection'](_0x41e6be[_0x313c('0x35')],qs[_0x313c('0x36')](_0xad7401['query'][_0x313c('0x36')]));_0x4f149f[_0x313c('0x37')]=_0x4f149f['attributes'][_0x313c('0x46')]?_0x4f149f[_0x313c('0x37')]:_0x41e6be[_0x313c('0x35')];if(_0xad7401[_0x313c('0x33')][_0x313c('0x47')]){_0x4f149f[_0x313c('0x40')]=[{'all':!![]}];}_0x4f149f=_['merge']({},_0x4f149f,_0xad7401[_0x313c('0x48')]);return db['VoiceQueuesLog']['find'](_0x4f149f)[_0x313c('0x26')](handleEntityNotFound(_0x22e8c6,null))[_0x313c('0x26')](respondWithResult(_0x22e8c6,null))[_0x313c('0x42')](handleError(_0x22e8c6,null));};exports['create']=function(_0x41db34,_0x365626){return db[_0x313c('0x2c')][_0x313c('0x49')](_0x41db34[_0x313c('0x4a')],{})[_0x313c('0x26')](respondWithResult(_0x365626,0xc9))[_0x313c('0x42')](handleError(_0x365626,null));};exports[_0x313c('0x24')]=function(_0x45e023,_0x176c55){if(_0x45e023['body']['id']){delete _0x45e023[_0x313c('0x4a')]['id'];}return db[_0x313c('0x2c')][_0x313c('0x4b')]({'where':{'id':_0x45e023['params']['id']}})[_0x313c('0x26')](handleEntityNotFound(_0x176c55,null))[_0x313c('0x26')](saveUpdates(_0x45e023[_0x313c('0x4a')],null))[_0x313c('0x26')](respondWithResult(_0x176c55,null))[_0x313c('0x42')](handleError(_0x176c55,null));};exports[_0x313c('0x25')]=function(_0x2fb44b,_0x4a2f12){return db[_0x313c('0x2c')][_0x313c('0x4b')]({'where':{'id':_0x2fb44b[_0x313c('0x44')]['id']}})['then'](handleEntityNotFound(_0x4a2f12,null))[_0x313c('0x26')](removeEntity(_0x4a2f12,null))[_0x313c('0x42')](handleError(_0x4a2f12,null));};