10ff9fb856ee6d8b748ed2655f1594e78e51089f
[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 _0xfc4e=['query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','merge','VIRTUAL','filter','options','VoiceQueuesLog','includeAll','include','catch','show','rawAttributes','body','params','find','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','status','offset','limit','undefined','count','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','fieldName','type','key','model','map'];(function(_0x577a59,_0x45088a){var _0x224214=function(_0x23c4d8){while(--_0x23c4d8){_0x577a59['push'](_0x577a59['shift']());}};_0x224214(++_0x45088a);}(_0xfc4e,0xb0));var _0xefc4=function(_0x68c979,_0x431cff){_0x68c979=_0x68c979-0x0;var _0x4f0001=_0xfc4e[_0x68c979];return _0x4f0001;};'use strict';var emlformat=require(_0xefc4('0x0'));var rimraf=require(_0xefc4('0x1'));var zipdir=require(_0xefc4('0x2'));var jsonpatch=require(_0xefc4('0x3'));var rp=require(_0xefc4('0x4'));var moment=require(_0xefc4('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xefc4('0x6'));var path=require(_0xefc4('0x7'));var sox=require(_0xefc4('0x8'));var csv=require('to-csv');var ejs=require(_0xefc4('0x9'));var fs=require('fs');var fs_extra=require(_0xefc4('0xa'));var _=require(_0xefc4('0xb'));var squel=require(_0xefc4('0xc'));var crypto=require(_0xefc4('0xd'));var jsforce=require(_0xefc4('0xe'));var deskjs=require(_0xefc4('0xf'));var toCsv=require('to-csv');var querystring=require(_0xefc4('0x10'));var Papa=require(_0xefc4('0x11'));var Redis=require('ioredis');var authService=require(_0xefc4('0x12'));var qs=require(_0xefc4('0x13'));var as=require(_0xefc4('0x14'));var hardwareService=require(_0xefc4('0x15'));var logger=require(_0xefc4('0x16'))(_0xefc4('0x17'));var utils=require(_0xefc4('0x18'));var config=require(_0xefc4('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0xefc4('0x1a'))['db'];function respondWithStatusCode(_0x2765fe,_0xad5a52){_0xad5a52=_0xad5a52||0xcc;return function(_0x393bb0){if(_0x393bb0){return _0x2765fe[_0xefc4('0x1b')](_0xad5a52);}return _0x2765fe['status'](_0xad5a52)[_0xefc4('0x1c')]();};}function respondWithResult(_0x5c62e5,_0x3eb74d){_0x3eb74d=_0x3eb74d||0xc8;return function(_0x2cfd3c){if(_0x2cfd3c){return _0x5c62e5[_0xefc4('0x1d')](_0x3eb74d)['json'](_0x2cfd3c);}};}function respondWithFilteredResult(_0xb2cded,_0x4e9158){return function(_0xcaf20c){if(_0xcaf20c){var _0x4a59c8=typeof _0x4e9158[_0xefc4('0x1e')]==='undefined'&&typeof _0x4e9158[_0xefc4('0x1f')]===_0xefc4('0x20');var _0x577984=_0xcaf20c[_0xefc4('0x21')];var _0x23b80a=_0x4a59c8?0x0:_0x4e9158[_0xefc4('0x1e')];var _0x50a00e=_0x4a59c8?_0xcaf20c['count']:_0x4e9158[_0xefc4('0x1e')]+_0x4e9158[_0xefc4('0x1f')];var _0x257d8e;if(_0x50a00e>=_0x577984){_0x50a00e=_0x577984;_0x257d8e=0xc8;}else{_0x257d8e=0xce;}_0xb2cded['status'](_0x257d8e);return _0xb2cded['set'](_0xefc4('0x22'),_0x23b80a+'-'+_0x50a00e+'/'+_0x577984)['json'](_0xcaf20c);}return null;};}function patchUpdates(_0x486fa6){return function(_0x43d0c5){try{jsonpatch[_0xefc4('0x23')](_0x43d0c5,_0x486fa6,!![]);}catch(_0x1564fe){return BPromise[_0xefc4('0x24')](_0x1564fe);}return _0x43d0c5[_0xefc4('0x25')]();};}function saveUpdates(_0x59f6f3,_0x3c16b2){return function(_0x5aeb84){if(_0x5aeb84){return _0x5aeb84[_0xefc4('0x26')](_0x59f6f3)[_0xefc4('0x27')](function(_0x377913){return _0x377913;});}return null;};}function removeEntity(_0x5e534e,_0x3cc73e){return function(_0x2976aa){if(_0x2976aa){return _0x2976aa[_0xefc4('0x28')]()[_0xefc4('0x27')](function(){_0x5e534e[_0xefc4('0x1d')](0xcc)[_0xefc4('0x1c')]();});}};}function handleEntityNotFound(_0x2b4dae,_0x57d6df){return function(_0x5c0bee){if(!_0x5c0bee){_0x2b4dae[_0xefc4('0x1b')](0x194);}return _0x5c0bee;};}function handleError(_0x1ef42b,_0x3a856d){_0x3a856d=_0x3a856d||0x1f4;return function(_0x1bdb63){logger[_0xefc4('0x29')](_0x1bdb63[_0xefc4('0x2a')]);if(_0x1bdb63['name']){delete _0x1bdb63[_0xefc4('0x2b')];}_0x1ef42b[_0xefc4('0x1d')](_0x3a856d)['send'](_0x1bdb63);};}exports['index']=function(_0x4cd2d4,_0x2888b0){var _0x1f0d4d={},_0x9b2eaa={},_0x26e75a={'count':0x0,'rows':[]};var _0x5a47f3=_['map'](db['VoiceQueuesLog']['rawAttributes'],function(_0x23b027){return{'name':_0x23b027[_0xefc4('0x2c')],'type':_0x23b027[_0xefc4('0x2d')][_0xefc4('0x2e')]};});_0x9b2eaa[_0xefc4('0x2f')]=_[_0xefc4('0x30')](_0x5a47f3,_0xefc4('0x2b'));_0x9b2eaa[_0xefc4('0x31')]=_[_0xefc4('0x32')](_0x4cd2d4[_0xefc4('0x31')]);_0x9b2eaa['filters']=_[_0xefc4('0x33')](_0x9b2eaa[_0xefc4('0x2f')],_0x9b2eaa['query']);_0x1f0d4d['attributes']=_[_0xefc4('0x33')](_0x9b2eaa[_0xefc4('0x2f')],qs[_0xefc4('0x34')](_0x4cd2d4[_0xefc4('0x31')][_0xefc4('0x34')]));_0x1f0d4d['attributes']=_0x1f0d4d[_0xefc4('0x35')][_0xefc4('0x36')]?_0x1f0d4d['attributes']:_0x9b2eaa['model'];if(!_0x4cd2d4[_0xefc4('0x31')][_0xefc4('0x37')](_0xefc4('0x38'))){_0x1f0d4d[_0xefc4('0x1f')]=qs[_0xefc4('0x1f')](_0x4cd2d4[_0xefc4('0x31')][_0xefc4('0x1f')]);_0x1f0d4d['offset']=qs[_0xefc4('0x1e')](_0x4cd2d4[_0xefc4('0x31')][_0xefc4('0x1e')]);}_0x1f0d4d[_0xefc4('0x39')]=qs[_0xefc4('0x3a')](_0x4cd2d4[_0xefc4('0x31')][_0xefc4('0x3a')]);_0x1f0d4d[_0xefc4('0x3b')]=qs[_0xefc4('0x3c')](_[_0xefc4('0x3d')](_0x4cd2d4[_0xefc4('0x31')],_0x9b2eaa[_0xefc4('0x3c')]),_0x5a47f3);if(_0x4cd2d4[_0xefc4('0x31')]['filter']){_0x1f0d4d[_0xefc4('0x3b')]=_[_0xefc4('0x3e')](_0x1f0d4d['where'],{'$or':_['map'](_0x5a47f3,function(_0x533b21){if(_0x533b21[_0xefc4('0x2d')]!==_0xefc4('0x3f')){var _0x260b0b={};_0x260b0b[_0x533b21[_0xefc4('0x2b')]]={'$like':'%'+_0x4cd2d4['query'][_0xefc4('0x40')]+'%'};return _0x260b0b;}})});}_0x1f0d4d=_[_0xefc4('0x3e')]({},_0x1f0d4d,_0x4cd2d4[_0xefc4('0x41')]);var _0xe60749={'where':_0x1f0d4d[_0xefc4('0x3b')]};return db[_0xefc4('0x42')]['count'](_0xe60749)[_0xefc4('0x27')](function(_0x1ea118){_0x26e75a[_0xefc4('0x21')]=_0x1ea118;if(_0x4cd2d4[_0xefc4('0x31')][_0xefc4('0x43')]){_0x1f0d4d[_0xefc4('0x44')]=[{'all':!![]}];}return db[_0xefc4('0x42')]['findAll'](_0x1f0d4d);})[_0xefc4('0x27')](function(_0x46fcfa){_0x26e75a['rows']=_0x46fcfa;return _0x26e75a;})[_0xefc4('0x27')](respondWithFilteredResult(_0x2888b0,_0x1f0d4d))[_0xefc4('0x45')](handleError(_0x2888b0,null));};exports[_0xefc4('0x46')]=function(_0x1887b1,_0x102c00){var _0x207e5f={'raw':!![],'where':{'id':_0x1887b1['params']['id']}},_0x2be8a1={};_0x2be8a1[_0xefc4('0x2f')]=_[_0xefc4('0x32')](db[_0xefc4('0x42')][_0xefc4('0x47')]);_0x2be8a1['query']=_[_0xefc4('0x32')](_0x1887b1[_0xefc4('0x31')]);_0x2be8a1[_0xefc4('0x3c')]=_[_0xefc4('0x33')](_0x2be8a1[_0xefc4('0x2f')],_0x2be8a1[_0xefc4('0x31')]);_0x207e5f[_0xefc4('0x35')]=_['intersection'](_0x2be8a1['model'],qs[_0xefc4('0x34')](_0x1887b1[_0xefc4('0x31')][_0xefc4('0x34')]));_0x207e5f[_0xefc4('0x35')]=_0x207e5f[_0xefc4('0x35')][_0xefc4('0x36')]?_0x207e5f[_0xefc4('0x35')]:_0x2be8a1[_0xefc4('0x2f')];if(_0x1887b1[_0xefc4('0x31')][_0xefc4('0x43')]){_0x207e5f[_0xefc4('0x44')]=[{'all':!![]}];}_0x207e5f=_[_0xefc4('0x3e')]({},_0x207e5f,_0x1887b1[_0xefc4('0x41')]);return db[_0xefc4('0x42')]['find'](_0x207e5f)[_0xefc4('0x27')](handleEntityNotFound(_0x102c00,null))[_0xefc4('0x27')](respondWithResult(_0x102c00,null))['catch'](handleError(_0x102c00,null));};exports['create']=function(_0x2b700a,_0x993ec9){return db[_0xefc4('0x42')]['create'](_0x2b700a[_0xefc4('0x48')],{})[_0xefc4('0x27')](respondWithResult(_0x993ec9,0xc9))[_0xefc4('0x45')](handleError(_0x993ec9,null));};exports[_0xefc4('0x26')]=function(_0x11863d,_0xa07612){if(_0x11863d['body']['id']){delete _0x11863d['body']['id'];}return db[_0xefc4('0x42')]['find']({'where':{'id':_0x11863d[_0xefc4('0x49')]['id']}})[_0xefc4('0x27')](handleEntityNotFound(_0xa07612,null))[_0xefc4('0x27')](saveUpdates(_0x11863d[_0xefc4('0x48')],null))['then'](respondWithResult(_0xa07612,null))[_0xefc4('0x45')](handleError(_0xa07612,null));};exports[_0xefc4('0x28')]=function(_0x29a285,_0x2c2146){return db[_0xefc4('0x42')][_0xefc4('0x4a')]({'where':{'id':_0x29a285[_0xefc4('0x49')]['id']}})['then'](handleEntityNotFound(_0x2c2146,null))[_0xefc4('0x27')](removeEntity(_0x2c2146,null))[_0xefc4('0x45')](handleError(_0x2c2146,null));};