Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / mailQueueReport / mailQueueReport.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 _0xf006=['api','../../config/environment','../../mysqldb','status','json','count','limit','set','Content-Range','apply','reject','save','then','destroy','end','stack','name','send','index','map','MailQueueReport','rawAttributes','fieldName','type','key','model','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','offset','order','sort','where','filters','pick','filter','merge','options','includeAll','include','catch','params','find','body','update','rimraf','zip-dir','request-promise','bluebird','path','sox','to-csv','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger'];(function(_0x19e859,_0x333efb){var _0x481f06=function(_0x5736ee){while(--_0x5736ee){_0x19e859['push'](_0x19e859['shift']());}};_0x481f06(++_0x333efb);}(_0xf006,0x146));var _0x6f00=function(_0xa50ed7,_0x4a3a3d){_0xa50ed7=_0xa50ed7-0x0;var _0x3c6344=_0xf006[_0xa50ed7];return _0x3c6344;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x6f00('0x0'));var zipdir=require(_0x6f00('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x6f00('0x2'));var moment=require('moment');var BPromise=require(_0x6f00('0x3'));var Mustache=require('mustache');var util=require('util');var path=require(_0x6f00('0x4'));var sox=require(_0x6f00('0x5'));var csv=require(_0x6f00('0x6'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x6f00('0x7'));var squel=require('squel');var crypto=require(_0x6f00('0x8'));var jsforce=require(_0x6f00('0x9'));var deskjs=require(_0x6f00('0xa'));var toCsv=require(_0x6f00('0x6'));var querystring=require(_0x6f00('0xb'));var Papa=require(_0x6f00('0xc'));var Redis=require(_0x6f00('0xd'));var authService=require(_0x6f00('0xe'));var qs=require(_0x6f00('0xf'));var as=require(_0x6f00('0x10'));var hardwareService=require(_0x6f00('0x11'));var logger=require(_0x6f00('0x12'))(_0x6f00('0x13'));var utils=require('../../config/utils');var config=require(_0x6f00('0x14'));var db=require(_0x6f00('0x15'))['db'];function respondWithStatusCode(_0x158817,_0x36a2ec){_0x36a2ec=_0x36a2ec||0xcc;return function(_0x289fe9){if(_0x289fe9){return _0x158817['sendStatus'](_0x36a2ec);}return _0x158817[_0x6f00('0x16')](_0x36a2ec)['end']();};}function respondWithResult(_0x30b10e,_0x5047f5){_0x5047f5=_0x5047f5||0xc8;return function(_0x324e67){if(_0x324e67){return _0x30b10e[_0x6f00('0x16')](_0x5047f5)[_0x6f00('0x17')](_0x324e67);}};}function respondWithFilteredResult(_0x33f3a2,_0xa6e7a1){return function(_0x411203){if(_0x411203){var _0x46bc2c=_0x411203[_0x6f00('0x18')],_0x4d8aee=_0xa6e7a1['offset'],_0x342c7f=_0xa6e7a1['offset']+_0xa6e7a1[_0x6f00('0x19')],_0x4bfac3;if(_0x342c7f>=_0x46bc2c){_0x342c7f=_0x46bc2c;_0x4bfac3=0xc8;}else{_0x4bfac3=0xce;}_0x33f3a2[_0x6f00('0x16')](_0x4bfac3);return _0x33f3a2[_0x6f00('0x1a')](_0x6f00('0x1b'),_0x4d8aee+'-'+_0x342c7f+'/'+_0x46bc2c)[_0x6f00('0x17')](_0x411203);}return null;};}function patchUpdates(_0x27e466){return function(_0x23fe10){try{jsonpatch[_0x6f00('0x1c')](_0x23fe10,_0x27e466,!![]);}catch(_0x9844bf){return BPromise[_0x6f00('0x1d')](_0x9844bf);}return _0x23fe10[_0x6f00('0x1e')]();};}function saveUpdates(_0x23f27a,_0x4e11de){return function(_0x4f3031){if(_0x4f3031){return _0x4f3031['update'](_0x23f27a)[_0x6f00('0x1f')](function(_0x1fd3d4){return _0x1fd3d4;});}return null;};}function removeEntity(_0x43bfb8,_0x57340f){return function(_0xe301e5){if(_0xe301e5){return _0xe301e5[_0x6f00('0x20')]()[_0x6f00('0x1f')](function(){_0x43bfb8[_0x6f00('0x16')](0xcc)[_0x6f00('0x21')]();});}};}function handleEntityNotFound(_0x1cbf1c,_0x90d74c){return function(_0x1ea061){if(!_0x1ea061){_0x1cbf1c['sendStatus'](0x194);}return _0x1ea061;};}function handleError(_0x3c05ef,_0x45945e){_0x45945e=_0x45945e||0x1f4;return function(_0x1fd40b){logger['error'](_0x1fd40b[_0x6f00('0x22')]);if(_0x1fd40b['name']){delete _0x1fd40b[_0x6f00('0x23')];}_0x3c05ef['status'](_0x45945e)[_0x6f00('0x24')](_0x1fd40b);};}exports[_0x6f00('0x25')]=function(_0x7c6bcb,_0x1f84a6){var _0x375d76={},_0x49eb87={},_0x23a346={'count':0x0,'rows':[]};var _0x25cc71=_[_0x6f00('0x26')](db[_0x6f00('0x27')][_0x6f00('0x28')],function(_0x235a86){return{'name':_0x235a86[_0x6f00('0x29')],'type':_0x235a86[_0x6f00('0x2a')][_0x6f00('0x2b')]};});_0x49eb87[_0x6f00('0x2c')]=_[_0x6f00('0x26')](_0x25cc71,_0x6f00('0x23'));_0x49eb87[_0x6f00('0x2d')]=_[_0x6f00('0x2e')](_0x7c6bcb['query']);_0x49eb87['filters']=_['intersection'](_0x49eb87['model'],_0x49eb87['query']);_0x375d76['attributes']=_[_0x6f00('0x2f')](_0x49eb87['model'],qs[_0x6f00('0x30')](_0x7c6bcb[_0x6f00('0x2d')][_0x6f00('0x30')]));_0x375d76[_0x6f00('0x31')]=_0x375d76[_0x6f00('0x31')][_0x6f00('0x32')]?_0x375d76['attributes']:_0x49eb87[_0x6f00('0x2c')];if(!_0x7c6bcb[_0x6f00('0x2d')][_0x6f00('0x33')](_0x6f00('0x34'))){_0x375d76[_0x6f00('0x19')]=qs['limit'](_0x7c6bcb['query']['limit']);_0x375d76[_0x6f00('0x35')]=qs[_0x6f00('0x35')](_0x7c6bcb[_0x6f00('0x2d')][_0x6f00('0x35')]);}_0x375d76[_0x6f00('0x36')]=qs['sort'](_0x7c6bcb[_0x6f00('0x2d')][_0x6f00('0x37')]);_0x375d76[_0x6f00('0x38')]=qs[_0x6f00('0x39')](_[_0x6f00('0x3a')](_0x7c6bcb[_0x6f00('0x2d')],_0x49eb87[_0x6f00('0x39')]),_0x25cc71);if(_0x7c6bcb['query'][_0x6f00('0x3b')]){_0x375d76[_0x6f00('0x38')]=_[_0x6f00('0x3c')](_0x375d76['where'],{'$or':_[_0x6f00('0x26')](_0x25cc71,function(_0x389ff9){if(_0x389ff9[_0x6f00('0x2a')]!=='VIRTUAL'){var _0x4163fd={};_0x4163fd[_0x389ff9['name']]={'$like':'%'+_0x7c6bcb[_0x6f00('0x2d')]['filter']+'%'};return _0x4163fd;}})});}_0x375d76=_[_0x6f00('0x3c')]({},_0x375d76,_0x7c6bcb[_0x6f00('0x3d')]);var _0x37c791={'where':_0x375d76[_0x6f00('0x38')]};return db['MailQueueReport'][_0x6f00('0x18')](_0x37c791)['then'](function(_0x231bd6){_0x23a346['count']=_0x231bd6;if(_0x7c6bcb[_0x6f00('0x2d')][_0x6f00('0x3e')]){_0x375d76[_0x6f00('0x3f')]=[{'all':!![]}];}return db[_0x6f00('0x27')]['findAll'](_0x375d76);})['then'](function(_0x2e745c){_0x23a346['rows']=_0x2e745c;return _0x23a346;})[_0x6f00('0x1f')](respondWithFilteredResult(_0x1f84a6,_0x375d76))[_0x6f00('0x40')](handleError(_0x1f84a6,null));};exports['show']=function(_0x2699af,_0x5dce37){var _0x4cac2c={'raw':!![],'where':{'id':_0x2699af[_0x6f00('0x41')]['id']}},_0x38da7f={};_0x38da7f[_0x6f00('0x2c')]=_[_0x6f00('0x2e')](db['MailQueueReport'][_0x6f00('0x28')]);_0x38da7f[_0x6f00('0x2d')]=_[_0x6f00('0x2e')](_0x2699af[_0x6f00('0x2d')]);_0x38da7f[_0x6f00('0x39')]=_[_0x6f00('0x2f')](_0x38da7f['model'],_0x38da7f[_0x6f00('0x2d')]);_0x4cac2c[_0x6f00('0x31')]=_[_0x6f00('0x2f')](_0x38da7f[_0x6f00('0x2c')],qs[_0x6f00('0x30')](_0x2699af[_0x6f00('0x2d')]['fields']));_0x4cac2c[_0x6f00('0x31')]=_0x4cac2c[_0x6f00('0x31')][_0x6f00('0x32')]?_0x4cac2c['attributes']:_0x38da7f[_0x6f00('0x2c')];if(_0x2699af['query'][_0x6f00('0x3e')]){_0x4cac2c[_0x6f00('0x3f')]=[{'all':!![]}];}_0x4cac2c=_['merge']({},_0x4cac2c,_0x2699af[_0x6f00('0x3d')]);return db['MailQueueReport'][_0x6f00('0x42')](_0x4cac2c)[_0x6f00('0x1f')](handleEntityNotFound(_0x5dce37,null))[_0x6f00('0x1f')](respondWithResult(_0x5dce37,null))[_0x6f00('0x40')](handleError(_0x5dce37,null));};exports['create']=function(_0x30272e,_0x59085a){return db[_0x6f00('0x27')]['create'](_0x30272e[_0x6f00('0x43')],{})[_0x6f00('0x1f')](respondWithResult(_0x59085a,0xc9))[_0x6f00('0x40')](handleError(_0x59085a,null));};exports[_0x6f00('0x44')]=function(_0x470ff3,_0x3472f0){if(_0x470ff3[_0x6f00('0x43')]['id']){delete _0x470ff3[_0x6f00('0x43')]['id'];}return db['MailQueueReport'][_0x6f00('0x42')]({'where':{'id':_0x470ff3['params']['id']}})[_0x6f00('0x1f')](handleEntityNotFound(_0x3472f0,null))[_0x6f00('0x1f')](saveUpdates(_0x470ff3[_0x6f00('0x43')],null))['then'](respondWithResult(_0x3472f0,null))['catch'](handleError(_0x3472f0,null));};exports[_0x6f00('0x20')]=function(_0x324c31,_0x494ba5){return db[_0x6f00('0x27')]['find']({'where':{'id':_0x324c31[_0x6f00('0x41')]['id']}})['then'](handleEntityNotFound(_0x494ba5,null))[_0x6f00('0x1f')](removeEntity(_0x494ba5,null))[_0x6f00('0x40')](handleError(_0x494ba5,null));};exports['describe']=function(_0x52ee5a,_0x418543){return db[_0x6f00('0x27')]['describe']()[_0x6f00('0x1f')](respondWithResult(_0x418543,null))['catch'](handleError(_0x418543,null));};