Built motion from commit 20b39a97.|2.6.29
[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 _0x255f=['zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','end','status','json','undefined','count','offset','limit','set','Content-Range','apply','reject','save','update','then','error','stack','name','send','map','FaxQueueReport','rawAttributes','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','filter','merge','VIRTUAL','includeAll','include','findAll','rows','catch','show','params','options','find','create','body','destroy','describe','eml-format'];(function(_0x1553d0,_0x1f7093){var _0xd35bcd=function(_0x551d07){while(--_0x551d07){_0x1553d0['push'](_0x1553d0['shift']());}};_0xd35bcd(++_0x1f7093);}(_0x255f,0x185));var _0xf255=function(_0x486a17,_0x14c452){_0x486a17=_0x486a17-0x0;var _0x584cb4=_0x255f[_0x486a17];return _0x584cb4;};'use strict';var emlformat=require(_0xf255('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xf255('0x1'));var jsonpatch=require(_0xf255('0x2'));var rp=require(_0xf255('0x3'));var moment=require('moment');var BPromise=require(_0xf255('0x4'));var Mustache=require(_0xf255('0x5'));var util=require(_0xf255('0x6'));var path=require(_0xf255('0x7'));var sox=require(_0xf255('0x8'));var csv=require(_0xf255('0x9'));var ejs=require(_0xf255('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xf255('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xf255('0xc'));var deskjs=require(_0xf255('0xd'));var toCsv=require('to-csv');var querystring=require(_0xf255('0xe'));var Papa=require(_0xf255('0xf'));var Redis=require('ioredis');var authService=require(_0xf255('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xf255('0x11'));var hardwareService=require(_0xf255('0x12'));var logger=require(_0xf255('0x13'))(_0xf255('0x14'));var utils=require(_0xf255('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xf255('0x16'));var db=require(_0xf255('0x17'))['db'];function respondWithStatusCode(_0x35fe1b,_0x50c1ca){_0x50c1ca=_0x50c1ca||0xcc;return function(_0x395f0f){if(_0x395f0f){return _0x35fe1b[_0xf255('0x18')](_0x50c1ca);}return _0x35fe1b['status'](_0x50c1ca)[_0xf255('0x19')]();};}function respondWithResult(_0x266b73,_0x233853){_0x233853=_0x233853||0xc8;return function(_0x49240a){if(_0x49240a){return _0x266b73[_0xf255('0x1a')](_0x233853)[_0xf255('0x1b')](_0x49240a);}};}function respondWithFilteredResult(_0x4b8c8,_0x750c8a){return function(_0x194e28){if(_0x194e28){var _0x4d9a07=typeof _0x750c8a['offset']===_0xf255('0x1c')&&typeof _0x750c8a['limit']===_0xf255('0x1c');var _0x516b16=_0x194e28[_0xf255('0x1d')];var _0x426286=_0x4d9a07?0x0:_0x750c8a[_0xf255('0x1e')];var _0x43902c=_0x4d9a07?_0x194e28[_0xf255('0x1d')]:_0x750c8a[_0xf255('0x1e')]+_0x750c8a[_0xf255('0x1f')];var _0x422a19;if(_0x43902c>=_0x516b16){_0x43902c=_0x516b16;_0x422a19=0xc8;}else{_0x422a19=0xce;}_0x4b8c8[_0xf255('0x1a')](_0x422a19);return _0x4b8c8[_0xf255('0x20')](_0xf255('0x21'),_0x426286+'-'+_0x43902c+'/'+_0x516b16)['json'](_0x194e28);}return null;};}function patchUpdates(_0x2fe87d){return function(_0x1ed880){try{jsonpatch[_0xf255('0x22')](_0x1ed880,_0x2fe87d,!![]);}catch(_0x2c5fbc){return BPromise[_0xf255('0x23')](_0x2c5fbc);}return _0x1ed880[_0xf255('0x24')]();};}function saveUpdates(_0x31bde5,_0x5b9b5f){return function(_0x25d910){if(_0x25d910){return _0x25d910[_0xf255('0x25')](_0x31bde5)[_0xf255('0x26')](function(_0x1dad1e){return _0x1dad1e;});}return null;};}function removeEntity(_0x325ee8,_0x1b3b1a){return function(_0x25eca0){if(_0x25eca0){return _0x25eca0['destroy']()[_0xf255('0x26')](function(){_0x325ee8['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3d64c5,_0x3270d4){return function(_0x382084){if(!_0x382084){_0x3d64c5[_0xf255('0x18')](0x194);}return _0x382084;};}function handleError(_0x3c0c32,_0x54d391){_0x54d391=_0x54d391||0x1f4;return function(_0x1c3a8e){logger[_0xf255('0x27')](_0x1c3a8e[_0xf255('0x28')]);if(_0x1c3a8e['name']){delete _0x1c3a8e[_0xf255('0x29')];}_0x3c0c32[_0xf255('0x1a')](_0x54d391)[_0xf255('0x2a')](_0x1c3a8e);};}exports['index']=function(_0xa1827e,_0x12424d){var _0x3bc770={},_0x39aac5={},_0x1b6f56={'count':0x0,'rows':[]};var _0x1ca07f=_[_0xf255('0x2b')](db[_0xf255('0x2c')][_0xf255('0x2d')],function(_0x280dac){return{'name':_0x280dac['fieldName'],'type':_0x280dac[_0xf255('0x2e')][_0xf255('0x2f')]};});_0x39aac5[_0xf255('0x30')]=_[_0xf255('0x2b')](_0x1ca07f,_0xf255('0x29'));_0x39aac5[_0xf255('0x31')]=_[_0xf255('0x32')](_0xa1827e[_0xf255('0x31')]);_0x39aac5['filters']=_[_0xf255('0x33')](_0x39aac5['model'],_0x39aac5['query']);_0x3bc770[_0xf255('0x34')]=_[_0xf255('0x33')](_0x39aac5[_0xf255('0x30')],qs[_0xf255('0x35')](_0xa1827e[_0xf255('0x31')][_0xf255('0x35')]));_0x3bc770[_0xf255('0x34')]=_0x3bc770['attributes'][_0xf255('0x36')]?_0x3bc770[_0xf255('0x34')]:_0x39aac5[_0xf255('0x30')];if(!_0xa1827e[_0xf255('0x31')][_0xf255('0x37')](_0xf255('0x38'))){_0x3bc770['limit']=qs[_0xf255('0x1f')](_0xa1827e[_0xf255('0x31')][_0xf255('0x1f')]);_0x3bc770[_0xf255('0x1e')]=qs[_0xf255('0x1e')](_0xa1827e['query'][_0xf255('0x1e')]);}_0x3bc770[_0xf255('0x39')]=qs[_0xf255('0x3a')](_0xa1827e[_0xf255('0x31')][_0xf255('0x3a')]);_0x3bc770[_0xf255('0x3b')]=qs['filters'](_[_0xf255('0x3c')](_0xa1827e[_0xf255('0x31')],_0x39aac5[_0xf255('0x3d')]),_0x1ca07f);if(_0xa1827e[_0xf255('0x31')][_0xf255('0x3e')]){_0x3bc770['where']=_[_0xf255('0x3f')](_0x3bc770[_0xf255('0x3b')],{'$or':_[_0xf255('0x2b')](_0x1ca07f,function(_0x1fd628){if(_0x1fd628[_0xf255('0x2e')]!==_0xf255('0x40')){var _0x4b3733={};_0x4b3733[_0x1fd628['name']]={'$like':'%'+_0xa1827e[_0xf255('0x31')][_0xf255('0x3e')]+'%'};return _0x4b3733;}})});}_0x3bc770=_[_0xf255('0x3f')]({},_0x3bc770,_0xa1827e['options']);var _0x1aef9c={'where':_0x3bc770['where']};return db[_0xf255('0x2c')][_0xf255('0x1d')](_0x1aef9c)[_0xf255('0x26')](function(_0x4516c5){_0x1b6f56[_0xf255('0x1d')]=_0x4516c5;if(_0xa1827e[_0xf255('0x31')][_0xf255('0x41')]){_0x3bc770[_0xf255('0x42')]=[{'all':!![]}];}return db[_0xf255('0x2c')][_0xf255('0x43')](_0x3bc770);})[_0xf255('0x26')](function(_0x22fe5c){_0x1b6f56[_0xf255('0x44')]=_0x22fe5c;return _0x1b6f56;})[_0xf255('0x26')](respondWithFilteredResult(_0x12424d,_0x3bc770))[_0xf255('0x45')](handleError(_0x12424d,null));};exports[_0xf255('0x46')]=function(_0x40a775,_0x4f9d63){var _0x44ea98={'raw':!![],'where':{'id':_0x40a775[_0xf255('0x47')]['id']}},_0x5eedd8={};_0x5eedd8[_0xf255('0x30')]=_['keys'](db[_0xf255('0x2c')]['rawAttributes']);_0x5eedd8[_0xf255('0x31')]=_[_0xf255('0x32')](_0x40a775['query']);_0x5eedd8[_0xf255('0x3d')]=_['intersection'](_0x5eedd8['model'],_0x5eedd8['query']);_0x44ea98[_0xf255('0x34')]=_[_0xf255('0x33')](_0x5eedd8[_0xf255('0x30')],qs[_0xf255('0x35')](_0x40a775['query'][_0xf255('0x35')]));_0x44ea98[_0xf255('0x34')]=_0x44ea98[_0xf255('0x34')][_0xf255('0x36')]?_0x44ea98[_0xf255('0x34')]:_0x5eedd8['model'];if(_0x40a775[_0xf255('0x31')][_0xf255('0x41')]){_0x44ea98[_0xf255('0x42')]=[{'all':!![]}];}_0x44ea98=_[_0xf255('0x3f')]({},_0x44ea98,_0x40a775[_0xf255('0x48')]);return db[_0xf255('0x2c')][_0xf255('0x49')](_0x44ea98)[_0xf255('0x26')](handleEntityNotFound(_0x4f9d63,null))['then'](respondWithResult(_0x4f9d63,null))['catch'](handleError(_0x4f9d63,null));};exports['create']=function(_0x34cc13,_0x4b27e7){return db['FaxQueueReport'][_0xf255('0x4a')](_0x34cc13[_0xf255('0x4b')],{})[_0xf255('0x26')](respondWithResult(_0x4b27e7,0xc9))[_0xf255('0x45')](handleError(_0x4b27e7,null));};exports['update']=function(_0x5bf6e7,_0x1a893c){if(_0x5bf6e7['body']['id']){delete _0x5bf6e7['body']['id'];}return db[_0xf255('0x2c')]['find']({'where':{'id':_0x5bf6e7[_0xf255('0x47')]['id']}})[_0xf255('0x26')](handleEntityNotFound(_0x1a893c,null))[_0xf255('0x26')](saveUpdates(_0x5bf6e7[_0xf255('0x4b')],null))[_0xf255('0x26')](respondWithResult(_0x1a893c,null))[_0xf255('0x45')](handleError(_0x1a893c,null));};exports[_0xf255('0x4c')]=function(_0x392632,_0x271074){return db[_0xf255('0x2c')][_0xf255('0x49')]({'where':{'id':_0x392632[_0xf255('0x47')]['id']}})[_0xf255('0x26')](handleEntityNotFound(_0x271074,null))[_0xf255('0x26')](removeEntity(_0x271074,null))[_0xf255('0x45')](handleError(_0x271074,null));};exports['describe']=function(_0x2d86ea,_0x11ecbd){return db[_0xf255('0x2c')][_0xf255('0x4d')]()[_0xf255('0x26')](respondWithResult(_0x11ecbd,null))['catch'](handleError(_0x11ecbd,null));};