Built motion from commit (unavailable).|2.5.14
[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 _0x9c3e=['stack','name','index','VoiceQueuesLog','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','find','create','body','update','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','crypto','jsforce','desk.js','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','json','count','offset','status','set','apply','reject','save','then','destroy','error'];(function(_0x4e1fbf,_0x4f2da9){var _0x4ee62f=function(_0x4e257c){while(--_0x4e257c){_0x4e1fbf['push'](_0x4e1fbf['shift']());}};_0x4ee62f(++_0x4f2da9);}(_0x9c3e,0xbf));var _0xe9c3=function(_0x186270,_0x59c68a){_0x186270=_0x186270-0x0;var _0x5a6c9a=_0x9c3e[_0x186270];return _0x5a6c9a;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xe9c3('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xe9c3('0x1'));var jsonpatch=require(_0xe9c3('0x2'));var rp=require(_0xe9c3('0x3'));var moment=require(_0xe9c3('0x4'));var BPromise=require(_0xe9c3('0x5'));var Mustache=require(_0xe9c3('0x6'));var util=require('util');var path=require(_0xe9c3('0x7'));var sox=require(_0xe9c3('0x8'));var csv=require(_0xe9c3('0x9'));var ejs=require(_0xe9c3('0xa'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0xe9c3('0xb'));var jsforce=require(_0xe9c3('0xc'));var deskjs=require(_0xe9c3('0xd'));var toCsv=require('to-csv');var querystring=require(_0xe9c3('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xe9c3('0xf'));var qs=require(_0xe9c3('0x10'));var as=require(_0xe9c3('0x11'));var hardwareService=require(_0xe9c3('0x12'));var logger=require(_0xe9c3('0x13'))(_0xe9c3('0x14'));var utils=require('../../config/utils');var config=require(_0xe9c3('0x15'));var licenseUtil=require(_0xe9c3('0x16'));var db=require(_0xe9c3('0x17'))['db'];function respondWithStatusCode(_0x21e6c3,_0x4b31e8){_0x4b31e8=_0x4b31e8||0xcc;return function(_0x364d53){if(_0x364d53){return _0x21e6c3[_0xe9c3('0x18')](_0x4b31e8);}return _0x21e6c3['status'](_0x4b31e8)[_0xe9c3('0x19')]();};}function respondWithResult(_0x276db2,_0x361467){_0x361467=_0x361467||0xc8;return function(_0xd56a2e){if(_0xd56a2e){return _0x276db2['status'](_0x361467)[_0xe9c3('0x1a')](_0xd56a2e);}};}function respondWithFilteredResult(_0x58bab5,_0x1483f0){return function(_0x5e9ac2){if(_0x5e9ac2){var _0x5e021e=_0x5e9ac2[_0xe9c3('0x1b')],_0x3e287e=_0x1483f0['offset'],_0x25dffa=_0x1483f0[_0xe9c3('0x1c')]+_0x1483f0['limit'],_0x804148;if(_0x25dffa>=_0x5e021e){_0x25dffa=_0x5e021e;_0x804148=0xc8;}else{_0x804148=0xce;}_0x58bab5[_0xe9c3('0x1d')](_0x804148);return _0x58bab5[_0xe9c3('0x1e')]('Content-Range',_0x3e287e+'-'+_0x25dffa+'/'+_0x5e021e)[_0xe9c3('0x1a')](_0x5e9ac2);}return null;};}function patchUpdates(_0x6fbde0){return function(_0x40850b){try{jsonpatch[_0xe9c3('0x1f')](_0x40850b,_0x6fbde0,!![]);}catch(_0x4c64b2){return BPromise[_0xe9c3('0x20')](_0x4c64b2);}return _0x40850b[_0xe9c3('0x21')]();};}function saveUpdates(_0x4b6dfd,_0x205218){return function(_0x38efac){if(_0x38efac){return _0x38efac['update'](_0x4b6dfd)[_0xe9c3('0x22')](function(_0x51a73f){return _0x51a73f;});}return null;};}function removeEntity(_0x36a898,_0x5ae390){return function(_0xde7850){if(_0xde7850){return _0xde7850[_0xe9c3('0x23')]()[_0xe9c3('0x22')](function(){_0x36a898['status'](0xcc)[_0xe9c3('0x19')]();});}};}function handleEntityNotFound(_0x36139b,_0x6df32e){return function(_0x3f4a82){if(!_0x3f4a82){_0x36139b[_0xe9c3('0x18')](0x194);}return _0x3f4a82;};}function handleError(_0x2cdd37,_0x15d4ca){_0x15d4ca=_0x15d4ca||0x1f4;return function(_0x2f067a){logger[_0xe9c3('0x24')](_0x2f067a[_0xe9c3('0x25')]);if(_0x2f067a[_0xe9c3('0x26')]){delete _0x2f067a['name'];}_0x2cdd37[_0xe9c3('0x1d')](_0x15d4ca)['send'](_0x2f067a);};}exports[_0xe9c3('0x27')]=function(_0x215aad,_0x40aa9f){var _0x389d86={},_0x5990d1={},_0x52eca0={'count':0x0,'rows':[]};var _0x4dafe2=_['map'](db[_0xe9c3('0x28')]['rawAttributes'],function(_0x56fdcc){return{'name':_0x56fdcc[_0xe9c3('0x29')],'type':_0x56fdcc[_0xe9c3('0x2a')][_0xe9c3('0x2b')]};});_0x5990d1[_0xe9c3('0x2c')]=_[_0xe9c3('0x2d')](_0x4dafe2,_0xe9c3('0x26'));_0x5990d1[_0xe9c3('0x2e')]=_[_0xe9c3('0x2f')](_0x215aad[_0xe9c3('0x2e')]);_0x5990d1[_0xe9c3('0x30')]=_[_0xe9c3('0x31')](_0x5990d1[_0xe9c3('0x2c')],_0x5990d1['query']);_0x389d86[_0xe9c3('0x32')]=_[_0xe9c3('0x31')](_0x5990d1[_0xe9c3('0x2c')],qs[_0xe9c3('0x33')](_0x215aad['query'][_0xe9c3('0x33')]));_0x389d86['attributes']=_0x389d86[_0xe9c3('0x32')][_0xe9c3('0x34')]?_0x389d86[_0xe9c3('0x32')]:_0x5990d1['model'];if(!_0x215aad[_0xe9c3('0x2e')][_0xe9c3('0x35')](_0xe9c3('0x36'))){_0x389d86['limit']=qs['limit'](_0x215aad[_0xe9c3('0x2e')][_0xe9c3('0x37')]);_0x389d86[_0xe9c3('0x1c')]=qs[_0xe9c3('0x1c')](_0x215aad[_0xe9c3('0x2e')]['offset']);}_0x389d86[_0xe9c3('0x38')]=qs[_0xe9c3('0x39')](_0x215aad[_0xe9c3('0x2e')][_0xe9c3('0x39')]);_0x389d86[_0xe9c3('0x3a')]=qs[_0xe9c3('0x30')](_[_0xe9c3('0x3b')](_0x215aad[_0xe9c3('0x2e')],_0x5990d1[_0xe9c3('0x30')]),_0x4dafe2);if(_0x215aad['query']['filter']){_0x389d86[_0xe9c3('0x3a')]=_[_0xe9c3('0x3c')](_0x389d86[_0xe9c3('0x3a')],{'$or':_[_0xe9c3('0x2d')](_0x4dafe2,function(_0x10251f){if(_0x10251f[_0xe9c3('0x2a')]!==_0xe9c3('0x3d')){var _0x219faa={};_0x219faa[_0x10251f[_0xe9c3('0x26')]]={'$like':'%'+_0x215aad[_0xe9c3('0x2e')][_0xe9c3('0x3e')]+'%'};return _0x219faa;}})});}_0x389d86=_[_0xe9c3('0x3c')]({},_0x389d86,_0x215aad[_0xe9c3('0x3f')]);var _0x20b06b={'where':_0x389d86['where']};return db[_0xe9c3('0x28')][_0xe9c3('0x1b')](_0x20b06b)[_0xe9c3('0x22')](function(_0x500365){_0x52eca0[_0xe9c3('0x1b')]=_0x500365;if(_0x215aad[_0xe9c3('0x2e')][_0xe9c3('0x40')]){_0x389d86[_0xe9c3('0x41')]=[{'all':!![]}];}return db[_0xe9c3('0x28')][_0xe9c3('0x42')](_0x389d86);})[_0xe9c3('0x22')](function(_0x343b31){_0x52eca0[_0xe9c3('0x43')]=_0x343b31;return _0x52eca0;})[_0xe9c3('0x22')](respondWithFilteredResult(_0x40aa9f,_0x389d86))[_0xe9c3('0x44')](handleError(_0x40aa9f,null));};exports[_0xe9c3('0x45')]=function(_0x169848,_0x422075){var _0x102592={'raw':!![],'where':{'id':_0x169848[_0xe9c3('0x46')]['id']}},_0x3fe183={};_0x3fe183['model']=_['keys'](db['VoiceQueuesLog'][_0xe9c3('0x47')]);_0x3fe183[_0xe9c3('0x2e')]=_[_0xe9c3('0x2f')](_0x169848['query']);_0x3fe183['filters']=_['intersection'](_0x3fe183[_0xe9c3('0x2c')],_0x3fe183['query']);_0x102592[_0xe9c3('0x32')]=_[_0xe9c3('0x31')](_0x3fe183[_0xe9c3('0x2c')],qs[_0xe9c3('0x33')](_0x169848[_0xe9c3('0x2e')][_0xe9c3('0x33')]));_0x102592[_0xe9c3('0x32')]=_0x102592['attributes'][_0xe9c3('0x34')]?_0x102592[_0xe9c3('0x32')]:_0x3fe183[_0xe9c3('0x2c')];if(_0x169848['query']['includeAll']){_0x102592[_0xe9c3('0x41')]=[{'all':!![]}];}_0x102592=_[_0xe9c3('0x3c')]({},_0x102592,_0x169848[_0xe9c3('0x3f')]);return db['VoiceQueuesLog'][_0xe9c3('0x48')](_0x102592)[_0xe9c3('0x22')](handleEntityNotFound(_0x422075,null))[_0xe9c3('0x22')](respondWithResult(_0x422075,null))[_0xe9c3('0x44')](handleError(_0x422075,null));};exports[_0xe9c3('0x49')]=function(_0x3d6e3b,_0x1c2bbb){return db[_0xe9c3('0x28')][_0xe9c3('0x49')](_0x3d6e3b[_0xe9c3('0x4a')],{})[_0xe9c3('0x22')](respondWithResult(_0x1c2bbb,0xc9))[_0xe9c3('0x44')](handleError(_0x1c2bbb,null));};exports[_0xe9c3('0x4b')]=function(_0x9ec933,_0xef5113){if(_0x9ec933[_0xe9c3('0x4a')]['id']){delete _0x9ec933[_0xe9c3('0x4a')]['id'];}return db[_0xe9c3('0x28')]['find']({'where':{'id':_0x9ec933['params']['id']}})[_0xe9c3('0x22')](handleEntityNotFound(_0xef5113,null))[_0xe9c3('0x22')](saveUpdates(_0x9ec933[_0xe9c3('0x4a')],null))[_0xe9c3('0x22')](respondWithResult(_0xef5113,null))[_0xe9c3('0x44')](handleError(_0xef5113,null));};exports[_0xe9c3('0x23')]=function(_0x1ed7f3,_0x40b206){return db['VoiceQueuesLog'][_0xe9c3('0x48')]({'where':{'id':_0x1ed7f3[_0xe9c3('0x46')]['id']}})['then'](handleEntityNotFound(_0x40b206,null))[_0xe9c3('0x22')](removeEntity(_0x40b206,null))['catch'](handleError(_0x40b206,null));};