Built motion from commit a61a4a20.|2.5.46
[motion2.git] / server / api / cmHopper / cmHopper.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 _0x1d0d=['CampaignId','VoiceQueueId','VoiceQueue','Campaign','omit','dataValues','createdAt','state','deleted','campaign','membername','user','UserId','deletedat','format','calleridnum','phone','queue','CmContact','ContactId','firstName','lastName','isNil','calleridname','finally','CmHopperFinal','getPreview','getVoiceQueues','outbound','preview','dialOrderByScheduledAt','transaction','YYYY-MM-DD\x20HH:mm:ss','dialPreviewAutoRecallMe','value','direction','prev','isEmpty','hopperIds','priority','scheduledAt','DESC','COALESCE(CmHopper.UserId,\x200)\x20ASC','literal','COALESCE(CmHopper.UserId,\x200)\x20DESC','ASC','findOne','scheduledat','recallme','LOCK','UPDATE','Contact','Company','List','Queue','dialActive','getPreviewRecall','hopperId','CmList','getOpenContacts','isNumber','error','entity\x20not\x20found','getTimezones','timezones','push','getTimezone','rimraf','zip-dir','mustache','util','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','apply','reject','save','update','destroy','stack','send','index','map','CmHopper','rawAttributes','fieldName','type','key','model','name','query','keys','filters','intersection','concat','$and','$or','$gt','$lt','$lte','$ne','$eq','$not','$between','$notBetween','$in','$like','$iLike','$notILike','$contains','$contained','$any','attributes','fields','length','order','sort','where','pick','filter','merge','VIRTUAL','options','then','includeAll','include','findAll','rows','catch','show','params','find','create','body','describe'];(function(_0xa35012,_0x3395a6){var _0x4a6e2d=function(_0x21fa96){while(--_0x21fa96){_0xa35012['push'](_0xa35012['shift']());}};_0x4a6e2d(++_0x3395a6);}(_0x1d0d,0x183));var _0xd1d0=function(_0x3443a4,_0x1dfe65){_0x3443a4=_0x3443a4-0x0;var _0xdd09ba=_0x1d0d[_0x3443a4];return _0xdd09ba;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xd1d0('0x0'));var zipdir=require(_0xd1d0('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xd1d0('0x2'));var util=require(_0xd1d0('0x3'));var path=require(_0xd1d0('0x4'));var sox=require(_0xd1d0('0x5'));var csv=require('to-csv');var ejs=require(_0xd1d0('0x6'));var fs=require('fs');var fs_extra=require(_0xd1d0('0x7'));var _=require(_0xd1d0('0x8'));var squel=require(_0xd1d0('0x9'));var crypto=require(_0xd1d0('0xa'));var jsforce=require(_0xd1d0('0xb'));var deskjs=require(_0xd1d0('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xd1d0('0xd'));var authService=require('../../components/auth/service');var qs=require(_0xd1d0('0xe'));var as=require(_0xd1d0('0xf'));var hardwareService=require(_0xd1d0('0x10'));var logger=require(_0xd1d0('0x11'))(_0xd1d0('0x12'));var utils=require(_0xd1d0('0x13'));var config=require(_0xd1d0('0x14'));var shared=require(_0xd1d0('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0xd1d0('0x15'))['db'];function respondWithStatusCode(_0x211b21,_0x34fdcc){_0x34fdcc=_0x34fdcc||0xcc;return function(_0x155953){if(_0x155953){return _0x211b21[_0xd1d0('0x16')](_0x34fdcc);}return _0x211b21[_0xd1d0('0x17')](_0x34fdcc)[_0xd1d0('0x18')]();};}function respondWithResult(_0x117500,_0x2cc9f8){_0x2cc9f8=_0x2cc9f8||0xc8;return function(_0x4c9e05){if(_0x4c9e05){return _0x117500[_0xd1d0('0x17')](_0x2cc9f8)[_0xd1d0('0x19')](_0x4c9e05);}};}function respondWithFilteredResult(_0x2f6696,_0x5b66e7){return function(_0xa16da8){if(_0xa16da8){var _0x489d03=typeof _0x5b66e7[_0xd1d0('0x1a')]==='undefined'&&typeof _0x5b66e7[_0xd1d0('0x1b')]===_0xd1d0('0x1c');var _0x2d9015=_0xa16da8[_0xd1d0('0x1d')];var _0x1c2034=_0x489d03?0x0:_0x5b66e7[_0xd1d0('0x1a')];var _0x5628a6=_0x489d03?_0xa16da8[_0xd1d0('0x1d')]:_0x5b66e7[_0xd1d0('0x1a')]+_0x5b66e7[_0xd1d0('0x1b')];var _0x403734;if(_0x5628a6>=_0x2d9015){_0x5628a6=_0x2d9015;_0x403734=0xc8;}else{_0x403734=0xce;}_0x2f6696[_0xd1d0('0x17')](_0x403734);return _0x2f6696[_0xd1d0('0x1e')](_0xd1d0('0x1f'),_0x1c2034+'-'+_0x5628a6+'/'+_0x2d9015)[_0xd1d0('0x19')](_0xa16da8);}return null;};}function patchUpdates(_0x4ac8f4){return function(_0x5300ef){try{jsonpatch[_0xd1d0('0x20')](_0x5300ef,_0x4ac8f4,!![]);}catch(_0x513051){return BPromise[_0xd1d0('0x21')](_0x513051);}return _0x5300ef[_0xd1d0('0x22')]();};}function saveUpdates(_0x5ea872,_0x755a1e){return function(_0x4b709a){if(_0x4b709a){return _0x4b709a[_0xd1d0('0x23')](_0x5ea872)['then'](function(_0x260ecf){return _0x260ecf;});}return null;};}function removeEntity(_0x1581a3,_0x11fa68){return function(_0x10b7bc){if(_0x10b7bc){return _0x10b7bc[_0xd1d0('0x24')]()['then'](function(){_0x1581a3[_0xd1d0('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x10ff22,_0x2dcc00){return function(_0xc5a755){if(!_0xc5a755){_0x10ff22[_0xd1d0('0x16')](0x194);}return _0xc5a755;};}function handleError(_0x48c469,_0x346ba6){_0x346ba6=_0x346ba6||0x1f4;return function(_0x55e38b){logger['error'](_0x55e38b[_0xd1d0('0x25')]);if(_0x55e38b['name']){delete _0x55e38b['name'];}_0x48c469[_0xd1d0('0x17')](_0x346ba6)[_0xd1d0('0x26')](_0x55e38b);};}exports[_0xd1d0('0x27')]=function(_0x2607af,_0x111d16){var _0x43be1b={},_0x594a98={},_0x30160c={'count':0x0,'rows':[]};var _0x339095=_[_0xd1d0('0x28')](db[_0xd1d0('0x29')][_0xd1d0('0x2a')],function(_0xd9f93c){return{'name':_0xd9f93c[_0xd1d0('0x2b')],'type':_0xd9f93c[_0xd1d0('0x2c')][_0xd1d0('0x2d')]};});_0x594a98[_0xd1d0('0x2e')]=_[_0xd1d0('0x28')](_0x339095,_0xd1d0('0x2f'));_0x594a98[_0xd1d0('0x30')]=_[_0xd1d0('0x31')](_0x2607af['query']);_0x594a98[_0xd1d0('0x32')]=_[_0xd1d0('0x33')](_0x594a98[_0xd1d0('0x2e')],_0x594a98[_0xd1d0('0x30')]);_0x594a98[_0xd1d0('0x32')]=_[_0xd1d0('0x34')](_0x594a98[_0xd1d0('0x32')],[_0xd1d0('0x35'),_0xd1d0('0x36'),_0xd1d0('0x37'),'$gte',_0xd1d0('0x38'),_0xd1d0('0x39'),_0xd1d0('0x3a'),_0xd1d0('0x3b'),_0xd1d0('0x3c'),_0xd1d0('0x3d'),_0xd1d0('0x3e'),_0xd1d0('0x3f'),'$notIn',_0xd1d0('0x40'),'$notLike',_0xd1d0('0x41'),_0xd1d0('0x42'),_0xd1d0('0x40'),'$overlap',_0xd1d0('0x43'),_0xd1d0('0x44'),_0xd1d0('0x45')]);_0x43be1b[_0xd1d0('0x46')]=_[_0xd1d0('0x33')](_0x594a98[_0xd1d0('0x2e')],qs[_0xd1d0('0x47')](_0x2607af['query'][_0xd1d0('0x47')]));_0x43be1b[_0xd1d0('0x46')]=_0x43be1b[_0xd1d0('0x46')][_0xd1d0('0x48')]?_0x43be1b[_0xd1d0('0x46')]:_0x594a98[_0xd1d0('0x2e')];if(!_0x2607af[_0xd1d0('0x30')]['hasOwnProperty']('nolimit')){_0x43be1b['limit']=qs[_0xd1d0('0x1b')](_0x2607af[_0xd1d0('0x30')]['limit']);_0x43be1b[_0xd1d0('0x1a')]=qs[_0xd1d0('0x1a')](_0x2607af[_0xd1d0('0x30')][_0xd1d0('0x1a')]);}_0x43be1b[_0xd1d0('0x49')]=qs[_0xd1d0('0x4a')](_0x2607af['query'][_0xd1d0('0x4a')]);_0x43be1b[_0xd1d0('0x4b')]=qs[_0xd1d0('0x32')](_[_0xd1d0('0x4c')](_0x2607af[_0xd1d0('0x30')],_0x594a98[_0xd1d0('0x32')]),_0x339095);if(_0x2607af[_0xd1d0('0x30')][_0xd1d0('0x4d')]){_0x43be1b['where']=_[_0xd1d0('0x4e')](_0x43be1b['where'],{'$or':_[_0xd1d0('0x28')](_0x339095,function(_0x123907){if(_0x123907[_0xd1d0('0x2c')]!==_0xd1d0('0x4f')){var _0x4a54c6={};_0x4a54c6[_0x123907[_0xd1d0('0x2f')]]={'$like':'%'+_0x2607af[_0xd1d0('0x30')]['filter']+'%'};return _0x4a54c6;}})});}_0x43be1b=_[_0xd1d0('0x4e')]({},_0x43be1b,_0x2607af[_0xd1d0('0x50')]);var _0x5f4cde={'where':_0x43be1b[_0xd1d0('0x4b')]};return db[_0xd1d0('0x29')][_0xd1d0('0x1d')](_0x5f4cde)[_0xd1d0('0x51')](function(_0x1747b9){_0x30160c[_0xd1d0('0x1d')]=_0x1747b9;if(_0x2607af[_0xd1d0('0x30')][_0xd1d0('0x52')]){_0x43be1b[_0xd1d0('0x53')]=[{'all':!![]}];}return db[_0xd1d0('0x29')][_0xd1d0('0x54')](_0x43be1b);})[_0xd1d0('0x51')](function(_0x2e2c13){_0x30160c[_0xd1d0('0x55')]=_0x2e2c13;return _0x30160c;})[_0xd1d0('0x51')](respondWithFilteredResult(_0x111d16,_0x43be1b))[_0xd1d0('0x56')](handleError(_0x111d16,null));};exports[_0xd1d0('0x57')]=function(_0x328522,_0x5e2e71){var _0x4b4ace={'raw':!![],'where':{'id':_0x328522[_0xd1d0('0x58')]['id']}},_0x336f07={};_0x336f07[_0xd1d0('0x2e')]=_[_0xd1d0('0x31')](db['CmHopper'][_0xd1d0('0x2a')]);_0x336f07['query']=_[_0xd1d0('0x31')](_0x328522['query']);_0x336f07[_0xd1d0('0x32')]=_['intersection'](_0x336f07['model'],_0x336f07[_0xd1d0('0x30')]);_0x4b4ace['attributes']=_[_0xd1d0('0x33')](_0x336f07['model'],qs[_0xd1d0('0x47')](_0x328522[_0xd1d0('0x30')][_0xd1d0('0x47')]));_0x4b4ace['attributes']=_0x4b4ace[_0xd1d0('0x46')]['length']?_0x4b4ace['attributes']:_0x336f07[_0xd1d0('0x2e')];if(_0x328522['query'][_0xd1d0('0x52')]){_0x4b4ace['include']=[{'all':!![]}];}_0x4b4ace=_[_0xd1d0('0x4e')]({},_0x4b4ace,_0x328522['options']);return db[_0xd1d0('0x29')][_0xd1d0('0x59')](_0x4b4ace)['then'](handleEntityNotFound(_0x5e2e71,null))[_0xd1d0('0x51')](respondWithResult(_0x5e2e71,null))[_0xd1d0('0x56')](handleError(_0x5e2e71,null));};exports[_0xd1d0('0x5a')]=function(_0x438eb0,_0x14092f){return db[_0xd1d0('0x29')][_0xd1d0('0x5a')](_0x438eb0['body'],{})[_0xd1d0('0x51')](respondWithResult(_0x14092f,0xc9))[_0xd1d0('0x56')](handleError(_0x14092f,null));};exports['update']=function(_0x5ed8ef,_0x1522f8){if(_0x5ed8ef[_0xd1d0('0x5b')]['id']){delete _0x5ed8ef[_0xd1d0('0x5b')]['id'];}return db[_0xd1d0('0x29')]['find']({'where':{'id':_0x5ed8ef[_0xd1d0('0x58')]['id']}})[_0xd1d0('0x51')](handleEntityNotFound(_0x1522f8,null))[_0xd1d0('0x51')](saveUpdates(_0x5ed8ef[_0xd1d0('0x5b')],null))['then'](respondWithResult(_0x1522f8,null))[_0xd1d0('0x56')](handleError(_0x1522f8,null));};exports[_0xd1d0('0x5c')]=function(_0x19c298,_0x52f0a8){return db[_0xd1d0('0x29')][_0xd1d0('0x5c')]()['then'](respondWithResult(_0x52f0a8,null))['catch'](handleError(_0x52f0a8,null));};exports['destroy']=function(_0x542281,_0x5c5383){var _0x3f8c1c;return db[_0xd1d0('0x29')]['find']({'where':{'id':_0x542281[_0xd1d0('0x58')]['id']}})[_0xd1d0('0x51')](handleEntityNotFound(_0x5c5383,null))['then'](function(_0x37bb1e){if(_0x37bb1e){return _0x37bb1e['destroy']()[_0xd1d0('0x51')](function(_0x131203){return _0x131203;});}})[_0xd1d0('0x51')](function(_0x39f7d4){_0x3f8c1c=_0x39f7d4;if(_0x39f7d4){if(_0x39f7d4['VoiceQueueId']||_0x39f7d4[_0xd1d0('0x5d')]){return db[_0x39f7d4[_0xd1d0('0x5e')]?_0xd1d0('0x5f'):_0xd1d0('0x60')][_0xd1d0('0x59')]({'where':{'id':_0x39f7d4['VoiceQueueId']?_0x39f7d4['VoiceQueueId']:_0x39f7d4[_0xd1d0('0x5d')]},'attributes':['id',_0xd1d0('0x2f')],'raw':!![]});}}})[_0xd1d0('0x51')](function(_0x514f11){var _0x492d09={};if(_0x514f11){_[_0xd1d0('0x4e')](_0x492d09,_[_0xd1d0('0x61')](_0x3f8c1c[_0xd1d0('0x62')],[_0xd1d0('0x63'),'updatedAt','id']));_0x492d09[_0xd1d0('0x64')]=0x15;_0x492d09['statedesc']=_0xd1d0('0x65');_0x492d09[_0xd1d0('0x66')]=_0x514f11[_0xd1d0('0x2f')];_0x492d09[_0xd1d0('0x67')]=_0x542281[_0xd1d0('0x68')][_0xd1d0('0x2f')];_0x492d09[_0xd1d0('0x69')]=_0x542281[_0xd1d0('0x68')]['id'];_0x492d09['deleted']=!![];_0x492d09[_0xd1d0('0x6a')]=moment()[_0xd1d0('0x6b')]('YYYY-MM-DD\x20HH:mm:ss');_0x492d09[_0xd1d0('0x6c')]=_0x3f8c1c[_0xd1d0('0x6d')];_0x492d09['campaigntype']=_0x3f8c1c[_0xd1d0('0x5e')]?_0xd1d0('0x6e'):'ivr';return db[_0xd1d0('0x6f')][_0xd1d0('0x59')]({'where':{'id':_0x492d09[_0xd1d0('0x70')]},'attributes':[_0xd1d0('0x71'),_0xd1d0('0x72')]})[_0xd1d0('0x51')](function(_0x5760c7){if(!_[_0xd1d0('0x73')](_0x5c5383)&&!_[_0xd1d0('0x73')](_0x5760c7[_0xd1d0('0x71')])){_0x492d09[_0xd1d0('0x74')]=_0x5760c7[_0xd1d0('0x71')];if(!_[_0xd1d0('0x73')](_0x5760c7[_0xd1d0('0x72')])){_0x492d09[_0xd1d0('0x74')]+='\x20'+_0x5760c7[_0xd1d0('0x72')];}}})[_0xd1d0('0x75')](function(){return db[_0xd1d0('0x76')][_0xd1d0('0x5a')](_0x492d09);});}})['then'](function(){return _0x5c5383[_0xd1d0('0x17')](0xcc)[_0xd1d0('0x18')]();})[_0xd1d0('0x56')](handleError(_0x5c5383,null));};exports[_0xd1d0('0x77')]=function(_0x2718c7,_0x348b0c,_0x82cdc1){var _0x43438f=[];return db[_0xd1d0('0x6f')]['describe']()[_0xd1d0('0x51')](function(_0xcfde04){_0x43438f=_[_0xd1d0('0x31')](_0xcfde04);return _0x2718c7[_0xd1d0('0x68')][_0xd1d0('0x78')]({'where':{'type':_0xd1d0('0x79'),'dialActive':!![],'dialMethod':_0xd1d0('0x7a')},'attributes':['id',_0xd1d0('0x7b'),'dialPreviewAutoRecallMe'],'raw':!![]});})[_0xd1d0('0x51')](function(_0x22acc8){if(_0x22acc8&&_0x22acc8[_0xd1d0('0x48')]){return db['sequelize'][_0xd1d0('0x7c')](function(_0x3230fd){var _0x3ce0a9={'active':![],'recallme':![],'scheduledAt':{'$lte':moment()['format'](_0xd1d0('0x7d'))},'VoiceQueueId':{'$in':_[_0xd1d0('0x28')](_0x22acc8,'id')},'$or':[{'UserId':null},{'UserId':_0x2718c7[_0xd1d0('0x68')]['id']}]};var _0x20dae6={'active':![],'recallme':!![],'VoiceQueueId':{'$in':_(_0x22acc8)[_0xd1d0('0x4d')]([_0xd1d0('0x7e'),0x0])[_0xd1d0('0x28')]('id')[_0xd1d0('0x7f')]()},'$or':[{'UserId':null},{'UserId':_0x2718c7['user']['id']}]};var _0x807d95={'$or':[_0x3ce0a9,_0x20dae6]};var _0xdc107e=[];if(_0x2718c7[_0xd1d0('0x5b')][_0xd1d0('0x80')]&&_0x2718c7[_0xd1d0('0x5b')][_0xd1d0('0x80')]===_0xd1d0('0x81')){if(!_[_0xd1d0('0x82')](_0x2718c7[_0xd1d0('0x5b')][_0xd1d0('0x83')])){_0x807d95['id']={'$in':_0x2718c7[_0xd1d0('0x5b')][_0xd1d0('0x83')]};}_0xdc107e=[[_0xd1d0('0x84'),'ASC'],[_0xd1d0('0x85'),_0x22acc8[0x0]['dialOrderByScheduledAt']==='ASC'?_0xd1d0('0x86'):'ASC'],db['sequelize']['literal'](_0xd1d0('0x87')),['id',_0xd1d0('0x86')]];}else{if(!_['isEmpty'](_0x2718c7[_0xd1d0('0x5b')][_0xd1d0('0x83')])){_0x807d95['id']={'$notIn':_0x2718c7[_0xd1d0('0x5b')][_0xd1d0('0x83')]};}_0xdc107e=[[_0xd1d0('0x84'),_0xd1d0('0x86')],[_0xd1d0('0x85'),_0x22acc8[0x0][_0xd1d0('0x7b')]],db['sequelize'][_0xd1d0('0x88')](_0xd1d0('0x89')),['id',_0xd1d0('0x8a')]];}return db['CmHopper'][_0xd1d0('0x8b')]({'attributes':['id',_0xd1d0('0x8c'),_0xd1d0('0x8d')],'where':_0x807d95,'order':_0xdc107e,'transaction':_0x3230fd,'lock':_0x3230fd[_0xd1d0('0x8e')][_0xd1d0('0x8f')],'include':[{'model':db[_0xd1d0('0x6f')],'as':_0xd1d0('0x90'),'attributes':_0x43438f,'include':[{'model':db['CmCompany'],'as':_0xd1d0('0x91'),'attributes':['id',_0xd1d0('0x2f')]}]},{'model':db['CmList'],'as':_0xd1d0('0x92'),'attributes':['id','name']},{'model':db[_0xd1d0('0x5f')],'as':_0xd1d0('0x93'),'attributes':['id','name',_0xd1d0('0x94')]}]})[_0xd1d0('0x51')](function(_0x4745c5){if(_0x4745c5){return _0x4745c5[_0xd1d0('0x23')]({'UserId':_0x2718c7[_0xd1d0('0x68')]['id']},{'transaction':_0x3230fd});}});});}})[_0xd1d0('0x51')](handleEntityNotFound(_0x348b0c,null))[_0xd1d0('0x51')](respondWithResult(_0x348b0c,null))[_0xd1d0('0x56')](handleError(_0x348b0c,null));};exports[_0xd1d0('0x95')]=function(_0x52abed,_0x2feee0,_0x18596a){var _0x1bec00=[];return db[_0xd1d0('0x6f')][_0xd1d0('0x5c')]()[_0xd1d0('0x51')](function(_0xcfe4b1){_0x1bec00=_[_0xd1d0('0x31')](_0xcfe4b1);return _0x52abed[_0xd1d0('0x68')]['getVoiceQueues']({'where':{'type':_0xd1d0('0x79'),'dialActive':!![],'dialMethod':_0xd1d0('0x7a')},'attributes':['id',_0xd1d0('0x7b'),_0xd1d0('0x7e')],'raw':!![]});})[_0xd1d0('0x51')](function(_0x235340){if(_0x235340&&_0x235340[_0xd1d0('0x48')]){return db['sequelize'][_0xd1d0('0x7c')](function(_0x2c5161){var _0x3da484={'active':![],'recallme':!![],'id':_0x52abed[_0xd1d0('0x5b')][_0xd1d0('0x96')]};return db[_0xd1d0('0x29')][_0xd1d0('0x8b')]({'attributes':['id','scheduledat',_0xd1d0('0x8d')],'where':_0x3da484,'transaction':_0x2c5161,'lock':_0x2c5161[_0xd1d0('0x8e')][_0xd1d0('0x8f')],'include':[{'model':db[_0xd1d0('0x6f')],'as':_0xd1d0('0x90'),'attributes':_0x1bec00,'include':[{'model':db['CmCompany'],'as':'Company','attributes':['id',_0xd1d0('0x2f')]}]},{'model':db[_0xd1d0('0x97')],'as':'List','attributes':['id','name']},{'model':db[_0xd1d0('0x5f')],'as':'Queue','attributes':['id',_0xd1d0('0x2f'),_0xd1d0('0x94')]}]})[_0xd1d0('0x51')](function(_0x43256e){if(_0x43256e){return _0x43256e[_0xd1d0('0x23')]({'UserId':_0x52abed[_0xd1d0('0x68')]['id']},{'transaction':_0x2c5161});}});});}})['then'](handleEntityNotFound(_0x2feee0,null))[_0xd1d0('0x51')](respondWithResult(_0x2feee0,null))[_0xd1d0('0x56')](handleError(_0x2feee0,null));};exports[_0xd1d0('0x98')]=function(_0x508df9,_0x4f935a,_0x5e4100){return _0x508df9[_0xd1d0('0x68')][_0xd1d0('0x78')]({'where':{'type':_0xd1d0('0x79'),'dialActive':!![],'dialMethod':_0xd1d0('0x7a')},'attributes':['id'],'raw':!![]})[_0xd1d0('0x51')](function(_0xf56ee){if(_0xf56ee&&_0xf56ee['length']){return db[_0xd1d0('0x29')]['count']({'where':{'active':![],'recallme':![],'scheduledAt':{'$lte':moment()[_0xd1d0('0x6b')]('YYYY-MM-DD\x20HH:mm:ss')},'VoiceQueueId':{'$in':_[_0xd1d0('0x28')](_0xf56ee,'id')},'$or':[{'UserId':null},{'UserId':_0x508df9[_0xd1d0('0x68')]['id']}]}});}return 0x0;})[_0xd1d0('0x51')](function(_0x277cb4){if(!_[_0xd1d0('0x73')](_0x277cb4)&&_[_0xd1d0('0x99')](_0x277cb4)){return _0x4f935a[_0xd1d0('0x17')](0xc8)[_0xd1d0('0x19')]({'contacts':_0x277cb4});}else{logger[_0xd1d0('0x9a')]('CmHopper,\x20%s,\x20%s,\x20%s',_0xd1d0('0x98'),0x194,_0xd1d0('0x9b'));_0x4f935a[_0xd1d0('0x16')](0x194);}})[_0xd1d0('0x56')](handleError(_0x4f935a,null));};exports[_0xd1d0('0x9c')]=function(_0x3f0277,_0x4bceab,_0x4be25c){var _0x5f11f0=shared[_0xd1d0('0x9d')];var _0x3b5db6=[];_[_0xd1d0('0x28')](_0x5f11f0,function(_0x4f7c43){_0x3b5db6[_0xd1d0('0x9e')]({'id':_0x4f7c43[_0xd1d0('0x2f')],'name':_0x4f7c43[_0xd1d0('0x2f')],'utcOffset':_0x4f7c43['utcOffset']});});return _0x4bceab[_0xd1d0('0x17')](0xc8)[_0xd1d0('0x19')]({'tz':_0x3b5db6});};exports[_0xd1d0('0x9f')]=function(_0x4be964,_0x4b46b0,_0x4adb22){var _0x441fd5=shared[_0xd1d0('0x9d')];var _0x342f75={};if(!_['isNil'](_0x441fd5[_0x4be964[_0xd1d0('0x5b')]['id']]))_0x342f75=_0x441fd5[_0x4be964['body']['id']];return _0x4b46b0['status'](0xc8)[_0xd1d0('0x19')](_0x342f75);};