Built motion from commit (unavailable).|2.2.0
[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 _0xb5f5=['VIRTUAL','field','options','includeAll','include','catch','rawAttributes','create','body','find','params','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','ioredis','api','../../config/utils','../../config/environment','../../mysqldb','status','json','count','offset','limit','set','Content-Range','reject','save','update','then','destroy','end','sendStatus','error','stack','name','send','VoiceQueuesLog','keys','dateStart','query','dateEnd','filters','intersection','model','fields','attributes','length','hasOwnProperty','order','sort','pick','day','add','merge','where','filter','map','type','key'];(function(_0x4d0556,_0x320b1a){var _0x32272f=function(_0x2de3ab){while(--_0x2de3ab){_0x4d0556['push'](_0x4d0556['shift']());}};_0x32272f(++_0x320b1a);}(_0xb5f5,0x133));var _0x5b5f=function(_0x32bbf8,_0x2dba2d){_0x32bbf8=_0x32bbf8-0x0;var _0x7a4270=_0xb5f5[_0x32bbf8];return _0x7a4270;};'use strict';var pdf=require(_0x5b5f('0x0'));var emlformat=require(_0x5b5f('0x1'));var rimraf=require(_0x5b5f('0x2'));var zipdir=require(_0x5b5f('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5b5f('0x4'));var moment=require(_0x5b5f('0x5'));var BPromise=require(_0x5b5f('0x6'));var Mustache=require(_0x5b5f('0x7'));var util=require(_0x5b5f('0x8'));var path=require(_0x5b5f('0x9'));var sox=require('sox');var csv=require(_0x5b5f('0xa'));var ejs=require(_0x5b5f('0xb'));var fs=require('fs');var _=require(_0x5b5f('0xc'));var squel=require(_0x5b5f('0xd'));var crypto=require(_0x5b5f('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x5b5f('0xf'));var toCsv=require(_0x5b5f('0xa'));var querystring=require(_0x5b5f('0x10'));var Papa=require('papaparse');var Redis=require(_0x5b5f('0x11'));var qs=require('../../components/parsers/qs');var logger=require('../../config/logger')(_0x5b5f('0x12'));var utils=require(_0x5b5f('0x13'));var config=require(_0x5b5f('0x14'));var db=require(_0x5b5f('0x15'))['db'];function respondWithStatusCode(_0x101465,_0x16d3b8){_0x16d3b8=_0x16d3b8||0xcc;return function(_0x525a3d){if(_0x525a3d){return _0x101465['sendStatus'](_0x16d3b8);}return _0x101465[_0x5b5f('0x16')](_0x16d3b8)['end']();};}function respondWithResult(_0x395fa2,_0x556ee0){_0x556ee0=_0x556ee0||0xc8;return function(_0x3a81e5){if(_0x3a81e5){return _0x395fa2[_0x5b5f('0x16')](_0x556ee0)[_0x5b5f('0x17')](_0x3a81e5);}};}function respondWithFilteredResult(_0x412f65,_0x2ba504){return function(_0x2d95f7){if(_0x2d95f7){var _0x176abb=_0x2d95f7[_0x5b5f('0x18')],_0x5323b5=_0x2ba504[_0x5b5f('0x19')],_0x234029=_0x2ba504['offset']+_0x2ba504[_0x5b5f('0x1a')],_0x285f0f;if(_0x234029>=_0x176abb){_0x234029=_0x176abb;_0x285f0f=0xc8;}else{_0x285f0f=0xce;}_0x412f65[_0x5b5f('0x16')](_0x285f0f);return _0x412f65[_0x5b5f('0x1b')](_0x5b5f('0x1c'),_0x5323b5+'-'+_0x234029+'/'+_0x176abb)[_0x5b5f('0x17')](_0x2d95f7);}return null;};}function patchUpdates(_0x5ea923){return function(_0x578fa2){try{jsonpatch['apply'](_0x578fa2,_0x5ea923,!![]);}catch(_0x587063){return BPromise[_0x5b5f('0x1d')](_0x587063);}return _0x578fa2[_0x5b5f('0x1e')]();};}function saveUpdates(_0x53c3dd,_0x30873f){return function(_0x3d97c2){if(_0x3d97c2){return _0x3d97c2[_0x5b5f('0x1f')](_0x53c3dd)[_0x5b5f('0x20')](function(_0x2c8636){return _0x2c8636;});}return null;};}function removeEntity(_0x8b2cd,_0x3b7583){return function(_0x38a6c3){if(_0x38a6c3){return _0x38a6c3[_0x5b5f('0x21')]()['then'](function(){_0x8b2cd[_0x5b5f('0x16')](0xcc)[_0x5b5f('0x22')]();});}};}function handleEntityNotFound(_0x53577a,_0x3e66ac){return function(_0x397009){if(!_0x397009){_0x53577a[_0x5b5f('0x23')](0x194);}return _0x397009;};}function handleError(_0x5498d2,_0x459035){_0x459035=_0x459035||0x1f4;return function(_0xe27f09){logger[_0x5b5f('0x24')](_0xe27f09[_0x5b5f('0x25')]);if(_0xe27f09[_0x5b5f('0x26')]){delete _0xe27f09['name'];}_0x5498d2['status'](_0x459035)[_0x5b5f('0x27')](_0xe27f09);};}exports['index']=function(_0x625b70,_0x2fde55){var _0x20b012={},_0x15b2fb={},_0x4b5b37={'count':0x0,'rows':[]};var _0x497f3e=db[_0x5b5f('0x28')]['rawAttributes'];_0x15b2fb['model']=_[_0x5b5f('0x29')](_0x497f3e);var _0x16da74={'dateStart':_0x625b70['query'][_0x5b5f('0x2a')],'dateEnd':_0x625b70[_0x5b5f('0x2b')][_0x5b5f('0x2c')]};delete _0x625b70[_0x5b5f('0x2b')][_0x5b5f('0x2a')];delete _0x625b70['query'][_0x5b5f('0x2c')];_0x15b2fb[_0x5b5f('0x2b')]=_[_0x5b5f('0x29')](_0x625b70[_0x5b5f('0x2b')]);_0x15b2fb[_0x5b5f('0x2d')]=_[_0x5b5f('0x2e')](_0x15b2fb[_0x5b5f('0x2f')],_0x15b2fb[_0x5b5f('0x2b')]);_0x20b012['attributes']=_[_0x5b5f('0x2e')](_0x15b2fb['model'],qs[_0x5b5f('0x30')](_0x625b70[_0x5b5f('0x2b')][_0x5b5f('0x30')]));_0x20b012[_0x5b5f('0x31')]=_0x20b012[_0x5b5f('0x31')][_0x5b5f('0x32')]?_0x20b012[_0x5b5f('0x31')]:_0x15b2fb[_0x5b5f('0x2f')];if(!_0x625b70['query'][_0x5b5f('0x33')]('nolimit')){_0x20b012[_0x5b5f('0x1a')]=qs[_0x5b5f('0x1a')](_0x625b70[_0x5b5f('0x2b')][_0x5b5f('0x1a')]);_0x20b012[_0x5b5f('0x19')]=qs[_0x5b5f('0x19')](_0x625b70[_0x5b5f('0x2b')][_0x5b5f('0x19')]);}_0x20b012[_0x5b5f('0x34')]=qs[_0x5b5f('0x35')](_0x625b70['query']['sort']);_0x20b012['where']=qs['filters'](_[_0x5b5f('0x36')](_0x625b70[_0x5b5f('0x2b')],_0x15b2fb[_0x5b5f('0x2d')]));if(_0x16da74[_0x5b5f('0x2a')]){if(_0x16da74[_0x5b5f('0x2c')]){_0x16da74[_0x5b5f('0x2c')]=moment(_0x16da74[_0x5b5f('0x2c')])['add'](0x1,_0x5b5f('0x37'));}else{_0x16da74[_0x5b5f('0x2c')]=moment(_0x16da74[_0x5b5f('0x2a')])[_0x5b5f('0x38')](0x1,_0x5b5f('0x37'));}_[_0x5b5f('0x39')](_0x20b012[_0x5b5f('0x3a')],{'createdAt':{'$gte':_0x16da74[_0x5b5f('0x2a')],'$lte':_0x16da74[_0x5b5f('0x2c')]}});}if(_0x625b70[_0x5b5f('0x2b')][_0x5b5f('0x3b')]){_0x20b012[_0x5b5f('0x3a')]=_[_0x5b5f('0x39')](_0x20b012[_0x5b5f('0x3a')],{'$or':_[_0x5b5f('0x3c')](_0x497f3e,function(_0x557f20){if(_0x557f20[_0x5b5f('0x3d')][_0x5b5f('0x3e')]!==_0x5b5f('0x3f')){var _0x22f2c6={};_0x22f2c6[_0x557f20[_0x5b5f('0x40')]]={'$like':'%'+_0x625b70[_0x5b5f('0x2b')][_0x5b5f('0x3b')]+'%'};return _0x22f2c6;}})});}_0x20b012=_['merge']({},_0x20b012,_0x625b70[_0x5b5f('0x41')]);var _0x44f3ed={'where':_0x20b012['where']};return db[_0x5b5f('0x28')][_0x5b5f('0x18')](_0x44f3ed)['then'](function(_0x248d94){_0x4b5b37['count']=_0x248d94;if(_0x625b70[_0x5b5f('0x2b')][_0x5b5f('0x42')]){_0x20b012[_0x5b5f('0x43')]=[{'all':!![]}];}return db['VoiceQueuesLog']['findAll'](_0x20b012);})[_0x5b5f('0x20')](function(_0x3b872b){_0x4b5b37['rows']=_0x3b872b;return _0x4b5b37;})[_0x5b5f('0x20')](respondWithFilteredResult(_0x2fde55,_0x20b012))[_0x5b5f('0x44')](handleError(_0x2fde55,null));};exports['show']=function(_0xaea44a,_0xdc1221){var _0x4cec71={'raw':!![],'where':{'id':_0xaea44a['params']['id']}},_0x467de1={};_0x467de1[_0x5b5f('0x2f')]=_[_0x5b5f('0x29')](db[_0x5b5f('0x28')][_0x5b5f('0x45')]);_0x467de1['query']=_[_0x5b5f('0x29')](_0xaea44a[_0x5b5f('0x2b')]);_0x467de1[_0x5b5f('0x2d')]=_['intersection'](_0x467de1[_0x5b5f('0x2f')],_0x467de1[_0x5b5f('0x2b')]);_0x4cec71[_0x5b5f('0x31')]=_['intersection'](_0x467de1[_0x5b5f('0x2f')],qs[_0x5b5f('0x30')](_0xaea44a['query'][_0x5b5f('0x30')]));_0x4cec71[_0x5b5f('0x31')]=_0x4cec71[_0x5b5f('0x31')]['length']?_0x4cec71['attributes']:_0x467de1['model'];if(_0xaea44a[_0x5b5f('0x2b')]['includeAll']){_0x4cec71[_0x5b5f('0x43')]=[{'all':!![]}];}_0x4cec71=_['merge']({},_0x4cec71,_0xaea44a[_0x5b5f('0x41')]);return db[_0x5b5f('0x28')]['find'](_0x4cec71)['then'](handleEntityNotFound(_0xdc1221,null))['then'](respondWithResult(_0xdc1221,null))[_0x5b5f('0x44')](handleError(_0xdc1221,null));};exports[_0x5b5f('0x46')]=function(_0x1a00b6,_0x18be8a){return db[_0x5b5f('0x28')]['create'](_0x1a00b6['body'],{})[_0x5b5f('0x20')](respondWithResult(_0x18be8a,0xc9))[_0x5b5f('0x44')](handleError(_0x18be8a,null));};exports[_0x5b5f('0x1f')]=function(_0x336aa4,_0x224c68){if(_0x336aa4[_0x5b5f('0x47')]['id']){delete _0x336aa4[_0x5b5f('0x47')]['id'];}return db[_0x5b5f('0x28')][_0x5b5f('0x48')]({'where':{'id':_0x336aa4[_0x5b5f('0x49')]['id']}})[_0x5b5f('0x20')](handleEntityNotFound(_0x224c68,null))['then'](saveUpdates(_0x336aa4[_0x5b5f('0x47')],null))[_0x5b5f('0x20')](respondWithResult(_0x224c68,null))[_0x5b5f('0x44')](handleError(_0x224c68,null));};exports[_0x5b5f('0x21')]=function(_0xa9c1d4,_0x49e319){return db['VoiceQueuesLog']['find']({'where':{'id':_0xa9c1d4[_0x5b5f('0x49')]['id']}})[_0x5b5f('0x20')](handleEntityNotFound(_0x49e319,null))[_0x5b5f('0x20')](removeEntity(_0x49e319,null))['catch'](handleError(_0x49e319,null));};