Built motion from commit (unavailable).|2.3.4
[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 _0xed89=['find','html-pdf','eml-format','rimraf','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../config/license/hardware','../../components/parsers/qs','../../config/logger','../../config/utils','../../config/environment','sendStatus','end','status','offset','set','json','apply','reject','save','update','destroy','then','stack','name','send','index','VoiceQueuesLog','rawAttributes','model','keys','filters','intersection','query','attributes','fields','length','limit','order','sort','filter','merge','where','map','type','key','VIRTUAL','field','options','count','includeAll','rows','catch','show','params','include','create'];(function(_0x3ca92f,_0x579ab8){var _0x2b5288=function(_0x16d655){while(--_0x16d655){_0x3ca92f['push'](_0x3ca92f['shift']());}};_0x2b5288(++_0x579ab8);}(_0xed89,0x8f));var _0x9ed8=function(_0x3e37b1,_0x2baf5d){_0x3e37b1=_0x3e37b1-0x0;var _0x2fe97e=_0xed89[_0x3e37b1];return _0x2fe97e;};'use strict';var pdf=require(_0x9ed8('0x0'));var emlformat=require(_0x9ed8('0x1'));var rimraf=require(_0x9ed8('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x9ed8('0x3'));var moment=require(_0x9ed8('0x4'));var BPromise=require(_0x9ed8('0x5'));var Mustache=require(_0x9ed8('0x6'));var util=require(_0x9ed8('0x7'));var path=require(_0x9ed8('0x8'));var sox=require(_0x9ed8('0x9'));var csv=require(_0x9ed8('0xa'));var ejs=require(_0x9ed8('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0x9ed8('0xc'));var crypto=require(_0x9ed8('0xd'));var jsforce=require(_0x9ed8('0xe'));var deskjs=require(_0x9ed8('0xf'));var toCsv=require(_0x9ed8('0xa'));var querystring=require(_0x9ed8('0x10'));var Papa=require(_0x9ed8('0x11'));var authService=require(_0x9ed8('0x12'));var hardwareService=require(_0x9ed8('0x13'));var Redis=require('ioredis');var qs=require(_0x9ed8('0x14'));var logger=require(_0x9ed8('0x15'))('api');var utils=require(_0x9ed8('0x16'));var config=require(_0x9ed8('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x545dc1,_0xf9b8ce){_0xf9b8ce=_0xf9b8ce||0xcc;return function(_0x465a34){if(_0x465a34){return _0x545dc1[_0x9ed8('0x18')](_0xf9b8ce);}return _0x545dc1['status'](_0xf9b8ce)[_0x9ed8('0x19')]();};}function respondWithResult(_0x2c424b,_0x3def5f){_0x3def5f=_0x3def5f||0xc8;return function(_0x4528f0){if(_0x4528f0){return _0x2c424b[_0x9ed8('0x1a')](_0x3def5f)['json'](_0x4528f0);}};}function respondWithFilteredResult(_0x451c11,_0x4dbdd4){return function(_0x171b0a){if(_0x171b0a){var _0x3b9630=_0x171b0a['count'],_0x158eac=_0x4dbdd4[_0x9ed8('0x1b')],_0x5dd4d1=_0x4dbdd4[_0x9ed8('0x1b')]+_0x4dbdd4['limit'],_0x27252a;if(_0x5dd4d1>=_0x3b9630){_0x5dd4d1=_0x3b9630;_0x27252a=0xc8;}else{_0x27252a=0xce;}_0x451c11[_0x9ed8('0x1a')](_0x27252a);return _0x451c11[_0x9ed8('0x1c')]('Content-Range',_0x158eac+'-'+_0x5dd4d1+'/'+_0x3b9630)[_0x9ed8('0x1d')](_0x171b0a);}return null;};}function patchUpdates(_0x3bfcb3){return function(_0x605857){try{jsonpatch[_0x9ed8('0x1e')](_0x605857,_0x3bfcb3,!![]);}catch(_0x14776d){return BPromise[_0x9ed8('0x1f')](_0x14776d);}return _0x605857[_0x9ed8('0x20')]();};}function saveUpdates(_0x317dca,_0x393e44){return function(_0x4c885b){if(_0x4c885b){return _0x4c885b[_0x9ed8('0x21')](_0x317dca)['then'](function(_0x1ba76b){return _0x1ba76b;});}return null;};}function removeEntity(_0x18129f,_0x1f59ea){return function(_0x20a95a){if(_0x20a95a){return _0x20a95a[_0x9ed8('0x22')]()[_0x9ed8('0x23')](function(){_0x18129f[_0x9ed8('0x1a')](0xcc)[_0x9ed8('0x19')]();});}};}function handleEntityNotFound(_0xdc0eb5,_0x310d76){return function(_0x365b4b){if(!_0x365b4b){_0xdc0eb5[_0x9ed8('0x18')](0x194);}return _0x365b4b;};}function handleError(_0x5c5cfb,_0x2ad7d9){_0x2ad7d9=_0x2ad7d9||0x1f4;return function(_0x2c7318){logger['error'](_0x2c7318[_0x9ed8('0x24')]);if(_0x2c7318[_0x9ed8('0x25')]){delete _0x2c7318[_0x9ed8('0x25')];}_0x5c5cfb['status'](_0x2ad7d9)[_0x9ed8('0x26')](_0x2c7318);};}exports[_0x9ed8('0x27')]=function(_0x4b314b,_0x33166e){var _0x40efd1={},_0x50835e={},_0xb30efe={'count':0x0,'rows':[]};var _0x1f2a25=db[_0x9ed8('0x28')][_0x9ed8('0x29')];_0x50835e[_0x9ed8('0x2a')]=_[_0x9ed8('0x2b')](_0x1f2a25);_0x50835e['query']=_[_0x9ed8('0x2b')](_0x4b314b['query']);_0x50835e[_0x9ed8('0x2c')]=_[_0x9ed8('0x2d')](_0x50835e['model'],_0x50835e[_0x9ed8('0x2e')]);_0x40efd1[_0x9ed8('0x2f')]=_[_0x9ed8('0x2d')](_0x50835e[_0x9ed8('0x2a')],qs[_0x9ed8('0x30')](_0x4b314b['query']['fields']));_0x40efd1[_0x9ed8('0x2f')]=_0x40efd1[_0x9ed8('0x2f')][_0x9ed8('0x31')]?_0x40efd1[_0x9ed8('0x2f')]:_0x50835e[_0x9ed8('0x2a')];if(!_0x4b314b[_0x9ed8('0x2e')]['hasOwnProperty']('nolimit')){_0x40efd1[_0x9ed8('0x32')]=qs['limit'](_0x4b314b['query'][_0x9ed8('0x32')]);_0x40efd1['offset']=qs['offset'](_0x4b314b[_0x9ed8('0x2e')][_0x9ed8('0x1b')]);}_0x40efd1[_0x9ed8('0x33')]=qs['sort'](_0x4b314b['query'][_0x9ed8('0x34')]);_0x40efd1['where']=qs[_0x9ed8('0x2c')](_['pick'](_0x4b314b['query'],_0x50835e[_0x9ed8('0x2c')]));if(_0x4b314b[_0x9ed8('0x2e')][_0x9ed8('0x35')]){_0x40efd1['where']=_[_0x9ed8('0x36')](_0x40efd1[_0x9ed8('0x37')],{'$or':_[_0x9ed8('0x38')](_0x1f2a25,function(_0x17393b){if(_0x17393b[_0x9ed8('0x39')][_0x9ed8('0x3a')]!==_0x9ed8('0x3b')){var _0x53dba4={};_0x53dba4[_0x17393b[_0x9ed8('0x3c')]]={'$like':'%'+_0x4b314b[_0x9ed8('0x2e')]['filter']+'%'};return _0x53dba4;}})});}_0x40efd1=_[_0x9ed8('0x36')]({},_0x40efd1,_0x4b314b[_0x9ed8('0x3d')]);var _0x3d9cbc={'where':_0x40efd1['where']};return db['VoiceQueuesLog']['count'](_0x3d9cbc)[_0x9ed8('0x23')](function(_0x58e079){_0xb30efe[_0x9ed8('0x3e')]=_0x58e079;if(_0x4b314b[_0x9ed8('0x2e')][_0x9ed8('0x3f')]){_0x40efd1['include']=[{'all':!![]}];}return db[_0x9ed8('0x28')]['findAll'](_0x40efd1);})[_0x9ed8('0x23')](function(_0x37b937){_0xb30efe[_0x9ed8('0x40')]=_0x37b937;return _0xb30efe;})[_0x9ed8('0x23')](respondWithFilteredResult(_0x33166e,_0x40efd1))[_0x9ed8('0x41')](handleError(_0x33166e,null));};exports[_0x9ed8('0x42')]=function(_0x3361f5,_0x320488){var _0x5926e0={'raw':!![],'where':{'id':_0x3361f5[_0x9ed8('0x43')]['id']}},_0x3a420b={};_0x3a420b[_0x9ed8('0x2a')]=_[_0x9ed8('0x2b')](db[_0x9ed8('0x28')][_0x9ed8('0x29')]);_0x3a420b[_0x9ed8('0x2e')]=_[_0x9ed8('0x2b')](_0x3361f5[_0x9ed8('0x2e')]);_0x3a420b[_0x9ed8('0x2c')]=_['intersection'](_0x3a420b[_0x9ed8('0x2a')],_0x3a420b['query']);_0x5926e0[_0x9ed8('0x2f')]=_[_0x9ed8('0x2d')](_0x3a420b['model'],qs['fields'](_0x3361f5[_0x9ed8('0x2e')][_0x9ed8('0x30')]));_0x5926e0[_0x9ed8('0x2f')]=_0x5926e0['attributes'][_0x9ed8('0x31')]?_0x5926e0[_0x9ed8('0x2f')]:_0x3a420b['model'];if(_0x3361f5[_0x9ed8('0x2e')]['includeAll']){_0x5926e0[_0x9ed8('0x44')]=[{'all':!![]}];}_0x5926e0=_[_0x9ed8('0x36')]({},_0x5926e0,_0x3361f5['options']);return db['VoiceQueuesLog']['find'](_0x5926e0)[_0x9ed8('0x23')](handleEntityNotFound(_0x320488,null))['then'](respondWithResult(_0x320488,null))[_0x9ed8('0x41')](handleError(_0x320488,null));};exports[_0x9ed8('0x45')]=function(_0x8a9405,_0x4e3402){return db[_0x9ed8('0x28')][_0x9ed8('0x45')](_0x8a9405['body'],{})[_0x9ed8('0x23')](respondWithResult(_0x4e3402,0xc9))[_0x9ed8('0x41')](handleError(_0x4e3402,null));};exports[_0x9ed8('0x21')]=function(_0x1a648b,_0x4973cb){if(_0x1a648b['body']['id']){delete _0x1a648b['body']['id'];}return db['VoiceQueuesLog'][_0x9ed8('0x46')]({'where':{'id':_0x1a648b[_0x9ed8('0x43')]['id']}})[_0x9ed8('0x23')](handleEntityNotFound(_0x4973cb,null))[_0x9ed8('0x23')](saveUpdates(_0x1a648b['body'],null))[_0x9ed8('0x23')](respondWithResult(_0x4973cb,null))[_0x9ed8('0x41')](handleError(_0x4973cb,null));};exports[_0x9ed8('0x22')]=function(_0x414a85,_0x48c0b0){return db[_0x9ed8('0x28')][_0x9ed8('0x46')]({'where':{'id':_0x414a85[_0x9ed8('0x43')]['id']}})[_0x9ed8('0x23')](handleEntityNotFound(_0x48c0b0,null))[_0x9ed8('0x23')](removeEntity(_0x48c0b0,null))[_0x9ed8('0x41')](handleError(_0x48c0b0,null));};