Built motion from commit (unavailable).|2.4.4
[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 _0xbf07=['status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','error','stack','name','send','SmsQueueReport','rawAttributes','keys','query','filters','model','attributes','fields','length','nolimit','order','sort','where','pick','filter','map','type','key','field','options','includeAll','include','rows','catch','show','params','intersection','merge','find','body','destroy','describe','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','path','lodash','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus'];(function(_0x269f37,_0x57fd73){var _0x572fad=function(_0x67a900){while(--_0x67a900){_0x269f37['push'](_0x269f37['shift']());}};_0x572fad(++_0x57fd73);}(_0xbf07,0x77));var _0x7bf0=function(_0x4d08b8,_0x34c445){_0x4d08b8=_0x4d08b8-0x0;var _0x70214a=_0xbf07[_0x4d08b8];return _0x70214a;};'use strict';var pdf=require(_0x7bf0('0x0'));var emlformat=require(_0x7bf0('0x1'));var rimraf=require(_0x7bf0('0x2'));var zipdir=require(_0x7bf0('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x7bf0('0x4'));var moment=require(_0x7bf0('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0x7bf0('0x6'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x7bf0('0x7'));var squel=require('squel');var crypto=require(_0x7bf0('0x8'));var jsforce=require('jsforce');var deskjs=require(_0x7bf0('0x9'));var toCsv=require(_0x7bf0('0xa'));var querystring=require(_0x7bf0('0xb'));var Papa=require(_0x7bf0('0xc'));var Redis=require(_0x7bf0('0xd'));var authService=require(_0x7bf0('0xe'));var qs=require('../../components/parsers/qs');var hardwareService=require(_0x7bf0('0xf'));var logger=require('../../config/logger')(_0x7bf0('0x10'));var utils=require(_0x7bf0('0x11'));var config=require(_0x7bf0('0x12'));var db=require(_0x7bf0('0x13'))['db'];function respondWithStatusCode(_0x13fe51,_0x1e2507){_0x1e2507=_0x1e2507||0xcc;return function(_0xf81111){if(_0xf81111){return _0x13fe51[_0x7bf0('0x14')](_0x1e2507);}return _0x13fe51[_0x7bf0('0x15')](_0x1e2507)[_0x7bf0('0x16')]();};}function respondWithResult(_0x40608b,_0x4300ce){_0x4300ce=_0x4300ce||0xc8;return function(_0xf15732){if(_0xf15732){return _0x40608b[_0x7bf0('0x15')](_0x4300ce)[_0x7bf0('0x17')](_0xf15732);}};}function respondWithFilteredResult(_0x16a7a4,_0x4424a5){return function(_0x383be0){if(_0x383be0){var _0x20fc70=_0x383be0[_0x7bf0('0x18')],_0x182df9=_0x4424a5[_0x7bf0('0x19')],_0x4f551c=_0x4424a5[_0x7bf0('0x19')]+_0x4424a5[_0x7bf0('0x1a')],_0x319809;if(_0x4f551c>=_0x20fc70){_0x4f551c=_0x20fc70;_0x319809=0xc8;}else{_0x319809=0xce;}_0x16a7a4['status'](_0x319809);return _0x16a7a4[_0x7bf0('0x1b')](_0x7bf0('0x1c'),_0x182df9+'-'+_0x4f551c+'/'+_0x20fc70)[_0x7bf0('0x17')](_0x383be0);}return null;};}function patchUpdates(_0x117342){return function(_0x15f9d0){try{jsonpatch[_0x7bf0('0x1d')](_0x15f9d0,_0x117342,!![]);}catch(_0xf97278){return BPromise[_0x7bf0('0x1e')](_0xf97278);}return _0x15f9d0[_0x7bf0('0x1f')]();};}function saveUpdates(_0x1cde3b,_0x5ca332){return function(_0x115f78){if(_0x115f78){return _0x115f78[_0x7bf0('0x20')](_0x1cde3b)[_0x7bf0('0x21')](function(_0x3a74b6){return _0x3a74b6;});}return null;};}function removeEntity(_0x2cdc59,_0x2fe5e2){return function(_0x4e41b6){if(_0x4e41b6){return _0x4e41b6['destroy']()[_0x7bf0('0x21')](function(){_0x2cdc59[_0x7bf0('0x15')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4345a3,_0x4b5278){return function(_0x157e0f){if(!_0x157e0f){_0x4345a3[_0x7bf0('0x14')](0x194);}return _0x157e0f;};}function handleError(_0x7c7be6,_0x2b8c6f){_0x2b8c6f=_0x2b8c6f||0x1f4;return function(_0x37d539){logger[_0x7bf0('0x22')](_0x37d539[_0x7bf0('0x23')]);if(_0x37d539[_0x7bf0('0x24')]){delete _0x37d539[_0x7bf0('0x24')];}_0x7c7be6[_0x7bf0('0x15')](_0x2b8c6f)[_0x7bf0('0x25')](_0x37d539);};}exports['index']=function(_0x366c54,_0x113e17){var _0x358efe={},_0x368f9f={},_0x2ba0a3={'count':0x0,'rows':[]};var _0x59cb00=db[_0x7bf0('0x26')][_0x7bf0('0x27')];_0x368f9f['model']=_[_0x7bf0('0x28')](_0x59cb00);_0x368f9f['query']=_[_0x7bf0('0x28')](_0x366c54[_0x7bf0('0x29')]);_0x368f9f[_0x7bf0('0x2a')]=_['intersection'](_0x368f9f[_0x7bf0('0x2b')],_0x368f9f[_0x7bf0('0x29')]);_0x358efe[_0x7bf0('0x2c')]=_['intersection'](_0x368f9f[_0x7bf0('0x2b')],qs[_0x7bf0('0x2d')](_0x366c54[_0x7bf0('0x29')][_0x7bf0('0x2d')]));_0x358efe['attributes']=_0x358efe[_0x7bf0('0x2c')][_0x7bf0('0x2e')]?_0x358efe[_0x7bf0('0x2c')]:_0x368f9f[_0x7bf0('0x2b')];if(!_0x366c54[_0x7bf0('0x29')]['hasOwnProperty'](_0x7bf0('0x2f'))){_0x358efe[_0x7bf0('0x1a')]=qs['limit'](_0x366c54[_0x7bf0('0x29')][_0x7bf0('0x1a')]);_0x358efe['offset']=qs[_0x7bf0('0x19')](_0x366c54[_0x7bf0('0x29')][_0x7bf0('0x19')]);}_0x358efe[_0x7bf0('0x30')]=qs[_0x7bf0('0x31')](_0x366c54[_0x7bf0('0x29')][_0x7bf0('0x31')]);_0x358efe[_0x7bf0('0x32')]=qs[_0x7bf0('0x2a')](_[_0x7bf0('0x33')](_0x366c54[_0x7bf0('0x29')],_0x368f9f[_0x7bf0('0x2a')]));if(_0x366c54[_0x7bf0('0x29')][_0x7bf0('0x34')]){_0x358efe[_0x7bf0('0x32')]=_['merge'](_0x358efe[_0x7bf0('0x32')],{'$or':_[_0x7bf0('0x35')](_0x59cb00,function(_0x351336){if(_0x351336[_0x7bf0('0x36')][_0x7bf0('0x37')]!=='VIRTUAL'){var _0x777078={};_0x777078[_0x351336[_0x7bf0('0x38')]]={'$like':'%'+_0x366c54['query'][_0x7bf0('0x34')]+'%'};return _0x777078;}})});}_0x358efe=_['merge']({},_0x358efe,_0x366c54[_0x7bf0('0x39')]);var _0x3e6ed3={'where':_0x358efe[_0x7bf0('0x32')]};return db[_0x7bf0('0x26')][_0x7bf0('0x18')](_0x3e6ed3)[_0x7bf0('0x21')](function(_0x2e3800){_0x2ba0a3['count']=_0x2e3800;if(_0x366c54['query'][_0x7bf0('0x3a')]){_0x358efe[_0x7bf0('0x3b')]=[{'all':!![]}];}return db[_0x7bf0('0x26')]['findAll'](_0x358efe);})[_0x7bf0('0x21')](function(_0x1704a0){_0x2ba0a3[_0x7bf0('0x3c')]=_0x1704a0;return _0x2ba0a3;})[_0x7bf0('0x21')](respondWithFilteredResult(_0x113e17,_0x358efe))[_0x7bf0('0x3d')](handleError(_0x113e17,null));};exports[_0x7bf0('0x3e')]=function(_0x1acdeb,_0x56cfa0){var _0x28ba44={'raw':!![],'where':{'id':_0x1acdeb[_0x7bf0('0x3f')]['id']}},_0x4d656d={};_0x4d656d[_0x7bf0('0x2b')]=_[_0x7bf0('0x28')](db[_0x7bf0('0x26')][_0x7bf0('0x27')]);_0x4d656d[_0x7bf0('0x29')]=_[_0x7bf0('0x28')](_0x1acdeb[_0x7bf0('0x29')]);_0x4d656d[_0x7bf0('0x2a')]=_[_0x7bf0('0x40')](_0x4d656d[_0x7bf0('0x2b')],_0x4d656d[_0x7bf0('0x29')]);_0x28ba44['attributes']=_['intersection'](_0x4d656d[_0x7bf0('0x2b')],qs[_0x7bf0('0x2d')](_0x1acdeb[_0x7bf0('0x29')][_0x7bf0('0x2d')]));_0x28ba44['attributes']=_0x28ba44[_0x7bf0('0x2c')][_0x7bf0('0x2e')]?_0x28ba44[_0x7bf0('0x2c')]:_0x4d656d['model'];if(_0x1acdeb['query']['includeAll']){_0x28ba44[_0x7bf0('0x3b')]=[{'all':!![]}];}_0x28ba44=_[_0x7bf0('0x41')]({},_0x28ba44,_0x1acdeb['options']);return db[_0x7bf0('0x26')][_0x7bf0('0x42')](_0x28ba44)[_0x7bf0('0x21')](handleEntityNotFound(_0x56cfa0,null))['then'](respondWithResult(_0x56cfa0,null))['catch'](handleError(_0x56cfa0,null));};exports['create']=function(_0x549e81,_0x134371){return db['SmsQueueReport']['create'](_0x549e81['body'],{})[_0x7bf0('0x21')](respondWithResult(_0x134371,0xc9))[_0x7bf0('0x3d')](handleError(_0x134371,null));};exports[_0x7bf0('0x20')]=function(_0x272b9c,_0x5353cc){if(_0x272b9c[_0x7bf0('0x43')]['id']){delete _0x272b9c[_0x7bf0('0x43')]['id'];}return db[_0x7bf0('0x26')]['find']({'where':{'id':_0x272b9c['params']['id']}})[_0x7bf0('0x21')](handleEntityNotFound(_0x5353cc,null))[_0x7bf0('0x21')](saveUpdates(_0x272b9c[_0x7bf0('0x43')],null))[_0x7bf0('0x21')](respondWithResult(_0x5353cc,null))[_0x7bf0('0x3d')](handleError(_0x5353cc,null));};exports[_0x7bf0('0x44')]=function(_0xe1e7d2,_0x2df1ad){return db[_0x7bf0('0x26')][_0x7bf0('0x42')]({'where':{'id':_0xe1e7d2[_0x7bf0('0x3f')]['id']}})[_0x7bf0('0x21')](handleEntityNotFound(_0x2df1ad,null))[_0x7bf0('0x21')](removeEntity(_0x2df1ad,null))[_0x7bf0('0x3d')](handleError(_0x2df1ad,null));};exports['describe']=function(_0x5c2a84,_0x5c4cb2){return db[_0x7bf0('0x26')][_0x7bf0('0x45')]()[_0x7bf0('0x21')](respondWithResult(_0x5c4cb2,null))[_0x7bf0('0x3d')](handleError(_0x5c4cb2,null));};