Built motion from commit d6d69adf.|2.6.33
[motion2.git] / server / api / dashboard / dashboard.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 _0x2846=['stack','name','index','map','Dashboard','rawAttributes','fieldName','key','model','query','keys','filters','attributes','intersection','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','options','includeAll','include','findAll','catch','show','fields','length','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','CustomDashboards','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','params','omit','createdAt','updatedAt','body','update','iframe','attrUrl','attrs','https://','custom','attrPath','value','clock','attrHourFormat','HH:mm:ss','attrTimezone','0.00','attrFontSize','counter','attrMetric','total','attrVoiceQueues','attrChannel','voice','attrEmailAccounts','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','multibar-chart','pie-chart','attrSerie1','attrSerie2','attrSerie3','web-report','attrReport','attrRefresh','widgetAttributes:\x20%s','stringify','addItem','DashboardId','findOne','getItems','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../mysqldb','redis','defaults','localhost','socket.io-emitter','sendStatus','status','end','json','offset','undefined','count','limit','apply','reject','save','then','get','UserProfileResource','destroy','error'];(function(_0x3a3c3d,_0x3b8542){var _0xf3142f=function(_0x479bb0){while(--_0x479bb0){_0x3a3c3d['push'](_0x3a3c3d['shift']());}};_0xf3142f(++_0x3b8542);}(_0x2846,0xd9));var _0x6284=function(_0x32819e,_0x1641bc){_0x32819e=_0x32819e-0x0;var _0x35bc86=_0x2846[_0x32819e];return _0x35bc86;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x6284('0x0'));var zipdir=require(_0x6284('0x1'));var jsonpatch=require(_0x6284('0x2'));var rp=require(_0x6284('0x3'));var moment=require('moment');var BPromise=require(_0x6284('0x4'));var Mustache=require(_0x6284('0x5'));var util=require('util');var path=require(_0x6284('0x6'));var sox=require(_0x6284('0x7'));var csv=require(_0x6284('0x8'));var ejs=require(_0x6284('0x9'));var fs=require('fs');var fs_extra=require(_0x6284('0xa'));var _=require(_0x6284('0xb'));var squel=require(_0x6284('0xc'));var crypto=require('crypto');var jsforce=require(_0x6284('0xd'));var deskjs=require(_0x6284('0xe'));var toCsv=require(_0x6284('0x8'));var querystring=require(_0x6284('0xf'));var Papa=require(_0x6284('0x10'));var Redis=require(_0x6284('0x11'));var authService=require(_0x6284('0x12'));var qs=require(_0x6284('0x13'));var as=require(_0x6284('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x6284('0x15'))(_0x6284('0x16'));var utils=require(_0x6284('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x6284('0x18'))['db'];config[_0x6284('0x19')]=_[_0x6284('0x1a')](config['redis'],{'host':_0x6284('0x1b'),'port':0x18eb});var socket=require(_0x6284('0x1c'))(new Redis(config[_0x6284('0x19')]));require('./dashboard.socket')['register'](socket);function respondWithStatusCode(_0x3b9206,_0x1fb90b){_0x1fb90b=_0x1fb90b||0xcc;return function(_0x20d9e1){if(_0x20d9e1){return _0x3b9206[_0x6284('0x1d')](_0x1fb90b);}return _0x3b9206[_0x6284('0x1e')](_0x1fb90b)[_0x6284('0x1f')]();};}function respondWithResult(_0x503f13,_0x1f1b8a){_0x1f1b8a=_0x1f1b8a||0xc8;return function(_0x319824){if(_0x319824){return _0x503f13[_0x6284('0x1e')](_0x1f1b8a)[_0x6284('0x20')](_0x319824);}};}function respondWithFilteredResult(_0x5ec90e,_0x3c1ea5){return function(_0x35e3a5){if(_0x35e3a5){var _0x4fb823=typeof _0x3c1ea5[_0x6284('0x21')]===_0x6284('0x22')&&typeof _0x3c1ea5['limit']===_0x6284('0x22');var _0x4559a4=_0x35e3a5[_0x6284('0x23')];var _0x2e8718=_0x4fb823?0x0:_0x3c1ea5[_0x6284('0x21')];var _0x60b073=_0x4fb823?_0x35e3a5[_0x6284('0x23')]:_0x3c1ea5['offset']+_0x3c1ea5[_0x6284('0x24')];var _0x5a1dce;if(_0x60b073>=_0x4559a4){_0x60b073=_0x4559a4;_0x5a1dce=0xc8;}else{_0x5a1dce=0xce;}_0x5ec90e[_0x6284('0x1e')](_0x5a1dce);return _0x5ec90e['set']('Content-Range',_0x2e8718+'-'+_0x60b073+'/'+_0x4559a4)[_0x6284('0x20')](_0x35e3a5);}return null;};}function patchUpdates(_0x5414d2){return function(_0x15bbe5){try{jsonpatch[_0x6284('0x25')](_0x15bbe5,_0x5414d2,!![]);}catch(_0xa3cb59){return BPromise[_0x6284('0x26')](_0xa3cb59);}return _0x15bbe5[_0x6284('0x27')]();};}function saveUpdates(_0x23ddba,_0x22e1d8){return function(_0x476bd9){if(_0x476bd9){return _0x476bd9['update'](_0x23ddba)[_0x6284('0x28')](function(_0x423163){return _0x423163;});}return null;};}function removeEntity(_0x273508,_0x880b31){return function(_0x27cb3c){if(_0x27cb3c){return _0x27cb3c['destroy']()[_0x6284('0x28')](function(){var _0xa87b11=_0x27cb3c[_0x6284('0x29')]({'plain':!![]});var _0x520aff='CustomDashboards';return db[_0x6284('0x2a')][_0x6284('0x2b')]({'where':{'type':_0x520aff,'resourceId':_0xa87b11['id']}})[_0x6284('0x28')](function(){return _0x27cb3c;});})[_0x6284('0x28')](function(){_0x273508[_0x6284('0x1e')](0xcc)['end']();});}};}function handleEntityNotFound(_0x13ccb4,_0x1cf61b){return function(_0x576020){if(!_0x576020){_0x13ccb4[_0x6284('0x1d')](0x194);}return _0x576020;};}function handleError(_0x201bb3,_0x29b5d4){_0x29b5d4=_0x29b5d4||0x1f4;return function(_0x472fcd){logger[_0x6284('0x2c')](_0x472fcd[_0x6284('0x2d')]);if(_0x472fcd[_0x6284('0x2e')]){delete _0x472fcd['name'];}_0x201bb3[_0x6284('0x1e')](_0x29b5d4)['send'](_0x472fcd);};}exports[_0x6284('0x2f')]=function(_0x3b420d,_0x3fb7bf){var _0x27b01f={},_0x7e1fa0={},_0x42969d={'count':0x0,'rows':[]};var _0x39c359=_[_0x6284('0x30')](db[_0x6284('0x31')][_0x6284('0x32')],function(_0x3e75d4){return{'name':_0x3e75d4[_0x6284('0x33')],'type':_0x3e75d4['type'][_0x6284('0x34')]};});_0x7e1fa0[_0x6284('0x35')]=_['map'](_0x39c359,_0x6284('0x2e'));_0x7e1fa0[_0x6284('0x36')]=_[_0x6284('0x37')](_0x3b420d[_0x6284('0x36')]);_0x7e1fa0[_0x6284('0x38')]=_['intersection'](_0x7e1fa0[_0x6284('0x35')],_0x7e1fa0[_0x6284('0x36')]);_0x27b01f[_0x6284('0x39')]=_[_0x6284('0x3a')](_0x7e1fa0[_0x6284('0x35')],qs['fields'](_0x3b420d[_0x6284('0x36')]['fields']));_0x27b01f[_0x6284('0x39')]=_0x27b01f[_0x6284('0x39')]['length']?_0x27b01f[_0x6284('0x39')]:_0x7e1fa0[_0x6284('0x35')];if(!_0x3b420d[_0x6284('0x36')]['hasOwnProperty'](_0x6284('0x3b'))){_0x27b01f['limit']=qs['limit'](_0x3b420d[_0x6284('0x36')][_0x6284('0x24')]);_0x27b01f[_0x6284('0x21')]=qs[_0x6284('0x21')](_0x3b420d[_0x6284('0x36')][_0x6284('0x21')]);}_0x27b01f[_0x6284('0x3c')]=qs[_0x6284('0x3d')](_0x3b420d[_0x6284('0x36')][_0x6284('0x3d')]);_0x27b01f[_0x6284('0x3e')]=qs[_0x6284('0x38')](_[_0x6284('0x3f')](_0x3b420d[_0x6284('0x36')],_0x7e1fa0[_0x6284('0x38')]),_0x39c359);if(_0x3b420d['query'][_0x6284('0x40')]){_0x27b01f[_0x6284('0x3e')]=_[_0x6284('0x41')](_0x27b01f[_0x6284('0x3e')],{'$or':_[_0x6284('0x30')](_0x39c359,function(_0x51439d){if(_0x51439d[_0x6284('0x42')]!==_0x6284('0x43')){var _0x107bb1={};_0x107bb1[_0x51439d[_0x6284('0x2e')]]={'$like':'%'+_0x3b420d['query']['filter']+'%'};return _0x107bb1;}})});}_0x27b01f=_['merge']({},_0x27b01f,_0x3b420d[_0x6284('0x44')]);var _0x218065={'where':_0x27b01f[_0x6284('0x3e')]};return db[_0x6284('0x31')][_0x6284('0x23')](_0x218065)[_0x6284('0x28')](function(_0x37668d){_0x42969d[_0x6284('0x23')]=_0x37668d;if(_0x3b420d[_0x6284('0x36')][_0x6284('0x45')]){_0x27b01f[_0x6284('0x46')]=[{'all':!![]}];}return db[_0x6284('0x31')][_0x6284('0x47')](_0x27b01f);})[_0x6284('0x28')](function(_0x20b1ea){_0x42969d['rows']=_0x20b1ea;return _0x42969d;})[_0x6284('0x28')](respondWithFilteredResult(_0x3fb7bf,_0x27b01f))[_0x6284('0x48')](handleError(_0x3fb7bf,null));};exports[_0x6284('0x49')]=function(_0x3057fb,_0x55f1b9){var _0x2ba7b3={'raw':![],'where':{'id':_0x3057fb['params']['id']}},_0x3fa19b={};_0x3fa19b[_0x6284('0x35')]=_[_0x6284('0x37')](db[_0x6284('0x31')]['rawAttributes']);_0x3fa19b['query']=_[_0x6284('0x37')](_0x3057fb[_0x6284('0x36')]);_0x3fa19b[_0x6284('0x38')]=_[_0x6284('0x3a')](_0x3fa19b[_0x6284('0x35')],_0x3fa19b[_0x6284('0x36')]);_0x2ba7b3['attributes']=_[_0x6284('0x3a')](_0x3fa19b['model'],qs[_0x6284('0x4a')](_0x3057fb[_0x6284('0x36')][_0x6284('0x4a')]));_0x2ba7b3[_0x6284('0x39')]=_0x2ba7b3['attributes'][_0x6284('0x4b')]?_0x2ba7b3[_0x6284('0x39')]:_0x3fa19b['model'];if(_0x3057fb['query'][_0x6284('0x45')]){_0x2ba7b3['include']=[{'all':!![]}];}_0x2ba7b3=_[_0x6284('0x41')]({},_0x2ba7b3,_0x3057fb[_0x6284('0x44')]);return db[_0x6284('0x31')][_0x6284('0x4c')](_0x2ba7b3)[_0x6284('0x28')](handleEntityNotFound(_0x55f1b9,null))[_0x6284('0x28')](respondWithResult(_0x55f1b9,null))[_0x6284('0x48')](handleError(_0x55f1b9,null));};exports['create']=function(_0x2bc18a,_0x3c0d34){return db[_0x6284('0x31')][_0x6284('0x4d')](_0x2bc18a['body'],{})[_0x6284('0x28')](function(_0x154f6c){var _0x23e311=_0x2bc18a[_0x6284('0x4e')][_0x6284('0x29')]({'plain':!![]});if(!_0x23e311)throw new Error(_0x6284('0x4f'));if(_0x23e311['role']===_0x6284('0x4e')){var _0x35c267=_0x154f6c['get']({'plain':!![]});var _0x22f0d5=_0x6284('0x50');return db[_0x6284('0x51')][_0x6284('0x4c')]({'where':{'name':_0x22f0d5,'userProfileId':_0x23e311[_0x6284('0x52')]},'raw':!![]})[_0x6284('0x28')](function(_0x17aa90){if(_0x17aa90&&_0x17aa90[_0x6284('0x53')]===0x0){return db['UserProfileResource'][_0x6284('0x4d')]({'name':_0x35c267['name'],'resourceId':_0x35c267['id'],'type':_0x17aa90[_0x6284('0x2e')],'sectionId':_0x17aa90['id']},{})[_0x6284('0x28')](function(){return _0x154f6c;});}else{return _0x154f6c;}})[_0x6284('0x48')](function(_0x2ba392){logger[_0x6284('0x2c')](_0x6284('0x54'),_0x2ba392);throw _0x2ba392;});}return _0x154f6c;})['then'](respondWithResult(_0x3c0d34,0xc9))[_0x6284('0x48')](handleError(_0x3c0d34,null));};exports[_0x6284('0x55')]=function(_0x38b96c,_0x17ace8){var _0x4327bb={'where':{'id':_0x38b96c[_0x6284('0x56')]['id']}},_0x393215={};_0x393215[_0x6284('0x35')]=_[_0x6284('0x37')](db[_0x6284('0x31')][_0x6284('0x32')]);_0x4327bb[_0x6284('0x39')]=_[_0x6284('0x3a')](_0x393215[_0x6284('0x35')],qs[_0x6284('0x4a')](_0x38b96c['query'][_0x6284('0x4a')]));_0x4327bb['attributes']=_0x4327bb['attributes'][_0x6284('0x4b')]?_0x4327bb[_0x6284('0x39')]:_0x393215[_0x6284('0x35')];if(_0x38b96c[_0x6284('0x36')][_0x6284('0x45')]){_0x4327bb['include']=[{'all':!![]}];}_0x4327bb=_[_0x6284('0x41')]({},_0x4327bb,_0x38b96c[_0x6284('0x44')]);return db['Dashboard'][_0x6284('0x4c')](_0x4327bb)[_0x6284('0x28')](handleEntityNotFound(_0x17ace8,null))[_0x6284('0x28')](function(_0x39f566){if(_0x39f566){var _0x1b8c4d=_0x39f566[_0x6284('0x29')]({'plain':!![]});_0x1b8c4d=qs[_0x6284('0x57')](_0x1b8c4d,['id',_0x6284('0x58'),_0x6284('0x59')]);_0x38b96c[_0x6284('0x5a')]=_['omit'](_0x38b96c[_0x6284('0x5a')],['id',_0x6284('0x58'),'updatedAt']);return db[_0x6284('0x31')][_0x6284('0x4d')](_[_0x6284('0x41')](_0x1b8c4d,_0x38b96c[_0x6284('0x5a')]),{'include':_0x38b96c['query'][_0x6284('0x45')]?[{'all':!![]}]:undefined})['then'](function(_0x77f47b){var _0x262aef=_0x38b96c[_0x6284('0x4e')][_0x6284('0x29')]({'plain':!![]});if(!_0x262aef)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x262aef['role']===_0x6284('0x4e')){var _0x161daa=_0x77f47b[_0x6284('0x29')]({'plain':!![]});var _0x1ab4cc=_0x6284('0x50');return db[_0x6284('0x51')][_0x6284('0x4c')]({'where':{'name':_0x1ab4cc,'userProfileId':_0x262aef['userProfileId']},'raw':!![]})[_0x6284('0x28')](function(_0x28213c){if(_0x28213c&&_0x28213c[_0x6284('0x53')]===0x0){return db[_0x6284('0x2a')][_0x6284('0x4d')]({'name':_0x161daa[_0x6284('0x2e')],'resourceId':_0x161daa['id'],'type':_0x28213c[_0x6284('0x2e')],'sectionId':_0x28213c['id']},{})[_0x6284('0x28')](function(){return _0x77f47b;});}else{return _0x77f47b;}})['catch'](function(_0xc2b83c){logger['error'](_0x6284('0x54'),_0xc2b83c);throw _0xc2b83c;});}return _0x77f47b;});}})['then'](respondWithResult(_0x17ace8,0xc9))['catch'](handleError(_0x17ace8,null));};exports[_0x6284('0x5b')]=function(_0x2cda39,_0x4e62db){if(_0x2cda39[_0x6284('0x5a')]['id']){delete _0x2cda39[_0x6284('0x5a')]['id'];}return db[_0x6284('0x31')]['find']({'where':{'id':_0x2cda39[_0x6284('0x56')]['id']}})[_0x6284('0x28')](handleEntityNotFound(_0x4e62db,null))[_0x6284('0x28')](saveUpdates(_0x2cda39[_0x6284('0x5a')],null))[_0x6284('0x28')](respondWithResult(_0x4e62db,null))[_0x6284('0x48')](handleError(_0x4e62db,null));};exports[_0x6284('0x2b')]=function(_0x47efc7,_0x58c338){return db[_0x6284('0x31')][_0x6284('0x4c')]({'where':{'id':_0x47efc7[_0x6284('0x56')]['id']}})['then'](handleEntityNotFound(_0x58c338,null))[_0x6284('0x28')](removeEntity(_0x58c338,null))[_0x6284('0x48')](handleError(_0x58c338,null));};function widgetAttributes(_0xf32129){try{switch(_0xf32129['type']){case _0x6284('0x5c'):return[{'name':_0x6284('0x5d'),'value':_0xf32129[_0x6284('0x5d')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129['attrs'][0x0]?_0xf32129['attrs'][0x0]['value']:undefined)||_0x6284('0x5f')}];case _0x6284('0x60'):return[{'name':_0x6284('0x61'),'value':_0xf32129['attrPath']||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x0]?_0xf32129['attrs'][0x0][_0x6284('0x62')]:undefined)||''}];case _0x6284('0x63'):return[{'name':_0x6284('0x64'),'value':_0xf32129['attrHourFormat']||(_0xf32129['attrs']&&_0xf32129['attrs'][0x0]?_0xf32129[_0x6284('0x5e')][0x0]['value']:undefined)||_0x6284('0x65')},{'name':'attrTimezone','value':_0xf32129[_0x6284('0x66')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129['attrs'][0x1]?_0xf32129[_0x6284('0x5e')][0x1][_0x6284('0x62')]:undefined)||_0x6284('0x67')},{'name':'attrFontSize','value':_0xf32129[_0x6284('0x68')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129['attrs'][0x2]?_0xf32129[_0x6284('0x5e')][0x2][_0x6284('0x62')]:undefined)||0xc}];case _0x6284('0x69'):return[{'name':_0x6284('0x6a'),'value':_0xf32129[_0x6284('0x6a')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x0]?_0xf32129[_0x6284('0x5e')][0x0][_0x6284('0x62')]:undefined)||_0x6284('0x6b')},{'name':_0x6284('0x6c'),'value':_0xf32129[_0x6284('0x6c')]||(_0xf32129['attrs']&&_0xf32129['attrs'][0x1]?_0xf32129[_0x6284('0x5e')][0x1][_0x6284('0x62')]:undefined)||[]},{'name':'attrFontSize','value':_0xf32129[_0x6284('0x68')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129['attrs'][0x2]?_0xf32129[_0x6284('0x5e')][0x2][_0x6284('0x62')]:undefined)||0x14},{'name':_0x6284('0x6d'),'value':_0xf32129['attrChannel']||(_0xf32129[_0x6284('0x5e')]&&_0xf32129['attrs'][0x3]?_0xf32129[_0x6284('0x5e')][0x3]['value']:undefined)||_0x6284('0x6e')},{'name':_0x6284('0x6f'),'value':_0xf32129[_0x6284('0x6f')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x4]?_0xf32129['attrs'][0x4][_0x6284('0x62')]:undefined)||''},{'name':_0x6284('0x70'),'value':_0xf32129[_0x6284('0x70')]||(_0xf32129['attrs']&&_0xf32129[_0x6284('0x5e')][0x5]?_0xf32129['attrs'][0x5][_0x6284('0x62')]:undefined)||''},{'name':_0x6284('0x71'),'value':_0xf32129[_0x6284('0x71')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x6]?_0xf32129[_0x6284('0x5e')][0x6][_0x6284('0x62')]:undefined)||''},{'name':_0x6284('0x72'),'value':_0xf32129[_0x6284('0x72')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x7]?_0xf32129['attrs'][0x7][_0x6284('0x62')]:undefined)||''},{'name':_0x6284('0x73'),'value':_0xf32129['attrWhatsappAccounts']||(_0xf32129[_0x6284('0x5e')]&&_0xf32129['attrs'][0x8]?_0xf32129[_0x6284('0x5e')][0x8][_0x6284('0x62')]:undefined)||''},{'name':'attrChatWebsites','value':_0xf32129[_0x6284('0x74')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x9]?_0xf32129[_0x6284('0x5e')][0x9]['value']:undefined)||''}];case _0x6284('0x75'):case _0x6284('0x76'):return[{'name':_0x6284('0x77'),'value':_0xf32129[_0x6284('0x77')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x0]?_0xf32129[_0x6284('0x5e')][0x0]['value']:undefined)||_0x6284('0x6b')},{'name':_0x6284('0x78'),'value':_0xf32129[_0x6284('0x78')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x1]?_0xf32129[_0x6284('0x5e')][0x1][_0x6284('0x62')]:undefined)||null},{'name':_0x6284('0x79'),'value':_0xf32129[_0x6284('0x79')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x2]?_0xf32129[_0x6284('0x5e')][0x2][_0x6284('0x62')]:undefined)||null},{'name':_0x6284('0x6c'),'value':_0xf32129[_0x6284('0x6c')]||(_0xf32129['attrs']&&_0xf32129[_0x6284('0x5e')][0x3]?_0xf32129[_0x6284('0x5e')][0x3]['value']:undefined)||[]},{'name':_0x6284('0x6d'),'value':_0xf32129['attrChannel']||(_0xf32129[_0x6284('0x5e')]&&_0xf32129['attrs'][0x4]?_0xf32129[_0x6284('0x5e')][0x4][_0x6284('0x62')]:undefined)||_0x6284('0x6e')},{'name':_0x6284('0x6f'),'value':_0xf32129['attrEmailAccounts']||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x5]?_0xf32129[_0x6284('0x5e')][0x5][_0x6284('0x62')]:undefined)||''},{'name':_0x6284('0x70'),'value':_0xf32129[_0x6284('0x70')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x6]?_0xf32129[_0x6284('0x5e')][0x6]['value']:undefined)||''},{'name':_0x6284('0x71'),'value':_0xf32129[_0x6284('0x71')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x7]?_0xf32129['attrs'][0x7][_0x6284('0x62')]:undefined)||''},{'name':_0x6284('0x72'),'value':_0xf32129['attrOpenchannelAccounts']||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x8]?_0xf32129['attrs'][0x8][_0x6284('0x62')]:undefined)||''},{'name':'attrWhatsappAccounts','value':_0xf32129['attrWhatsappAccounts']||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x9]?_0xf32129['attrs'][0x9]['value']:undefined)||''},{'name':_0x6284('0x74'),'value':_0xf32129[_0x6284('0x74')]||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0xa]?_0xf32129['attrs'][0xa][_0x6284('0x62')]:undefined)||''}];case _0x6284('0x7a'):return[{'name':_0x6284('0x7b'),'type':_0xf32129['reportType']||(_0xf32129[_0x6284('0x5e')]&&_0xf32129[_0x6284('0x5e')][0x0]?_0xf32129[_0x6284('0x5e')][0x0]['type']:undefined)||null,'value':_0xf32129['attrReport']||(_0xf32129[_0x6284('0x5e')]&&_0xf32129['attrs'][0x0]?_0xf32129[_0x6284('0x5e')][0x0][_0x6284('0x62')]:undefined)||null},{'name':'attrRefresh','value':_0xf32129[_0x6284('0x7c')]||(_0xf32129['attrs']&&_0xf32129[_0x6284('0x5e')][0x1]?_0xf32129['attrs'][0x1][_0x6284('0x62')]:undefined)||0x0}];default:return[];}}catch(_0x39e186){logger['error'](_0x6284('0x7d'),JSON[_0x6284('0x7e')](_0x39e186));return[];}}exports[_0x6284('0x7f')]=function(_0x23caaa,_0x532799,_0x189ca8){if(_0x23caaa[_0x6284('0x5a')]['id']){delete _0x23caaa[_0x6284('0x5a')]['id'];}return db[_0x6284('0x31')][_0x6284('0x4c')]({'where':{'id':_0x23caaa[_0x6284('0x56')]['id']}})['then'](handleEntityNotFound(_0x532799,null))[_0x6284('0x28')](function(_0x236cf0){if(_0x236cf0){_0x23caaa['body'][_0x6284('0x80')]=_0x236cf0['id'];_0x23caaa['body']['attrs']=widgetAttributes(_0x23caaa[_0x6284('0x5a')]);return db['DashboardItem'][_0x6284('0x4d')](_0x23caaa[_0x6284('0x5a')]);}})[_0x6284('0x28')](respondWithResult(_0x532799,null))['catch'](handleError(_0x532799,null));};exports['getItems']=function(_0x2f79fd,_0x5ab088,_0xdf9b2c){var _0x5855f4={};var _0x328717={};var _0x5e1d7a;var _0x37e3bf;return db[_0x6284('0x31')][_0x6284('0x81')]({'where':{'id':_0x2f79fd[_0x6284('0x56')]['id']}})[_0x6284('0x28')](handleEntityNotFound(_0x5ab088,null))['then'](function(_0x5da259){if(_0x5da259){_0x5e1d7a=_0x5da259;_0x328717[_0x6284('0x35')]=_['keys'](db['DashboardItem']['rawAttributes']);_0x328717['query']=_[_0x6284('0x37')](_0x2f79fd['query']);_0x328717['filters']=_[_0x6284('0x3a')](_0x328717[_0x6284('0x35')],_0x328717[_0x6284('0x36')]);_0x5855f4['attributes']=_[_0x6284('0x3a')](_0x328717[_0x6284('0x35')],qs[_0x6284('0x4a')](_0x2f79fd[_0x6284('0x36')][_0x6284('0x4a')]));_0x5855f4[_0x6284('0x39')]=_0x5855f4[_0x6284('0x39')][_0x6284('0x4b')]?_0x5855f4[_0x6284('0x39')]:_0x328717[_0x6284('0x35')];_0x5855f4['order']=qs[_0x6284('0x3d')](_0x2f79fd[_0x6284('0x36')][_0x6284('0x3d')]);_0x5855f4['where']=qs['filters'](_[_0x6284('0x3f')](_0x2f79fd[_0x6284('0x36')],_0x328717[_0x6284('0x38')]));if(_0x2f79fd[_0x6284('0x36')][_0x6284('0x40')]){_0x5855f4[_0x6284('0x3e')]=_[_0x6284('0x41')](_0x5855f4[_0x6284('0x3e')],{'$or':_[_0x6284('0x30')](_0x5855f4[_0x6284('0x39')],function(_0x231c98){var _0x5102b0={};_0x5102b0[_0x231c98]={'$like':'%'+_0x2f79fd['query'][_0x6284('0x40')]+'%'};return _0x5102b0;})});}_0x5855f4=_[_0x6284('0x41')]({},_0x5855f4,_0x2f79fd[_0x6284('0x44')]);return _0x5e1d7a['getItems'](_0x5855f4);}})['then'](function(_0x4eca24){if(_0x4eca24){_0x37e3bf=_0x4eca24['length'];if(!_0x2f79fd['query']['hasOwnProperty'](_0x6284('0x3b'))){_0x5855f4[_0x6284('0x24')]=qs[_0x6284('0x24')](_0x2f79fd[_0x6284('0x36')][_0x6284('0x24')]);_0x5855f4['offset']=qs[_0x6284('0x21')](_0x2f79fd[_0x6284('0x36')][_0x6284('0x21')]);}return _0x5e1d7a[_0x6284('0x82')](_0x5855f4);}})[_0x6284('0x28')](function(_0x181639){if(_0x181639){return _0x181639?{'count':_0x37e3bf,'rows':_0x181639}:null;}})[_0x6284('0x28')](respondWithResult(_0x5ab088,null))[_0x6284('0x48')](handleError(_0x5ab088,null));};