Built motion from commit (unavailable).|2.5.10
[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 _0x1f72=['map','VoiceQueuesLog','rawAttributes','type','key','model','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filters','where','merge','VIRTUAL','options','findAll','rows','show','params','keys','include','find','catch','create','body','html-pdf','rimraf','fast-json-patch','request-promise','path','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','end','status','json','count','offset','limit','Content-Range','apply','reject','save','update','then','destroy','sendStatus','error','stack','name','send','index'];(function(_0x298e73,_0x4a537c){var _0x5391d8=function(_0x1c010e){while(--_0x1c010e){_0x298e73['push'](_0x298e73['shift']());}};_0x5391d8(++_0x4a537c);}(_0x1f72,0xaa));var _0x21f7=function(_0xf9ad3,_0x448841){_0xf9ad3=_0xf9ad3-0x0;var _0x4d5f88=_0x1f72[_0xf9ad3];return _0x4d5f88;};'use strict';var pdf=require(_0x21f7('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x21f7('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x21f7('0x2'));var rp=require(_0x21f7('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0x21f7('0x4'));var sox=require('sox');var csv=require(_0x21f7('0x5'));var ejs=require(_0x21f7('0x6'));var fs=require('fs');var _=require(_0x21f7('0x7'));var squel=require(_0x21f7('0x8'));var crypto=require('crypto');var jsforce=require(_0x21f7('0x9'));var deskjs=require(_0x21f7('0xa'));var toCsv=require(_0x21f7('0x5'));var querystring=require(_0x21f7('0xb'));var Papa=require(_0x21f7('0xc'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x21f7('0xd'));var as=require(_0x21f7('0xe'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x21f7('0xf'))(_0x21f7('0x10'));var utils=require(_0x21f7('0x11'));var config=require(_0x21f7('0x12'));var licenseUtil=require(_0x21f7('0x13'));var db=require(_0x21f7('0x14'))['db'];function respondWithStatusCode(_0x5cc733,_0x81bc94){_0x81bc94=_0x81bc94||0xcc;return function(_0x4b4417){if(_0x4b4417){return _0x5cc733['sendStatus'](_0x81bc94);}return _0x5cc733['status'](_0x81bc94)[_0x21f7('0x15')]();};}function respondWithResult(_0xdefdfb,_0x116790){_0x116790=_0x116790||0xc8;return function(_0xf7a6f5){if(_0xf7a6f5){return _0xdefdfb[_0x21f7('0x16')](_0x116790)[_0x21f7('0x17')](_0xf7a6f5);}};}function respondWithFilteredResult(_0x19d6a8,_0x289f2e){return function(_0x2c87ab){if(_0x2c87ab){var _0x1cb487=_0x2c87ab[_0x21f7('0x18')],_0x2bc24d=_0x289f2e[_0x21f7('0x19')],_0x496f7e=_0x289f2e['offset']+_0x289f2e[_0x21f7('0x1a')],_0x4b544e;if(_0x496f7e>=_0x1cb487){_0x496f7e=_0x1cb487;_0x4b544e=0xc8;}else{_0x4b544e=0xce;}_0x19d6a8[_0x21f7('0x16')](_0x4b544e);return _0x19d6a8['set'](_0x21f7('0x1b'),_0x2bc24d+'-'+_0x496f7e+'/'+_0x1cb487)[_0x21f7('0x17')](_0x2c87ab);}return null;};}function patchUpdates(_0x14581c){return function(_0x35d96a){try{jsonpatch[_0x21f7('0x1c')](_0x35d96a,_0x14581c,!![]);}catch(_0x5bc685){return BPromise[_0x21f7('0x1d')](_0x5bc685);}return _0x35d96a[_0x21f7('0x1e')]();};}function saveUpdates(_0x20986a,_0x3299f1){return function(_0x1de426){if(_0x1de426){return _0x1de426[_0x21f7('0x1f')](_0x20986a)[_0x21f7('0x20')](function(_0x35783b){return _0x35783b;});}return null;};}function removeEntity(_0x120a6d,_0x3ac68f){return function(_0x39cce5){if(_0x39cce5){return _0x39cce5[_0x21f7('0x21')]()['then'](function(){_0x120a6d['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3b4ce8,_0xf2a60d){return function(_0x11ce5e){if(!_0x11ce5e){_0x3b4ce8[_0x21f7('0x22')](0x194);}return _0x11ce5e;};}function handleError(_0x1c489c,_0x96d85c){_0x96d85c=_0x96d85c||0x1f4;return function(_0x420909){logger[_0x21f7('0x23')](_0x420909[_0x21f7('0x24')]);if(_0x420909[_0x21f7('0x25')]){delete _0x420909[_0x21f7('0x25')];}_0x1c489c[_0x21f7('0x16')](_0x96d85c)[_0x21f7('0x26')](_0x420909);};}exports[_0x21f7('0x27')]=function(_0x5bd43c,_0x275a93){var _0x26f74b={},_0x6722d7={},_0x1db96d={'count':0x0,'rows':[]};var _0x20b029=_[_0x21f7('0x28')](db[_0x21f7('0x29')][_0x21f7('0x2a')],function(_0x306dd2){return{'name':_0x306dd2['fieldName'],'type':_0x306dd2[_0x21f7('0x2b')][_0x21f7('0x2c')]};});_0x6722d7[_0x21f7('0x2d')]=_[_0x21f7('0x28')](_0x20b029,_0x21f7('0x25'));_0x6722d7[_0x21f7('0x2e')]=_['keys'](_0x5bd43c[_0x21f7('0x2e')]);_0x6722d7['filters']=_[_0x21f7('0x2f')](_0x6722d7['model'],_0x6722d7[_0x21f7('0x2e')]);_0x26f74b[_0x21f7('0x30')]=_[_0x21f7('0x2f')](_0x6722d7[_0x21f7('0x2d')],qs[_0x21f7('0x31')](_0x5bd43c[_0x21f7('0x2e')]['fields']));_0x26f74b['attributes']=_0x26f74b[_0x21f7('0x30')][_0x21f7('0x32')]?_0x26f74b[_0x21f7('0x30')]:_0x6722d7[_0x21f7('0x2d')];if(!_0x5bd43c[_0x21f7('0x2e')][_0x21f7('0x33')](_0x21f7('0x34'))){_0x26f74b['limit']=qs[_0x21f7('0x1a')](_0x5bd43c[_0x21f7('0x2e')]['limit']);_0x26f74b[_0x21f7('0x19')]=qs[_0x21f7('0x19')](_0x5bd43c[_0x21f7('0x2e')][_0x21f7('0x19')]);}_0x26f74b[_0x21f7('0x35')]=qs[_0x21f7('0x36')](_0x5bd43c[_0x21f7('0x2e')][_0x21f7('0x36')]);_0x26f74b['where']=qs[_0x21f7('0x37')](_['pick'](_0x5bd43c[_0x21f7('0x2e')],_0x6722d7[_0x21f7('0x37')]),_0x20b029);if(_0x5bd43c[_0x21f7('0x2e')]['filter']){_0x26f74b[_0x21f7('0x38')]=_[_0x21f7('0x39')](_0x26f74b[_0x21f7('0x38')],{'$or':_[_0x21f7('0x28')](_0x20b029,function(_0x2ec095){if(_0x2ec095[_0x21f7('0x2b')]!==_0x21f7('0x3a')){var _0x57b6f8={};_0x57b6f8[_0x2ec095[_0x21f7('0x25')]]={'$like':'%'+_0x5bd43c[_0x21f7('0x2e')]['filter']+'%'};return _0x57b6f8;}})});}_0x26f74b=_[_0x21f7('0x39')]({},_0x26f74b,_0x5bd43c[_0x21f7('0x3b')]);var _0x2fe9fd={'where':_0x26f74b['where']};return db[_0x21f7('0x29')][_0x21f7('0x18')](_0x2fe9fd)[_0x21f7('0x20')](function(_0x5a21e9){_0x1db96d[_0x21f7('0x18')]=_0x5a21e9;if(_0x5bd43c[_0x21f7('0x2e')]['includeAll']){_0x26f74b['include']=[{'all':!![]}];}return db[_0x21f7('0x29')][_0x21f7('0x3c')](_0x26f74b);})[_0x21f7('0x20')](function(_0x2e6861){_0x1db96d[_0x21f7('0x3d')]=_0x2e6861;return _0x1db96d;})[_0x21f7('0x20')](respondWithFilteredResult(_0x275a93,_0x26f74b))['catch'](handleError(_0x275a93,null));};exports[_0x21f7('0x3e')]=function(_0x49ca5d,_0x46b239){var _0x300aad={'raw':!![],'where':{'id':_0x49ca5d[_0x21f7('0x3f')]['id']}},_0x4a7ac8={};_0x4a7ac8[_0x21f7('0x2d')]=_[_0x21f7('0x40')](db[_0x21f7('0x29')]['rawAttributes']);_0x4a7ac8[_0x21f7('0x2e')]=_['keys'](_0x49ca5d['query']);_0x4a7ac8[_0x21f7('0x37')]=_[_0x21f7('0x2f')](_0x4a7ac8[_0x21f7('0x2d')],_0x4a7ac8[_0x21f7('0x2e')]);_0x300aad['attributes']=_[_0x21f7('0x2f')](_0x4a7ac8[_0x21f7('0x2d')],qs[_0x21f7('0x31')](_0x49ca5d['query'][_0x21f7('0x31')]));_0x300aad[_0x21f7('0x30')]=_0x300aad[_0x21f7('0x30')]['length']?_0x300aad['attributes']:_0x4a7ac8[_0x21f7('0x2d')];if(_0x49ca5d['query']['includeAll']){_0x300aad[_0x21f7('0x41')]=[{'all':!![]}];}_0x300aad=_[_0x21f7('0x39')]({},_0x300aad,_0x49ca5d[_0x21f7('0x3b')]);return db[_0x21f7('0x29')][_0x21f7('0x42')](_0x300aad)['then'](handleEntityNotFound(_0x46b239,null))[_0x21f7('0x20')](respondWithResult(_0x46b239,null))[_0x21f7('0x43')](handleError(_0x46b239,null));};exports['create']=function(_0x29ed42,_0x4d3bd8){return db['VoiceQueuesLog'][_0x21f7('0x44')](_0x29ed42[_0x21f7('0x45')],{})[_0x21f7('0x20')](respondWithResult(_0x4d3bd8,0xc9))['catch'](handleError(_0x4d3bd8,null));};exports['update']=function(_0x3473b4,_0x480882){if(_0x3473b4[_0x21f7('0x45')]['id']){delete _0x3473b4[_0x21f7('0x45')]['id'];}return db['VoiceQueuesLog']['find']({'where':{'id':_0x3473b4[_0x21f7('0x3f')]['id']}})[_0x21f7('0x20')](handleEntityNotFound(_0x480882,null))['then'](saveUpdates(_0x3473b4[_0x21f7('0x45')],null))[_0x21f7('0x20')](respondWithResult(_0x480882,null))['catch'](handleError(_0x480882,null));};exports['destroy']=function(_0x243184,_0x24de41){return db[_0x21f7('0x29')][_0x21f7('0x42')]({'where':{'id':_0x243184[_0x21f7('0x3f')]['id']}})['then'](handleEntityNotFound(_0x24de41,null))[_0x21f7('0x20')](removeEntity(_0x24de41,null))[_0x21f7('0x43')](handleError(_0x24de41,null));};