Built motion from commit (unavailable).|2.5.10
[motion2.git] / server / api / whatsappQueueReport / whatsappQueueReport.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 _0x3f29=['json','offset','set','Content-Range','apply','reject','save','update','then','status','error','stack','name','send','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','hasOwnProperty','limit','order','sort','where','pick','filter','merge','VIRTUAL','options','WhatsappQueueReport','count','include','findAll','catch','params','length','includeAll','find','create','body','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','ejs','lodash','squel','jsforce','desk.js','to-csv','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end'];(function(_0x5cf506,_0x246a7b){var _0x49bd2d=function(_0x11f344){while(--_0x11f344){_0x5cf506['push'](_0x5cf506['shift']());}};_0x49bd2d(++_0x246a7b);}(_0x3f29,0xc5));var _0x93f2=function(_0x311c35,_0x534915){_0x311c35=_0x311c35-0x0;var _0x5cc50c=_0x3f29[_0x311c35];return _0x5cc50c;};'use strict';var pdf=require(_0x93f2('0x0'));var emlformat=require(_0x93f2('0x1'));var rimraf=require(_0x93f2('0x2'));var zipdir=require(_0x93f2('0x3'));var jsonpatch=require(_0x93f2('0x4'));var rp=require(_0x93f2('0x5'));var moment=require(_0x93f2('0x6'));var BPromise=require(_0x93f2('0x7'));var Mustache=require(_0x93f2('0x8'));var util=require(_0x93f2('0x9'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x93f2('0xa'));var fs=require('fs');var _=require(_0x93f2('0xb'));var squel=require(_0x93f2('0xc'));var crypto=require('crypto');var jsforce=require(_0x93f2('0xd'));var deskjs=require(_0x93f2('0xe'));var toCsv=require(_0x93f2('0xf'));var querystring=require('querystring');var Papa=require(_0x93f2('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x93f2('0x11'));var as=require(_0x93f2('0x12'));var hardwareService=require(_0x93f2('0x13'));var logger=require(_0x93f2('0x14'))(_0x93f2('0x15'));var utils=require(_0x93f2('0x16'));var config=require(_0x93f2('0x17'));var licenseUtil=require(_0x93f2('0x18'));var db=require(_0x93f2('0x19'))['db'];function respondWithStatusCode(_0x575b15,_0x412953){_0x412953=_0x412953||0xcc;return function(_0x2efc39){if(_0x2efc39){return _0x575b15[_0x93f2('0x1a')](_0x412953);}return _0x575b15['status'](_0x412953)[_0x93f2('0x1b')]();};}function respondWithResult(_0x2957d8,_0xfbf43d){_0xfbf43d=_0xfbf43d||0xc8;return function(_0x2bbc34){if(_0x2bbc34){return _0x2957d8['status'](_0xfbf43d)[_0x93f2('0x1c')](_0x2bbc34);}};}function respondWithFilteredResult(_0x352784,_0x55f53c){return function(_0x440c45){if(_0x440c45){var _0x4c200f=_0x440c45['count'],_0x591257=_0x55f53c['offset'],_0x189d57=_0x55f53c[_0x93f2('0x1d')]+_0x55f53c['limit'],_0x583f01;if(_0x189d57>=_0x4c200f){_0x189d57=_0x4c200f;_0x583f01=0xc8;}else{_0x583f01=0xce;}_0x352784['status'](_0x583f01);return _0x352784[_0x93f2('0x1e')](_0x93f2('0x1f'),_0x591257+'-'+_0x189d57+'/'+_0x4c200f)['json'](_0x440c45);}return null;};}function patchUpdates(_0x55bfa1){return function(_0x2a5a65){try{jsonpatch[_0x93f2('0x20')](_0x2a5a65,_0x55bfa1,!![]);}catch(_0x3362f9){return BPromise[_0x93f2('0x21')](_0x3362f9);}return _0x2a5a65[_0x93f2('0x22')]();};}function saveUpdates(_0x57aa1c,_0x3f969a){return function(_0x1882a7){if(_0x1882a7){return _0x1882a7[_0x93f2('0x23')](_0x57aa1c)[_0x93f2('0x24')](function(_0x346f23){return _0x346f23;});}return null;};}function removeEntity(_0x368021,_0x4d3315){return function(_0x299904){if(_0x299904){return _0x299904['destroy']()['then'](function(){_0x368021[_0x93f2('0x25')](0xcc)[_0x93f2('0x1b')]();});}};}function handleEntityNotFound(_0x282eeb,_0x5f3404){return function(_0x1bce34){if(!_0x1bce34){_0x282eeb[_0x93f2('0x1a')](0x194);}return _0x1bce34;};}function handleError(_0x447e88,_0x40eab6){_0x40eab6=_0x40eab6||0x1f4;return function(_0x6a9619){logger[_0x93f2('0x26')](_0x6a9619[_0x93f2('0x27')]);if(_0x6a9619[_0x93f2('0x28')]){delete _0x6a9619[_0x93f2('0x28')];}_0x447e88[_0x93f2('0x25')](_0x40eab6)[_0x93f2('0x29')](_0x6a9619);};}exports['index']=function(_0xae9c3c,_0x1cd0cd){var _0x43d82e={},_0x1dc0c0={},_0x17b0d9={'count':0x0,'rows':[]};var _0x517cd5=_[_0x93f2('0x2a')](db['WhatsappQueueReport'][_0x93f2('0x2b')],function(_0x4ddd2d){return{'name':_0x4ddd2d[_0x93f2('0x2c')],'type':_0x4ddd2d[_0x93f2('0x2d')][_0x93f2('0x2e')]};});_0x1dc0c0[_0x93f2('0x2f')]=_['map'](_0x517cd5,'name');_0x1dc0c0[_0x93f2('0x30')]=_[_0x93f2('0x31')](_0xae9c3c[_0x93f2('0x30')]);_0x1dc0c0[_0x93f2('0x32')]=_[_0x93f2('0x33')](_0x1dc0c0[_0x93f2('0x2f')],_0x1dc0c0['query']);_0x43d82e['attributes']=_[_0x93f2('0x33')](_0x1dc0c0['model'],qs[_0x93f2('0x34')](_0xae9c3c['query'][_0x93f2('0x34')]));_0x43d82e[_0x93f2('0x35')]=_0x43d82e[_0x93f2('0x35')]['length']?_0x43d82e[_0x93f2('0x35')]:_0x1dc0c0[_0x93f2('0x2f')];if(!_0xae9c3c[_0x93f2('0x30')][_0x93f2('0x36')]('nolimit')){_0x43d82e[_0x93f2('0x37')]=qs[_0x93f2('0x37')](_0xae9c3c['query'][_0x93f2('0x37')]);_0x43d82e[_0x93f2('0x1d')]=qs[_0x93f2('0x1d')](_0xae9c3c[_0x93f2('0x30')][_0x93f2('0x1d')]);}_0x43d82e[_0x93f2('0x38')]=qs[_0x93f2('0x39')](_0xae9c3c[_0x93f2('0x30')][_0x93f2('0x39')]);_0x43d82e[_0x93f2('0x3a')]=qs['filters'](_[_0x93f2('0x3b')](_0xae9c3c[_0x93f2('0x30')],_0x1dc0c0[_0x93f2('0x32')]),_0x517cd5);if(_0xae9c3c['query'][_0x93f2('0x3c')]){_0x43d82e[_0x93f2('0x3a')]=_[_0x93f2('0x3d')](_0x43d82e[_0x93f2('0x3a')],{'$or':_[_0x93f2('0x2a')](_0x517cd5,function(_0x3cc774){if(_0x3cc774[_0x93f2('0x2d')]!==_0x93f2('0x3e')){var _0x1baad8={};_0x1baad8[_0x3cc774[_0x93f2('0x28')]]={'$like':'%'+_0xae9c3c[_0x93f2('0x30')][_0x93f2('0x3c')]+'%'};return _0x1baad8;}})});}_0x43d82e=_['merge']({},_0x43d82e,_0xae9c3c[_0x93f2('0x3f')]);var _0x568e14={'where':_0x43d82e['where']};return db[_0x93f2('0x40')][_0x93f2('0x41')](_0x568e14)['then'](function(_0x2653de){_0x17b0d9[_0x93f2('0x41')]=_0x2653de;if(_0xae9c3c[_0x93f2('0x30')]['includeAll']){_0x43d82e[_0x93f2('0x42')]=[{'all':!![]}];}return db['WhatsappQueueReport'][_0x93f2('0x43')](_0x43d82e);})[_0x93f2('0x24')](function(_0x34e89c){_0x17b0d9['rows']=_0x34e89c;return _0x17b0d9;})[_0x93f2('0x24')](respondWithFilteredResult(_0x1cd0cd,_0x43d82e))[_0x93f2('0x44')](handleError(_0x1cd0cd,null));};exports['show']=function(_0x3f909d,_0x41dedc){var _0x35b8c6={'raw':!![],'where':{'id':_0x3f909d[_0x93f2('0x45')]['id']}},_0x1f3ed7={};_0x1f3ed7[_0x93f2('0x2f')]=_[_0x93f2('0x31')](db[_0x93f2('0x40')][_0x93f2('0x2b')]);_0x1f3ed7[_0x93f2('0x30')]=_[_0x93f2('0x31')](_0x3f909d['query']);_0x1f3ed7[_0x93f2('0x32')]=_[_0x93f2('0x33')](_0x1f3ed7['model'],_0x1f3ed7[_0x93f2('0x30')]);_0x35b8c6[_0x93f2('0x35')]=_[_0x93f2('0x33')](_0x1f3ed7['model'],qs[_0x93f2('0x34')](_0x3f909d[_0x93f2('0x30')][_0x93f2('0x34')]));_0x35b8c6[_0x93f2('0x35')]=_0x35b8c6[_0x93f2('0x35')][_0x93f2('0x46')]?_0x35b8c6['attributes']:_0x1f3ed7['model'];if(_0x3f909d['query'][_0x93f2('0x47')]){_0x35b8c6[_0x93f2('0x42')]=[{'all':!![]}];}_0x35b8c6=_[_0x93f2('0x3d')]({},_0x35b8c6,_0x3f909d[_0x93f2('0x3f')]);return db[_0x93f2('0x40')][_0x93f2('0x48')](_0x35b8c6)[_0x93f2('0x24')](handleEntityNotFound(_0x41dedc,null))[_0x93f2('0x24')](respondWithResult(_0x41dedc,null))[_0x93f2('0x44')](handleError(_0x41dedc,null));};exports[_0x93f2('0x49')]=function(_0x37472a,_0x10d49c){return db[_0x93f2('0x40')][_0x93f2('0x49')](_0x37472a[_0x93f2('0x4a')],{})['then'](respondWithResult(_0x10d49c,0xc9))[_0x93f2('0x44')](handleError(_0x10d49c,null));};exports[_0x93f2('0x23')]=function(_0x4432a9,_0x494873){if(_0x4432a9[_0x93f2('0x4a')]['id']){delete _0x4432a9[_0x93f2('0x4a')]['id'];}return db[_0x93f2('0x40')]['find']({'where':{'id':_0x4432a9[_0x93f2('0x45')]['id']}})['then'](handleEntityNotFound(_0x494873,null))[_0x93f2('0x24')](saveUpdates(_0x4432a9['body'],null))[_0x93f2('0x24')](respondWithResult(_0x494873,null))['catch'](handleError(_0x494873,null));};exports['destroy']=function(_0x1600c4,_0x3e7fd5){return db[_0x93f2('0x40')][_0x93f2('0x48')]({'where':{'id':_0x1600c4[_0x93f2('0x45')]['id']}})[_0x93f2('0x24')](handleEntityNotFound(_0x3e7fd5,null))[_0x93f2('0x24')](removeEntity(_0x3e7fd5,null))[_0x93f2('0x44')](handleError(_0x3e7fd5,null));};exports['describe']=function(_0x4413b7,_0x13b2db){return db['WhatsappQueueReport']['describe']()['then'](respondWithResult(_0x13b2db,null))[_0x93f2('0x44')](handleError(_0x13b2db,null));};