cf16400bcf52e40b317ce02cafb14f7898465900
[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 _0xebf0=['VIRTUAL','includeAll','include','catch','show','params','rawAttributes','options','find','create','body','update','html-pdf','eml-format','zip-dir','request-promise','moment','mustache','path','sox','to-csv','ejs','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','count','offset','limit','apply','then','destroy','error','stack','name','send','index','VoiceQueuesLog','fieldName','type','key','model','map','query','keys','intersection','attributes','fields','length','nolimit','sort','filters','pick','filter','where','merge'];(function(_0xfad7dd,_0x1dd999){var _0x2d37c6=function(_0x44f935){while(--_0x44f935){_0xfad7dd['push'](_0xfad7dd['shift']());}};_0x2d37c6(++_0x1dd999);}(_0xebf0,0x98));var _0x0ebf=function(_0x2669b6,_0x2193ea){_0x2669b6=_0x2669b6-0x0;var _0x4ebc0b=_0xebf0[_0x2669b6];return _0x4ebc0b;};'use strict';var pdf=require(_0x0ebf('0x0'));var emlformat=require(_0x0ebf('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x0ebf('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x0ebf('0x3'));var moment=require(_0x0ebf('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x0ebf('0x5'));var util=require('util');var path=require(_0x0ebf('0x6'));var sox=require(_0x0ebf('0x7'));var csv=require(_0x0ebf('0x8'));var ejs=require(_0x0ebf('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0x0ebf('0xa'));var crypto=require(_0x0ebf('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x0ebf('0xc'));var toCsv=require('to-csv');var querystring=require(_0x0ebf('0xd'));var Papa=require(_0x0ebf('0xe'));var Redis=require(_0x0ebf('0xf'));var authService=require(_0x0ebf('0x10'));var qs=require(_0x0ebf('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0ebf('0x12'));var logger=require(_0x0ebf('0x13'))(_0x0ebf('0x14'));var utils=require(_0x0ebf('0x15'));var config=require(_0x0ebf('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x0ebf('0x17'))['db'];function respondWithStatusCode(_0x551e5c,_0x2948a8){_0x2948a8=_0x2948a8||0xcc;return function(_0x350c46){if(_0x350c46){return _0x551e5c[_0x0ebf('0x18')](_0x2948a8);}return _0x551e5c[_0x0ebf('0x19')](_0x2948a8)[_0x0ebf('0x1a')]();};}function respondWithResult(_0xd7402b,_0xbe726b){_0xbe726b=_0xbe726b||0xc8;return function(_0x1c72f3){if(_0x1c72f3){return _0xd7402b[_0x0ebf('0x19')](_0xbe726b)[_0x0ebf('0x1b')](_0x1c72f3);}};}function respondWithFilteredResult(_0x401650,_0x2b51be){return function(_0x1eaad0){if(_0x1eaad0){var _0x43c6d6=_0x1eaad0[_0x0ebf('0x1c')],_0x2ab4fe=_0x2b51be[_0x0ebf('0x1d')],_0x518d8a=_0x2b51be[_0x0ebf('0x1d')]+_0x2b51be[_0x0ebf('0x1e')],_0x1e0e6e;if(_0x518d8a>=_0x43c6d6){_0x518d8a=_0x43c6d6;_0x1e0e6e=0xc8;}else{_0x1e0e6e=0xce;}_0x401650[_0x0ebf('0x19')](_0x1e0e6e);return _0x401650['set']('Content-Range',_0x2ab4fe+'-'+_0x518d8a+'/'+_0x43c6d6)[_0x0ebf('0x1b')](_0x1eaad0);}return null;};}function patchUpdates(_0xcf7e84){return function(_0x49470c){try{jsonpatch[_0x0ebf('0x1f')](_0x49470c,_0xcf7e84,!![]);}catch(_0x36a1ff){return BPromise['reject'](_0x36a1ff);}return _0x49470c['save']();};}function saveUpdates(_0x7b9b50,_0x34509c){return function(_0x246529){if(_0x246529){return _0x246529['update'](_0x7b9b50)[_0x0ebf('0x20')](function(_0x236539){return _0x236539;});}return null;};}function removeEntity(_0x2e6d38,_0x4dff1e){return function(_0x368f29){if(_0x368f29){return _0x368f29[_0x0ebf('0x21')]()[_0x0ebf('0x20')](function(){_0x2e6d38['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x231d2b,_0x3f727a){return function(_0x331755){if(!_0x331755){_0x231d2b[_0x0ebf('0x18')](0x194);}return _0x331755;};}function handleError(_0x40e2a9,_0x33b8be){_0x33b8be=_0x33b8be||0x1f4;return function(_0x4b4162){logger[_0x0ebf('0x22')](_0x4b4162[_0x0ebf('0x23')]);if(_0x4b4162['name']){delete _0x4b4162[_0x0ebf('0x24')];}_0x40e2a9[_0x0ebf('0x19')](_0x33b8be)[_0x0ebf('0x25')](_0x4b4162);};}exports[_0x0ebf('0x26')]=function(_0x4b2d60,_0x1c261f){var _0x3ea6c1={},_0x5f05dc={},_0x595e3f={'count':0x0,'rows':[]};var _0x340c9e=_['map'](db[_0x0ebf('0x27')]['rawAttributes'],function(_0x4b976c){return{'name':_0x4b976c[_0x0ebf('0x28')],'type':_0x4b976c[_0x0ebf('0x29')][_0x0ebf('0x2a')]};});_0x5f05dc[_0x0ebf('0x2b')]=_[_0x0ebf('0x2c')](_0x340c9e,_0x0ebf('0x24'));_0x5f05dc[_0x0ebf('0x2d')]=_[_0x0ebf('0x2e')](_0x4b2d60[_0x0ebf('0x2d')]);_0x5f05dc['filters']=_[_0x0ebf('0x2f')](_0x5f05dc[_0x0ebf('0x2b')],_0x5f05dc['query']);_0x3ea6c1[_0x0ebf('0x30')]=_[_0x0ebf('0x2f')](_0x5f05dc[_0x0ebf('0x2b')],qs[_0x0ebf('0x31')](_0x4b2d60[_0x0ebf('0x2d')][_0x0ebf('0x31')]));_0x3ea6c1['attributes']=_0x3ea6c1['attributes'][_0x0ebf('0x32')]?_0x3ea6c1['attributes']:_0x5f05dc[_0x0ebf('0x2b')];if(!_0x4b2d60['query']['hasOwnProperty'](_0x0ebf('0x33'))){_0x3ea6c1[_0x0ebf('0x1e')]=qs[_0x0ebf('0x1e')](_0x4b2d60[_0x0ebf('0x2d')]['limit']);_0x3ea6c1['offset']=qs[_0x0ebf('0x1d')](_0x4b2d60[_0x0ebf('0x2d')][_0x0ebf('0x1d')]);}_0x3ea6c1['order']=qs['sort'](_0x4b2d60[_0x0ebf('0x2d')][_0x0ebf('0x34')]);_0x3ea6c1['where']=qs[_0x0ebf('0x35')](_[_0x0ebf('0x36')](_0x4b2d60[_0x0ebf('0x2d')],_0x5f05dc[_0x0ebf('0x35')]),_0x340c9e);if(_0x4b2d60[_0x0ebf('0x2d')][_0x0ebf('0x37')]){_0x3ea6c1[_0x0ebf('0x38')]=_[_0x0ebf('0x39')](_0x3ea6c1[_0x0ebf('0x38')],{'$or':_[_0x0ebf('0x2c')](_0x340c9e,function(_0x5a4238){if(_0x5a4238[_0x0ebf('0x29')]!==_0x0ebf('0x3a')){var _0x1982e8={};_0x1982e8[_0x5a4238[_0x0ebf('0x24')]]={'$like':'%'+_0x4b2d60['query'][_0x0ebf('0x37')]+'%'};return _0x1982e8;}})});}_0x3ea6c1=_['merge']({},_0x3ea6c1,_0x4b2d60['options']);var _0x53ff53={'where':_0x3ea6c1[_0x0ebf('0x38')]};return db['VoiceQueuesLog']['count'](_0x53ff53)[_0x0ebf('0x20')](function(_0x1f21ca){_0x595e3f[_0x0ebf('0x1c')]=_0x1f21ca;if(_0x4b2d60[_0x0ebf('0x2d')][_0x0ebf('0x3b')]){_0x3ea6c1[_0x0ebf('0x3c')]=[{'all':!![]}];}return db['VoiceQueuesLog']['findAll'](_0x3ea6c1);})[_0x0ebf('0x20')](function(_0xb0b0e4){_0x595e3f['rows']=_0xb0b0e4;return _0x595e3f;})[_0x0ebf('0x20')](respondWithFilteredResult(_0x1c261f,_0x3ea6c1))[_0x0ebf('0x3d')](handleError(_0x1c261f,null));};exports[_0x0ebf('0x3e')]=function(_0x1ef74b,_0x2669bf){var _0x13c88b={'raw':!![],'where':{'id':_0x1ef74b[_0x0ebf('0x3f')]['id']}},_0x89a35={};_0x89a35[_0x0ebf('0x2b')]=_[_0x0ebf('0x2e')](db[_0x0ebf('0x27')][_0x0ebf('0x40')]);_0x89a35['query']=_[_0x0ebf('0x2e')](_0x1ef74b[_0x0ebf('0x2d')]);_0x89a35[_0x0ebf('0x35')]=_[_0x0ebf('0x2f')](_0x89a35[_0x0ebf('0x2b')],_0x89a35['query']);_0x13c88b[_0x0ebf('0x30')]=_[_0x0ebf('0x2f')](_0x89a35[_0x0ebf('0x2b')],qs[_0x0ebf('0x31')](_0x1ef74b[_0x0ebf('0x2d')][_0x0ebf('0x31')]));_0x13c88b[_0x0ebf('0x30')]=_0x13c88b[_0x0ebf('0x30')][_0x0ebf('0x32')]?_0x13c88b[_0x0ebf('0x30')]:_0x89a35['model'];if(_0x1ef74b[_0x0ebf('0x2d')][_0x0ebf('0x3b')]){_0x13c88b['include']=[{'all':!![]}];}_0x13c88b=_[_0x0ebf('0x39')]({},_0x13c88b,_0x1ef74b[_0x0ebf('0x41')]);return db[_0x0ebf('0x27')][_0x0ebf('0x42')](_0x13c88b)[_0x0ebf('0x20')](handleEntityNotFound(_0x2669bf,null))[_0x0ebf('0x20')](respondWithResult(_0x2669bf,null))[_0x0ebf('0x3d')](handleError(_0x2669bf,null));};exports[_0x0ebf('0x43')]=function(_0x5c9c65,_0x367fc1){return db[_0x0ebf('0x27')][_0x0ebf('0x43')](_0x5c9c65[_0x0ebf('0x44')],{})[_0x0ebf('0x20')](respondWithResult(_0x367fc1,0xc9))[_0x0ebf('0x3d')](handleError(_0x367fc1,null));};exports[_0x0ebf('0x45')]=function(_0x48930b,_0x261f13){if(_0x48930b[_0x0ebf('0x44')]['id']){delete _0x48930b[_0x0ebf('0x44')]['id'];}return db[_0x0ebf('0x27')][_0x0ebf('0x42')]({'where':{'id':_0x48930b[_0x0ebf('0x3f')]['id']}})[_0x0ebf('0x20')](handleEntityNotFound(_0x261f13,null))['then'](saveUpdates(_0x48930b[_0x0ebf('0x44')],null))['then'](respondWithResult(_0x261f13,null))[_0x0ebf('0x3d')](handleError(_0x261f13,null));};exports['destroy']=function(_0x5842d7,_0x5e9c74){return db['VoiceQueuesLog']['find']({'where':{'id':_0x5842d7[_0x0ebf('0x3f')]['id']}})[_0x0ebf('0x20')](handleEntityNotFound(_0x5e9c74,null))['then'](removeEntity(_0x5e9c74,null))[_0x0ebf('0x3d')](handleError(_0x5e9c74,null));};