Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / api / cmHopperFinal / cmHopperFinal.controller.js
index baf4eb0..130a8b7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x26c2=['COUNT','`state`\x20=\x205,\x201,\x20null','`state`\x20=\x208,\x201,\x20null','dropContacts','`state`\x20=\x2011\x20,\x201,\x20null','abandonedContacts','`state`\x20=\x2022,\x201,\x20null','reCallContacts','`state`\x20=\x2019,\x201,\x20null','answeringMachine','countContactsIvrCampaignHopperFinal','`state`\x20=\x200,\x201,\x20null','busyContacts','congestionContacts','`state`\x20=\x2010\x20,\x201,\x20null','VoiceQueue','insert','cm_hopper','phone','scheduledAt','ListId','updatedAt','select','field','ANY_VALUE(calleridnum)','NOW()','from','VoiceQueueId\x20=\x20?','toString','state\x20=\x20?','state','calleridnum\x20IS\x20NOT\x20NULL','calleridnum\x20NOT\x20IN\x20(?)','calleridnum','cm_hopper_final','state\x20=\x204','group','ContactId','moveContactsIvrCampaignHopperFinal','fromQuery','CampaignId','createdAt','ANY_VALUE(ContactId)','ANY_VALUE(ListId)','CampaignId\x20=\x20?','checkContactHopper','findOne','VoiceQueueId','zip-dir','fast-json-patch','request-promise','moment','mustache','util','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','count','set','Content-Range','apply','reject','save','update','then','stack','name','send','map','CmHopperFinal','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','offset','order','sort','pick','filter','where','merge','VIRTUAL','options','include','rows','show','params','includeAll','find','describe','body','uniqueid','catch','countContactsQueueCampaignHopperFinal','findAll','sequelize','literal','noSuchContacts','`state`\x20=\x203,\x201,\x20null','noAnswerContacts'];(function(_0x4e676e,_0x2a7c6d){var _0x336a3c=function(_0x4767c4){while(--_0x4767c4){_0x4e676e['push'](_0x4e676e['shift']());}};_0x336a3c(++_0x2a7c6d);}(_0x26c2,0x130));var _0x226c=function(_0x4af93f,_0x13bdac){_0x4af93f=_0x4af93f-0x0;var _0x5f47fd=_0x26c2[_0x4af93f];return _0x5f47fd;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x226c('0x0'));var jsonpatch=require(_0x226c('0x1'));var rp=require(_0x226c('0x2'));var moment=require(_0x226c('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x226c('0x4'));var util=require(_0x226c('0x5'));var path=require('path');var sox=require(_0x226c('0x6'));var csv=require(_0x226c('0x7'));var ejs=require(_0x226c('0x8'));var fs=require('fs');var _=require(_0x226c('0x9'));var squel=require(_0x226c('0xa'));var crypto=require('crypto');var jsforce=require(_0x226c('0xb'));var deskjs=require(_0x226c('0xc'));var toCsv=require(_0x226c('0x7'));var querystring=require(_0x226c('0xd'));var Papa=require(_0x226c('0xe'));var Redis=require('ioredis');var authService=require(_0x226c('0xf'));var qs=require(_0x226c('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x226c('0x11'))(_0x226c('0x12'));var utils=require(_0x226c('0x13'));var config=require(_0x226c('0x14'));var licenseUtil=require(_0x226c('0x15'));var db=require(_0x226c('0x16'))['db'];function respondWithStatusCode(_0x2964c2,_0x57dbc4){_0x57dbc4=_0x57dbc4||0xcc;return function(_0x481496){if(_0x481496){return _0x2964c2[_0x226c('0x17')](_0x57dbc4);}return _0x2964c2[_0x226c('0x18')](_0x57dbc4)[_0x226c('0x19')]();};}function respondWithResult(_0x36af55,_0x4eb557){_0x4eb557=_0x4eb557||0xc8;return function(_0x4bfd5c){if(_0x4bfd5c){return _0x36af55[_0x226c('0x18')](_0x4eb557)[_0x226c('0x1a')](_0x4bfd5c);}};}function respondWithFilteredResult(_0x15e13b,_0x55697c){return function(_0x5d6c21){if(_0x5d6c21){var _0x694eef=_0x5d6c21[_0x226c('0x1b')],_0x2e4a51=_0x55697c['offset'],_0x30755=_0x55697c['offset']+_0x55697c['limit'],_0x45a804;if(_0x30755>=_0x694eef){_0x30755=_0x694eef;_0x45a804=0xc8;}else{_0x45a804=0xce;}_0x15e13b[_0x226c('0x18')](_0x45a804);return _0x15e13b[_0x226c('0x1c')](_0x226c('0x1d'),_0x2e4a51+'-'+_0x30755+'/'+_0x694eef)[_0x226c('0x1a')](_0x5d6c21);}return null;};}function patchUpdates(_0x57c869){return function(_0x7fc168){try{jsonpatch[_0x226c('0x1e')](_0x7fc168,_0x57c869,!![]);}catch(_0xab9e6c){return BPromise[_0x226c('0x1f')](_0xab9e6c);}return _0x7fc168[_0x226c('0x20')]();};}function saveUpdates(_0x3d412a,_0x4dabf3){return function(_0x13bb6b){if(_0x13bb6b){return _0x13bb6b[_0x226c('0x21')](_0x3d412a)[_0x226c('0x22')](function(_0x269a8f){return _0x269a8f;});}return null;};}function removeEntity(_0x272f26,_0x57eb9f){return function(_0x575c7a){if(_0x575c7a){return _0x575c7a['destroy']()[_0x226c('0x22')](function(){_0x272f26[_0x226c('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0xbaee21,_0x5b3919){return function(_0x3a862c){if(!_0x3a862c){_0xbaee21[_0x226c('0x17')](0x194);}return _0x3a862c;};}function handleError(_0x2a570a,_0x48341f){_0x48341f=_0x48341f||0x1f4;return function(_0x25165d){logger['error'](_0x25165d[_0x226c('0x23')]);if(_0x25165d['name']){delete _0x25165d[_0x226c('0x24')];}_0x2a570a[_0x226c('0x18')](_0x48341f)[_0x226c('0x25')](_0x25165d);};}exports['index']=function(_0x14c49b,_0x4a0b38){var _0xbe7c35={},_0x4f1b85={},_0x431875={'count':0x0,'rows':[]};var _0x539e59=_[_0x226c('0x26')](db[_0x226c('0x27')]['rawAttributes'],function(_0x54f175){return{'name':_0x54f175[_0x226c('0x28')],'type':_0x54f175[_0x226c('0x29')][_0x226c('0x2a')]};});_0x4f1b85[_0x226c('0x2b')]=_[_0x226c('0x26')](_0x539e59,_0x226c('0x24'));_0x4f1b85[_0x226c('0x2c')]=_[_0x226c('0x2d')](_0x14c49b[_0x226c('0x2c')]);_0x4f1b85[_0x226c('0x2e')]=_[_0x226c('0x2f')](_0x4f1b85[_0x226c('0x2b')],_0x4f1b85['query']);_0xbe7c35[_0x226c('0x30')]=_[_0x226c('0x2f')](_0x4f1b85[_0x226c('0x2b')],qs[_0x226c('0x31')](_0x14c49b[_0x226c('0x2c')]['fields']));_0xbe7c35[_0x226c('0x30')]=_0xbe7c35[_0x226c('0x30')][_0x226c('0x32')]?_0xbe7c35['attributes']:_0x4f1b85[_0x226c('0x2b')];if(!_0x14c49b['query'][_0x226c('0x33')](_0x226c('0x34'))){_0xbe7c35[_0x226c('0x35')]=qs[_0x226c('0x35')](_0x14c49b[_0x226c('0x2c')][_0x226c('0x35')]);_0xbe7c35[_0x226c('0x36')]=qs[_0x226c('0x36')](_0x14c49b[_0x226c('0x2c')][_0x226c('0x36')]);}_0xbe7c35[_0x226c('0x37')]=qs[_0x226c('0x38')](_0x14c49b[_0x226c('0x2c')][_0x226c('0x38')]);_0xbe7c35['where']=qs[_0x226c('0x2e')](_[_0x226c('0x39')](_0x14c49b[_0x226c('0x2c')],_0x4f1b85[_0x226c('0x2e')]),_0x539e59);if(_0x14c49b[_0x226c('0x2c')][_0x226c('0x3a')]){_0xbe7c35[_0x226c('0x3b')]=_[_0x226c('0x3c')](_0xbe7c35[_0x226c('0x3b')],{'$or':_['map'](_0x539e59,function(_0x5f517e){if(_0x5f517e[_0x226c('0x29')]!==_0x226c('0x3d')){var _0x312269={};_0x312269[_0x5f517e[_0x226c('0x24')]]={'$like':'%'+_0x14c49b[_0x226c('0x2c')][_0x226c('0x3a')]+'%'};return _0x312269;}})});}_0xbe7c35=_[_0x226c('0x3c')]({},_0xbe7c35,_0x14c49b[_0x226c('0x3e')]);var _0x182b01={'where':_0xbe7c35['where']};return db[_0x226c('0x27')]['count'](_0x182b01)[_0x226c('0x22')](function(_0x1a7d0d){_0x431875[_0x226c('0x1b')]=_0x1a7d0d;if(_0x14c49b['query']['includeAll']){_0xbe7c35[_0x226c('0x3f')]=[{'all':!![]}];}return db[_0x226c('0x27')]['findAll'](_0xbe7c35);})[_0x226c('0x22')](function(_0x11a16b){_0x431875[_0x226c('0x40')]=_0x11a16b;return _0x431875;})[_0x226c('0x22')](respondWithFilteredResult(_0x4a0b38,_0xbe7c35))['catch'](handleError(_0x4a0b38,null));};exports[_0x226c('0x41')]=function(_0x1e771d,_0x12f34d){var _0x54e3bc={'raw':!![],'where':{'id':_0x1e771d[_0x226c('0x42')]['id']}},_0x33e851={};_0x33e851[_0x226c('0x2b')]=_[_0x226c('0x2d')](db[_0x226c('0x27')]['rawAttributes']);_0x33e851['query']=_['keys'](_0x1e771d[_0x226c('0x2c')]);_0x33e851[_0x226c('0x2e')]=_[_0x226c('0x2f')](_0x33e851[_0x226c('0x2b')],_0x33e851[_0x226c('0x2c')]);_0x54e3bc[_0x226c('0x30')]=_[_0x226c('0x2f')](_0x33e851[_0x226c('0x2b')],qs[_0x226c('0x31')](_0x1e771d['query']['fields']));_0x54e3bc[_0x226c('0x30')]=_0x54e3bc[_0x226c('0x30')]['length']?_0x54e3bc[_0x226c('0x30')]:_0x33e851['model'];if(_0x1e771d['query'][_0x226c('0x43')]){_0x54e3bc['include']=[{'all':!![]}];}_0x54e3bc=_[_0x226c('0x3c')]({},_0x54e3bc,_0x1e771d[_0x226c('0x3e')]);return db[_0x226c('0x27')][_0x226c('0x44')](_0x54e3bc)[_0x226c('0x22')](handleEntityNotFound(_0x12f34d,null))[_0x226c('0x22')](respondWithResult(_0x12f34d,null))['catch'](handleError(_0x12f34d,null));};exports[_0x226c('0x45')]=function(_0x5699c2,_0x269d5a){return db[_0x226c('0x27')][_0x226c('0x45')]()[_0x226c('0x22')](respondWithResult(_0x269d5a,null))['catch'](handleError(_0x269d5a,null));};exports[_0x226c('0x21')]=function(_0x524088,_0x3fc603){if(_0x524088[_0x226c('0x46')][_0x226c('0x47')]){delete _0x524088[_0x226c('0x46')][_0x226c('0x47')];}return db[_0x226c('0x27')]['find']({'where':{'uniqueid':_0x524088[_0x226c('0x42')]['id']}})[_0x226c('0x22')](handleEntityNotFound(_0x3fc603,null))[_0x226c('0x22')](saveUpdates(_0x524088[_0x226c('0x46')],null))[_0x226c('0x22')](respondWithResult(_0x3fc603,null))[_0x226c('0x48')](handleError(_0x3fc603,null));};exports[_0x226c('0x49')]=function(_0x12f3f3,_0x3a9c77,_0xffb8d5){return db[_0x226c('0x27')][_0x226c('0x4a')]({'raw':![],'where':{'VoiceQueueId':_0x12f3f3['params']['id']},'attributes':[[db['sequelize']['fn']('COUNT',db[_0x226c('0x4b')]['fn']('IF',db[_0x226c('0x4b')][_0x226c('0x4c')]('`state`\x20=\x200,\x201,\x20null'))),_0x226c('0x4d')],[db[_0x226c('0x4b')]['fn']('COUNT',db[_0x226c('0x4b')]['fn']('IF',db[_0x226c('0x4b')][_0x226c('0x4c')](_0x226c('0x4e')))),_0x226c('0x4f')],[db[_0x226c('0x4b')]['fn'](_0x226c('0x50'),db[_0x226c('0x4b')]['fn']('IF',db['sequelize'][_0x226c('0x4c')](_0x226c('0x51')))),'busyContacts'],[db[_0x226c('0x4b')]['fn'](_0x226c('0x50'),db[_0x226c('0x4b')]['fn']('IF',db[_0x226c('0x4b')][_0x226c('0x4c')](_0x226c('0x52')))),'congestionContacts'],[db[_0x226c('0x4b')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x226c('0x4b')][_0x226c('0x4c')]('`state`\x20=\x2010\x20,\x201,\x20null'))),_0x226c('0x53')],[db[_0x226c('0x4b')]['fn'](_0x226c('0x50'),db['sequelize']['fn']('IF',db[_0x226c('0x4b')][_0x226c('0x4c')](_0x226c('0x54')))),_0x226c('0x55')],[db[_0x226c('0x4b')]['fn']('COUNT',db[_0x226c('0x4b')]['fn']('IF',db['sequelize']['literal'](_0x226c('0x56')))),_0x226c('0x57')],[db[_0x226c('0x4b')]['fn']('COUNT',db[_0x226c('0x4b')]['fn']('IF',db[_0x226c('0x4b')]['literal'](_0x226c('0x58')))),_0x226c('0x59')]]})[_0x226c('0x22')](handleEntityNotFound(_0x3a9c77,null))['then'](respondWithResult(_0x3a9c77,null))['catch'](handleError(_0x3a9c77,null));};exports[_0x226c('0x5a')]=function(_0x55db16,_0x29d34c,_0xfb8c4b){return db['CmHopperFinal']['findAll']({'raw':![],'where':{'CampaignId':_0x55db16[_0x226c('0x42')]['id']},'attributes':[[db[_0x226c('0x4b')]['fn'](_0x226c('0x50'),db[_0x226c('0x4b')]['fn']('IF',db['sequelize'][_0x226c('0x4c')](_0x226c('0x5b')))),_0x226c('0x4d')],[db['sequelize']['fn'](_0x226c('0x50'),db['sequelize']['fn']('IF',db[_0x226c('0x4b')][_0x226c('0x4c')](_0x226c('0x4e')))),_0x226c('0x4f')],[db[_0x226c('0x4b')]['fn'](_0x226c('0x50'),db[_0x226c('0x4b')]['fn']('IF',db[_0x226c('0x4b')][_0x226c('0x4c')](_0x226c('0x51')))),_0x226c('0x5c')],[db[_0x226c('0x4b')]['fn']('COUNT',db[_0x226c('0x4b')]['fn']('IF',db[_0x226c('0x4b')][_0x226c('0x4c')](_0x226c('0x52')))),_0x226c('0x5d')],[db[_0x226c('0x4b')]['fn'](_0x226c('0x50'),db['sequelize']['fn']('IF',db[_0x226c('0x4b')]['literal'](_0x226c('0x5e')))),'dropContacts'],[db[_0x226c('0x4b')]['fn'](_0x226c('0x50'),db[_0x226c('0x4b')]['fn']('IF',db[_0x226c('0x4b')][_0x226c('0x4c')](_0x226c('0x54')))),_0x226c('0x55')],[db[_0x226c('0x4b')]['fn']('COUNT',db[_0x226c('0x4b')]['fn']('IF',db[_0x226c('0x4b')][_0x226c('0x4c')](_0x226c('0x56')))),_0x226c('0x57')],[db['sequelize']['fn'](_0x226c('0x50'),db['sequelize']['fn']('IF',db[_0x226c('0x4b')][_0x226c('0x4c')](_0x226c('0x58')))),_0x226c('0x59')]]})['then'](handleEntityNotFound(_0x29d34c,null))[_0x226c('0x22')](respondWithResult(_0x29d34c,null))[_0x226c('0x48')](handleError(_0x29d34c,null));};exports['moveContactsQueueCampaignHopperFinal']=function(_0x19d927,_0x3fc153,_0x1016f1){return db[_0x226c('0x5f')][_0x226c('0x44')]({'where':{'id':_0x19d927[_0x226c('0x42')]['id']}})['then'](handleEntityNotFound(_0x3fc153,null))[_0x226c('0x22')](function(_0x8ba1f7){var _0x289fd7;if(_0x8ba1f7){_0x289fd7=squel[_0x226c('0x60')]()['into'](_0x226c('0x61'))['fromQuery']([_0x226c('0x62'),_0x226c('0x63'),'ContactId',_0x226c('0x64'),'VoiceQueueId','createdAt',_0x226c('0x65')],squel[_0x226c('0x66')]()[_0x226c('0x67')](_0x226c('0x68'),_0x226c('0x62'))['field'](_0x226c('0x69'),_0x226c('0x63'))[_0x226c('0x67')]('ANY_VALUE(ContactId)','ContactId')[_0x226c('0x67')]('ANY_VALUE(ListId)',_0x226c('0x64'))['field']('ANY_VALUE(VoiceQueueId)','VoiceQueueId')[_0x226c('0x67')](_0x226c('0x69'),'createdAt')['field']('NOW()','updatedAt')[_0x226c('0x6a')]('cm_hopper_final')[_0x226c('0x3b')](_0x226c('0x6b'),_0x19d927[_0x226c('0x42')]['id'][_0x226c('0x6c')]())[_0x226c('0x3b')](_0x226c('0x6d'),_0x19d927[_0x226c('0x46')][_0x226c('0x6e')]['toString']())[_0x226c('0x3b')](_0x226c('0x6f'))[_0x226c('0x3b')](_0x226c('0x70'),squel[_0x226c('0x66')]()[_0x226c('0x67')](_0x226c('0x62'))[_0x226c('0x6a')]('cm_hopper')[_0x226c('0x3b')](_0x226c('0x6b'),_0x19d927[_0x226c('0x42')]['id'][_0x226c('0x6c')]()))[_0x226c('0x3b')](_0x226c('0x70'),squel[_0x226c('0x66')]()['field'](_0x226c('0x71'))[_0x226c('0x6a')](_0x226c('0x72'))[_0x226c('0x3b')](_0x226c('0x6b'),_0x19d927[_0x226c('0x42')]['id']['toString']())[_0x226c('0x3b')](_0x226c('0x73')))[_0x226c('0x74')](_0x226c('0x75')))[_0x226c('0x6c')]();return db[_0x226c('0x4b')][_0x226c('0x2c')](_0x289fd7);}return[];})['then'](respondWithResult(_0x3fc153,null))['catch'](handleError(_0x3fc153,null));};exports[_0x226c('0x76')]=function(_0x44d128,_0x4bdecf,_0xbd31d7){return db['Campaign']['find']({'where':{'id':_0x44d128[_0x226c('0x42')]['id']}})[_0x226c('0x22')](handleEntityNotFound(_0x4bdecf,null))[_0x226c('0x22')](function(_0x5ca16e){var _0x6ef63d;if(_0x5ca16e){_0x6ef63d=squel[_0x226c('0x60')]()['into'](_0x226c('0x61'))[_0x226c('0x77')](['phone',_0x226c('0x63'),_0x226c('0x75'),_0x226c('0x64'),_0x226c('0x78'),_0x226c('0x79'),_0x226c('0x65')],squel[_0x226c('0x66')]()[_0x226c('0x67')](_0x226c('0x68'),_0x226c('0x62'))[_0x226c('0x67')](_0x226c('0x69'),_0x226c('0x63'))[_0x226c('0x67')](_0x226c('0x7a'),'ContactId')['field'](_0x226c('0x7b'),'ListId')[_0x226c('0x67')]('ANY_VALUE(CampaignId)',_0x226c('0x78'))[_0x226c('0x67')](_0x226c('0x69'),_0x226c('0x79'))[_0x226c('0x67')](_0x226c('0x69'),_0x226c('0x65'))['from']('cm_hopper_final')[_0x226c('0x3b')]('CampaignId\x20=\x20?',_0x44d128[_0x226c('0x42')]['id'][_0x226c('0x6c')]())['where']('state\x20=\x20?',_0x44d128[_0x226c('0x46')][_0x226c('0x6e')][_0x226c('0x6c')]())['where'](_0x226c('0x6f'))[_0x226c('0x3b')]('calleridnum\x20NOT\x20IN\x20(?)',squel[_0x226c('0x66')]()[_0x226c('0x67')]('phone')[_0x226c('0x6a')]('cm_hopper')[_0x226c('0x3b')]('CampaignId\x20=\x20?',_0x44d128['params']['id'][_0x226c('0x6c')]()))[_0x226c('0x3b')]('calleridnum\x20NOT\x20IN\x20(?)',squel[_0x226c('0x66')]()['field'](_0x226c('0x71'))['from']('cm_hopper_final')[_0x226c('0x3b')](_0x226c('0x7c'),_0x44d128['params']['id'][_0x226c('0x6c')]())['where'](_0x226c('0x73')))[_0x226c('0x74')](_0x226c('0x75')))['toString']();return db[_0x226c('0x4b')][_0x226c('0x2c')](_0x6ef63d);}return[];})[_0x226c('0x22')](respondWithResult(_0x4bdecf,null))[_0x226c('0x48')](handleError(_0x4bdecf,null));};exports[_0x226c('0x7d')]=function(_0x404cfc,_0x5d6886,_0x1c5270){return db['CmHopper'][_0x226c('0x7e')]({'where':{'VoiceQueueId':_0x404cfc[_0x226c('0x46')][_0x226c('0x7f')],'CampaignId':_0x404cfc[_0x226c('0x46')][_0x226c('0x78')],'ContactId':_0x404cfc[_0x226c('0x46')][_0x226c('0x75')]}})[_0x226c('0x22')](handleEntityNotFound(_0x5d6886,null))[_0x226c('0x22')](function(_0x383326){if(_0x383326){return _0x383326;}return null;})[_0x226c('0x22')](respondWithResult(_0x5d6886,null))[_0x226c('0x48')](handleError(_0x5d6886,null));};
\ No newline at end of file
+var _0xf403=['update','then','destroy','name','send','index','CmHopperFinal','key','model','map','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','findAll','rows','catch','params','rawAttributes','find','describe','body','uniqueid','countContactsQueueCampaignHopperFinal','sequelize','COUNT','literal','`state`\x20=\x200,\x201,\x20null','noSuchContacts','`state`\x20=\x203,\x201,\x20null','`state`\x20=\x205,\x201,\x20null','busyContacts','`state`\x20=\x208,\x201,\x20null','congestionContacts','`state`\x20=\x2010\x20,\x201,\x20null','dropContacts','`state`\x20=\x2011\x20,\x201,\x20null','abandonedContacts','`state`\x20=\x2022,\x201,\x20null','answeringMachine','noAnswerContacts','reCallContacts','`state`\x20=\x2019,\x201,\x20null','moveContactsQueueCampaignHopperFinal','insert','cm_hopper','fromQuery','phone','scheduledAt','ContactId','VoiceQueueId','createdAt','updatedAt','select','field','ANY_VALUE(calleridnum)','NOW()','ANY_VALUE(ContactId)','ListId','ANY_VALUE(VoiceQueueId)','from','cm_hopper_final','toString','state','calleridnum\x20IS\x20NOT\x20NULL','calleridnum\x20NOT\x20IN\x20(?)','VoiceQueueId\x20=\x20?','calleridnum','moveContactsIvrCampaignHopperFinal','Campaign','CampaignId','CampaignId\x20=\x20?','state\x20=\x20?','state\x20=\x204','group','checkContactHopper','CmHopper','findOne','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','to-csv','ejs','lodash','squel','jsforce','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','count','offset','limit','Content-Range','apply','reject'];(function(_0xefd519,_0xc62635){var _0x4bb882=function(_0x37e0a1){while(--_0x37e0a1){_0xefd519['push'](_0xefd519['shift']());}};_0x4bb882(++_0xc62635);}(_0xf403,0x1d3));var _0x3f40=function(_0x2ea2b4,_0x5ea227){_0x2ea2b4=_0x2ea2b4-0x0;var _0x18e02c=_0xf403[_0x2ea2b4];return _0x18e02c;};'use strict';var pdf=require(_0x3f40('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x3f40('0x1'));var zipdir=require(_0x3f40('0x2'));var jsonpatch=require(_0x3f40('0x3'));var rp=require(_0x3f40('0x4'));var moment=require(_0x3f40('0x5'));var BPromise=require(_0x3f40('0x6'));var Mustache=require(_0x3f40('0x7'));var util=require(_0x3f40('0x8'));var path=require('path');var sox=require('sox');var csv=require(_0x3f40('0x9'));var ejs=require(_0x3f40('0xa'));var fs=require('fs');var _=require(_0x3f40('0xb'));var squel=require(_0x3f40('0xc'));var crypto=require('crypto');var jsforce=require(_0x3f40('0xd'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x3f40('0xe'));var Papa=require(_0x3f40('0xf'));var Redis=require(_0x3f40('0x10'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x3f40('0x11'));var hardwareService=require(_0x3f40('0x12'));var logger=require(_0x3f40('0x13'))('api');var utils=require(_0x3f40('0x14'));var config=require(_0x3f40('0x15'));var licenseUtil=require(_0x3f40('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x332635,_0x509c02){_0x509c02=_0x509c02||0xcc;return function(_0x116460){if(_0x116460){return _0x332635[_0x3f40('0x17')](_0x509c02);}return _0x332635[_0x3f40('0x18')](_0x509c02)[_0x3f40('0x19')]();};}function respondWithResult(_0x569c6e,_0x2b2bfe){_0x2b2bfe=_0x2b2bfe||0xc8;return function(_0x308e97){if(_0x308e97){return _0x569c6e[_0x3f40('0x18')](_0x2b2bfe)[_0x3f40('0x1a')](_0x308e97);}};}function respondWithFilteredResult(_0x232241,_0x4e28b9){return function(_0x2e51ed){if(_0x2e51ed){var _0x3d11c9=_0x2e51ed[_0x3f40('0x1b')],_0x535f85=_0x4e28b9[_0x3f40('0x1c')],_0x4ef80e=_0x4e28b9[_0x3f40('0x1c')]+_0x4e28b9[_0x3f40('0x1d')],_0x54f596;if(_0x4ef80e>=_0x3d11c9){_0x4ef80e=_0x3d11c9;_0x54f596=0xc8;}else{_0x54f596=0xce;}_0x232241[_0x3f40('0x18')](_0x54f596);return _0x232241['set'](_0x3f40('0x1e'),_0x535f85+'-'+_0x4ef80e+'/'+_0x3d11c9)[_0x3f40('0x1a')](_0x2e51ed);}return null;};}function patchUpdates(_0x464b26){return function(_0x29405a){try{jsonpatch[_0x3f40('0x1f')](_0x29405a,_0x464b26,!![]);}catch(_0x55337f){return BPromise[_0x3f40('0x20')](_0x55337f);}return _0x29405a['save']();};}function saveUpdates(_0x12aabf,_0x32b945){return function(_0x3f4a93){if(_0x3f4a93){return _0x3f4a93[_0x3f40('0x21')](_0x12aabf)[_0x3f40('0x22')](function(_0x4aa559){return _0x4aa559;});}return null;};}function removeEntity(_0x27f5a5,_0x379b4e){return function(_0x117823){if(_0x117823){return _0x117823[_0x3f40('0x23')]()[_0x3f40('0x22')](function(){_0x27f5a5[_0x3f40('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x31fc91,_0x59eb32){return function(_0x5d9e35){if(!_0x5d9e35){_0x31fc91['sendStatus'](0x194);}return _0x5d9e35;};}function handleError(_0x2bc437,_0x487b51){_0x487b51=_0x487b51||0x1f4;return function(_0x37b47e){logger['error'](_0x37b47e['stack']);if(_0x37b47e['name']){delete _0x37b47e[_0x3f40('0x24')];}_0x2bc437[_0x3f40('0x18')](_0x487b51)[_0x3f40('0x25')](_0x37b47e);};}exports[_0x3f40('0x26')]=function(_0x5b1079,_0x300665){var _0x47ec1c={},_0x319997={},_0xbaf5d4={'count':0x0,'rows':[]};var _0xbd4333=_['map'](db[_0x3f40('0x27')]['rawAttributes'],function(_0x1cab5c){return{'name':_0x1cab5c['fieldName'],'type':_0x1cab5c['type'][_0x3f40('0x28')]};});_0x319997[_0x3f40('0x29')]=_[_0x3f40('0x2a')](_0xbd4333,_0x3f40('0x24'));_0x319997[_0x3f40('0x2b')]=_[_0x3f40('0x2c')](_0x5b1079[_0x3f40('0x2b')]);_0x319997[_0x3f40('0x2d')]=_['intersection'](_0x319997[_0x3f40('0x29')],_0x319997[_0x3f40('0x2b')]);_0x47ec1c[_0x3f40('0x2e')]=_[_0x3f40('0x2f')](_0x319997[_0x3f40('0x29')],qs['fields'](_0x5b1079[_0x3f40('0x2b')][_0x3f40('0x30')]));_0x47ec1c[_0x3f40('0x2e')]=_0x47ec1c['attributes'][_0x3f40('0x31')]?_0x47ec1c[_0x3f40('0x2e')]:_0x319997[_0x3f40('0x29')];if(!_0x5b1079[_0x3f40('0x2b')][_0x3f40('0x32')](_0x3f40('0x33'))){_0x47ec1c[_0x3f40('0x1d')]=qs[_0x3f40('0x1d')](_0x5b1079[_0x3f40('0x2b')][_0x3f40('0x1d')]);_0x47ec1c[_0x3f40('0x1c')]=qs[_0x3f40('0x1c')](_0x5b1079[_0x3f40('0x2b')][_0x3f40('0x1c')]);}_0x47ec1c[_0x3f40('0x34')]=qs[_0x3f40('0x35')](_0x5b1079[_0x3f40('0x2b')][_0x3f40('0x35')]);_0x47ec1c[_0x3f40('0x36')]=qs[_0x3f40('0x2d')](_[_0x3f40('0x37')](_0x5b1079[_0x3f40('0x2b')],_0x319997[_0x3f40('0x2d')]),_0xbd4333);if(_0x5b1079[_0x3f40('0x2b')][_0x3f40('0x38')]){_0x47ec1c[_0x3f40('0x36')]=_[_0x3f40('0x39')](_0x47ec1c[_0x3f40('0x36')],{'$or':_[_0x3f40('0x2a')](_0xbd4333,function(_0x2df15b){if(_0x2df15b['type']!=='VIRTUAL'){var _0x1b5d96={};_0x1b5d96[_0x2df15b[_0x3f40('0x24')]]={'$like':'%'+_0x5b1079[_0x3f40('0x2b')][_0x3f40('0x38')]+'%'};return _0x1b5d96;}})});}_0x47ec1c=_[_0x3f40('0x39')]({},_0x47ec1c,_0x5b1079[_0x3f40('0x3a')]);var _0x1ffa33={'where':_0x47ec1c['where']};return db[_0x3f40('0x27')]['count'](_0x1ffa33)[_0x3f40('0x22')](function(_0x3bec11){_0xbaf5d4[_0x3f40('0x1b')]=_0x3bec11;if(_0x5b1079['query'][_0x3f40('0x3b')]){_0x47ec1c[_0x3f40('0x3c')]=[{'all':!![]}];}return db['CmHopperFinal'][_0x3f40('0x3d')](_0x47ec1c);})[_0x3f40('0x22')](function(_0x4b1a66){_0xbaf5d4[_0x3f40('0x3e')]=_0x4b1a66;return _0xbaf5d4;})['then'](respondWithFilteredResult(_0x300665,_0x47ec1c))[_0x3f40('0x3f')](handleError(_0x300665,null));};exports['show']=function(_0x557f27,_0x8e89a){var _0x4bf783={'raw':!![],'where':{'id':_0x557f27[_0x3f40('0x40')]['id']}},_0x2210bc={};_0x2210bc[_0x3f40('0x29')]=_[_0x3f40('0x2c')](db['CmHopperFinal'][_0x3f40('0x41')]);_0x2210bc['query']=_[_0x3f40('0x2c')](_0x557f27[_0x3f40('0x2b')]);_0x2210bc[_0x3f40('0x2d')]=_['intersection'](_0x2210bc['model'],_0x2210bc[_0x3f40('0x2b')]);_0x4bf783[_0x3f40('0x2e')]=_[_0x3f40('0x2f')](_0x2210bc[_0x3f40('0x29')],qs[_0x3f40('0x30')](_0x557f27[_0x3f40('0x2b')][_0x3f40('0x30')]));_0x4bf783[_0x3f40('0x2e')]=_0x4bf783['attributes'][_0x3f40('0x31')]?_0x4bf783['attributes']:_0x2210bc['model'];if(_0x557f27[_0x3f40('0x2b')][_0x3f40('0x3b')]){_0x4bf783[_0x3f40('0x3c')]=[{'all':!![]}];}_0x4bf783=_[_0x3f40('0x39')]({},_0x4bf783,_0x557f27[_0x3f40('0x3a')]);return db[_0x3f40('0x27')][_0x3f40('0x42')](_0x4bf783)[_0x3f40('0x22')](handleEntityNotFound(_0x8e89a,null))[_0x3f40('0x22')](respondWithResult(_0x8e89a,null))[_0x3f40('0x3f')](handleError(_0x8e89a,null));};exports[_0x3f40('0x43')]=function(_0x10678b,_0x2068ab){return db[_0x3f40('0x27')]['describe']()[_0x3f40('0x22')](respondWithResult(_0x2068ab,null))['catch'](handleError(_0x2068ab,null));};exports[_0x3f40('0x21')]=function(_0x2f16d6,_0x50b268){if(_0x2f16d6[_0x3f40('0x44')][_0x3f40('0x45')]){delete _0x2f16d6[_0x3f40('0x44')][_0x3f40('0x45')];}return db[_0x3f40('0x27')][_0x3f40('0x42')]({'where':{'uniqueid':_0x2f16d6[_0x3f40('0x40')]['id']}})[_0x3f40('0x22')](handleEntityNotFound(_0x50b268,null))[_0x3f40('0x22')](saveUpdates(_0x2f16d6[_0x3f40('0x44')],null))[_0x3f40('0x22')](respondWithResult(_0x50b268,null))[_0x3f40('0x3f')](handleError(_0x50b268,null));};exports[_0x3f40('0x46')]=function(_0x421670,_0x171c13,_0x3cbcd3){return db[_0x3f40('0x27')][_0x3f40('0x3d')]({'raw':![],'where':{'VoiceQueueId':_0x421670[_0x3f40('0x40')]['id']},'attributes':[[db[_0x3f40('0x47')]['fn'](_0x3f40('0x48'),db['sequelize']['fn']('IF',db[_0x3f40('0x47')][_0x3f40('0x49')](_0x3f40('0x4a')))),_0x3f40('0x4b')],[db[_0x3f40('0x47')]['fn']('COUNT',db['sequelize']['fn']('IF',db['sequelize'][_0x3f40('0x49')](_0x3f40('0x4c')))),'noAnswerContacts'],[db[_0x3f40('0x47')]['fn'](_0x3f40('0x48'),db['sequelize']['fn']('IF',db[_0x3f40('0x47')]['literal'](_0x3f40('0x4d')))),_0x3f40('0x4e')],[db[_0x3f40('0x47')]['fn'](_0x3f40('0x48'),db[_0x3f40('0x47')]['fn']('IF',db[_0x3f40('0x47')][_0x3f40('0x49')](_0x3f40('0x4f')))),_0x3f40('0x50')],[db[_0x3f40('0x47')]['fn'](_0x3f40('0x48'),db[_0x3f40('0x47')]['fn']('IF',db[_0x3f40('0x47')]['literal'](_0x3f40('0x51')))),_0x3f40('0x52')],[db[_0x3f40('0x47')]['fn'](_0x3f40('0x48'),db[_0x3f40('0x47')]['fn']('IF',db['sequelize'][_0x3f40('0x49')](_0x3f40('0x53')))),_0x3f40('0x54')],[db[_0x3f40('0x47')]['fn'](_0x3f40('0x48'),db['sequelize']['fn']('IF',db['sequelize'][_0x3f40('0x49')](_0x3f40('0x55')))),'reCallContacts'],[db[_0x3f40('0x47')]['fn']('COUNT',db[_0x3f40('0x47')]['fn']('IF',db['sequelize'][_0x3f40('0x49')]('`state`\x20=\x2019,\x201,\x20null'))),_0x3f40('0x56')]]})[_0x3f40('0x22')](handleEntityNotFound(_0x171c13,null))[_0x3f40('0x22')](respondWithResult(_0x171c13,null))['catch'](handleError(_0x171c13,null));};exports['countContactsIvrCampaignHopperFinal']=function(_0x4b4d14,_0x56e654,_0x273739){return db['CmHopperFinal']['findAll']({'raw':![],'where':{'CampaignId':_0x4b4d14[_0x3f40('0x40')]['id']},'attributes':[[db[_0x3f40('0x47')]['fn'](_0x3f40('0x48'),db[_0x3f40('0x47')]['fn']('IF',db['sequelize'][_0x3f40('0x49')]('`state`\x20=\x200,\x201,\x20null'))),'noSuchContacts'],[db['sequelize']['fn'](_0x3f40('0x48'),db['sequelize']['fn']('IF',db['sequelize'][_0x3f40('0x49')](_0x3f40('0x4c')))),_0x3f40('0x57')],[db[_0x3f40('0x47')]['fn'](_0x3f40('0x48'),db['sequelize']['fn']('IF',db[_0x3f40('0x47')]['literal'](_0x3f40('0x4d')))),_0x3f40('0x4e')],[db[_0x3f40('0x47')]['fn']('COUNT',db[_0x3f40('0x47')]['fn']('IF',db[_0x3f40('0x47')][_0x3f40('0x49')](_0x3f40('0x4f')))),_0x3f40('0x50')],[db['sequelize']['fn'](_0x3f40('0x48'),db[_0x3f40('0x47')]['fn']('IF',db[_0x3f40('0x47')][_0x3f40('0x49')](_0x3f40('0x51')))),_0x3f40('0x52')],[db[_0x3f40('0x47')]['fn'](_0x3f40('0x48'),db[_0x3f40('0x47')]['fn']('IF',db[_0x3f40('0x47')][_0x3f40('0x49')](_0x3f40('0x53')))),'abandonedContacts'],[db['sequelize']['fn']('COUNT',db[_0x3f40('0x47')]['fn']('IF',db[_0x3f40('0x47')][_0x3f40('0x49')](_0x3f40('0x55')))),_0x3f40('0x58')],[db[_0x3f40('0x47')]['fn']('COUNT',db[_0x3f40('0x47')]['fn']('IF',db['sequelize'][_0x3f40('0x49')](_0x3f40('0x59')))),_0x3f40('0x56')]]})[_0x3f40('0x22')](handleEntityNotFound(_0x56e654,null))[_0x3f40('0x22')](respondWithResult(_0x56e654,null))['catch'](handleError(_0x56e654,null));};exports[_0x3f40('0x5a')]=function(_0x54667a,_0x4a333a,_0xba4554){return db['VoiceQueue'][_0x3f40('0x42')]({'where':{'id':_0x54667a[_0x3f40('0x40')]['id']}})[_0x3f40('0x22')](handleEntityNotFound(_0x4a333a,null))[_0x3f40('0x22')](function(_0xad9005){var _0x391997;if(_0xad9005){_0x391997=squel[_0x3f40('0x5b')]()['into'](_0x3f40('0x5c'))[_0x3f40('0x5d')]([_0x3f40('0x5e'),_0x3f40('0x5f'),_0x3f40('0x60'),'ListId',_0x3f40('0x61'),_0x3f40('0x62'),_0x3f40('0x63')],squel[_0x3f40('0x64')]()[_0x3f40('0x65')](_0x3f40('0x66'),'phone')[_0x3f40('0x65')](_0x3f40('0x67'),_0x3f40('0x5f'))[_0x3f40('0x65')](_0x3f40('0x68'),'ContactId')['field']('ANY_VALUE(ListId)',_0x3f40('0x69'))[_0x3f40('0x65')](_0x3f40('0x6a'),_0x3f40('0x61'))[_0x3f40('0x65')](_0x3f40('0x67'),_0x3f40('0x62'))[_0x3f40('0x65')](_0x3f40('0x67'),_0x3f40('0x63'))[_0x3f40('0x6b')](_0x3f40('0x6c'))[_0x3f40('0x36')]('VoiceQueueId\x20=\x20?',_0x54667a[_0x3f40('0x40')]['id'][_0x3f40('0x6d')]())[_0x3f40('0x36')]('state\x20=\x20?',_0x54667a['body'][_0x3f40('0x6e')][_0x3f40('0x6d')]())[_0x3f40('0x36')](_0x3f40('0x6f'))['where'](_0x3f40('0x70'),squel[_0x3f40('0x64')]()[_0x3f40('0x65')](_0x3f40('0x5e'))[_0x3f40('0x6b')](_0x3f40('0x5c'))[_0x3f40('0x36')](_0x3f40('0x71'),_0x54667a[_0x3f40('0x40')]['id'][_0x3f40('0x6d')]()))['where']('calleridnum\x20NOT\x20IN\x20(?)',squel[_0x3f40('0x64')]()[_0x3f40('0x65')](_0x3f40('0x72'))[_0x3f40('0x6b')]('cm_hopper_final')[_0x3f40('0x36')](_0x3f40('0x71'),_0x54667a[_0x3f40('0x40')]['id'][_0x3f40('0x6d')]())[_0x3f40('0x36')]('state\x20=\x204'))['group'](_0x3f40('0x60')))[_0x3f40('0x6d')]();return db[_0x3f40('0x47')]['query'](_0x391997);}return[];})[_0x3f40('0x22')](respondWithResult(_0x4a333a,null))[_0x3f40('0x3f')](handleError(_0x4a333a,null));};exports[_0x3f40('0x73')]=function(_0x53eade,_0x4cbc7b,_0xd842ca){return db[_0x3f40('0x74')][_0x3f40('0x42')]({'where':{'id':_0x53eade[_0x3f40('0x40')]['id']}})[_0x3f40('0x22')](handleEntityNotFound(_0x4cbc7b,null))[_0x3f40('0x22')](function(_0x330d5a){var _0x59c918;if(_0x330d5a){_0x59c918=squel[_0x3f40('0x5b')]()['into'](_0x3f40('0x5c'))['fromQuery'](['phone',_0x3f40('0x5f'),'ContactId','ListId',_0x3f40('0x75'),_0x3f40('0x62'),_0x3f40('0x63')],squel[_0x3f40('0x64')]()[_0x3f40('0x65')](_0x3f40('0x66'),_0x3f40('0x5e'))['field'](_0x3f40('0x67'),'scheduledAt')['field'](_0x3f40('0x68'),_0x3f40('0x60'))[_0x3f40('0x65')]('ANY_VALUE(ListId)',_0x3f40('0x69'))['field']('ANY_VALUE(CampaignId)','CampaignId')['field']('NOW()','createdAt')[_0x3f40('0x65')](_0x3f40('0x67'),_0x3f40('0x63'))[_0x3f40('0x6b')](_0x3f40('0x6c'))[_0x3f40('0x36')](_0x3f40('0x76'),_0x53eade[_0x3f40('0x40')]['id']['toString']())[_0x3f40('0x36')](_0x3f40('0x77'),_0x53eade[_0x3f40('0x44')][_0x3f40('0x6e')][_0x3f40('0x6d')]())[_0x3f40('0x36')](_0x3f40('0x6f'))[_0x3f40('0x36')](_0x3f40('0x70'),squel[_0x3f40('0x64')]()['field'](_0x3f40('0x5e'))[_0x3f40('0x6b')]('cm_hopper')['where']('CampaignId\x20=\x20?',_0x53eade[_0x3f40('0x40')]['id']['toString']()))[_0x3f40('0x36')](_0x3f40('0x70'),squel['select']()[_0x3f40('0x65')](_0x3f40('0x72'))[_0x3f40('0x6b')](_0x3f40('0x6c'))[_0x3f40('0x36')](_0x3f40('0x76'),_0x53eade[_0x3f40('0x40')]['id'][_0x3f40('0x6d')]())[_0x3f40('0x36')](_0x3f40('0x78')))[_0x3f40('0x79')](_0x3f40('0x60')))[_0x3f40('0x6d')]();return db[_0x3f40('0x47')][_0x3f40('0x2b')](_0x59c918);}return[];})['then'](respondWithResult(_0x4cbc7b,null))[_0x3f40('0x3f')](handleError(_0x4cbc7b,null));};exports[_0x3f40('0x7a')]=function(_0x3df1f4,_0x1926d3,_0xec63eb){return db[_0x3f40('0x7b')][_0x3f40('0x7c')]({'where':{'VoiceQueueId':_0x3df1f4['body'][_0x3f40('0x61')],'CampaignId':_0x3df1f4['body'][_0x3f40('0x75')],'ContactId':_0x3df1f4['body']['ContactId']}})[_0x3f40('0x22')](handleEntityNotFound(_0x1926d3,null))[_0x3f40('0x22')](function(_0x5420b1){if(_0x5420b1){return _0x5420b1;}return null;})[_0x3f40('0x22')](respondWithResult(_0x1926d3,null))['catch'](handleError(_0x1926d3,null));};
\ No newline at end of file