Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / cmHopperFinal / cmHopperFinal.controller.js
index 3c6a2dc..bb44965 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7ed1=['filter','merge','where','map','type','options','includeAll','include','findAll','rows','show','params','find','describe','catch','uniqueid','body','countContactsQueueCampaignHopperFinal','sequelize','COUNT','`state`\x20=\x200,\x201,\x20null','noSuchContacts','literal','`state`\x20=\x203,\x201,\x20null','noAnswerContacts','`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','reCallContacts','`state`\x20=\x2019,\x201,\x20null','answeringMachine','countContactsIvrCampaignHopperFinal','`state`\x20=\x2022,\x201,\x20null','VoiceQueue','insert','into','cm_hopper','fromQuery','updatedAt','select','field','ANY_VALUE(calleridnum)','phone','NOW()','scheduledAt','ContactId','ANY_VALUE(ListId)','ListId','ANY_VALUE(VoiceQueueId)','VoiceQueueId','from','toString','state','calleridnum\x20IS\x20NOT\x20NULL','calleridnum\x20NOT\x20IN\x20(?)','VoiceQueueId\x20=\x20?','calleridnum','cm_hopper_final','state\x20=\x204','group','Campaign','CampaignId','ANY_VALUE(ContactId)','createdAt','state\x20=\x20?','CampaignId\x20=\x20?','CmHopper','findOne','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/environment','../../mysqldb','status','end','count','offset','set','Content-Range','json','reject','update','then','destroy','stack','name','send','index','CmHopperFinal','rawAttributes','fieldName','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','limit','sort','pick'];(function(_0x4be53f,_0x5aec1e){var _0x10d2b3=function(_0x3346a1){while(--_0x3346a1){_0x4be53f['push'](_0x4be53f['shift']());}};_0x10d2b3(++_0x5aec1e);}(_0x7ed1,0xca));var _0x17ed=function(_0x4b73a2,_0x40b5fe){_0x4b73a2=_0x4b73a2-0x0;var _0x383c66=_0x7ed1[_0x4b73a2];return _0x383c66;};'use strict';var pdf=require(_0x17ed('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x17ed('0x1'));var zipdir=require(_0x17ed('0x2'));var jsonpatch=require(_0x17ed('0x3'));var rp=require(_0x17ed('0x4'));var moment=require(_0x17ed('0x5'));var BPromise=require(_0x17ed('0x6'));var Mustache=require('mustache');var util=require(_0x17ed('0x7'));var path=require(_0x17ed('0x8'));var sox=require(_0x17ed('0x9'));var csv=require(_0x17ed('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x17ed('0xb'));var crypto=require(_0x17ed('0xc'));var jsforce=require(_0x17ed('0xd'));var deskjs=require(_0x17ed('0xe'));var toCsv=require('to-csv');var querystring=require(_0x17ed('0xf'));var Papa=require(_0x17ed('0x10'));var Redis=require(_0x17ed('0x11'));var authService=require(_0x17ed('0x12'));var qs=require(_0x17ed('0x13'));var as=require(_0x17ed('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x17ed('0x15'))('api');var utils=require('../../config/utils');var config=require(_0x17ed('0x16'));var db=require(_0x17ed('0x17'))['db'];function respondWithStatusCode(_0x4533bc,_0x10d961){_0x10d961=_0x10d961||0xcc;return function(_0x3f2851){if(_0x3f2851){return _0x4533bc['sendStatus'](_0x10d961);}return _0x4533bc[_0x17ed('0x18')](_0x10d961)[_0x17ed('0x19')]();};}function respondWithResult(_0x197135,_0x5f408e){_0x5f408e=_0x5f408e||0xc8;return function(_0x2ae9aa){if(_0x2ae9aa){return _0x197135['status'](_0x5f408e)['json'](_0x2ae9aa);}};}function respondWithFilteredResult(_0x30a0c6,_0x570d98){return function(_0x41b741){if(_0x41b741){var _0x4782c3=_0x41b741[_0x17ed('0x1a')],_0xd10a00=_0x570d98[_0x17ed('0x1b')],_0x6ccf15=_0x570d98[_0x17ed('0x1b')]+_0x570d98['limit'],_0x5458ff;if(_0x6ccf15>=_0x4782c3){_0x6ccf15=_0x4782c3;_0x5458ff=0xc8;}else{_0x5458ff=0xce;}_0x30a0c6['status'](_0x5458ff);return _0x30a0c6[_0x17ed('0x1c')](_0x17ed('0x1d'),_0xd10a00+'-'+_0x6ccf15+'/'+_0x4782c3)[_0x17ed('0x1e')](_0x41b741);}return null;};}function patchUpdates(_0x22e43d){return function(_0x418f4e){try{jsonpatch['apply'](_0x418f4e,_0x22e43d,!![]);}catch(_0x427340){return BPromise[_0x17ed('0x1f')](_0x427340);}return _0x418f4e['save']();};}function saveUpdates(_0x2cac50,_0x3368aa){return function(_0x532b3a){if(_0x532b3a){return _0x532b3a[_0x17ed('0x20')](_0x2cac50)[_0x17ed('0x21')](function(_0x2298ea){return _0x2298ea;});}return null;};}function removeEntity(_0x390342,_0x3918e4){return function(_0x2e5f56){if(_0x2e5f56){return _0x2e5f56[_0x17ed('0x22')]()['then'](function(){_0x390342[_0x17ed('0x18')](0xcc)[_0x17ed('0x19')]();});}};}function handleEntityNotFound(_0x5e1602,_0x5e4f27){return function(_0x464799){if(!_0x464799){_0x5e1602['sendStatus'](0x194);}return _0x464799;};}function handleError(_0x5e03b3,_0x4f014b){_0x4f014b=_0x4f014b||0x1f4;return function(_0x284c72){logger['error'](_0x284c72[_0x17ed('0x23')]);if(_0x284c72[_0x17ed('0x24')]){delete _0x284c72[_0x17ed('0x24')];}_0x5e03b3['status'](_0x4f014b)[_0x17ed('0x25')](_0x284c72);};}exports[_0x17ed('0x26')]=function(_0x29049e,_0x4d1de9){var _0x57470d={},_0x170d4f={},_0xb3ea65={'count':0x0,'rows':[]};var _0x376f03=_['map'](db[_0x17ed('0x27')][_0x17ed('0x28')],function(_0x20ece2){return{'name':_0x20ece2[_0x17ed('0x29')],'type':_0x20ece2['type'][_0x17ed('0x2a')]};});_0x170d4f[_0x17ed('0x2b')]=_['map'](_0x376f03,_0x17ed('0x24'));_0x170d4f[_0x17ed('0x2c')]=_[_0x17ed('0x2d')](_0x29049e['query']);_0x170d4f[_0x17ed('0x2e')]=_[_0x17ed('0x2f')](_0x170d4f[_0x17ed('0x2b')],_0x170d4f[_0x17ed('0x2c')]);_0x57470d['attributes']=_[_0x17ed('0x2f')](_0x170d4f['model'],qs[_0x17ed('0x30')](_0x29049e[_0x17ed('0x2c')][_0x17ed('0x30')]));_0x57470d[_0x17ed('0x31')]=_0x57470d['attributes'][_0x17ed('0x32')]?_0x57470d[_0x17ed('0x31')]:_0x170d4f[_0x17ed('0x2b')];if(!_0x29049e[_0x17ed('0x2c')][_0x17ed('0x33')](_0x17ed('0x34'))){_0x57470d[_0x17ed('0x35')]=qs[_0x17ed('0x35')](_0x29049e['query'][_0x17ed('0x35')]);_0x57470d[_0x17ed('0x1b')]=qs[_0x17ed('0x1b')](_0x29049e[_0x17ed('0x2c')][_0x17ed('0x1b')]);}_0x57470d['order']=qs[_0x17ed('0x36')](_0x29049e[_0x17ed('0x2c')]['sort']);_0x57470d['where']=qs['filters'](_[_0x17ed('0x37')](_0x29049e['query'],_0x170d4f[_0x17ed('0x2e')]),_0x376f03);if(_0x29049e[_0x17ed('0x2c')][_0x17ed('0x38')]){_0x57470d['where']=_[_0x17ed('0x39')](_0x57470d[_0x17ed('0x3a')],{'$or':_[_0x17ed('0x3b')](_0x376f03,function(_0x471b09){if(_0x471b09[_0x17ed('0x3c')]!=='VIRTUAL'){var _0x245778={};_0x245778[_0x471b09[_0x17ed('0x24')]]={'$like':'%'+_0x29049e[_0x17ed('0x2c')][_0x17ed('0x38')]+'%'};return _0x245778;}})});}_0x57470d=_[_0x17ed('0x39')]({},_0x57470d,_0x29049e[_0x17ed('0x3d')]);var _0x54d037={'where':_0x57470d['where']};return db[_0x17ed('0x27')][_0x17ed('0x1a')](_0x54d037)['then'](function(_0x6b4bb4){_0xb3ea65[_0x17ed('0x1a')]=_0x6b4bb4;if(_0x29049e['query'][_0x17ed('0x3e')]){_0x57470d[_0x17ed('0x3f')]=[{'all':!![]}];}return db[_0x17ed('0x27')][_0x17ed('0x40')](_0x57470d);})[_0x17ed('0x21')](function(_0x369145){_0xb3ea65[_0x17ed('0x41')]=_0x369145;return _0xb3ea65;})[_0x17ed('0x21')](respondWithFilteredResult(_0x4d1de9,_0x57470d))['catch'](handleError(_0x4d1de9,null));};exports[_0x17ed('0x42')]=function(_0x20a05e,_0x37f91f){var _0xb6a76a={'raw':!![],'where':{'id':_0x20a05e[_0x17ed('0x43')]['id']}},_0x58c19a={};_0x58c19a[_0x17ed('0x2b')]=_[_0x17ed('0x2d')](db[_0x17ed('0x27')][_0x17ed('0x28')]);_0x58c19a[_0x17ed('0x2c')]=_[_0x17ed('0x2d')](_0x20a05e[_0x17ed('0x2c')]);_0x58c19a[_0x17ed('0x2e')]=_[_0x17ed('0x2f')](_0x58c19a[_0x17ed('0x2b')],_0x58c19a[_0x17ed('0x2c')]);_0xb6a76a[_0x17ed('0x31')]=_[_0x17ed('0x2f')](_0x58c19a['model'],qs[_0x17ed('0x30')](_0x20a05e[_0x17ed('0x2c')][_0x17ed('0x30')]));_0xb6a76a[_0x17ed('0x31')]=_0xb6a76a[_0x17ed('0x31')]['length']?_0xb6a76a[_0x17ed('0x31')]:_0x58c19a[_0x17ed('0x2b')];if(_0x20a05e[_0x17ed('0x2c')][_0x17ed('0x3e')]){_0xb6a76a[_0x17ed('0x3f')]=[{'all':!![]}];}_0xb6a76a=_[_0x17ed('0x39')]({},_0xb6a76a,_0x20a05e[_0x17ed('0x3d')]);return db[_0x17ed('0x27')][_0x17ed('0x44')](_0xb6a76a)[_0x17ed('0x21')](handleEntityNotFound(_0x37f91f,null))[_0x17ed('0x21')](respondWithResult(_0x37f91f,null))['catch'](handleError(_0x37f91f,null));};exports['describe']=function(_0xab7fc1,_0x4238bc){return db[_0x17ed('0x27')][_0x17ed('0x45')]()[_0x17ed('0x21')](respondWithResult(_0x4238bc,null))[_0x17ed('0x46')](handleError(_0x4238bc,null));};exports[_0x17ed('0x20')]=function(_0xc9b7c4,_0x2a63bc){if(_0xc9b7c4['body'][_0x17ed('0x47')]){delete _0xc9b7c4[_0x17ed('0x48')][_0x17ed('0x47')];}return db['CmHopperFinal']['find']({'where':{'uniqueid':_0xc9b7c4[_0x17ed('0x43')]['id']}})[_0x17ed('0x21')](handleEntityNotFound(_0x2a63bc,null))['then'](saveUpdates(_0xc9b7c4['body'],null))['then'](respondWithResult(_0x2a63bc,null))[_0x17ed('0x46')](handleError(_0x2a63bc,null));};exports[_0x17ed('0x49')]=function(_0x2b2db0,_0x3888b7,_0x27f3b6){return db[_0x17ed('0x27')][_0x17ed('0x40')]({'raw':![],'where':{'VoiceQueueId':_0x2b2db0[_0x17ed('0x43')]['id']},'attributes':[[db[_0x17ed('0x4a')]['fn'](_0x17ed('0x4b'),db[_0x17ed('0x4a')]['fn']('IF',db[_0x17ed('0x4a')]['literal'](_0x17ed('0x4c')))),_0x17ed('0x4d')],[db['sequelize']['fn'](_0x17ed('0x4b'),db[_0x17ed('0x4a')]['fn']('IF',db[_0x17ed('0x4a')][_0x17ed('0x4e')](_0x17ed('0x4f')))),_0x17ed('0x50')],[db['sequelize']['fn'](_0x17ed('0x4b'),db['sequelize']['fn']('IF',db[_0x17ed('0x4a')]['literal'](_0x17ed('0x51')))),_0x17ed('0x52')],[db[_0x17ed('0x4a')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x17ed('0x4a')][_0x17ed('0x4e')](_0x17ed('0x53')))),_0x17ed('0x54')],[db[_0x17ed('0x4a')]['fn'](_0x17ed('0x4b'),db['sequelize']['fn']('IF',db['sequelize'][_0x17ed('0x4e')](_0x17ed('0x55')))),_0x17ed('0x56')],[db[_0x17ed('0x4a')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x17ed('0x4a')][_0x17ed('0x4e')](_0x17ed('0x57')))),_0x17ed('0x58')],[db[_0x17ed('0x4a')]['fn'](_0x17ed('0x4b'),db['sequelize']['fn']('IF',db['sequelize'][_0x17ed('0x4e')]('`state`\x20=\x2022,\x201,\x20null'))),_0x17ed('0x59')],[db['sequelize']['fn'](_0x17ed('0x4b'),db['sequelize']['fn']('IF',db[_0x17ed('0x4a')][_0x17ed('0x4e')](_0x17ed('0x5a')))),_0x17ed('0x5b')]]})['then'](handleEntityNotFound(_0x3888b7,null))[_0x17ed('0x21')](respondWithResult(_0x3888b7,null))[_0x17ed('0x46')](handleError(_0x3888b7,null));};exports[_0x17ed('0x5c')]=function(_0x4b10ad,_0x10821b,_0x2892bb){return db[_0x17ed('0x27')][_0x17ed('0x40')]({'raw':![],'where':{'CampaignId':_0x4b10ad['params']['id']},'attributes':[[db[_0x17ed('0x4a')]['fn']('COUNT',db[_0x17ed('0x4a')]['fn']('IF',db[_0x17ed('0x4a')]['literal']('`state`\x20=\x200,\x201,\x20null'))),_0x17ed('0x4d')],[db[_0x17ed('0x4a')]['fn'](_0x17ed('0x4b'),db['sequelize']['fn']('IF',db[_0x17ed('0x4a')][_0x17ed('0x4e')]('`state`\x20=\x203,\x201,\x20null'))),'noAnswerContacts'],[db[_0x17ed('0x4a')]['fn'](_0x17ed('0x4b'),db[_0x17ed('0x4a')]['fn']('IF',db[_0x17ed('0x4a')][_0x17ed('0x4e')](_0x17ed('0x51')))),_0x17ed('0x52')],[db['sequelize']['fn']('COUNT',db[_0x17ed('0x4a')]['fn']('IF',db[_0x17ed('0x4a')]['literal']('`state`\x20=\x208,\x201,\x20null'))),_0x17ed('0x54')],[db['sequelize']['fn']('COUNT',db[_0x17ed('0x4a')]['fn']('IF',db['sequelize']['literal'](_0x17ed('0x55')))),_0x17ed('0x56')],[db['sequelize']['fn'](_0x17ed('0x4b'),db[_0x17ed('0x4a')]['fn']('IF',db[_0x17ed('0x4a')][_0x17ed('0x4e')](_0x17ed('0x57')))),_0x17ed('0x58')],[db[_0x17ed('0x4a')]['fn']('COUNT',db[_0x17ed('0x4a')]['fn']('IF',db[_0x17ed('0x4a')][_0x17ed('0x4e')](_0x17ed('0x5d')))),_0x17ed('0x59')],[db[_0x17ed('0x4a')]['fn'](_0x17ed('0x4b'),db[_0x17ed('0x4a')]['fn']('IF',db[_0x17ed('0x4a')][_0x17ed('0x4e')](_0x17ed('0x5a')))),_0x17ed('0x5b')]]})['then'](handleEntityNotFound(_0x10821b,null))[_0x17ed('0x21')](respondWithResult(_0x10821b,null))['catch'](handleError(_0x10821b,null));};exports['moveContactsQueueCampaignHopperFinal']=function(_0x49d90d,_0xf6f991,_0x70290c){return db[_0x17ed('0x5e')][_0x17ed('0x44')]({'where':{'id':_0x49d90d['params']['id']}})[_0x17ed('0x21')](handleEntityNotFound(_0xf6f991,null))[_0x17ed('0x21')](function(_0x17ac01){var _0x3156db;if(_0x17ac01){_0x3156db=squel[_0x17ed('0x5f')]()[_0x17ed('0x60')](_0x17ed('0x61'))[_0x17ed('0x62')](['phone','scheduledAt','ContactId','ListId','VoiceQueueId','createdAt',_0x17ed('0x63')],squel[_0x17ed('0x64')]()[_0x17ed('0x65')](_0x17ed('0x66'),_0x17ed('0x67'))[_0x17ed('0x65')](_0x17ed('0x68'),_0x17ed('0x69'))['field']('ANY_VALUE(ContactId)',_0x17ed('0x6a'))[_0x17ed('0x65')](_0x17ed('0x6b'),_0x17ed('0x6c'))[_0x17ed('0x65')](_0x17ed('0x6d'),_0x17ed('0x6e'))[_0x17ed('0x65')](_0x17ed('0x68'),'createdAt')[_0x17ed('0x65')](_0x17ed('0x68'),_0x17ed('0x63'))[_0x17ed('0x6f')]('cm_hopper_final')[_0x17ed('0x3a')]('VoiceQueueId\x20=\x20?',_0x49d90d['params']['id'][_0x17ed('0x70')]())['where']('state\x20=\x20?',_0x49d90d[_0x17ed('0x48')][_0x17ed('0x71')][_0x17ed('0x70')]())[_0x17ed('0x3a')](_0x17ed('0x72'))[_0x17ed('0x3a')](_0x17ed('0x73'),squel[_0x17ed('0x64')]()[_0x17ed('0x65')](_0x17ed('0x67'))[_0x17ed('0x6f')](_0x17ed('0x61'))[_0x17ed('0x3a')](_0x17ed('0x74'),_0x49d90d[_0x17ed('0x43')]['id'][_0x17ed('0x70')]()))[_0x17ed('0x3a')](_0x17ed('0x73'),squel[_0x17ed('0x64')]()[_0x17ed('0x65')](_0x17ed('0x75'))[_0x17ed('0x6f')](_0x17ed('0x76'))['where'](_0x17ed('0x74'),_0x49d90d[_0x17ed('0x43')]['id']['toString']())[_0x17ed('0x3a')](_0x17ed('0x77')))[_0x17ed('0x78')](_0x17ed('0x6a')))[_0x17ed('0x70')]();return db[_0x17ed('0x4a')]['query'](_0x3156db);}return[];})[_0x17ed('0x21')](respondWithResult(_0xf6f991,null))['catch'](handleError(_0xf6f991,null));};exports['moveContactsIvrCampaignHopperFinal']=function(_0x2458ea,_0x327cc4,_0x3e58e6){return db[_0x17ed('0x79')][_0x17ed('0x44')]({'where':{'id':_0x2458ea[_0x17ed('0x43')]['id']}})[_0x17ed('0x21')](handleEntityNotFound(_0x327cc4,null))[_0x17ed('0x21')](function(_0xa1ba59){var _0x1f4e83;if(_0xa1ba59){_0x1f4e83=squel[_0x17ed('0x5f')]()[_0x17ed('0x60')](_0x17ed('0x61'))['fromQuery'](['phone',_0x17ed('0x69'),_0x17ed('0x6a'),_0x17ed('0x6c'),_0x17ed('0x7a'),'createdAt',_0x17ed('0x63')],squel[_0x17ed('0x64')]()[_0x17ed('0x65')](_0x17ed('0x66'),_0x17ed('0x67'))[_0x17ed('0x65')](_0x17ed('0x68'),_0x17ed('0x69'))[_0x17ed('0x65')](_0x17ed('0x7b'),_0x17ed('0x6a'))[_0x17ed('0x65')](_0x17ed('0x6b'),_0x17ed('0x6c'))[_0x17ed('0x65')]('ANY_VALUE(CampaignId)',_0x17ed('0x7a'))[_0x17ed('0x65')](_0x17ed('0x68'),_0x17ed('0x7c'))[_0x17ed('0x65')]('NOW()',_0x17ed('0x63'))[_0x17ed('0x6f')]('cm_hopper_final')['where']('CampaignId\x20=\x20?',_0x2458ea[_0x17ed('0x43')]['id']['toString']())[_0x17ed('0x3a')](_0x17ed('0x7d'),_0x2458ea['body'][_0x17ed('0x71')][_0x17ed('0x70')]())[_0x17ed('0x3a')](_0x17ed('0x72'))[_0x17ed('0x3a')](_0x17ed('0x73'),squel[_0x17ed('0x64')]()[_0x17ed('0x65')](_0x17ed('0x67'))[_0x17ed('0x6f')]('cm_hopper')[_0x17ed('0x3a')](_0x17ed('0x7e'),_0x2458ea[_0x17ed('0x43')]['id'][_0x17ed('0x70')]()))[_0x17ed('0x3a')]('calleridnum\x20NOT\x20IN\x20(?)',squel['select']()['field'](_0x17ed('0x75'))[_0x17ed('0x6f')](_0x17ed('0x76'))[_0x17ed('0x3a')]('CampaignId\x20=\x20?',_0x2458ea['params']['id'][_0x17ed('0x70')]())['where'](_0x17ed('0x77')))[_0x17ed('0x78')](_0x17ed('0x6a')))[_0x17ed('0x70')]();return db['sequelize'][_0x17ed('0x2c')](_0x1f4e83);}return[];})[_0x17ed('0x21')](respondWithResult(_0x327cc4,null))[_0x17ed('0x46')](handleError(_0x327cc4,null));};exports['checkContactHopper']=function(_0xa43beb,_0x51c06b,_0x1e7800){return db[_0x17ed('0x7f')][_0x17ed('0x80')]({'where':{'VoiceQueueId':_0xa43beb[_0x17ed('0x48')]['VoiceQueueId'],'CampaignId':_0xa43beb['body'][_0x17ed('0x7a')],'ContactId':_0xa43beb['body'][_0x17ed('0x6a')]}})[_0x17ed('0x21')](handleEntityNotFound(_0x51c06b,null))[_0x17ed('0x21')](function(_0x47f3fa){if(_0x47f3fa){return _0x47f3fa;}return null;})[_0x17ed('0x21')](respondWithResult(_0x51c06b,null))['catch'](handleError(_0x51c06b,null));};
\ No newline at end of file
+var _0x75dc=['model','map','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','filters','pick','filter','where','merge','VIRTUAL','options','CmHopperFinal','count','includeAll','include','rows','catch','show','find','body','uniqueid','params','findAll','sequelize','COUNT','`state`\x20=\x200,\x201,\x20null','literal','noAnswerContacts','`state`\x20=\x205,\x201,\x20null','busyContacts','`state`\x20=\x208,\x201,\x20null','congestionContacts','abandonedContacts','`state`\x20=\x2022,\x201,\x20null','reCallContacts','answeringMachine','countContactsIvrCampaignHopperFinal','noSuchContacts','`state`\x20=\x203,\x201,\x20null','`state`\x20=\x2010\x20,\x201,\x20null','dropContacts','`state`\x20=\x2019,\x201,\x20null','moveContactsQueueCampaignHopperFinal','into','cm_hopper','fromQuery','phone','scheduledAt','updatedAt','select','field','ANY_VALUE(calleridnum)','NOW()','ANY_VALUE(ContactId)','ContactId','ANY_VALUE(ListId)','ListId','ANY_VALUE(VoiceQueueId)','VoiceQueueId','createdAt','cm_hopper_final','VoiceQueueId\x20=\x20?','toString','state\x20=\x20?','state','calleridnum\x20IS\x20NOT\x20NULL','calleridnum\x20NOT\x20IN\x20(?)','calleridnum','from','group','moveContactsIvrCampaignHopperFinal','Campaign','insert','CampaignId','ANY_VALUE(CampaignId)','CampaignId\x20=\x20?','state\x20=\x204','checkContactHopper','CmHopper','findOne','html-pdf','eml-format','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','crypto','jsforce','desk.js','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','offset','limit','status','set','json','apply','reject','save','update','then','destroy','error','stack','name','rawAttributes','type','key'];(function(_0xca7609,_0x54d886){var _0x215ce0=function(_0x1ec445){while(--_0x1ec445){_0xca7609['push'](_0xca7609['shift']());}};_0x215ce0(++_0x54d886);}(_0x75dc,0x1d7));var _0xc75d=function(_0x203271,_0x542139){_0x203271=_0x203271-0x0;var _0x37b0dd=_0x75dc[_0x203271];return _0x37b0dd;};'use strict';var pdf=require(_0xc75d('0x0'));var emlformat=require(_0xc75d('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xc75d('0x2'));var moment=require(_0xc75d('0x3'));var BPromise=require(_0xc75d('0x4'));var Mustache=require(_0xc75d('0x5'));var util=require(_0xc75d('0x6'));var path=require(_0xc75d('0x7'));var sox=require('sox');var csv=require(_0xc75d('0x8'));var ejs=require(_0xc75d('0x9'));var fs=require('fs');var _=require(_0xc75d('0xa'));var squel=require('squel');var crypto=require(_0xc75d('0xb'));var jsforce=require(_0xc75d('0xc'));var deskjs=require(_0xc75d('0xd'));var toCsv=require(_0xc75d('0x8'));var querystring=require('querystring');var Papa=require(_0xc75d('0xe'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xc75d('0xf'));var as=require(_0xc75d('0x10'));var hardwareService=require(_0xc75d('0x11'));var logger=require(_0xc75d('0x12'))('api');var utils=require(_0xc75d('0x13'));var config=require(_0xc75d('0x14'));var db=require(_0xc75d('0x15'))['db'];function respondWithStatusCode(_0x1b0911,_0x1a7984){_0x1a7984=_0x1a7984||0xcc;return function(_0x2521fd){if(_0x2521fd){return _0x1b0911[_0xc75d('0x16')](_0x1a7984);}return _0x1b0911['status'](_0x1a7984)[_0xc75d('0x17')]();};}function respondWithResult(_0x2313be,_0x3f01a0){_0x3f01a0=_0x3f01a0||0xc8;return function(_0x421b53){if(_0x421b53){return _0x2313be['status'](_0x3f01a0)['json'](_0x421b53);}};}function respondWithFilteredResult(_0x1208d7,_0x182f56){return function(_0x174998){if(_0x174998){var _0x1b0bfc=_0x174998['count'],_0x1d49b9=_0x182f56[_0xc75d('0x18')],_0x331d68=_0x182f56[_0xc75d('0x18')]+_0x182f56[_0xc75d('0x19')],_0x2bd581;if(_0x331d68>=_0x1b0bfc){_0x331d68=_0x1b0bfc;_0x2bd581=0xc8;}else{_0x2bd581=0xce;}_0x1208d7[_0xc75d('0x1a')](_0x2bd581);return _0x1208d7[_0xc75d('0x1b')]('Content-Range',_0x1d49b9+'-'+_0x331d68+'/'+_0x1b0bfc)[_0xc75d('0x1c')](_0x174998);}return null;};}function patchUpdates(_0x50e44f){return function(_0x54f089){try{jsonpatch[_0xc75d('0x1d')](_0x54f089,_0x50e44f,!![]);}catch(_0x431948){return BPromise[_0xc75d('0x1e')](_0x431948);}return _0x54f089[_0xc75d('0x1f')]();};}function saveUpdates(_0x84ded6,_0x576117){return function(_0x3d4141){if(_0x3d4141){return _0x3d4141[_0xc75d('0x20')](_0x84ded6)[_0xc75d('0x21')](function(_0x20739f){return _0x20739f;});}return null;};}function removeEntity(_0x1ae4e9,_0x1b614f){return function(_0x2181e1){if(_0x2181e1){return _0x2181e1[_0xc75d('0x22')]()['then'](function(){_0x1ae4e9[_0xc75d('0x1a')](0xcc)[_0xc75d('0x17')]();});}};}function handleEntityNotFound(_0x18589b,_0x4314cc){return function(_0x5ef8d0){if(!_0x5ef8d0){_0x18589b[_0xc75d('0x16')](0x194);}return _0x5ef8d0;};}function handleError(_0x2f7741,_0xdb14e1){_0xdb14e1=_0xdb14e1||0x1f4;return function(_0x3b10cd){logger[_0xc75d('0x23')](_0x3b10cd[_0xc75d('0x24')]);if(_0x3b10cd['name']){delete _0x3b10cd[_0xc75d('0x25')];}_0x2f7741[_0xc75d('0x1a')](_0xdb14e1)['send'](_0x3b10cd);};}exports['index']=function(_0x4b5c88,_0xd2b678){var _0x452c51={},_0x393694={},_0x2bf10e={'count':0x0,'rows':[]};var _0x6bee54=_['map'](db['CmHopperFinal'][_0xc75d('0x26')],function(_0x17f45b){return{'name':_0x17f45b['fieldName'],'type':_0x17f45b[_0xc75d('0x27')][_0xc75d('0x28')]};});_0x393694[_0xc75d('0x29')]=_[_0xc75d('0x2a')](_0x6bee54,'name');_0x393694[_0xc75d('0x2b')]=_[_0xc75d('0x2c')](_0x4b5c88[_0xc75d('0x2b')]);_0x393694['filters']=_['intersection'](_0x393694[_0xc75d('0x29')],_0x393694[_0xc75d('0x2b')]);_0x452c51['attributes']=_[_0xc75d('0x2d')](_0x393694[_0xc75d('0x29')],qs[_0xc75d('0x2e')](_0x4b5c88[_0xc75d('0x2b')][_0xc75d('0x2e')]));_0x452c51[_0xc75d('0x2f')]=_0x452c51[_0xc75d('0x2f')][_0xc75d('0x30')]?_0x452c51[_0xc75d('0x2f')]:_0x393694[_0xc75d('0x29')];if(!_0x4b5c88[_0xc75d('0x2b')][_0xc75d('0x31')](_0xc75d('0x32'))){_0x452c51['limit']=qs[_0xc75d('0x19')](_0x4b5c88[_0xc75d('0x2b')][_0xc75d('0x19')]);_0x452c51[_0xc75d('0x18')]=qs['offset'](_0x4b5c88[_0xc75d('0x2b')][_0xc75d('0x18')]);}_0x452c51[_0xc75d('0x33')]=qs['sort'](_0x4b5c88['query']['sort']);_0x452c51['where']=qs[_0xc75d('0x34')](_[_0xc75d('0x35')](_0x4b5c88['query'],_0x393694[_0xc75d('0x34')]),_0x6bee54);if(_0x4b5c88[_0xc75d('0x2b')][_0xc75d('0x36')]){_0x452c51[_0xc75d('0x37')]=_[_0xc75d('0x38')](_0x452c51[_0xc75d('0x37')],{'$or':_[_0xc75d('0x2a')](_0x6bee54,function(_0x3a2e54){if(_0x3a2e54[_0xc75d('0x27')]!==_0xc75d('0x39')){var _0x5de483={};_0x5de483[_0x3a2e54['name']]={'$like':'%'+_0x4b5c88[_0xc75d('0x2b')][_0xc75d('0x36')]+'%'};return _0x5de483;}})});}_0x452c51=_[_0xc75d('0x38')]({},_0x452c51,_0x4b5c88[_0xc75d('0x3a')]);var _0x339972={'where':_0x452c51['where']};return db[_0xc75d('0x3b')][_0xc75d('0x3c')](_0x339972)[_0xc75d('0x21')](function(_0x1e432a){_0x2bf10e[_0xc75d('0x3c')]=_0x1e432a;if(_0x4b5c88['query'][_0xc75d('0x3d')]){_0x452c51[_0xc75d('0x3e')]=[{'all':!![]}];}return db['CmHopperFinal']['findAll'](_0x452c51);})[_0xc75d('0x21')](function(_0x38509b){_0x2bf10e[_0xc75d('0x3f')]=_0x38509b;return _0x2bf10e;})[_0xc75d('0x21')](respondWithFilteredResult(_0xd2b678,_0x452c51))[_0xc75d('0x40')](handleError(_0xd2b678,null));};exports[_0xc75d('0x41')]=function(_0x81af32,_0x499918){var _0x1a5698={'raw':!![],'where':{'id':_0x81af32['params']['id']}},_0x13a89b={};_0x13a89b['model']=_[_0xc75d('0x2c')](db[_0xc75d('0x3b')][_0xc75d('0x26')]);_0x13a89b['query']=_[_0xc75d('0x2c')](_0x81af32[_0xc75d('0x2b')]);_0x13a89b[_0xc75d('0x34')]=_[_0xc75d('0x2d')](_0x13a89b[_0xc75d('0x29')],_0x13a89b[_0xc75d('0x2b')]);_0x1a5698['attributes']=_['intersection'](_0x13a89b[_0xc75d('0x29')],qs[_0xc75d('0x2e')](_0x81af32[_0xc75d('0x2b')][_0xc75d('0x2e')]));_0x1a5698[_0xc75d('0x2f')]=_0x1a5698[_0xc75d('0x2f')][_0xc75d('0x30')]?_0x1a5698[_0xc75d('0x2f')]:_0x13a89b[_0xc75d('0x29')];if(_0x81af32[_0xc75d('0x2b')][_0xc75d('0x3d')]){_0x1a5698[_0xc75d('0x3e')]=[{'all':!![]}];}_0x1a5698=_[_0xc75d('0x38')]({},_0x1a5698,_0x81af32[_0xc75d('0x3a')]);return db[_0xc75d('0x3b')][_0xc75d('0x42')](_0x1a5698)[_0xc75d('0x21')](handleEntityNotFound(_0x499918,null))[_0xc75d('0x21')](respondWithResult(_0x499918,null))[_0xc75d('0x40')](handleError(_0x499918,null));};exports['describe']=function(_0x3c64f4,_0x24234d){return db[_0xc75d('0x3b')]['describe']()['then'](respondWithResult(_0x24234d,null))[_0xc75d('0x40')](handleError(_0x24234d,null));};exports['update']=function(_0x58f81d,_0x255225){if(_0x58f81d[_0xc75d('0x43')][_0xc75d('0x44')]){delete _0x58f81d[_0xc75d('0x43')]['uniqueid'];}return db[_0xc75d('0x3b')]['find']({'where':{'uniqueid':_0x58f81d[_0xc75d('0x45')]['id']}})[_0xc75d('0x21')](handleEntityNotFound(_0x255225,null))[_0xc75d('0x21')](saveUpdates(_0x58f81d[_0xc75d('0x43')],null))[_0xc75d('0x21')](respondWithResult(_0x255225,null))[_0xc75d('0x40')](handleError(_0x255225,null));};exports['countContactsQueueCampaignHopperFinal']=function(_0x59e694,_0x3e0b23,_0x35e9cd){return db['CmHopperFinal'][_0xc75d('0x46')]({'raw':![],'where':{'VoiceQueueId':_0x59e694['params']['id']},'attributes':[[db[_0xc75d('0x47')]['fn'](_0xc75d('0x48'),db[_0xc75d('0x47')]['fn']('IF',db[_0xc75d('0x47')]['literal'](_0xc75d('0x49')))),'noSuchContacts'],[db[_0xc75d('0x47')]['fn']('COUNT',db[_0xc75d('0x47')]['fn']('IF',db[_0xc75d('0x47')][_0xc75d('0x4a')]('`state`\x20=\x203,\x201,\x20null'))),_0xc75d('0x4b')],[db['sequelize']['fn'](_0xc75d('0x48'),db['sequelize']['fn']('IF',db[_0xc75d('0x47')][_0xc75d('0x4a')](_0xc75d('0x4c')))),_0xc75d('0x4d')],[db['sequelize']['fn'](_0xc75d('0x48'),db['sequelize']['fn']('IF',db[_0xc75d('0x47')]['literal'](_0xc75d('0x4e')))),_0xc75d('0x4f')],[db[_0xc75d('0x47')]['fn'](_0xc75d('0x48'),db['sequelize']['fn']('IF',db[_0xc75d('0x47')]['literal']('`state`\x20=\x2010\x20,\x201,\x20null'))),'dropContacts'],[db[_0xc75d('0x47')]['fn'](_0xc75d('0x48'),db['sequelize']['fn']('IF',db[_0xc75d('0x47')][_0xc75d('0x4a')]('`state`\x20=\x2011\x20,\x201,\x20null'))),_0xc75d('0x50')],[db[_0xc75d('0x47')]['fn'](_0xc75d('0x48'),db['sequelize']['fn']('IF',db['sequelize'][_0xc75d('0x4a')](_0xc75d('0x51')))),_0xc75d('0x52')],[db[_0xc75d('0x47')]['fn'](_0xc75d('0x48'),db[_0xc75d('0x47')]['fn']('IF',db[_0xc75d('0x47')]['literal']('`state`\x20=\x2019,\x201,\x20null'))),_0xc75d('0x53')]]})[_0xc75d('0x21')](handleEntityNotFound(_0x3e0b23,null))[_0xc75d('0x21')](respondWithResult(_0x3e0b23,null))[_0xc75d('0x40')](handleError(_0x3e0b23,null));};exports[_0xc75d('0x54')]=function(_0x3e5b46,_0x4ebf7d,_0x304161){return db[_0xc75d('0x3b')][_0xc75d('0x46')]({'raw':![],'where':{'CampaignId':_0x3e5b46[_0xc75d('0x45')]['id']},'attributes':[[db[_0xc75d('0x47')]['fn'](_0xc75d('0x48'),db['sequelize']['fn']('IF',db[_0xc75d('0x47')][_0xc75d('0x4a')](_0xc75d('0x49')))),_0xc75d('0x55')],[db['sequelize']['fn'](_0xc75d('0x48'),db['sequelize']['fn']('IF',db['sequelize'][_0xc75d('0x4a')](_0xc75d('0x56')))),_0xc75d('0x4b')],[db['sequelize']['fn']('COUNT',db[_0xc75d('0x47')]['fn']('IF',db[_0xc75d('0x47')]['literal'](_0xc75d('0x4c')))),'busyContacts'],[db[_0xc75d('0x47')]['fn'](_0xc75d('0x48'),db['sequelize']['fn']('IF',db[_0xc75d('0x47')][_0xc75d('0x4a')](_0xc75d('0x4e')))),_0xc75d('0x4f')],[db[_0xc75d('0x47')]['fn'](_0xc75d('0x48'),db['sequelize']['fn']('IF',db['sequelize'][_0xc75d('0x4a')](_0xc75d('0x57')))),_0xc75d('0x58')],[db[_0xc75d('0x47')]['fn']('COUNT',db[_0xc75d('0x47')]['fn']('IF',db['sequelize'][_0xc75d('0x4a')]('`state`\x20=\x2011\x20,\x201,\x20null'))),_0xc75d('0x50')],[db['sequelize']['fn']('COUNT',db[_0xc75d('0x47')]['fn']('IF',db['sequelize'][_0xc75d('0x4a')]('`state`\x20=\x2022,\x201,\x20null'))),_0xc75d('0x52')],[db[_0xc75d('0x47')]['fn'](_0xc75d('0x48'),db[_0xc75d('0x47')]['fn']('IF',db['sequelize']['literal'](_0xc75d('0x59')))),'answeringMachine']]})[_0xc75d('0x21')](handleEntityNotFound(_0x4ebf7d,null))['then'](respondWithResult(_0x4ebf7d,null))[_0xc75d('0x40')](handleError(_0x4ebf7d,null));};exports[_0xc75d('0x5a')]=function(_0x270e54,_0x5934c6,_0x52abb8){return db['VoiceQueue'][_0xc75d('0x42')]({'where':{'id':_0x270e54[_0xc75d('0x45')]['id']}})[_0xc75d('0x21')](handleEntityNotFound(_0x5934c6,null))[_0xc75d('0x21')](function(_0x4c77d){var _0x349011;if(_0x4c77d){_0x349011=squel['insert']()[_0xc75d('0x5b')](_0xc75d('0x5c'))[_0xc75d('0x5d')]([_0xc75d('0x5e'),_0xc75d('0x5f'),'ContactId','ListId','VoiceQueueId','createdAt',_0xc75d('0x60')],squel[_0xc75d('0x61')]()[_0xc75d('0x62')](_0xc75d('0x63'),_0xc75d('0x5e'))[_0xc75d('0x62')](_0xc75d('0x64'),_0xc75d('0x5f'))['field'](_0xc75d('0x65'),_0xc75d('0x66'))['field'](_0xc75d('0x67'),_0xc75d('0x68'))['field'](_0xc75d('0x69'),_0xc75d('0x6a'))['field'](_0xc75d('0x64'),_0xc75d('0x6b'))[_0xc75d('0x62')](_0xc75d('0x64'),_0xc75d('0x60'))['from'](_0xc75d('0x6c'))[_0xc75d('0x37')](_0xc75d('0x6d'),_0x270e54[_0xc75d('0x45')]['id'][_0xc75d('0x6e')]())[_0xc75d('0x37')](_0xc75d('0x6f'),_0x270e54[_0xc75d('0x43')][_0xc75d('0x70')][_0xc75d('0x6e')]())[_0xc75d('0x37')](_0xc75d('0x71'))['where']('calleridnum\x20NOT\x20IN\x20(?)',squel['select']()[_0xc75d('0x62')](_0xc75d('0x5e'))['from']('cm_hopper')[_0xc75d('0x37')](_0xc75d('0x6d'),_0x270e54[_0xc75d('0x45')]['id'][_0xc75d('0x6e')]()))['where'](_0xc75d('0x72'),squel[_0xc75d('0x61')]()['field'](_0xc75d('0x73'))[_0xc75d('0x74')](_0xc75d('0x6c'))[_0xc75d('0x37')](_0xc75d('0x6d'),_0x270e54[_0xc75d('0x45')]['id'][_0xc75d('0x6e')]())['where']('state\x20=\x204'))[_0xc75d('0x75')]('ContactId'))[_0xc75d('0x6e')]();return db[_0xc75d('0x47')][_0xc75d('0x2b')](_0x349011);}return[];})[_0xc75d('0x21')](respondWithResult(_0x5934c6,null))[_0xc75d('0x40')](handleError(_0x5934c6,null));};exports[_0xc75d('0x76')]=function(_0x2f7175,_0x5b0407,_0x238ef0){return db[_0xc75d('0x77')][_0xc75d('0x42')]({'where':{'id':_0x2f7175['params']['id']}})['then'](handleEntityNotFound(_0x5b0407,null))[_0xc75d('0x21')](function(_0x4c171d){var _0xce67c2;if(_0x4c171d){_0xce67c2=squel[_0xc75d('0x78')]()[_0xc75d('0x5b')](_0xc75d('0x5c'))['fromQuery'](['phone','scheduledAt',_0xc75d('0x66'),_0xc75d('0x68'),_0xc75d('0x79'),'createdAt',_0xc75d('0x60')],squel[_0xc75d('0x61')]()[_0xc75d('0x62')]('ANY_VALUE(calleridnum)',_0xc75d('0x5e'))[_0xc75d('0x62')]('NOW()',_0xc75d('0x5f'))[_0xc75d('0x62')](_0xc75d('0x65'),_0xc75d('0x66'))[_0xc75d('0x62')](_0xc75d('0x67'),'ListId')[_0xc75d('0x62')](_0xc75d('0x7a'),_0xc75d('0x79'))[_0xc75d('0x62')](_0xc75d('0x64'),_0xc75d('0x6b'))['field'](_0xc75d('0x64'),'updatedAt')[_0xc75d('0x74')](_0xc75d('0x6c'))[_0xc75d('0x37')](_0xc75d('0x7b'),_0x2f7175[_0xc75d('0x45')]['id'][_0xc75d('0x6e')]())[_0xc75d('0x37')](_0xc75d('0x6f'),_0x2f7175[_0xc75d('0x43')][_0xc75d('0x70')][_0xc75d('0x6e')]())[_0xc75d('0x37')](_0xc75d('0x71'))[_0xc75d('0x37')](_0xc75d('0x72'),squel[_0xc75d('0x61')]()[_0xc75d('0x62')](_0xc75d('0x5e'))['from']('cm_hopper')[_0xc75d('0x37')]('CampaignId\x20=\x20?',_0x2f7175['params']['id']['toString']()))[_0xc75d('0x37')]('calleridnum\x20NOT\x20IN\x20(?)',squel[_0xc75d('0x61')]()['field'](_0xc75d('0x73'))['from']('cm_hopper_final')['where'](_0xc75d('0x7b'),_0x2f7175[_0xc75d('0x45')]['id'][_0xc75d('0x6e')]())['where'](_0xc75d('0x7c')))['group'](_0xc75d('0x66')))['toString']();return db[_0xc75d('0x47')]['query'](_0xce67c2);}return[];})[_0xc75d('0x21')](respondWithResult(_0x5b0407,null))['catch'](handleError(_0x5b0407,null));};exports[_0xc75d('0x7d')]=function(_0x4f8c86,_0x121f22,_0x3a831a){return db[_0xc75d('0x7e')][_0xc75d('0x7f')]({'where':{'VoiceQueueId':_0x4f8c86[_0xc75d('0x43')][_0xc75d('0x6a')],'CampaignId':_0x4f8c86[_0xc75d('0x43')][_0xc75d('0x79')],'ContactId':_0x4f8c86[_0xc75d('0x43')]['ContactId']}})[_0xc75d('0x21')](handleEntityNotFound(_0x121f22,null))['then'](function(_0x2c4dc5){if(_0x2c4dc5){return _0x2c4dc5;}return null;})['then'](respondWithResult(_0x121f22,null))[_0xc75d('0x40')](handleError(_0x121f22,null));};
\ No newline at end of file