Built motion from commit (unavailable).|2.4.17
[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 _0xb5fd=['send','index','map','VoiceQueuesLog','rawAttributes','fieldName','type','key','model','keys','query','attributes','intersection','fields','length','order','sort','filters','pick','filter','where','VIRTUAL','merge','options','includeAll','include','rows','catch','show','create','update','body','find','params','html-pdf','eml-format','rimraf','request-promise','bluebird','util','path','lodash','squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','then','destroy','error','stack','name'];(function(_0x1facfa,_0x1acf7d){var _0x9ec701=function(_0x115e37){while(--_0x115e37){_0x1facfa['push'](_0x1facfa['shift']());}};_0x9ec701(++_0x1acf7d);}(_0xb5fd,0xfa));var _0xdb5f=function(_0x4e4a48,_0x22cf1f){_0x4e4a48=_0x4e4a48-0x0;var _0x5b070e=_0xb5fd[_0x4e4a48];return _0x5b070e;};'use strict';var pdf=require(_0xdb5f('0x0'));var emlformat=require(_0xdb5f('0x1'));var rimraf=require(_0xdb5f('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xdb5f('0x3'));var moment=require('moment');var BPromise=require(_0xdb5f('0x4'));var Mustache=require('mustache');var util=require(_0xdb5f('0x5'));var path=require(_0xdb5f('0x6'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0xdb5f('0x7'));var squel=require(_0xdb5f('0x8'));var crypto=require('crypto');var jsforce=require(_0xdb5f('0x9'));var deskjs=require(_0xdb5f('0xa'));var toCsv=require(_0xdb5f('0xb'));var querystring=require(_0xdb5f('0xc'));var Papa=require(_0xdb5f('0xd'));var Redis=require(_0xdb5f('0xe'));var authService=require(_0xdb5f('0xf'));var qs=require(_0xdb5f('0x10'));var as=require(_0xdb5f('0x11'));var hardwareService=require(_0xdb5f('0x12'));var logger=require(_0xdb5f('0x13'))('api');var utils=require(_0xdb5f('0x14'));var config=require(_0xdb5f('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1e4f67,_0x309083){_0x309083=_0x309083||0xcc;return function(_0x25791b){if(_0x25791b){return _0x1e4f67['sendStatus'](_0x309083);}return _0x1e4f67[_0xdb5f('0x16')](_0x309083)[_0xdb5f('0x17')]();};}function respondWithResult(_0x9752e4,_0x10b89e){_0x10b89e=_0x10b89e||0xc8;return function(_0xffbf5b){if(_0xffbf5b){return _0x9752e4['status'](_0x10b89e)[_0xdb5f('0x18')](_0xffbf5b);}};}function respondWithFilteredResult(_0x3be207,_0x32c7da){return function(_0x368c41){if(_0x368c41){var _0x1e0285=_0x368c41[_0xdb5f('0x19')],_0x15f943=_0x32c7da[_0xdb5f('0x1a')],_0x258693=_0x32c7da[_0xdb5f('0x1a')]+_0x32c7da[_0xdb5f('0x1b')],_0x2486ea;if(_0x258693>=_0x1e0285){_0x258693=_0x1e0285;_0x2486ea=0xc8;}else{_0x2486ea=0xce;}_0x3be207['status'](_0x2486ea);return _0x3be207[_0xdb5f('0x1c')](_0xdb5f('0x1d'),_0x15f943+'-'+_0x258693+'/'+_0x1e0285)[_0xdb5f('0x18')](_0x368c41);}return null;};}function patchUpdates(_0xc7ebd1){return function(_0x40de84){try{jsonpatch[_0xdb5f('0x1e')](_0x40de84,_0xc7ebd1,!![]);}catch(_0x1fdb5e){return BPromise[_0xdb5f('0x1f')](_0x1fdb5e);}return _0x40de84[_0xdb5f('0x20')]();};}function saveUpdates(_0x481d96,_0x3eb171){return function(_0x5523a8){if(_0x5523a8){return _0x5523a8['update'](_0x481d96)[_0xdb5f('0x21')](function(_0x339c6c){return _0x339c6c;});}return null;};}function removeEntity(_0x317507,_0x4c27cc){return function(_0x2f01ec){if(_0x2f01ec){return _0x2f01ec[_0xdb5f('0x22')]()[_0xdb5f('0x21')](function(){_0x317507[_0xdb5f('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1a442b,_0x121740){return function(_0x292d45){if(!_0x292d45){_0x1a442b['sendStatus'](0x194);}return _0x292d45;};}function handleError(_0x4e3ec6,_0x97cd24){_0x97cd24=_0x97cd24||0x1f4;return function(_0x526c4b){logger[_0xdb5f('0x23')](_0x526c4b[_0xdb5f('0x24')]);if(_0x526c4b[_0xdb5f('0x25')]){delete _0x526c4b[_0xdb5f('0x25')];}_0x4e3ec6['status'](_0x97cd24)[_0xdb5f('0x26')](_0x526c4b);};}exports[_0xdb5f('0x27')]=function(_0x1b8a47,_0x1b92fa){var _0x5acc61={},_0x432002={},_0x5becd8={'count':0x0,'rows':[]};var _0x33d8c1=_[_0xdb5f('0x28')](db[_0xdb5f('0x29')][_0xdb5f('0x2a')],function(_0x574ffd){return{'name':_0x574ffd[_0xdb5f('0x2b')],'type':_0x574ffd[_0xdb5f('0x2c')][_0xdb5f('0x2d')]};});_0x432002[_0xdb5f('0x2e')]=_[_0xdb5f('0x28')](_0x33d8c1,'name');_0x432002['query']=_[_0xdb5f('0x2f')](_0x1b8a47[_0xdb5f('0x30')]);_0x432002['filters']=_['intersection'](_0x432002['model'],_0x432002[_0xdb5f('0x30')]);_0x5acc61[_0xdb5f('0x31')]=_[_0xdb5f('0x32')](_0x432002[_0xdb5f('0x2e')],qs[_0xdb5f('0x33')](_0x1b8a47[_0xdb5f('0x30')][_0xdb5f('0x33')]));_0x5acc61[_0xdb5f('0x31')]=_0x5acc61['attributes'][_0xdb5f('0x34')]?_0x5acc61['attributes']:_0x432002['model'];if(!_0x1b8a47['query']['hasOwnProperty']('nolimit')){_0x5acc61[_0xdb5f('0x1b')]=qs[_0xdb5f('0x1b')](_0x1b8a47['query'][_0xdb5f('0x1b')]);_0x5acc61[_0xdb5f('0x1a')]=qs[_0xdb5f('0x1a')](_0x1b8a47[_0xdb5f('0x30')][_0xdb5f('0x1a')]);}_0x5acc61[_0xdb5f('0x35')]=qs[_0xdb5f('0x36')](_0x1b8a47['query'][_0xdb5f('0x36')]);_0x5acc61['where']=qs[_0xdb5f('0x37')](_[_0xdb5f('0x38')](_0x1b8a47[_0xdb5f('0x30')],_0x432002['filters']));if(_0x1b8a47[_0xdb5f('0x30')][_0xdb5f('0x39')]){_0x5acc61[_0xdb5f('0x3a')]=_['merge'](_0x5acc61[_0xdb5f('0x3a')],{'$or':_[_0xdb5f('0x28')](_0x33d8c1,function(_0x4ae3e5){if(_0x4ae3e5[_0xdb5f('0x2c')]!==_0xdb5f('0x3b')){var _0x4a6bde={};_0x4a6bde[_0x4ae3e5[_0xdb5f('0x25')]]={'$like':'%'+_0x1b8a47[_0xdb5f('0x30')][_0xdb5f('0x39')]+'%'};return _0x4a6bde;}})});}_0x5acc61=_[_0xdb5f('0x3c')]({},_0x5acc61,_0x1b8a47[_0xdb5f('0x3d')]);var _0x126332={'where':_0x5acc61[_0xdb5f('0x3a')]};return db[_0xdb5f('0x29')][_0xdb5f('0x19')](_0x126332)[_0xdb5f('0x21')](function(_0x3f0279){_0x5becd8[_0xdb5f('0x19')]=_0x3f0279;if(_0x1b8a47['query'][_0xdb5f('0x3e')]){_0x5acc61[_0xdb5f('0x3f')]=[{'all':!![]}];}return db[_0xdb5f('0x29')]['findAll'](_0x5acc61);})[_0xdb5f('0x21')](function(_0x331d6a){_0x5becd8[_0xdb5f('0x40')]=_0x331d6a;return _0x5becd8;})[_0xdb5f('0x21')](respondWithFilteredResult(_0x1b92fa,_0x5acc61))[_0xdb5f('0x41')](handleError(_0x1b92fa,null));};exports[_0xdb5f('0x42')]=function(_0x4b6b4b,_0x301a5f){var _0x409001={'raw':!![],'where':{'id':_0x4b6b4b['params']['id']}},_0x4f4a3f={};_0x4f4a3f[_0xdb5f('0x2e')]=_[_0xdb5f('0x2f')](db[_0xdb5f('0x29')][_0xdb5f('0x2a')]);_0x4f4a3f['query']=_[_0xdb5f('0x2f')](_0x4b6b4b[_0xdb5f('0x30')]);_0x4f4a3f['filters']=_[_0xdb5f('0x32')](_0x4f4a3f[_0xdb5f('0x2e')],_0x4f4a3f[_0xdb5f('0x30')]);_0x409001['attributes']=_[_0xdb5f('0x32')](_0x4f4a3f[_0xdb5f('0x2e')],qs[_0xdb5f('0x33')](_0x4b6b4b[_0xdb5f('0x30')]['fields']));_0x409001[_0xdb5f('0x31')]=_0x409001[_0xdb5f('0x31')][_0xdb5f('0x34')]?_0x409001[_0xdb5f('0x31')]:_0x4f4a3f[_0xdb5f('0x2e')];if(_0x4b6b4b[_0xdb5f('0x30')][_0xdb5f('0x3e')]){_0x409001[_0xdb5f('0x3f')]=[{'all':!![]}];}_0x409001=_[_0xdb5f('0x3c')]({},_0x409001,_0x4b6b4b[_0xdb5f('0x3d')]);return db['VoiceQueuesLog']['find'](_0x409001)[_0xdb5f('0x21')](handleEntityNotFound(_0x301a5f,null))[_0xdb5f('0x21')](respondWithResult(_0x301a5f,null))[_0xdb5f('0x41')](handleError(_0x301a5f,null));};exports['create']=function(_0x4b14c8,_0x268290){return db['VoiceQueuesLog'][_0xdb5f('0x43')](_0x4b14c8['body'],{})['then'](respondWithResult(_0x268290,0xc9))['catch'](handleError(_0x268290,null));};exports[_0xdb5f('0x44')]=function(_0x4ccf91,_0x111535){if(_0x4ccf91[_0xdb5f('0x45')]['id']){delete _0x4ccf91[_0xdb5f('0x45')]['id'];}return db[_0xdb5f('0x29')][_0xdb5f('0x46')]({'where':{'id':_0x4ccf91[_0xdb5f('0x47')]['id']}})[_0xdb5f('0x21')](handleEntityNotFound(_0x111535,null))[_0xdb5f('0x21')](saveUpdates(_0x4ccf91[_0xdb5f('0x45')],null))['then'](respondWithResult(_0x111535,null))[_0xdb5f('0x41')](handleError(_0x111535,null));};exports[_0xdb5f('0x22')]=function(_0x4c8126,_0x291910){return db['VoiceQueuesLog'][_0xdb5f('0x46')]({'where':{'id':_0x4c8126[_0xdb5f('0x47')]['id']}})[_0xdb5f('0x21')](handleEntityNotFound(_0x291910,null))['then'](removeEntity(_0x291910,null))[_0xdb5f('0x41')](handleError(_0x291910,null));};