Built motion from commit (unavailable).|2.5.9
[motion2.git] / server / api / smsQueueReport / smsQueueReport.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 _0x29f7=['query','filters','intersection','attributes','fields','length','hasOwnProperty','limit','order','sort','filter','where','merge','type','count','includeAll','findAll','rows','show','params','keys','include','options','create','body','catch','find','describe','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','offset','Content-Range','json','apply','save','update','then','destroy','error','stack','name','index','map','SmsQueueReport','rawAttributes','key','model'];(function(_0x2299e8,_0x3e4063){var _0x433c0e=function(_0x43f27e){while(--_0x43f27e){_0x2299e8['push'](_0x2299e8['shift']());}};_0x433c0e(++_0x3e4063);}(_0x29f7,0x100));var _0x729f=function(_0x326845,_0x152fef){_0x326845=_0x326845-0x0;var _0x52c03c=_0x29f7[_0x326845];return _0x52c03c;};'use strict';var pdf=require(_0x729f('0x0'));var emlformat=require(_0x729f('0x1'));var rimraf=require(_0x729f('0x2'));var zipdir=require(_0x729f('0x3'));var jsonpatch=require(_0x729f('0x4'));var rp=require(_0x729f('0x5'));var moment=require(_0x729f('0x6'));var BPromise=require(_0x729f('0x7'));var Mustache=require('mustache');var util=require(_0x729f('0x8'));var path=require(_0x729f('0x9'));var sox=require(_0x729f('0xa'));var csv=require(_0x729f('0xb'));var ejs=require(_0x729f('0xc'));var fs=require('fs');var _=require(_0x729f('0xd'));var squel=require(_0x729f('0xe'));var crypto=require(_0x729f('0xf'));var jsforce=require(_0x729f('0x10'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x729f('0x11'));var Papa=require(_0x729f('0x12'));var Redis=require(_0x729f('0x13'));var authService=require(_0x729f('0x14'));var qs=require(_0x729f('0x15'));var as=require(_0x729f('0x16'));var hardwareService=require(_0x729f('0x17'));var logger=require(_0x729f('0x18'))('api');var utils=require(_0x729f('0x19'));var config=require(_0x729f('0x1a'));var licenseUtil=require(_0x729f('0x1b'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x62f621,_0x5ea3d2){_0x5ea3d2=_0x5ea3d2||0xcc;return function(_0x22602f){if(_0x22602f){return _0x62f621[_0x729f('0x1c')](_0x5ea3d2);}return _0x62f621[_0x729f('0x1d')](_0x5ea3d2)[_0x729f('0x1e')]();};}function respondWithResult(_0x460e36,_0xea50c8){_0xea50c8=_0xea50c8||0xc8;return function(_0x311307){if(_0x311307){return _0x460e36['status'](_0xea50c8)['json'](_0x311307);}};}function respondWithFilteredResult(_0x5df47e,_0x5bb447){return function(_0x50f383){if(_0x50f383){var _0x45784b=_0x50f383['count'],_0x431425=_0x5bb447[_0x729f('0x1f')],_0x54d499=_0x5bb447[_0x729f('0x1f')]+_0x5bb447['limit'],_0x571be2;if(_0x54d499>=_0x45784b){_0x54d499=_0x45784b;_0x571be2=0xc8;}else{_0x571be2=0xce;}_0x5df47e[_0x729f('0x1d')](_0x571be2);return _0x5df47e['set'](_0x729f('0x20'),_0x431425+'-'+_0x54d499+'/'+_0x45784b)[_0x729f('0x21')](_0x50f383);}return null;};}function patchUpdates(_0x4abd88){return function(_0x406f52){try{jsonpatch[_0x729f('0x22')](_0x406f52,_0x4abd88,!![]);}catch(_0x32aa56){return BPromise['reject'](_0x32aa56);}return _0x406f52[_0x729f('0x23')]();};}function saveUpdates(_0x3b3ec6,_0xd35dc7){return function(_0x4fa035){if(_0x4fa035){return _0x4fa035[_0x729f('0x24')](_0x3b3ec6)[_0x729f('0x25')](function(_0xfff375){return _0xfff375;});}return null;};}function removeEntity(_0x29ce84,_0x4a21c7){return function(_0x25b9ad){if(_0x25b9ad){return _0x25b9ad[_0x729f('0x26')]()['then'](function(){_0x29ce84[_0x729f('0x1d')](0xcc)[_0x729f('0x1e')]();});}};}function handleEntityNotFound(_0x5b7df0,_0x1af913){return function(_0x20b34b){if(!_0x20b34b){_0x5b7df0['sendStatus'](0x194);}return _0x20b34b;};}function handleError(_0x55b94e,_0x2ec525){_0x2ec525=_0x2ec525||0x1f4;return function(_0x472a99){logger[_0x729f('0x27')](_0x472a99[_0x729f('0x28')]);if(_0x472a99[_0x729f('0x29')]){delete _0x472a99[_0x729f('0x29')];}_0x55b94e[_0x729f('0x1d')](_0x2ec525)['send'](_0x472a99);};}exports[_0x729f('0x2a')]=function(_0x41b130,_0x56f88c){var _0x240b1c={},_0x374c15={},_0x4b9782={'count':0x0,'rows':[]};var _0x5df10a=_[_0x729f('0x2b')](db[_0x729f('0x2c')][_0x729f('0x2d')],function(_0x39e207){return{'name':_0x39e207['fieldName'],'type':_0x39e207['type'][_0x729f('0x2e')]};});_0x374c15[_0x729f('0x2f')]=_[_0x729f('0x2b')](_0x5df10a,_0x729f('0x29'));_0x374c15[_0x729f('0x30')]=_['keys'](_0x41b130['query']);_0x374c15[_0x729f('0x31')]=_[_0x729f('0x32')](_0x374c15['model'],_0x374c15[_0x729f('0x30')]);_0x240b1c[_0x729f('0x33')]=_['intersection'](_0x374c15[_0x729f('0x2f')],qs['fields'](_0x41b130[_0x729f('0x30')][_0x729f('0x34')]));_0x240b1c[_0x729f('0x33')]=_0x240b1c['attributes'][_0x729f('0x35')]?_0x240b1c[_0x729f('0x33')]:_0x374c15[_0x729f('0x2f')];if(!_0x41b130[_0x729f('0x30')][_0x729f('0x36')]('nolimit')){_0x240b1c[_0x729f('0x37')]=qs[_0x729f('0x37')](_0x41b130[_0x729f('0x30')][_0x729f('0x37')]);_0x240b1c['offset']=qs[_0x729f('0x1f')](_0x41b130[_0x729f('0x30')][_0x729f('0x1f')]);}_0x240b1c[_0x729f('0x38')]=qs[_0x729f('0x39')](_0x41b130[_0x729f('0x30')][_0x729f('0x39')]);_0x240b1c['where']=qs[_0x729f('0x31')](_['pick'](_0x41b130[_0x729f('0x30')],_0x374c15[_0x729f('0x31')]),_0x5df10a);if(_0x41b130[_0x729f('0x30')][_0x729f('0x3a')]){_0x240b1c[_0x729f('0x3b')]=_[_0x729f('0x3c')](_0x240b1c[_0x729f('0x3b')],{'$or':_['map'](_0x5df10a,function(_0x159fbb){if(_0x159fbb[_0x729f('0x3d')]!=='VIRTUAL'){var _0xccf081={};_0xccf081[_0x159fbb['name']]={'$like':'%'+_0x41b130['query'][_0x729f('0x3a')]+'%'};return _0xccf081;}})});}_0x240b1c=_[_0x729f('0x3c')]({},_0x240b1c,_0x41b130['options']);var _0x2e8871={'where':_0x240b1c[_0x729f('0x3b')]};return db[_0x729f('0x2c')][_0x729f('0x3e')](_0x2e8871)[_0x729f('0x25')](function(_0x5da035){_0x4b9782['count']=_0x5da035;if(_0x41b130[_0x729f('0x30')][_0x729f('0x3f')]){_0x240b1c['include']=[{'all':!![]}];}return db['SmsQueueReport'][_0x729f('0x40')](_0x240b1c);})[_0x729f('0x25')](function(_0xecf853){_0x4b9782[_0x729f('0x41')]=_0xecf853;return _0x4b9782;})[_0x729f('0x25')](respondWithFilteredResult(_0x56f88c,_0x240b1c))['catch'](handleError(_0x56f88c,null));};exports[_0x729f('0x42')]=function(_0x5d8ec5,_0x384c6a){var _0x6165f2={'raw':!![],'where':{'id':_0x5d8ec5[_0x729f('0x43')]['id']}},_0x40a5b7={};_0x40a5b7[_0x729f('0x2f')]=_[_0x729f('0x44')](db[_0x729f('0x2c')][_0x729f('0x2d')]);_0x40a5b7[_0x729f('0x30')]=_[_0x729f('0x44')](_0x5d8ec5[_0x729f('0x30')]);_0x40a5b7[_0x729f('0x31')]=_[_0x729f('0x32')](_0x40a5b7[_0x729f('0x2f')],_0x40a5b7[_0x729f('0x30')]);_0x6165f2[_0x729f('0x33')]=_['intersection'](_0x40a5b7[_0x729f('0x2f')],qs['fields'](_0x5d8ec5[_0x729f('0x30')][_0x729f('0x34')]));_0x6165f2['attributes']=_0x6165f2[_0x729f('0x33')][_0x729f('0x35')]?_0x6165f2[_0x729f('0x33')]:_0x40a5b7['model'];if(_0x5d8ec5[_0x729f('0x30')][_0x729f('0x3f')]){_0x6165f2[_0x729f('0x45')]=[{'all':!![]}];}_0x6165f2=_[_0x729f('0x3c')]({},_0x6165f2,_0x5d8ec5[_0x729f('0x46')]);return db[_0x729f('0x2c')]['find'](_0x6165f2)['then'](handleEntityNotFound(_0x384c6a,null))[_0x729f('0x25')](respondWithResult(_0x384c6a,null))['catch'](handleError(_0x384c6a,null));};exports[_0x729f('0x47')]=function(_0x44f32d,_0x212d2f){return db[_0x729f('0x2c')][_0x729f('0x47')](_0x44f32d[_0x729f('0x48')],{})[_0x729f('0x25')](respondWithResult(_0x212d2f,0xc9))[_0x729f('0x49')](handleError(_0x212d2f,null));};exports[_0x729f('0x24')]=function(_0x372e2f,_0x377124){if(_0x372e2f[_0x729f('0x48')]['id']){delete _0x372e2f[_0x729f('0x48')]['id'];}return db['SmsQueueReport'][_0x729f('0x4a')]({'where':{'id':_0x372e2f[_0x729f('0x43')]['id']}})[_0x729f('0x25')](handleEntityNotFound(_0x377124,null))[_0x729f('0x25')](saveUpdates(_0x372e2f[_0x729f('0x48')],null))[_0x729f('0x25')](respondWithResult(_0x377124,null))[_0x729f('0x49')](handleError(_0x377124,null));};exports[_0x729f('0x26')]=function(_0x35f6f0,_0x3e2e50){return db[_0x729f('0x2c')][_0x729f('0x4a')]({'where':{'id':_0x35f6f0[_0x729f('0x43')]['id']}})[_0x729f('0x25')](handleEntityNotFound(_0x3e2e50,null))[_0x729f('0x25')](removeEntity(_0x3e2e50,null))[_0x729f('0x49')](handleError(_0x3e2e50,null));};exports[_0x729f('0x4b')]=function(_0x44ade0,_0x446b91){return db[_0x729f('0x2c')]['describe']()[_0x729f('0x25')](respondWithResult(_0x446b91,null))[_0x729f('0x49')](handleError(_0x446b91,null));};