Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / api / faxQueueReport / faxQueueReport.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 _0x24a6=['rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','nolimit','order','sort','where','filter','VIRTUAL','merge','includeAll','include','findAll','rows','catch','show','params','keys','FaxQueueReport','length','options','find','body','describe','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','end','json','offset','undefined','limit','count','status','Content-Range','apply','reject','save','update','then','destroy','name','map'];(function(_0x578a41,_0x457926){var _0x246b9b=function(_0x7e749d){while(--_0x7e749d){_0x578a41['push'](_0x578a41['shift']());}};_0x246b9b(++_0x457926);}(_0x24a6,0x14f));var _0x624a=function(_0x97f172,_0x5bd724){_0x97f172=_0x97f172-0x0;var _0xeab429=_0x24a6[_0x97f172];return _0xeab429;};'use strict';var emlformat=require(_0x624a('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x624a('0x1'));var jsonpatch=require(_0x624a('0x2'));var rp=require(_0x624a('0x3'));var moment=require(_0x624a('0x4'));var BPromise=require(_0x624a('0x5'));var Mustache=require(_0x624a('0x6'));var util=require(_0x624a('0x7'));var path=require(_0x624a('0x8'));var sox=require(_0x624a('0x9'));var csv=require(_0x624a('0xa'));var ejs=require(_0x624a('0xb'));var fs=require('fs');var fs_extra=require(_0x624a('0xc'));var _=require(_0x624a('0xd'));var squel=require(_0x624a('0xe'));var crypto=require(_0x624a('0xf'));var jsforce=require(_0x624a('0x10'));var deskjs=require(_0x624a('0x11'));var toCsv=require(_0x624a('0xa'));var querystring=require(_0x624a('0x12'));var Papa=require(_0x624a('0x13'));var Redis=require(_0x624a('0x14'));var authService=require(_0x624a('0x15'));var qs=require(_0x624a('0x16'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x624a('0x17'))(_0x624a('0x18'));var utils=require(_0x624a('0x19'));var config=require('../../config/environment');var licenseUtil=require(_0x624a('0x1a'));var db=require(_0x624a('0x1b'))['db'];function respondWithStatusCode(_0x5f0954,_0x50d1aa){_0x50d1aa=_0x50d1aa||0xcc;return function(_0x5406ce){if(_0x5406ce){return _0x5f0954[_0x624a('0x1c')](_0x50d1aa);}return _0x5f0954['status'](_0x50d1aa)[_0x624a('0x1d')]();};}function respondWithResult(_0x89e2fd,_0xe310b4){_0xe310b4=_0xe310b4||0xc8;return function(_0x1e6ffd){if(_0x1e6ffd){return _0x89e2fd['status'](_0xe310b4)[_0x624a('0x1e')](_0x1e6ffd);}};}function respondWithFilteredResult(_0x4935f4,_0x424200){return function(_0x195bfc){if(_0x195bfc){var _0x53005e=typeof _0x424200[_0x624a('0x1f')]===_0x624a('0x20')&&typeof _0x424200[_0x624a('0x21')]===_0x624a('0x20');var _0xce9cd5=_0x195bfc[_0x624a('0x22')];var _0x364867=_0x53005e?0x0:_0x424200[_0x624a('0x1f')];var _0x35342c=_0x53005e?_0x195bfc[_0x624a('0x22')]:_0x424200['offset']+_0x424200[_0x624a('0x21')];var _0x5c6901;if(_0x35342c>=_0xce9cd5){_0x35342c=_0xce9cd5;_0x5c6901=0xc8;}else{_0x5c6901=0xce;}_0x4935f4[_0x624a('0x23')](_0x5c6901);return _0x4935f4['set'](_0x624a('0x24'),_0x364867+'-'+_0x35342c+'/'+_0xce9cd5)[_0x624a('0x1e')](_0x195bfc);}return null;};}function patchUpdates(_0x415af0){return function(_0x200fdc){try{jsonpatch[_0x624a('0x25')](_0x200fdc,_0x415af0,!![]);}catch(_0x54e669){return BPromise[_0x624a('0x26')](_0x54e669);}return _0x200fdc[_0x624a('0x27')]();};}function saveUpdates(_0x156d32,_0x22beca){return function(_0x5dfeec){if(_0x5dfeec){return _0x5dfeec[_0x624a('0x28')](_0x156d32)[_0x624a('0x29')](function(_0x264349){return _0x264349;});}return null;};}function removeEntity(_0x4ba881,_0x4aee03){return function(_0x56834b){if(_0x56834b){return _0x56834b[_0x624a('0x2a')]()[_0x624a('0x29')](function(){_0x4ba881[_0x624a('0x23')](0xcc)[_0x624a('0x1d')]();});}};}function handleEntityNotFound(_0x51a817,_0x5ca99b){return function(_0x2234dc){if(!_0x2234dc){_0x51a817[_0x624a('0x1c')](0x194);}return _0x2234dc;};}function handleError(_0x57eb2e,_0xd0730c){_0xd0730c=_0xd0730c||0x1f4;return function(_0x19b8a6){logger['error'](_0x19b8a6['stack']);if(_0x19b8a6['name']){delete _0x19b8a6[_0x624a('0x2b')];}_0x57eb2e[_0x624a('0x23')](_0xd0730c)['send'](_0x19b8a6);};}exports['index']=function(_0x59917f,_0x422c20){var _0x35c8d0={},_0x4dab19={},_0x55dff7={'count':0x0,'rows':[]};var _0x16178d=_[_0x624a('0x2c')](db['FaxQueueReport'][_0x624a('0x2d')],function(_0x59df8f){return{'name':_0x59df8f[_0x624a('0x2e')],'type':_0x59df8f[_0x624a('0x2f')][_0x624a('0x30')]};});_0x4dab19[_0x624a('0x31')]=_['map'](_0x16178d,_0x624a('0x2b'));_0x4dab19[_0x624a('0x32')]=_['keys'](_0x59917f[_0x624a('0x32')]);_0x4dab19[_0x624a('0x33')]=_[_0x624a('0x34')](_0x4dab19[_0x624a('0x31')],_0x4dab19[_0x624a('0x32')]);_0x35c8d0[_0x624a('0x35')]=_['intersection'](_0x4dab19['model'],qs[_0x624a('0x36')](_0x59917f[_0x624a('0x32')][_0x624a('0x36')]));_0x35c8d0['attributes']=_0x35c8d0[_0x624a('0x35')]['length']?_0x35c8d0['attributes']:_0x4dab19['model'];if(!_0x59917f[_0x624a('0x32')]['hasOwnProperty'](_0x624a('0x37'))){_0x35c8d0['limit']=qs[_0x624a('0x21')](_0x59917f['query']['limit']);_0x35c8d0[_0x624a('0x1f')]=qs[_0x624a('0x1f')](_0x59917f[_0x624a('0x32')][_0x624a('0x1f')]);}_0x35c8d0[_0x624a('0x38')]=qs[_0x624a('0x39')](_0x59917f[_0x624a('0x32')][_0x624a('0x39')]);_0x35c8d0[_0x624a('0x3a')]=qs[_0x624a('0x33')](_['pick'](_0x59917f[_0x624a('0x32')],_0x4dab19[_0x624a('0x33')]),_0x16178d);if(_0x59917f[_0x624a('0x32')][_0x624a('0x3b')]){_0x35c8d0[_0x624a('0x3a')]=_['merge'](_0x35c8d0[_0x624a('0x3a')],{'$or':_[_0x624a('0x2c')](_0x16178d,function(_0x1eb6c5){if(_0x1eb6c5[_0x624a('0x2f')]!==_0x624a('0x3c')){var _0x2f7e73={};_0x2f7e73[_0x1eb6c5['name']]={'$like':'%'+_0x59917f[_0x624a('0x32')][_0x624a('0x3b')]+'%'};return _0x2f7e73;}})});}_0x35c8d0=_[_0x624a('0x3d')]({},_0x35c8d0,_0x59917f['options']);var _0x2794a8={'where':_0x35c8d0['where']};return db['FaxQueueReport'][_0x624a('0x22')](_0x2794a8)[_0x624a('0x29')](function(_0x860d75){_0x55dff7['count']=_0x860d75;if(_0x59917f['query'][_0x624a('0x3e')]){_0x35c8d0[_0x624a('0x3f')]=[{'all':!![]}];}return db['FaxQueueReport'][_0x624a('0x40')](_0x35c8d0);})[_0x624a('0x29')](function(_0x574651){_0x55dff7[_0x624a('0x41')]=_0x574651;return _0x55dff7;})[_0x624a('0x29')](respondWithFilteredResult(_0x422c20,_0x35c8d0))[_0x624a('0x42')](handleError(_0x422c20,null));};exports[_0x624a('0x43')]=function(_0x5cd777,_0x577ec5){var _0x48e061={'raw':!![],'where':{'id':_0x5cd777[_0x624a('0x44')]['id']}},_0x23168b={};_0x23168b[_0x624a('0x31')]=_[_0x624a('0x45')](db[_0x624a('0x46')][_0x624a('0x2d')]);_0x23168b[_0x624a('0x32')]=_['keys'](_0x5cd777[_0x624a('0x32')]);_0x23168b[_0x624a('0x33')]=_['intersection'](_0x23168b['model'],_0x23168b[_0x624a('0x32')]);_0x48e061['attributes']=_[_0x624a('0x34')](_0x23168b[_0x624a('0x31')],qs[_0x624a('0x36')](_0x5cd777['query'][_0x624a('0x36')]));_0x48e061[_0x624a('0x35')]=_0x48e061[_0x624a('0x35')][_0x624a('0x47')]?_0x48e061[_0x624a('0x35')]:_0x23168b['model'];if(_0x5cd777[_0x624a('0x32')][_0x624a('0x3e')]){_0x48e061[_0x624a('0x3f')]=[{'all':!![]}];}_0x48e061=_['merge']({},_0x48e061,_0x5cd777[_0x624a('0x48')]);return db[_0x624a('0x46')][_0x624a('0x49')](_0x48e061)[_0x624a('0x29')](handleEntityNotFound(_0x577ec5,null))[_0x624a('0x29')](respondWithResult(_0x577ec5,null))[_0x624a('0x42')](handleError(_0x577ec5,null));};exports['create']=function(_0x181433,_0x519bce){return db['FaxQueueReport']['create'](_0x181433[_0x624a('0x4a')],{})[_0x624a('0x29')](respondWithResult(_0x519bce,0xc9))[_0x624a('0x42')](handleError(_0x519bce,null));};exports[_0x624a('0x28')]=function(_0x5312ec,_0x18c318){if(_0x5312ec[_0x624a('0x4a')]['id']){delete _0x5312ec[_0x624a('0x4a')]['id'];}return db['FaxQueueReport']['find']({'where':{'id':_0x5312ec[_0x624a('0x44')]['id']}})[_0x624a('0x29')](handleEntityNotFound(_0x18c318,null))[_0x624a('0x29')](saveUpdates(_0x5312ec[_0x624a('0x4a')],null))[_0x624a('0x29')](respondWithResult(_0x18c318,null))[_0x624a('0x42')](handleError(_0x18c318,null));};exports['destroy']=function(_0x351dc9,_0x47422e){return db['FaxQueueReport'][_0x624a('0x49')]({'where':{'id':_0x351dc9[_0x624a('0x44')]['id']}})[_0x624a('0x29')](handleEntityNotFound(_0x47422e,null))[_0x624a('0x29')](removeEntity(_0x47422e,null))[_0x624a('0x42')](handleError(_0x47422e,null));};exports[_0x624a('0x4b')]=function(_0x5f2151,_0x8cb341){return db[_0x624a('0x46')]['describe']()[_0x624a('0x29')](respondWithResult(_0x8cb341,null))[_0x624a('0x42')](handleError(_0x8cb341,null));};