Built motion from commit d69f4380.|2.6.29
[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 _0x0361=['DashboardItem','getItems','findOne','order','nolimit','rimraf','zip-dir','request-promise','mustache','util','path','to-csv','crypto','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./dashboard.socket','register','sendStatus','status','end','offset','limit','set','Content-Range','json','reject','save','update','then','destroy','get','CustomDashboards','UserProfileResource','name','send','index','map','Dashboard','rawAttributes','fieldName','key','query','filters','intersection','model','fields','attributes','length','hasOwnProperty','sort','where','pick','filter','type','VIRTUAL','merge','count','includeAll','include','findAll','catch','show','keys','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','createdAt','omit','updatedAt','autoAssociation','params','attrUrl','attrs','value','https://','custom','attrHourFormat','HH:mm:ss','attrTimezone','0.00','attrFontSize','attrMetric','total','attrVoiceQueues','attrChannel','voice','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','multibar-chart','pie-chart','attrSerie1','attrSerie2','attrSerie3','attrEmailAccounts','web-report','attrReport','reportType','attrRefresh','widgetAttributes:\x20%s','stringify'];(function(_0x5f7203,_0x334239){var _0x4d1702=function(_0x777529){while(--_0x777529){_0x5f7203['push'](_0x5f7203['shift']());}};_0x4d1702(++_0x334239);}(_0x0361,0x17c));var _0x1036=function(_0xfae23b,_0x2be4ba){_0xfae23b=_0xfae23b-0x0;var _0x200640=_0x0361[_0xfae23b];return _0x200640;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x1036('0x0'));var zipdir=require(_0x1036('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x1036('0x2'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x1036('0x3'));var util=require(_0x1036('0x4'));var path=require(_0x1036('0x5'));var sox=require('sox');var csv=require(_0x1036('0x6'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require('squel');var crypto=require(_0x1036('0x7'));var jsforce=require(_0x1036('0x8'));var deskjs=require(_0x1036('0x9'));var toCsv=require(_0x1036('0x6'));var querystring=require(_0x1036('0xa'));var Papa=require('papaparse');var Redis=require(_0x1036('0xb'));var authService=require('../../components/auth/service');var qs=require(_0x1036('0xc'));var as=require(_0x1036('0xd'));var hardwareService=require(_0x1036('0xe'));var logger=require('../../config/logger')(_0x1036('0xf'));var utils=require(_0x1036('0x10'));var config=require(_0x1036('0x11'));var licenseUtil=require(_0x1036('0x12'));var db=require(_0x1036('0x13'))['db'];config[_0x1036('0x14')]=_[_0x1036('0x15')](config[_0x1036('0x14')],{'host':'localhost','port':0x18eb});var socket=require(_0x1036('0x16'))(new Redis(config[_0x1036('0x14')]));require(_0x1036('0x17'))[_0x1036('0x18')](socket);function respondWithStatusCode(_0x2e49ad,_0x4b68cb){_0x4b68cb=_0x4b68cb||0xcc;return function(_0x32700d){if(_0x32700d){return _0x2e49ad[_0x1036('0x19')](_0x4b68cb);}return _0x2e49ad[_0x1036('0x1a')](_0x4b68cb)[_0x1036('0x1b')]();};}function respondWithResult(_0x54ca8b,_0x2271df){_0x2271df=_0x2271df||0xc8;return function(_0x323913){if(_0x323913){return _0x54ca8b[_0x1036('0x1a')](_0x2271df)['json'](_0x323913);}};}function respondWithFilteredResult(_0x22adc1,_0x25421d){return function(_0x3d5ec1){if(_0x3d5ec1){var _0x41567a=typeof _0x25421d[_0x1036('0x1c')]==='undefined'&&typeof _0x25421d['limit']==='undefined';var _0x4371ab=_0x3d5ec1['count'];var _0xea6168=_0x41567a?0x0:_0x25421d[_0x1036('0x1c')];var _0x5d4483=_0x41567a?_0x3d5ec1['count']:_0x25421d[_0x1036('0x1c')]+_0x25421d[_0x1036('0x1d')];var _0x43f6b4;if(_0x5d4483>=_0x4371ab){_0x5d4483=_0x4371ab;_0x43f6b4=0xc8;}else{_0x43f6b4=0xce;}_0x22adc1[_0x1036('0x1a')](_0x43f6b4);return _0x22adc1[_0x1036('0x1e')](_0x1036('0x1f'),_0xea6168+'-'+_0x5d4483+'/'+_0x4371ab)[_0x1036('0x20')](_0x3d5ec1);}return null;};}function patchUpdates(_0x43c65a){return function(_0x575dc8){try{jsonpatch['apply'](_0x575dc8,_0x43c65a,!![]);}catch(_0x598325){return BPromise[_0x1036('0x21')](_0x598325);}return _0x575dc8[_0x1036('0x22')]();};}function saveUpdates(_0x48507f,_0x409e31){return function(_0x34b9da){if(_0x34b9da){return _0x34b9da[_0x1036('0x23')](_0x48507f)[_0x1036('0x24')](function(_0x596ca3){return _0x596ca3;});}return null;};}function removeEntity(_0xba36d0,_0x1b5418){return function(_0x1e016a){if(_0x1e016a){return _0x1e016a[_0x1036('0x25')]()[_0x1036('0x24')](function(){var _0x58e310=_0x1e016a[_0x1036('0x26')]({'plain':!![]});var _0x4c992c=_0x1036('0x27');return db[_0x1036('0x28')][_0x1036('0x25')]({'where':{'type':_0x4c992c,'resourceId':_0x58e310['id']}})[_0x1036('0x24')](function(){return _0x1e016a;});})[_0x1036('0x24')](function(){_0xba36d0[_0x1036('0x1a')](0xcc)[_0x1036('0x1b')]();});}};}function handleEntityNotFound(_0xc96cc1,_0x323c14){return function(_0x350d5d){if(!_0x350d5d){_0xc96cc1[_0x1036('0x19')](0x194);}return _0x350d5d;};}function handleError(_0x4cc975,_0x3d9646){_0x3d9646=_0x3d9646||0x1f4;return function(_0x4b358f){logger['error'](_0x4b358f['stack']);if(_0x4b358f[_0x1036('0x29')]){delete _0x4b358f[_0x1036('0x29')];}_0x4cc975[_0x1036('0x1a')](_0x3d9646)[_0x1036('0x2a')](_0x4b358f);};}exports[_0x1036('0x2b')]=function(_0x1e4228,_0x385057){var _0x3c74b3={},_0x5180e2={},_0x1f58ba={'count':0x0,'rows':[]};var _0x56afa7=_[_0x1036('0x2c')](db[_0x1036('0x2d')][_0x1036('0x2e')],function(_0x3c728c){return{'name':_0x3c728c[_0x1036('0x2f')],'type':_0x3c728c['type'][_0x1036('0x30')]};});_0x5180e2['model']=_[_0x1036('0x2c')](_0x56afa7,_0x1036('0x29'));_0x5180e2[_0x1036('0x31')]=_['keys'](_0x1e4228[_0x1036('0x31')]);_0x5180e2[_0x1036('0x32')]=_[_0x1036('0x33')](_0x5180e2[_0x1036('0x34')],_0x5180e2['query']);_0x3c74b3['attributes']=_[_0x1036('0x33')](_0x5180e2['model'],qs['fields'](_0x1e4228[_0x1036('0x31')][_0x1036('0x35')]));_0x3c74b3[_0x1036('0x36')]=_0x3c74b3['attributes'][_0x1036('0x37')]?_0x3c74b3[_0x1036('0x36')]:_0x5180e2[_0x1036('0x34')];if(!_0x1e4228[_0x1036('0x31')][_0x1036('0x38')]('nolimit')){_0x3c74b3[_0x1036('0x1d')]=qs[_0x1036('0x1d')](_0x1e4228['query'][_0x1036('0x1d')]);_0x3c74b3[_0x1036('0x1c')]=qs[_0x1036('0x1c')](_0x1e4228[_0x1036('0x31')][_0x1036('0x1c')]);}_0x3c74b3['order']=qs[_0x1036('0x39')](_0x1e4228[_0x1036('0x31')][_0x1036('0x39')]);_0x3c74b3[_0x1036('0x3a')]=qs[_0x1036('0x32')](_[_0x1036('0x3b')](_0x1e4228[_0x1036('0x31')],_0x5180e2[_0x1036('0x32')]),_0x56afa7);if(_0x1e4228[_0x1036('0x31')][_0x1036('0x3c')]){_0x3c74b3[_0x1036('0x3a')]=_['merge'](_0x3c74b3[_0x1036('0x3a')],{'$or':_[_0x1036('0x2c')](_0x56afa7,function(_0x5ae848){if(_0x5ae848[_0x1036('0x3d')]!==_0x1036('0x3e')){var _0x261217={};_0x261217[_0x5ae848[_0x1036('0x29')]]={'$like':'%'+_0x1e4228[_0x1036('0x31')][_0x1036('0x3c')]+'%'};return _0x261217;}})});}_0x3c74b3=_[_0x1036('0x3f')]({},_0x3c74b3,_0x1e4228['options']);var _0x55a8da={'where':_0x3c74b3[_0x1036('0x3a')]};return db[_0x1036('0x2d')][_0x1036('0x40')](_0x55a8da)[_0x1036('0x24')](function(_0x5d2ca0){_0x1f58ba[_0x1036('0x40')]=_0x5d2ca0;if(_0x1e4228['query'][_0x1036('0x41')]){_0x3c74b3[_0x1036('0x42')]=[{'all':!![]}];}return db[_0x1036('0x2d')][_0x1036('0x43')](_0x3c74b3);})[_0x1036('0x24')](function(_0x38c6a1){_0x1f58ba['rows']=_0x38c6a1;return _0x1f58ba;})[_0x1036('0x24')](respondWithFilteredResult(_0x385057,_0x3c74b3))[_0x1036('0x44')](handleError(_0x385057,null));};exports[_0x1036('0x45')]=function(_0x202fd0,_0x313bca){var _0x372857={'raw':![],'where':{'id':_0x202fd0['params']['id']}},_0x36e689={};_0x36e689['model']=_[_0x1036('0x46')](db[_0x1036('0x2d')]['rawAttributes']);_0x36e689[_0x1036('0x31')]=_[_0x1036('0x46')](_0x202fd0[_0x1036('0x31')]);_0x36e689[_0x1036('0x32')]=_[_0x1036('0x33')](_0x36e689['model'],_0x36e689[_0x1036('0x31')]);_0x372857['attributes']=_[_0x1036('0x33')](_0x36e689[_0x1036('0x34')],qs['fields'](_0x202fd0[_0x1036('0x31')][_0x1036('0x35')]));_0x372857[_0x1036('0x36')]=_0x372857[_0x1036('0x36')][_0x1036('0x37')]?_0x372857['attributes']:_0x36e689[_0x1036('0x34')];if(_0x202fd0['query'][_0x1036('0x41')]){_0x372857['include']=[{'all':!![]}];}_0x372857=_['merge']({},_0x372857,_0x202fd0[_0x1036('0x47')]);return db['Dashboard']['find'](_0x372857)['then'](handleEntityNotFound(_0x313bca,null))[_0x1036('0x24')](respondWithResult(_0x313bca,null))[_0x1036('0x44')](handleError(_0x313bca,null));};exports[_0x1036('0x48')]=function(_0x1f9198,_0x9a6d00){return db[_0x1036('0x2d')][_0x1036('0x48')](_0x1f9198[_0x1036('0x49')],{})[_0x1036('0x24')](function(_0x2b13c5){var _0x187d55=_0x1f9198[_0x1036('0x4a')][_0x1036('0x26')]({'plain':!![]});if(!_0x187d55)throw new Error(_0x1036('0x4b'));if(_0x187d55[_0x1036('0x4c')]===_0x1036('0x4a')){var _0x4f36e3=_0x2b13c5[_0x1036('0x26')]({'plain':!![]});var _0x5cf6e7=_0x1036('0x27');return db[_0x1036('0x4d')][_0x1036('0x4e')]({'where':{'name':_0x5cf6e7,'userProfileId':_0x187d55[_0x1036('0x4f')]},'raw':!![]})[_0x1036('0x24')](function(_0x3cd948){if(_0x3cd948&&_0x3cd948['autoAssociation']===0x0){return db[_0x1036('0x28')]['create']({'name':_0x4f36e3['name'],'resourceId':_0x4f36e3['id'],'type':_0x3cd948[_0x1036('0x29')],'sectionId':_0x3cd948['id']},{})['then'](function(){return _0x2b13c5;});}else{return _0x2b13c5;}})[_0x1036('0x44')](function(_0x31c42a){logger[_0x1036('0x50')](_0x1036('0x51'),_0x31c42a);throw _0x31c42a;});}return _0x2b13c5;})[_0x1036('0x24')](respondWithResult(_0x9a6d00,0xc9))['catch'](handleError(_0x9a6d00,null));};exports[_0x1036('0x52')]=function(_0x320a22,_0x1f573a){var _0x3a9460={'where':{'id':_0x320a22['params']['id']}},_0x2b510a={};_0x2b510a['model']=_[_0x1036('0x46')](db[_0x1036('0x2d')][_0x1036('0x2e')]);_0x3a9460[_0x1036('0x36')]=_[_0x1036('0x33')](_0x2b510a[_0x1036('0x34')],qs['fields'](_0x320a22[_0x1036('0x31')][_0x1036('0x35')]));_0x3a9460[_0x1036('0x36')]=_0x3a9460[_0x1036('0x36')][_0x1036('0x37')]?_0x3a9460[_0x1036('0x36')]:_0x2b510a[_0x1036('0x34')];if(_0x320a22[_0x1036('0x31')][_0x1036('0x41')]){_0x3a9460['include']=[{'all':!![]}];}_0x3a9460=_[_0x1036('0x3f')]({},_0x3a9460,_0x320a22[_0x1036('0x47')]);return db[_0x1036('0x2d')][_0x1036('0x4e')](_0x3a9460)[_0x1036('0x24')](handleEntityNotFound(_0x1f573a,null))[_0x1036('0x24')](function(_0x45488c){if(_0x45488c){var _0x2bef60=_0x45488c['get']({'plain':!![]});_0x2bef60=qs['omit'](_0x2bef60,['id',_0x1036('0x53'),'updatedAt']);_0x320a22['body']=_[_0x1036('0x54')](_0x320a22[_0x1036('0x49')],['id','createdAt',_0x1036('0x55')]);return db[_0x1036('0x2d')][_0x1036('0x48')](_['merge'](_0x2bef60,_0x320a22[_0x1036('0x49')]),{'include':_0x320a22['query'][_0x1036('0x41')]?[{'all':!![]}]:undefined})[_0x1036('0x24')](function(_0x9f71d3){var _0xb9a230=_0x320a22[_0x1036('0x4a')][_0x1036('0x26')]({'plain':!![]});if(!_0xb9a230)throw new Error(_0x1036('0x4b'));if(_0xb9a230[_0x1036('0x4c')]==='user'){var _0x595b0f=_0x9f71d3[_0x1036('0x26')]({'plain':!![]});var _0x4371db=_0x1036('0x27');return db[_0x1036('0x4d')][_0x1036('0x4e')]({'where':{'name':_0x4371db,'userProfileId':_0xb9a230[_0x1036('0x4f')]},'raw':!![]})[_0x1036('0x24')](function(_0x4716ee){if(_0x4716ee&&_0x4716ee[_0x1036('0x56')]===0x0){return db[_0x1036('0x28')][_0x1036('0x48')]({'name':_0x595b0f[_0x1036('0x29')],'resourceId':_0x595b0f['id'],'type':_0x4716ee[_0x1036('0x29')],'sectionId':_0x4716ee['id']},{})['then'](function(){return _0x9f71d3;});}else{return _0x9f71d3;}})['catch'](function(_0xdb0fae){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xdb0fae);throw _0xdb0fae;});}return _0x9f71d3;});}})[_0x1036('0x24')](respondWithResult(_0x1f573a,0xc9))[_0x1036('0x44')](handleError(_0x1f573a,null));};exports['update']=function(_0x116d1b,_0x1ff93e){if(_0x116d1b[_0x1036('0x49')]['id']){delete _0x116d1b[_0x1036('0x49')]['id'];}return db[_0x1036('0x2d')][_0x1036('0x4e')]({'where':{'id':_0x116d1b[_0x1036('0x57')]['id']}})[_0x1036('0x24')](handleEntityNotFound(_0x1ff93e,null))[_0x1036('0x24')](saveUpdates(_0x116d1b['body'],null))[_0x1036('0x24')](respondWithResult(_0x1ff93e,null))[_0x1036('0x44')](handleError(_0x1ff93e,null));};exports[_0x1036('0x25')]=function(_0x1f8a54,_0x418eaa){return db['Dashboard'][_0x1036('0x4e')]({'where':{'id':_0x1f8a54[_0x1036('0x57')]['id']}})[_0x1036('0x24')](handleEntityNotFound(_0x418eaa,null))['then'](removeEntity(_0x418eaa,null))[_0x1036('0x44')](handleError(_0x418eaa,null));};function widgetAttributes(_0x4517cf){try{switch(_0x4517cf[_0x1036('0x3d')]){case'iframe':return[{'name':_0x1036('0x58'),'value':_0x4517cf['attrUrl']||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x0]?_0x4517cf[_0x1036('0x59')][0x0][_0x1036('0x5a')]:undefined)||_0x1036('0x5b')}];case _0x1036('0x5c'):return[{'name':'attrPath','value':_0x4517cf['attrPath']||(_0x4517cf['attrs']&&_0x4517cf[_0x1036('0x59')][0x0]?_0x4517cf[_0x1036('0x59')][0x0][_0x1036('0x5a')]:undefined)||''}];case'clock':return[{'name':'attrHourFormat','value':_0x4517cf[_0x1036('0x5d')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x0]?_0x4517cf['attrs'][0x0][_0x1036('0x5a')]:undefined)||_0x1036('0x5e')},{'name':_0x1036('0x5f'),'value':_0x4517cf[_0x1036('0x5f')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x1]?_0x4517cf[_0x1036('0x59')][0x1][_0x1036('0x5a')]:undefined)||_0x1036('0x60')},{'name':_0x1036('0x61'),'value':_0x4517cf[_0x1036('0x61')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x2]?_0x4517cf[_0x1036('0x59')][0x2][_0x1036('0x5a')]:undefined)||0xc}];case'counter':return[{'name':_0x1036('0x62'),'value':_0x4517cf[_0x1036('0x62')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x0]?_0x4517cf[_0x1036('0x59')][0x0][_0x1036('0x5a')]:undefined)||_0x1036('0x63')},{'name':_0x1036('0x64'),'value':_0x4517cf[_0x1036('0x64')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x1]?_0x4517cf[_0x1036('0x59')][0x1]['value']:undefined)||[]},{'name':_0x1036('0x61'),'value':_0x4517cf[_0x1036('0x61')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x2]?_0x4517cf['attrs'][0x2]['value']:undefined)||0x14},{'name':'attrChannel','value':_0x4517cf[_0x1036('0x65')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x3]?_0x4517cf[_0x1036('0x59')][0x3][_0x1036('0x5a')]:undefined)||_0x1036('0x66')},{'name':'attrEmailAccounts','value':_0x4517cf['attrEmailAccounts']||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x4]?_0x4517cf[_0x1036('0x59')][0x4][_0x1036('0x5a')]:undefined)||''},{'name':'attrFaxAccounts','value':_0x4517cf[_0x1036('0x67')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf['attrs'][0x5]?_0x4517cf['attrs'][0x5][_0x1036('0x5a')]:undefined)||''},{'name':_0x1036('0x68'),'value':_0x4517cf['attrSmsAccounts']||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x6]?_0x4517cf[_0x1036('0x59')][0x6][_0x1036('0x5a')]:undefined)||''},{'name':_0x1036('0x69'),'value':_0x4517cf[_0x1036('0x69')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x7]?_0x4517cf[_0x1036('0x59')][0x7][_0x1036('0x5a')]:undefined)||''},{'name':_0x1036('0x6a'),'value':_0x4517cf['attrWhatsappAccounts']||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x8]?_0x4517cf[_0x1036('0x59')][0x8][_0x1036('0x5a')]:undefined)||''},{'name':'attrChatWebsites','value':_0x4517cf[_0x1036('0x6b')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x9]?_0x4517cf[_0x1036('0x59')][0x9]['value']:undefined)||''}];case _0x1036('0x6c'):case _0x1036('0x6d'):return[{'name':'attrSerie1','value':_0x4517cf[_0x1036('0x6e')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf['attrs'][0x0]?_0x4517cf[_0x1036('0x59')][0x0][_0x1036('0x5a')]:undefined)||_0x1036('0x63')},{'name':_0x1036('0x6f'),'value':_0x4517cf['attrSerie2']||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x1]?_0x4517cf[_0x1036('0x59')][0x1][_0x1036('0x5a')]:undefined)||null},{'name':_0x1036('0x70'),'value':_0x4517cf[_0x1036('0x70')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x2]?_0x4517cf['attrs'][0x2]['value']:undefined)||null},{'name':_0x1036('0x64'),'value':_0x4517cf['attrVoiceQueues']||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x3]?_0x4517cf[_0x1036('0x59')][0x3][_0x1036('0x5a')]:undefined)||[]},{'name':_0x1036('0x65'),'value':_0x4517cf[_0x1036('0x65')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x4]?_0x4517cf[_0x1036('0x59')][0x4]['value']:undefined)||'voice'},{'name':_0x1036('0x71'),'value':_0x4517cf[_0x1036('0x71')]||(_0x4517cf['attrs']&&_0x4517cf['attrs'][0x5]?_0x4517cf['attrs'][0x5][_0x1036('0x5a')]:undefined)||''},{'name':_0x1036('0x67'),'value':_0x4517cf[_0x1036('0x67')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf['attrs'][0x6]?_0x4517cf[_0x1036('0x59')][0x6][_0x1036('0x5a')]:undefined)||''},{'name':_0x1036('0x68'),'value':_0x4517cf[_0x1036('0x68')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf['attrs'][0x7]?_0x4517cf[_0x1036('0x59')][0x7][_0x1036('0x5a')]:undefined)||''},{'name':_0x1036('0x69'),'value':_0x4517cf[_0x1036('0x69')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x8]?_0x4517cf[_0x1036('0x59')][0x8]['value']:undefined)||''},{'name':'attrWhatsappAccounts','value':_0x4517cf[_0x1036('0x6a')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x9]?_0x4517cf[_0x1036('0x59')][0x9][_0x1036('0x5a')]:undefined)||''},{'name':'attrChatWebsites','value':_0x4517cf[_0x1036('0x6b')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0xa]?_0x4517cf['attrs'][0xa][_0x1036('0x5a')]:undefined)||''}];case _0x1036('0x72'):return[{'name':_0x1036('0x73'),'type':_0x4517cf[_0x1036('0x74')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x0]?_0x4517cf['attrs'][0x0][_0x1036('0x3d')]:undefined)||null,'value':_0x4517cf[_0x1036('0x73')]||(_0x4517cf[_0x1036('0x59')]&&_0x4517cf[_0x1036('0x59')][0x0]?_0x4517cf[_0x1036('0x59')][0x0]['value']:undefined)||null},{'name':_0x1036('0x75'),'value':_0x4517cf[_0x1036('0x75')]||(_0x4517cf['attrs']&&_0x4517cf[_0x1036('0x59')][0x1]?_0x4517cf[_0x1036('0x59')][0x1][_0x1036('0x5a')]:undefined)||0x0}];default:return[];}}catch(_0x3d603b){logger[_0x1036('0x50')](_0x1036('0x76'),JSON[_0x1036('0x77')](_0x3d603b));return[];}}exports['addItem']=function(_0x1d5aaa,_0x512b2f,_0x2d7d93){if(_0x1d5aaa[_0x1036('0x49')]['id']){delete _0x1d5aaa[_0x1036('0x49')]['id'];}return db[_0x1036('0x2d')]['find']({'where':{'id':_0x1d5aaa[_0x1036('0x57')]['id']}})[_0x1036('0x24')](handleEntityNotFound(_0x512b2f,null))['then'](function(_0x5abfd8){if(_0x5abfd8){_0x1d5aaa['body']['DashboardId']=_0x5abfd8['id'];_0x1d5aaa[_0x1036('0x49')][_0x1036('0x59')]=widgetAttributes(_0x1d5aaa[_0x1036('0x49')]);return db[_0x1036('0x78')][_0x1036('0x48')](_0x1d5aaa['body']);}})['then'](respondWithResult(_0x512b2f,null))[_0x1036('0x44')](handleError(_0x512b2f,null));};exports[_0x1036('0x79')]=function(_0x210166,_0x3fe3ad,_0x155a29){var _0x31de10={};var _0x24d9f5={};var _0x54f213;var _0x4cd3c5;return db[_0x1036('0x2d')][_0x1036('0x7a')]({'where':{'id':_0x210166[_0x1036('0x57')]['id']}})[_0x1036('0x24')](handleEntityNotFound(_0x3fe3ad,null))[_0x1036('0x24')](function(_0x104746){if(_0x104746){_0x54f213=_0x104746;_0x24d9f5[_0x1036('0x34')]=_[_0x1036('0x46')](db[_0x1036('0x78')][_0x1036('0x2e')]);_0x24d9f5['query']=_[_0x1036('0x46')](_0x210166[_0x1036('0x31')]);_0x24d9f5[_0x1036('0x32')]=_[_0x1036('0x33')](_0x24d9f5[_0x1036('0x34')],_0x24d9f5[_0x1036('0x31')]);_0x31de10[_0x1036('0x36')]=_[_0x1036('0x33')](_0x24d9f5[_0x1036('0x34')],qs[_0x1036('0x35')](_0x210166['query'][_0x1036('0x35')]));_0x31de10[_0x1036('0x36')]=_0x31de10[_0x1036('0x36')]['length']?_0x31de10[_0x1036('0x36')]:_0x24d9f5[_0x1036('0x34')];_0x31de10[_0x1036('0x7b')]=qs[_0x1036('0x39')](_0x210166[_0x1036('0x31')][_0x1036('0x39')]);_0x31de10[_0x1036('0x3a')]=qs[_0x1036('0x32')](_[_0x1036('0x3b')](_0x210166[_0x1036('0x31')],_0x24d9f5[_0x1036('0x32')]));if(_0x210166[_0x1036('0x31')][_0x1036('0x3c')]){_0x31de10[_0x1036('0x3a')]=_[_0x1036('0x3f')](_0x31de10[_0x1036('0x3a')],{'$or':_[_0x1036('0x2c')](_0x31de10[_0x1036('0x36')],function(_0x30454f){var _0x1c364e={};_0x1c364e[_0x30454f]={'$like':'%'+_0x210166[_0x1036('0x31')][_0x1036('0x3c')]+'%'};return _0x1c364e;})});}_0x31de10=_[_0x1036('0x3f')]({},_0x31de10,_0x210166[_0x1036('0x47')]);return _0x54f213['getItems'](_0x31de10);}})[_0x1036('0x24')](function(_0x5120ee){if(_0x5120ee){_0x4cd3c5=_0x5120ee[_0x1036('0x37')];if(!_0x210166[_0x1036('0x31')][_0x1036('0x38')](_0x1036('0x7c'))){_0x31de10[_0x1036('0x1d')]=qs[_0x1036('0x1d')](_0x210166[_0x1036('0x31')][_0x1036('0x1d')]);_0x31de10[_0x1036('0x1c')]=qs[_0x1036('0x1c')](_0x210166['query'][_0x1036('0x1c')]);}return _0x54f213[_0x1036('0x79')](_0x31de10);}})[_0x1036('0x24')](function(_0x8b6170){if(_0x8b6170){return _0x8b6170?{'count':_0x4cd3c5,'rows':_0x8b6170}:null;}})['then'](respondWithResult(_0x3fe3ad,null))[_0x1036('0x44')](handleError(_0x3fe3ad,null));};