Built motion from commit b5413ace.|2.6.9
[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 _0xb4ff=['options','VoiceQueuesLog','includeAll','findAll','rows','show','params','rawAttributes','length','include','catch','create','body','find','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','json','offset','undefined','limit','count','set','apply','update','then','destroy','end','error','stack','name','send','map','fieldName','type','key','model','keys','filters','query','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL'];(function(_0x387777,_0x356171){var _0x3f84c0=function(_0x4d4423){while(--_0x4d4423){_0x387777['push'](_0x387777['shift']());}};_0x3f84c0(++_0x356171);}(_0xb4ff,0xef));var _0xfb4f=function(_0x3acfbc,_0x2455e5){_0x3acfbc=_0x3acfbc-0x0;var _0x1a05d4=_0xb4ff[_0x3acfbc];return _0x1a05d4;};'use strict';var emlformat=require(_0xfb4f('0x0'));var rimraf=require(_0xfb4f('0x1'));var zipdir=require(_0xfb4f('0x2'));var jsonpatch=require(_0xfb4f('0x3'));var rp=require('request-promise');var moment=require(_0xfb4f('0x4'));var BPromise=require(_0xfb4f('0x5'));var Mustache=require('mustache');var util=require(_0xfb4f('0x6'));var path=require('path');var sox=require(_0xfb4f('0x7'));var csv=require(_0xfb4f('0x8'));var ejs=require(_0xfb4f('0x9'));var fs=require('fs');var fs_extra=require(_0xfb4f('0xa'));var _=require(_0xfb4f('0xb'));var squel=require('squel');var crypto=require(_0xfb4f('0xc'));var jsforce=require(_0xfb4f('0xd'));var deskjs=require(_0xfb4f('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xfb4f('0xf'));var Redis=require('ioredis');var authService=require(_0xfb4f('0x10'));var qs=require(_0xfb4f('0x11'));var as=require(_0xfb4f('0x12'));var hardwareService=require(_0xfb4f('0x13'));var logger=require(_0xfb4f('0x14'))('api');var utils=require(_0xfb4f('0x15'));var config=require(_0xfb4f('0x16'));var licenseUtil=require(_0xfb4f('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x468d33,_0x4f3082){_0x4f3082=_0x4f3082||0xcc;return function(_0x246b3b){if(_0x246b3b){return _0x468d33[_0xfb4f('0x18')](_0x4f3082);}return _0x468d33[_0xfb4f('0x19')](_0x4f3082)['end']();};}function respondWithResult(_0x4d5ccf,_0x50642a){_0x50642a=_0x50642a||0xc8;return function(_0x48aac5){if(_0x48aac5){return _0x4d5ccf[_0xfb4f('0x19')](_0x50642a)[_0xfb4f('0x1a')](_0x48aac5);}};}function respondWithFilteredResult(_0x2b08be,_0x42d1d3){return function(_0x3381a8){if(_0x3381a8){var _0x5e5e36=typeof _0x42d1d3[_0xfb4f('0x1b')]===_0xfb4f('0x1c')&&typeof _0x42d1d3[_0xfb4f('0x1d')]===_0xfb4f('0x1c');var _0x37bf6c=_0x3381a8[_0xfb4f('0x1e')];var _0x1b1b00=_0x5e5e36?0x0:_0x42d1d3[_0xfb4f('0x1b')];var _0x80bdd4=_0x5e5e36?_0x3381a8[_0xfb4f('0x1e')]:_0x42d1d3[_0xfb4f('0x1b')]+_0x42d1d3[_0xfb4f('0x1d')];var _0x3a44d2;if(_0x80bdd4>=_0x37bf6c){_0x80bdd4=_0x37bf6c;_0x3a44d2=0xc8;}else{_0x3a44d2=0xce;}_0x2b08be[_0xfb4f('0x19')](_0x3a44d2);return _0x2b08be[_0xfb4f('0x1f')]('Content-Range',_0x1b1b00+'-'+_0x80bdd4+'/'+_0x37bf6c)[_0xfb4f('0x1a')](_0x3381a8);}return null;};}function patchUpdates(_0x299f93){return function(_0x174cbc){try{jsonpatch[_0xfb4f('0x20')](_0x174cbc,_0x299f93,!![]);}catch(_0x154e36){return BPromise['reject'](_0x154e36);}return _0x174cbc['save']();};}function saveUpdates(_0x3a660e,_0x58f355){return function(_0x3903fa){if(_0x3903fa){return _0x3903fa[_0xfb4f('0x21')](_0x3a660e)[_0xfb4f('0x22')](function(_0x81861){return _0x81861;});}return null;};}function removeEntity(_0x18cc77,_0x59ff87){return function(_0x5dd208){if(_0x5dd208){return _0x5dd208[_0xfb4f('0x23')]()['then'](function(){_0x18cc77['status'](0xcc)[_0xfb4f('0x24')]();});}};}function handleEntityNotFound(_0x36c08f,_0x593afd){return function(_0x22f276){if(!_0x22f276){_0x36c08f['sendStatus'](0x194);}return _0x22f276;};}function handleError(_0x447b9a,_0x4104e8){_0x4104e8=_0x4104e8||0x1f4;return function(_0x65909b){logger[_0xfb4f('0x25')](_0x65909b[_0xfb4f('0x26')]);if(_0x65909b[_0xfb4f('0x27')]){delete _0x65909b[_0xfb4f('0x27')];}_0x447b9a[_0xfb4f('0x19')](_0x4104e8)[_0xfb4f('0x28')](_0x65909b);};}exports['index']=function(_0x370eee,_0x204b84){var _0x441ad6={},_0x5b2e57={},_0x7de1a5={'count':0x0,'rows':[]};var _0x1a37fc=_[_0xfb4f('0x29')](db['VoiceQueuesLog']['rawAttributes'],function(_0x153df1){return{'name':_0x153df1[_0xfb4f('0x2a')],'type':_0x153df1[_0xfb4f('0x2b')][_0xfb4f('0x2c')]};});_0x5b2e57[_0xfb4f('0x2d')]=_['map'](_0x1a37fc,'name');_0x5b2e57['query']=_[_0xfb4f('0x2e')](_0x370eee['query']);_0x5b2e57[_0xfb4f('0x2f')]=_['intersection'](_0x5b2e57[_0xfb4f('0x2d')],_0x5b2e57[_0xfb4f('0x30')]);_0x441ad6[_0xfb4f('0x31')]=_[_0xfb4f('0x32')](_0x5b2e57[_0xfb4f('0x2d')],qs[_0xfb4f('0x33')](_0x370eee['query'][_0xfb4f('0x33')]));_0x441ad6[_0xfb4f('0x31')]=_0x441ad6[_0xfb4f('0x31')]['length']?_0x441ad6[_0xfb4f('0x31')]:_0x5b2e57['model'];if(!_0x370eee[_0xfb4f('0x30')][_0xfb4f('0x34')](_0xfb4f('0x35'))){_0x441ad6[_0xfb4f('0x1d')]=qs[_0xfb4f('0x1d')](_0x370eee[_0xfb4f('0x30')][_0xfb4f('0x1d')]);_0x441ad6[_0xfb4f('0x1b')]=qs[_0xfb4f('0x1b')](_0x370eee[_0xfb4f('0x30')][_0xfb4f('0x1b')]);}_0x441ad6[_0xfb4f('0x36')]=qs[_0xfb4f('0x37')](_0x370eee['query'][_0xfb4f('0x37')]);_0x441ad6[_0xfb4f('0x38')]=qs[_0xfb4f('0x2f')](_[_0xfb4f('0x39')](_0x370eee[_0xfb4f('0x30')],_0x5b2e57[_0xfb4f('0x2f')]),_0x1a37fc);if(_0x370eee['query'][_0xfb4f('0x3a')]){_0x441ad6['where']=_[_0xfb4f('0x3b')](_0x441ad6['where'],{'$or':_[_0xfb4f('0x29')](_0x1a37fc,function(_0xe8fbce){if(_0xe8fbce[_0xfb4f('0x2b')]!==_0xfb4f('0x3c')){var _0x51c44a={};_0x51c44a[_0xe8fbce[_0xfb4f('0x27')]]={'$like':'%'+_0x370eee['query'][_0xfb4f('0x3a')]+'%'};return _0x51c44a;}})});}_0x441ad6=_['merge']({},_0x441ad6,_0x370eee[_0xfb4f('0x3d')]);var _0x3a13ae={'where':_0x441ad6[_0xfb4f('0x38')]};return db[_0xfb4f('0x3e')][_0xfb4f('0x1e')](_0x3a13ae)['then'](function(_0x22864b){_0x7de1a5[_0xfb4f('0x1e')]=_0x22864b;if(_0x370eee[_0xfb4f('0x30')][_0xfb4f('0x3f')]){_0x441ad6['include']=[{'all':!![]}];}return db['VoiceQueuesLog'][_0xfb4f('0x40')](_0x441ad6);})[_0xfb4f('0x22')](function(_0x5d9b4c){_0x7de1a5[_0xfb4f('0x41')]=_0x5d9b4c;return _0x7de1a5;})[_0xfb4f('0x22')](respondWithFilteredResult(_0x204b84,_0x441ad6))['catch'](handleError(_0x204b84,null));};exports[_0xfb4f('0x42')]=function(_0x368c40,_0x2a30ed){var _0x2f4479={'raw':!![],'where':{'id':_0x368c40[_0xfb4f('0x43')]['id']}},_0x34723f={};_0x34723f['model']=_['keys'](db[_0xfb4f('0x3e')][_0xfb4f('0x44')]);_0x34723f[_0xfb4f('0x30')]=_[_0xfb4f('0x2e')](_0x368c40[_0xfb4f('0x30')]);_0x34723f[_0xfb4f('0x2f')]=_[_0xfb4f('0x32')](_0x34723f[_0xfb4f('0x2d')],_0x34723f[_0xfb4f('0x30')]);_0x2f4479[_0xfb4f('0x31')]=_[_0xfb4f('0x32')](_0x34723f[_0xfb4f('0x2d')],qs['fields'](_0x368c40[_0xfb4f('0x30')][_0xfb4f('0x33')]));_0x2f4479['attributes']=_0x2f4479['attributes'][_0xfb4f('0x45')]?_0x2f4479['attributes']:_0x34723f[_0xfb4f('0x2d')];if(_0x368c40[_0xfb4f('0x30')][_0xfb4f('0x3f')]){_0x2f4479[_0xfb4f('0x46')]=[{'all':!![]}];}_0x2f4479=_[_0xfb4f('0x3b')]({},_0x2f4479,_0x368c40[_0xfb4f('0x3d')]);return db['VoiceQueuesLog']['find'](_0x2f4479)[_0xfb4f('0x22')](handleEntityNotFound(_0x2a30ed,null))[_0xfb4f('0x22')](respondWithResult(_0x2a30ed,null))[_0xfb4f('0x47')](handleError(_0x2a30ed,null));};exports[_0xfb4f('0x48')]=function(_0x287066,_0x46cf69){return db[_0xfb4f('0x3e')][_0xfb4f('0x48')](_0x287066[_0xfb4f('0x49')],{})[_0xfb4f('0x22')](respondWithResult(_0x46cf69,0xc9))[_0xfb4f('0x47')](handleError(_0x46cf69,null));};exports[_0xfb4f('0x21')]=function(_0x4efe25,_0xe83155){if(_0x4efe25[_0xfb4f('0x49')]['id']){delete _0x4efe25[_0xfb4f('0x49')]['id'];}return db[_0xfb4f('0x3e')]['find']({'where':{'id':_0x4efe25[_0xfb4f('0x43')]['id']}})['then'](handleEntityNotFound(_0xe83155,null))['then'](saveUpdates(_0x4efe25[_0xfb4f('0x49')],null))[_0xfb4f('0x22')](respondWithResult(_0xe83155,null))['catch'](handleError(_0xe83155,null));};exports[_0xfb4f('0x23')]=function(_0xf2895e,_0x15e8dd){return db[_0xfb4f('0x3e')][_0xfb4f('0x4a')]({'where':{'id':_0xf2895e[_0xfb4f('0x43')]['id']}})['then'](handleEntityNotFound(_0x15e8dd,null))[_0xfb4f('0x22')](removeEntity(_0x15e8dd,null))[_0xfb4f('0x47')](handleError(_0x15e8dd,null));};