Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / campaign / campaign.controller.js
index 4b99afa..c01af2b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x010a=['sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','sendStatus','status','count','offset','limit','Content-Range','json','apply','reject','save','update','then','destroy','get','IvrCampaigns','UserProfileResource','end','error','stack','name','index','Campaign','type','model','map','query','filters','intersection','fields','length','nolimit','order','sort','where','pick','filter','merge','includeAll','include','findAll','rows','catch','params','keys','attributes','options','create','body','user','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','rawAttributes','updatedAt','createdAt','getHoppers','findOne','CmHopper','hasOwnProperty','CmHopperHistory','CampaignId','CmHopperFinal','CmHopperBlack','getLists','CmList','addLists','ids','omit','spread','dialCheckDuplicateType','always','insert','cm_hopper','fromQuery','scheduledAt','ContactId','ListId','field','phone','NOW()','CmListId','toString','cm_contacts','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','select','COALESCE(calleridnum,\x27\x27)','from','cm_hopper_final','CampaignId\x20=\x20?','into','deletedAt\x20IS\x20NULL','COALESCE(phone,\x27\x27)','push','sequelize','removeLists','getBlackLists','addBlackLists','removeBlackLists','eml-format','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x010a,0x1f4));var _0xa010=function(_0x29c076,_0x1e62c7){_0x29c076=_0x29c076-0x0;var _0x7cace3=_0x010a[_0x29c076];return _0x7cace3;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xa010('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xa010('0x1'));var jsonpatch=require(_0xa010('0x2'));var rp=require('request-promise');var moment=require(_0xa010('0x3'));var BPromise=require(_0xa010('0x4'));var Mustache=require(_0xa010('0x5'));var util=require(_0xa010('0x6'));var path=require(_0xa010('0x7'));var sox=require(_0xa010('0x8'));var csv=require(_0xa010('0x9'));var ejs=require(_0xa010('0xa'));var fs=require('fs');var _=require(_0xa010('0xb'));var squel=require('squel');var crypto=require(_0xa010('0xc'));var jsforce=require(_0xa010('0xd'));var deskjs=require(_0xa010('0xe'));var toCsv=require(_0xa010('0x9'));var querystring=require('querystring');var Papa=require(_0xa010('0xf'));var Redis=require(_0xa010('0x10'));var authService=require(_0xa010('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0xa010('0x12'));var hardwareService=require(_0xa010('0x13'));var logger=require(_0xa010('0x14'))(_0xa010('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xa010('0x16'));var db=require(_0xa010('0x17'))['db'];function respondWithStatusCode(_0x5ac7c6,_0xe2189e){_0xe2189e=_0xe2189e||0xcc;return function(_0x5ddab0){if(_0x5ddab0){return _0x5ac7c6[_0xa010('0x18')](_0xe2189e);}return _0x5ac7c6[_0xa010('0x19')](_0xe2189e)['end']();};}function respondWithResult(_0x3979b8,_0x2b5668){_0x2b5668=_0x2b5668||0xc8;return function(_0x2a1f86){if(_0x2a1f86){return _0x3979b8[_0xa010('0x19')](_0x2b5668)['json'](_0x2a1f86);}};}function respondWithFilteredResult(_0x369bc2,_0x2bb5e0){return function(_0x2d72a8){if(_0x2d72a8){var _0x283a93=_0x2d72a8[_0xa010('0x1a')],_0x1dd776=_0x2bb5e0[_0xa010('0x1b')],_0x4ffaba=_0x2bb5e0['offset']+_0x2bb5e0[_0xa010('0x1c')],_0x1c9077;if(_0x4ffaba>=_0x283a93){_0x4ffaba=_0x283a93;_0x1c9077=0xc8;}else{_0x1c9077=0xce;}_0x369bc2['status'](_0x1c9077);return _0x369bc2['set'](_0xa010('0x1d'),_0x1dd776+'-'+_0x4ffaba+'/'+_0x283a93)[_0xa010('0x1e')](_0x2d72a8);}return null;};}function patchUpdates(_0x4bdabc){return function(_0x51a7fd){try{jsonpatch[_0xa010('0x1f')](_0x51a7fd,_0x4bdabc,!![]);}catch(_0x2d616e){return BPromise[_0xa010('0x20')](_0x2d616e);}return _0x51a7fd[_0xa010('0x21')]();};}function saveUpdates(_0x180de0,_0x102d26){return function(_0x3fb6a0){if(_0x3fb6a0){return _0x3fb6a0[_0xa010('0x22')](_0x180de0)[_0xa010('0x23')](function(_0x113b8e){return _0x113b8e;});}return null;};}function removeEntity(_0x430613,_0x12dd18){return function(_0x4b7fb4){if(_0x4b7fb4){return _0x4b7fb4[_0xa010('0x24')]()['then'](function(){var _0x3c89de=_0x4b7fb4[_0xa010('0x25')]({'plain':!![]});var _0x450d19=_0xa010('0x26');return db[_0xa010('0x27')][_0xa010('0x24')]({'where':{'type':_0x450d19,'resourceId':_0x3c89de['id']}})[_0xa010('0x23')](function(){return _0x4b7fb4;});})[_0xa010('0x23')](function(){_0x430613[_0xa010('0x19')](0xcc)[_0xa010('0x28')]();});}};}function handleEntityNotFound(_0x44caa6,_0x1abd6a){return function(_0x1984b0){if(!_0x1984b0){_0x44caa6['sendStatus'](0x194);}return _0x1984b0;};}function handleError(_0x3caf1a,_0x3d152c){_0x3d152c=_0x3d152c||0x1f4;return function(_0x41c671){logger[_0xa010('0x29')](_0x41c671[_0xa010('0x2a')]);if(_0x41c671[_0xa010('0x2b')]){delete _0x41c671['name'];}_0x3caf1a[_0xa010('0x19')](_0x3d152c)['send'](_0x41c671);};}exports[_0xa010('0x2c')]=function(_0x10b210,_0x386018){var _0xce75bf={},_0x148075={},_0x5baa29={'count':0x0,'rows':[]};var _0x410dcc=_['map'](db[_0xa010('0x2d')]['rawAttributes'],function(_0x2d9718){return{'name':_0x2d9718['fieldName'],'type':_0x2d9718[_0xa010('0x2e')]['key']};});_0x148075[_0xa010('0x2f')]=_[_0xa010('0x30')](_0x410dcc,'name');_0x148075[_0xa010('0x31')]=_['keys'](_0x10b210['query']);_0x148075[_0xa010('0x32')]=_['intersection'](_0x148075[_0xa010('0x2f')],_0x148075['query']);_0xce75bf['attributes']=_[_0xa010('0x33')](_0x148075['model'],qs[_0xa010('0x34')](_0x10b210[_0xa010('0x31')][_0xa010('0x34')]));_0xce75bf['attributes']=_0xce75bf['attributes'][_0xa010('0x35')]?_0xce75bf['attributes']:_0x148075[_0xa010('0x2f')];if(!_0x10b210['query']['hasOwnProperty'](_0xa010('0x36'))){_0xce75bf[_0xa010('0x1c')]=qs[_0xa010('0x1c')](_0x10b210[_0xa010('0x31')][_0xa010('0x1c')]);_0xce75bf['offset']=qs[_0xa010('0x1b')](_0x10b210[_0xa010('0x31')][_0xa010('0x1b')]);}_0xce75bf[_0xa010('0x37')]=qs[_0xa010('0x38')](_0x10b210[_0xa010('0x31')][_0xa010('0x38')]);_0xce75bf[_0xa010('0x39')]=qs['filters'](_[_0xa010('0x3a')](_0x10b210[_0xa010('0x31')],_0x148075[_0xa010('0x32')]),_0x410dcc);if(_0x10b210[_0xa010('0x31')][_0xa010('0x3b')]){_0xce75bf[_0xa010('0x39')]=_[_0xa010('0x3c')](_0xce75bf['where'],{'$or':_[_0xa010('0x30')](_0x410dcc,function(_0x2917e9){if(_0x2917e9[_0xa010('0x2e')]!=='VIRTUAL'){var _0x4a93e3={};_0x4a93e3[_0x2917e9[_0xa010('0x2b')]]={'$like':'%'+_0x10b210['query']['filter']+'%'};return _0x4a93e3;}})});}_0xce75bf=_[_0xa010('0x3c')]({},_0xce75bf,_0x10b210['options']);var _0x4df2ed={'where':_0xce75bf[_0xa010('0x39')]};return db[_0xa010('0x2d')][_0xa010('0x1a')](_0x4df2ed)[_0xa010('0x23')](function(_0x1eb772){_0x5baa29[_0xa010('0x1a')]=_0x1eb772;if(_0x10b210[_0xa010('0x31')][_0xa010('0x3d')]){_0xce75bf[_0xa010('0x3e')]=[{'all':!![]}];}return db[_0xa010('0x2d')][_0xa010('0x3f')](_0xce75bf);})[_0xa010('0x23')](function(_0x19f476){_0x5baa29[_0xa010('0x40')]=_0x19f476;return _0x5baa29;})[_0xa010('0x23')](respondWithFilteredResult(_0x386018,_0xce75bf))[_0xa010('0x41')](handleError(_0x386018,null));};exports['show']=function(_0x2ec2a7,_0x2aac60){var _0x46b9ac={'raw':![],'where':{'id':_0x2ec2a7[_0xa010('0x42')]['id']}},_0x2053be={};_0x2053be[_0xa010('0x2f')]=_[_0xa010('0x43')](db[_0xa010('0x2d')]['rawAttributes']);_0x2053be[_0xa010('0x31')]=_[_0xa010('0x43')](_0x2ec2a7['query']);_0x2053be['filters']=_['intersection'](_0x2053be[_0xa010('0x2f')],_0x2053be[_0xa010('0x31')]);_0x46b9ac['attributes']=_[_0xa010('0x33')](_0x2053be[_0xa010('0x2f')],qs[_0xa010('0x34')](_0x2ec2a7['query'][_0xa010('0x34')]));_0x46b9ac[_0xa010('0x44')]=_0x46b9ac[_0xa010('0x44')][_0xa010('0x35')]?_0x46b9ac['attributes']:_0x2053be['model'];if(_0x2ec2a7[_0xa010('0x31')][_0xa010('0x3d')]){_0x46b9ac['include']=[{'all':!![]}];}_0x46b9ac=_[_0xa010('0x3c')]({},_0x46b9ac,_0x2ec2a7[_0xa010('0x45')]);return db[_0xa010('0x2d')]['find'](_0x46b9ac)[_0xa010('0x23')](handleEntityNotFound(_0x2aac60,null))[_0xa010('0x23')](respondWithResult(_0x2aac60,null))[_0xa010('0x41')](handleError(_0x2aac60,null));};exports[_0xa010('0x46')]=function(_0x357df9,_0x27e971){return db['Campaign'][_0xa010('0x46')](_0x357df9[_0xa010('0x47')],{})['then'](function(_0xa7076){var _0x542839=_0x357df9[_0xa010('0x48')][_0xa010('0x25')]({'plain':!![]});if(!_0x542839)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x542839['role']===_0xa010('0x48')){var _0x3f184e=_0xa7076[_0xa010('0x25')]({'plain':!![]});var _0xb0fac1=_0xa010('0x26');return db[_0xa010('0x49')][_0xa010('0x4a')]({'where':{'name':_0xb0fac1,'userProfileId':_0x542839[_0xa010('0x4b')]},'raw':!![]})[_0xa010('0x23')](function(_0x565cec){if(_0x565cec&&_0x565cec[_0xa010('0x4c')]===0x0){return db[_0xa010('0x27')]['create']({'name':_0x3f184e[_0xa010('0x2b')],'resourceId':_0x3f184e['id'],'type':_0x565cec['name'],'sectionId':_0x565cec['id']},{})[_0xa010('0x23')](function(){return _0xa7076;});}else{return _0xa7076;}})['catch'](function(_0x3b82f6){logger[_0xa010('0x29')](_0xa010('0x4d'),_0x3b82f6);throw _0x3b82f6;});}return _0xa7076;})[_0xa010('0x23')](respondWithResult(_0x27e971,0xc9))[_0xa010('0x41')](handleError(_0x27e971,null));};exports[_0xa010('0x4e')]=function(_0x2c32b5,_0x4a2514){var _0x24090a={'where':{'id':_0x2c32b5[_0xa010('0x42')]['id']}},_0x280829={};_0x280829[_0xa010('0x2f')]=_[_0xa010('0x43')](db[_0xa010('0x2d')][_0xa010('0x4f')]);_0x24090a['attributes']=_['intersection'](_0x280829[_0xa010('0x2f')],qs[_0xa010('0x34')](_0x2c32b5[_0xa010('0x31')][_0xa010('0x34')]));_0x24090a[_0xa010('0x44')]=_0x24090a[_0xa010('0x44')][_0xa010('0x35')]?_0x24090a[_0xa010('0x44')]:_0x280829[_0xa010('0x2f')];if(_0x2c32b5[_0xa010('0x31')][_0xa010('0x3d')]){_0x24090a[_0xa010('0x3e')]=[{'all':!![]}];}_0x24090a=_[_0xa010('0x3c')]({},_0x24090a,_0x2c32b5[_0xa010('0x45')]);return db[_0xa010('0x2d')][_0xa010('0x4a')](_0x24090a)[_0xa010('0x23')](handleEntityNotFound(_0x4a2514,null))[_0xa010('0x23')](function(_0x40caaa){if(_0x40caaa){var _0x1f6061=_0x40caaa['get']({'plain':!![]});_0x1f6061=qs['omit'](_0x1f6061,['id','createdAt',_0xa010('0x50')]);_0x2c32b5[_0xa010('0x47')]=_['omit'](_0x2c32b5[_0xa010('0x47')],['id',_0xa010('0x51'),'updatedAt']);return db[_0xa010('0x2d')][_0xa010('0x46')](_['merge'](_0x1f6061,_0x2c32b5['body']),{'include':_0x2c32b5[_0xa010('0x31')][_0xa010('0x3d')]?[{'all':!![]}]:undefined})[_0xa010('0x23')](function(_0x207ac7){var _0xb32e3c=_0x2c32b5[_0xa010('0x48')][_0xa010('0x25')]({'plain':!![]});if(!_0xb32e3c)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0xb32e3c['role']===_0xa010('0x48')){var _0x44fe20=_0x207ac7['get']({'plain':!![]});var _0x16a9cd='IvrCampaigns';return db[_0xa010('0x49')]['find']({'where':{'name':_0x16a9cd,'userProfileId':_0xb32e3c['userProfileId']},'raw':!![]})[_0xa010('0x23')](function(_0x244068){if(_0x244068&&_0x244068[_0xa010('0x4c')]===0x0){return db['UserProfileResource'][_0xa010('0x46')]({'name':_0x44fe20[_0xa010('0x2b')],'resourceId':_0x44fe20['id'],'type':_0x244068[_0xa010('0x2b')],'sectionId':_0x244068['id']},{})['then'](function(){return _0x207ac7;});}else{return _0x207ac7;}})['catch'](function(_0x91ba19){logger['error'](_0xa010('0x4d'),_0x91ba19);throw _0x91ba19;});}return _0x207ac7;});}})[_0xa010('0x23')](respondWithResult(_0x4a2514,0xc9))['catch'](handleError(_0x4a2514,null));};exports[_0xa010('0x22')]=function(_0x21fe74,_0x5c2804){if(_0x21fe74[_0xa010('0x47')]['id']){delete _0x21fe74[_0xa010('0x47')]['id'];}return db[_0xa010('0x2d')][_0xa010('0x4a')]({'where':{'id':_0x21fe74[_0xa010('0x42')]['id']}})['then'](handleEntityNotFound(_0x5c2804,null))[_0xa010('0x23')](saveUpdates(_0x21fe74[_0xa010('0x47')],null))[_0xa010('0x23')](respondWithResult(_0x5c2804,null))[_0xa010('0x41')](handleError(_0x5c2804,null));};exports['destroy']=function(_0x4e7d92,_0x203260){return db['Campaign']['find']({'where':{'id':_0x4e7d92[_0xa010('0x42')]['id']}})['then'](handleEntityNotFound(_0x203260,null))[_0xa010('0x23')](removeEntity(_0x203260,null))['catch'](handleError(_0x203260,null));};exports[_0xa010('0x52')]=function(_0x41628d,_0x2bf110,_0x54a4f2){var _0x18ef41={'raw':!![],'where':{}};var _0x2773a1={};var _0x3bd55e={'count':0x0,'rows':[]};return db[_0xa010('0x2d')][_0xa010('0x53')]({'where':{'id':_0x41628d[_0xa010('0x42')]['id']}})['then'](handleEntityNotFound(_0x2bf110,null))['then'](function(_0x27a215){if(_0x27a215){_0x2773a1['model']=_[_0xa010('0x43')](db[_0xa010('0x54')][_0xa010('0x4f')]);_0x2773a1[_0xa010('0x31')]=_['keys'](_0x41628d[_0xa010('0x31')]);_0x2773a1[_0xa010('0x32')]=_[_0xa010('0x33')](_0x2773a1[_0xa010('0x2f')],_0x2773a1[_0xa010('0x31')]);_0x18ef41[_0xa010('0x44')]=_[_0xa010('0x33')](_0x2773a1[_0xa010('0x2f')],qs[_0xa010('0x34')](_0x41628d[_0xa010('0x31')][_0xa010('0x34')]));_0x18ef41[_0xa010('0x44')]=_0x18ef41[_0xa010('0x44')]['length']?_0x18ef41[_0xa010('0x44')]:_0x2773a1[_0xa010('0x2f')];if(!_0x41628d[_0xa010('0x31')][_0xa010('0x55')](_0xa010('0x36'))){_0x18ef41[_0xa010('0x1c')]=qs[_0xa010('0x1c')](_0x41628d[_0xa010('0x31')][_0xa010('0x1c')]);_0x18ef41[_0xa010('0x1b')]=qs[_0xa010('0x1b')](_0x41628d[_0xa010('0x31')]['offset']);}_0x18ef41[_0xa010('0x37')]=qs[_0xa010('0x38')](_0x41628d[_0xa010('0x31')][_0xa010('0x38')]);_0x18ef41[_0xa010('0x39')]=qs[_0xa010('0x32')](_[_0xa010('0x3a')](_0x41628d[_0xa010('0x31')],_0x2773a1[_0xa010('0x32')]));_0x18ef41[_0xa010('0x39')]['CampaignId']=_0x27a215['id'];if(_0x41628d['query'][_0xa010('0x3b')]){_0x18ef41[_0xa010('0x39')]=_[_0xa010('0x3c')](_0x18ef41[_0xa010('0x39')],{'$or':_[_0xa010('0x30')](_0x18ef41[_0xa010('0x44')],function(_0x132b4a){var _0x46e5d3={};_0x46e5d3[_0x132b4a]={'$like':'%'+_0x41628d[_0xa010('0x31')][_0xa010('0x3b')]+'%'};return _0x46e5d3;})});}_0x18ef41=_[_0xa010('0x3c')]({},_0x18ef41,_0x41628d[_0xa010('0x45')]);return db['CmHopper'][_0xa010('0x1a')]({'where':_0x18ef41[_0xa010('0x39')]})[_0xa010('0x23')](function(_0xd07000){_0x3bd55e['count']=_0xd07000;if(_0x41628d[_0xa010('0x31')][_0xa010('0x3d')]){_0x18ef41[_0xa010('0x3e')]=[{'all':!![]}];}return db[_0xa010('0x54')][_0xa010('0x3f')](_0x18ef41);})[_0xa010('0x23')](function(_0xc76c5a){_0x3bd55e[_0xa010('0x40')]=_0xc76c5a;return _0x3bd55e;});}})[_0xa010('0x23')](respondWithFilteredResult(_0x2bf110,_0x18ef41))[_0xa010('0x41')](handleError(_0x2bf110,null));};exports['getHopperHistories']=function(_0x55e98f,_0x174677,_0x26df6b){var _0x8e9e82={'raw':!![],'where':{}};var _0x1d64fc={};var _0x23cba8={'count':0x0,'rows':[]};return db[_0xa010('0x2d')]['findOne']({'where':{'id':_0x55e98f[_0xa010('0x42')]['id']}})['then'](handleEntityNotFound(_0x174677,null))[_0xa010('0x23')](function(_0x2a7319){if(_0x2a7319){_0x1d64fc[_0xa010('0x2f')]=_[_0xa010('0x43')](db[_0xa010('0x56')][_0xa010('0x4f')]);_0x1d64fc['query']=_[_0xa010('0x43')](_0x55e98f[_0xa010('0x31')]);_0x1d64fc[_0xa010('0x32')]=_[_0xa010('0x33')](_0x1d64fc[_0xa010('0x2f')],_0x1d64fc[_0xa010('0x31')]);_0x8e9e82['attributes']=_[_0xa010('0x33')](_0x1d64fc[_0xa010('0x2f')],qs[_0xa010('0x34')](_0x55e98f[_0xa010('0x31')][_0xa010('0x34')]));_0x8e9e82['attributes']=_0x8e9e82[_0xa010('0x44')][_0xa010('0x35')]?_0x8e9e82[_0xa010('0x44')]:_0x1d64fc['model'];if(!_0x55e98f['query'][_0xa010('0x55')](_0xa010('0x36'))){_0x8e9e82[_0xa010('0x1c')]=qs[_0xa010('0x1c')](_0x55e98f[_0xa010('0x31')][_0xa010('0x1c')]);_0x8e9e82['offset']=qs[_0xa010('0x1b')](_0x55e98f[_0xa010('0x31')][_0xa010('0x1b')]);}_0x8e9e82[_0xa010('0x37')]=qs[_0xa010('0x38')](_0x55e98f[_0xa010('0x31')][_0xa010('0x38')]);_0x8e9e82['where']=qs[_0xa010('0x32')](_[_0xa010('0x3a')](_0x55e98f[_0xa010('0x31')],_0x1d64fc['filters']));_0x8e9e82[_0xa010('0x39')][_0xa010('0x57')]=_0x2a7319['id'];if(_0x55e98f[_0xa010('0x31')]['filter']){_0x8e9e82['where']=_[_0xa010('0x3c')](_0x8e9e82[_0xa010('0x39')],{'$or':_['map'](_0x8e9e82[_0xa010('0x44')],function(_0x1b53cb){var _0x4a48c8={};_0x4a48c8[_0x1b53cb]={'$like':'%'+_0x55e98f[_0xa010('0x31')][_0xa010('0x3b')]+'%'};return _0x4a48c8;})});}_0x8e9e82=_[_0xa010('0x3c')]({},_0x8e9e82,_0x55e98f['options']);return db[_0xa010('0x56')][_0xa010('0x1a')]({'where':_0x8e9e82['where']})['then'](function(_0x5330fc){_0x23cba8['count']=_0x5330fc;if(_0x55e98f['query'][_0xa010('0x3d')]){_0x8e9e82[_0xa010('0x3e')]=[{'all':!![]}];}return db[_0xa010('0x56')]['findAll'](_0x8e9e82);})[_0xa010('0x23')](function(_0x592bdd){_0x23cba8[_0xa010('0x40')]=_0x592bdd;return _0x23cba8;});}})['then'](respondWithFilteredResult(_0x174677,_0x8e9e82))['catch'](handleError(_0x174677,null));};exports['getHopperFinals']=function(_0x20cd8c,_0x13559f,_0x1eac45){var _0xf2575f={'raw':!![],'where':{}};var _0x4ad074={};var _0x5b1470={'count':0x0,'rows':[]};return db[_0xa010('0x2d')]['findOne']({'where':{'id':_0x20cd8c[_0xa010('0x42')]['id']}})[_0xa010('0x23')](handleEntityNotFound(_0x13559f,null))[_0xa010('0x23')](function(_0xec3ede){if(_0xec3ede){_0x4ad074[_0xa010('0x2f')]=_[_0xa010('0x43')](db['CmHopperFinal'][_0xa010('0x4f')]);_0x4ad074[_0xa010('0x31')]=_[_0xa010('0x43')](_0x20cd8c[_0xa010('0x31')]);_0x4ad074['filters']=_[_0xa010('0x33')](_0x4ad074[_0xa010('0x2f')],_0x4ad074[_0xa010('0x31')]);_0xf2575f[_0xa010('0x44')]=_[_0xa010('0x33')](_0x4ad074['model'],qs[_0xa010('0x34')](_0x20cd8c[_0xa010('0x31')]['fields']));_0xf2575f[_0xa010('0x44')]=_0xf2575f[_0xa010('0x44')][_0xa010('0x35')]?_0xf2575f[_0xa010('0x44')]:_0x4ad074['model'];if(!_0x20cd8c[_0xa010('0x31')]['hasOwnProperty'](_0xa010('0x36'))){_0xf2575f['limit']=qs['limit'](_0x20cd8c[_0xa010('0x31')][_0xa010('0x1c')]);_0xf2575f[_0xa010('0x1b')]=qs[_0xa010('0x1b')](_0x20cd8c[_0xa010('0x31')][_0xa010('0x1b')]);}_0xf2575f['order']=qs['sort'](_0x20cd8c[_0xa010('0x31')][_0xa010('0x38')]);_0xf2575f[_0xa010('0x39')]=qs[_0xa010('0x32')](_[_0xa010('0x3a')](_0x20cd8c['query'],_0x4ad074['filters']));_0xf2575f[_0xa010('0x39')][_0xa010('0x57')]=_0xec3ede['id'];if(_0x20cd8c[_0xa010('0x31')]['filter']){_0xf2575f[_0xa010('0x39')]=_['merge'](_0xf2575f[_0xa010('0x39')],{'$or':_[_0xa010('0x30')](_0xf2575f[_0xa010('0x44')],function(_0x51dc78){var _0x52ca68={};_0x52ca68[_0x51dc78]={'$like':'%'+_0x20cd8c[_0xa010('0x31')][_0xa010('0x3b')]+'%'};return _0x52ca68;})});}_0xf2575f=_[_0xa010('0x3c')]({},_0xf2575f,_0x20cd8c['options']);return db['CmHopperFinal'][_0xa010('0x1a')]({'where':_0xf2575f['where']})[_0xa010('0x23')](function(_0x274556){_0x5b1470[_0xa010('0x1a')]=_0x274556;if(_0x20cd8c[_0xa010('0x31')]['includeAll']){_0xf2575f[_0xa010('0x3e')]=[{'all':!![]}];}return db[_0xa010('0x58')]['findAll'](_0xf2575f);})[_0xa010('0x23')](function(_0x42aa10){_0x5b1470[_0xa010('0x40')]=_0x42aa10;return _0x5b1470;});}})[_0xa010('0x23')](respondWithFilteredResult(_0x13559f,_0xf2575f))[_0xa010('0x41')](handleError(_0x13559f,null));};exports['getHopperBlacks']=function(_0x25aa99,_0x44d4b9,_0x12524d){var _0x22221d={'raw':!![],'where':{}};var _0x25a7d2={};var _0x286ca7={'count':0x0,'rows':[]};return db[_0xa010('0x2d')][_0xa010('0x53')]({'where':{'id':_0x25aa99[_0xa010('0x42')]['id']}})[_0xa010('0x23')](handleEntityNotFound(_0x44d4b9,null))['then'](function(_0x226a69){if(_0x226a69){_0x25a7d2[_0xa010('0x2f')]=_['keys'](db[_0xa010('0x59')]['rawAttributes']);_0x25a7d2['query']=_[_0xa010('0x43')](_0x25aa99[_0xa010('0x31')]);_0x25a7d2[_0xa010('0x32')]=_[_0xa010('0x33')](_0x25a7d2[_0xa010('0x2f')],_0x25a7d2['query']);_0x22221d['attributes']=_[_0xa010('0x33')](_0x25a7d2[_0xa010('0x2f')],qs['fields'](_0x25aa99[_0xa010('0x31')]['fields']));_0x22221d['attributes']=_0x22221d[_0xa010('0x44')][_0xa010('0x35')]?_0x22221d[_0xa010('0x44')]:_0x25a7d2['model'];if(!_0x25aa99[_0xa010('0x31')][_0xa010('0x55')](_0xa010('0x36'))){_0x22221d['limit']=qs[_0xa010('0x1c')](_0x25aa99[_0xa010('0x31')][_0xa010('0x1c')]);_0x22221d[_0xa010('0x1b')]=qs[_0xa010('0x1b')](_0x25aa99[_0xa010('0x31')]['offset']);}_0x22221d[_0xa010('0x37')]=qs[_0xa010('0x38')](_0x25aa99[_0xa010('0x31')][_0xa010('0x38')]);_0x22221d['where']=qs[_0xa010('0x32')](_['pick'](_0x25aa99[_0xa010('0x31')],_0x25a7d2['filters']));_0x22221d[_0xa010('0x39')]['CampaignId']=_0x226a69['id'];if(_0x25aa99[_0xa010('0x31')][_0xa010('0x3b')]){_0x22221d[_0xa010('0x39')]=_[_0xa010('0x3c')](_0x22221d['where'],{'$or':_[_0xa010('0x30')](_0x22221d[_0xa010('0x44')],function(_0x52387a){var _0x449dba={};_0x449dba[_0x52387a]={'$like':'%'+_0x25aa99[_0xa010('0x31')][_0xa010('0x3b')]+'%'};return _0x449dba;})});}_0x22221d=_['merge']({},_0x22221d,_0x25aa99[_0xa010('0x45')]);return db[_0xa010('0x59')][_0xa010('0x1a')]({'where':_0x22221d[_0xa010('0x39')]})['then'](function(_0x608507){_0x286ca7[_0xa010('0x1a')]=_0x608507;if(_0x25aa99[_0xa010('0x31')][_0xa010('0x3d')]){_0x22221d[_0xa010('0x3e')]=[{'all':!![]}];}return db[_0xa010('0x59')][_0xa010('0x3f')](_0x22221d);})[_0xa010('0x23')](function(_0x3f1607){_0x286ca7[_0xa010('0x40')]=_0x3f1607;return _0x286ca7;});}})[_0xa010('0x23')](respondWithFilteredResult(_0x44d4b9,_0x22221d))[_0xa010('0x41')](handleError(_0x44d4b9,null));};exports[_0xa010('0x5a')]=function(_0x2eeb05,_0x235553,_0x5a6fe3){var _0x26aba2={};var _0x4baf09={};var _0xc9af9e;var _0x456806;return db['Campaign']['findOne']({'where':{'id':_0x2eeb05[_0xa010('0x42')]['id']}})[_0xa010('0x23')](handleEntityNotFound(_0x235553,null))['then'](function(_0xa3603e){if(_0xa3603e){_0xc9af9e=_0xa3603e;_0x4baf09[_0xa010('0x2f')]=_[_0xa010('0x43')](db[_0xa010('0x5b')][_0xa010('0x4f')]);_0x4baf09[_0xa010('0x31')]=_[_0xa010('0x43')](_0x2eeb05[_0xa010('0x31')]);_0x4baf09[_0xa010('0x32')]=_[_0xa010('0x33')](_0x4baf09[_0xa010('0x2f')],_0x4baf09[_0xa010('0x31')]);_0x26aba2['attributes']=_[_0xa010('0x33')](_0x4baf09['model'],qs[_0xa010('0x34')](_0x2eeb05[_0xa010('0x31')][_0xa010('0x34')]));_0x26aba2[_0xa010('0x44')]=_0x26aba2[_0xa010('0x44')]['length']?_0x26aba2[_0xa010('0x44')]:_0x4baf09[_0xa010('0x2f')];_0x26aba2['order']=qs[_0xa010('0x38')](_0x2eeb05[_0xa010('0x31')][_0xa010('0x38')]);_0x26aba2[_0xa010('0x39')]=qs[_0xa010('0x32')](_[_0xa010('0x3a')](_0x2eeb05[_0xa010('0x31')],_0x4baf09[_0xa010('0x32')]));if(_0x2eeb05[_0xa010('0x31')][_0xa010('0x3b')]){_0x26aba2['where']=_[_0xa010('0x3c')](_0x26aba2[_0xa010('0x39')],{'$or':_[_0xa010('0x30')](_0x26aba2[_0xa010('0x44')],function(_0x57a28c){var _0x55c1ea={};_0x55c1ea[_0x57a28c]={'$like':'%'+_0x2eeb05['query'][_0xa010('0x3b')]+'%'};return _0x55c1ea;})});}_0x26aba2=_[_0xa010('0x3c')]({},_0x26aba2,_0x2eeb05[_0xa010('0x45')]);return _0xc9af9e[_0xa010('0x5a')](_0x26aba2);}})[_0xa010('0x23')](function(_0x553695){if(_0x553695){_0x456806=_0x553695[_0xa010('0x35')];if(!_0x2eeb05[_0xa010('0x31')][_0xa010('0x55')](_0xa010('0x36'))){_0x26aba2[_0xa010('0x1c')]=qs[_0xa010('0x1c')](_0x2eeb05[_0xa010('0x31')]['limit']);_0x26aba2['offset']=qs[_0xa010('0x1b')](_0x2eeb05[_0xa010('0x31')][_0xa010('0x1b')]);}return _0xc9af9e['getLists'](_0x26aba2);}})['then'](function(_0x1b44ef){if(_0x1b44ef){return _0x1b44ef?{'count':_0x456806,'rows':_0x1b44ef}:null;}})[_0xa010('0x23')](respondWithResult(_0x235553,null))[_0xa010('0x41')](handleError(_0x235553,null));};exports[_0xa010('0x5c')]=function(_0x3ca630,_0x2d7efc,_0x206926){var _0x40e472,_0x937374;return db[_0xa010('0x2d')]['find']({'where':{'id':_0x3ca630[_0xa010('0x42')]['id']}})[_0xa010('0x23')](handleEntityNotFound(_0x2d7efc,null))[_0xa010('0x23')](function(_0x4cf760){if(_0x4cf760){_0x937374=_0x4cf760;return _0x4cf760[_0xa010('0x5c')](_0x3ca630[_0xa010('0x47')][_0xa010('0x5d')],_[_0xa010('0x5e')](_0x3ca630['body'],[_0xa010('0x5d'),'id'])||{});}return null;})[_0xa010('0x5f')](function(_0x36a16b){var _0x38048e;_0x40e472=_0x36a16b||[];var _0x41b456=[];if(_0x36a16b){for(var _0x185fd7=0x0;_0x185fd7<_0x36a16b[_0xa010('0x35')];_0x185fd7+=0x1){var _0x4a23b1=_0x36a16b[_0x185fd7][_0xa010('0x25')]({'plain':!![]});_0x937374[_0xa010('0x60')]=_0x3ca630[_0xa010('0x47')][_0xa010('0x60')]?_0x3ca630[_0xa010('0x47')][_0xa010('0x60')]:_0x937374[_0xa010('0x60')];switch(_0x937374['dialCheckDuplicateType']){case _0xa010('0x61'):_0x38048e=squel[_0xa010('0x62')]()['into'](_0xa010('0x63'))[_0xa010('0x64')](['phone',_0xa010('0x65'),_0xa010('0x66'),_0xa010('0x67'),_0xa010('0x57'),'createdAt',_0xa010('0x50')],squel['select']()[_0xa010('0x68')](_0xa010('0x69'),_0xa010('0x69'))[_0xa010('0x68')](_0xa010('0x6a'),_0xa010('0x65'))[_0xa010('0x68')]('id',_0xa010('0x66'))[_0xa010('0x68')](_0x4a23b1[_0xa010('0x6b')][_0xa010('0x6c')](),_0xa010('0x67'))['field'](_0x3ca630['params']['id'][_0xa010('0x6c')](),_0xa010('0x57'))[_0xa010('0x68')](_0xa010('0x6a'),_0xa010('0x51'))['field'](_0xa010('0x6a'),'updatedAt')['from'](_0xa010('0x6d'))[_0xa010('0x39')]('deletedAt\x20IS\x20NULL')[_0xa010('0x39')](_0xa010('0x6e'),_0x4a23b1[_0xa010('0x6b')][_0xa010('0x6c')]())[_0xa010('0x39')](_0xa010('0x6f'))[_0xa010('0x39')](_0xa010('0x70'),squel[_0xa010('0x71')]()[_0xa010('0x68')](_0xa010('0x72'))[_0xa010('0x73')](_0xa010('0x74'))[_0xa010('0x39')](_0xa010('0x75'),_0x3ca630['params']['id'][_0xa010('0x6c')]()))[_0xa010('0x39')]('phone\x20NOT\x20IN\x20(?)',squel['select']()[_0xa010('0x68')]('COALESCE(phone,\x27\x27)')['from'](_0xa010('0x63'))[_0xa010('0x39')](_0xa010('0x75'),_0x3ca630[_0xa010('0x42')]['id']['toString']())))['toString']();break;case'onlyIfOpen':_0x38048e=squel[_0xa010('0x62')]()[_0xa010('0x76')](_0xa010('0x63'))[_0xa010('0x64')]([_0xa010('0x69'),_0xa010('0x65'),_0xa010('0x66'),_0xa010('0x67'),_0xa010('0x57'),'createdAt',_0xa010('0x50')],squel[_0xa010('0x71')]()[_0xa010('0x68')](_0xa010('0x69'),'phone')['field'](_0xa010('0x6a'),'scheduledAt')['field']('id',_0xa010('0x66'))[_0xa010('0x68')](_0x4a23b1['CmListId']['toString'](),_0xa010('0x67'))[_0xa010('0x68')](_0x3ca630[_0xa010('0x42')]['id'][_0xa010('0x6c')](),_0xa010('0x57'))['field'](_0xa010('0x6a'),_0xa010('0x51'))[_0xa010('0x68')]('NOW()',_0xa010('0x50'))[_0xa010('0x73')]('cm_contacts')['where'](_0xa010('0x77'))['where']('ListId\x20=\x20?',_0x4a23b1[_0xa010('0x6b')]['toString']())[_0xa010('0x39')]('phone\x20IS\x20NOT\x20NULL')[_0xa010('0x39')](_0xa010('0x70'),squel['select']()[_0xa010('0x68')](_0xa010('0x78'))[_0xa010('0x73')](_0xa010('0x63'))[_0xa010('0x39')](_0xa010('0x75'),_0x3ca630[_0xa010('0x42')]['id'][_0xa010('0x6c')]())))[_0xa010('0x6c')]();break;default:_0x38048e=squel[_0xa010('0x62')]()[_0xa010('0x76')](_0xa010('0x63'))[_0xa010('0x64')]([_0xa010('0x69'),_0xa010('0x65'),_0xa010('0x66'),_0xa010('0x67'),_0xa010('0x57'),_0xa010('0x51'),'updatedAt'],squel[_0xa010('0x71')]()['field']('phone',_0xa010('0x69'))[_0xa010('0x68')]('NOW()',_0xa010('0x65'))[_0xa010('0x68')]('id',_0xa010('0x66'))[_0xa010('0x68')](_0x4a23b1[_0xa010('0x6b')][_0xa010('0x6c')](),_0xa010('0x67'))[_0xa010('0x68')](_0x3ca630[_0xa010('0x42')]['id']['toString'](),'CampaignId')[_0xa010('0x68')]('NOW()',_0xa010('0x51'))['field']('NOW()',_0xa010('0x50'))[_0xa010('0x73')](_0xa010('0x6d'))['where'](_0xa010('0x77'))[_0xa010('0x39')]('ListId\x20=\x20?',_0x4a23b1['CmListId'][_0xa010('0x6c')]())[_0xa010('0x39')]('phone\x20IS\x20NOT\x20NULL'))['toString']();}_0x41b456[_0xa010('0x79')](db[_0xa010('0x7a')][_0xa010('0x31')](_0x38048e));}return BPromise['all'](_0x41b456);}})['then'](function(){return _0x40e472;})[_0xa010('0x23')](respondWithResult(_0x2d7efc,null))[_0xa010('0x41')](handleError(_0x2d7efc,null));};exports[_0xa010('0x7b')]=function(_0x1b08ed,_0x25bcee,_0x4f7b1f){return db[_0xa010('0x2d')][_0xa010('0x4a')]({'where':{'id':_0x1b08ed[_0xa010('0x42')]['id']}})[_0xa010('0x23')](handleEntityNotFound(_0x25bcee,null))[_0xa010('0x23')](function(_0x470cc0){if(_0x470cc0){return _0x470cc0['removeLists'](_0x1b08ed['query']['ids']);}})[_0xa010('0x23')](function(_0x3a31ac){if(_0x3a31ac){return db[_0xa010('0x54')][_0xa010('0x24')]({'where':{'ListId':_0x1b08ed['query'][_0xa010('0x5d')],'CampaignId':_0x1b08ed[_0xa010('0x42')]['id']}})[_0xa010('0x23')](function(){return _0x3a31ac;});}})['then'](respondWithStatusCode(_0x25bcee,null))[_0xa010('0x41')](handleError(_0x25bcee,null));};exports[_0xa010('0x7c')]=function(_0x33b10e,_0x408a63,_0x265553){var _0x2647f4={};var _0x4666b1={};var _0x4301d0;var _0x5305af;return db[_0xa010('0x2d')][_0xa010('0x53')]({'where':{'id':_0x33b10e['params']['id']}})[_0xa010('0x23')](handleEntityNotFound(_0x408a63,null))[_0xa010('0x23')](function(_0x51d232){if(_0x51d232){_0x4301d0=_0x51d232;_0x4666b1['model']=_[_0xa010('0x43')](db['CmList']['rawAttributes']);_0x4666b1[_0xa010('0x31')]=_[_0xa010('0x43')](_0x33b10e[_0xa010('0x31')]);_0x4666b1[_0xa010('0x32')]=_[_0xa010('0x33')](_0x4666b1[_0xa010('0x2f')],_0x4666b1[_0xa010('0x31')]);_0x2647f4['attributes']=_[_0xa010('0x33')](_0x4666b1['model'],qs[_0xa010('0x34')](_0x33b10e[_0xa010('0x31')]['fields']));_0x2647f4[_0xa010('0x44')]=_0x2647f4['attributes'][_0xa010('0x35')]?_0x2647f4[_0xa010('0x44')]:_0x4666b1[_0xa010('0x2f')];_0x2647f4[_0xa010('0x37')]=qs[_0xa010('0x38')](_0x33b10e[_0xa010('0x31')][_0xa010('0x38')]);_0x2647f4[_0xa010('0x39')]=qs[_0xa010('0x32')](_[_0xa010('0x3a')](_0x33b10e[_0xa010('0x31')],_0x4666b1['filters']));if(_0x33b10e['query']['filter']){_0x2647f4['where']=_[_0xa010('0x3c')](_0x2647f4[_0xa010('0x39')],{'$or':_['map'](_0x2647f4[_0xa010('0x44')],function(_0xc0b75c){var _0x393d2b={};_0x393d2b[_0xc0b75c]={'$like':'%'+_0x33b10e[_0xa010('0x31')][_0xa010('0x3b')]+'%'};return _0x393d2b;})});}_0x2647f4=_[_0xa010('0x3c')]({},_0x2647f4,_0x33b10e['options']);return _0x4301d0[_0xa010('0x7c')](_0x2647f4);}})[_0xa010('0x23')](function(_0x1fbdc8){if(_0x1fbdc8){_0x5305af=_0x1fbdc8['length'];if(!_0x33b10e[_0xa010('0x31')]['hasOwnProperty'](_0xa010('0x36'))){_0x2647f4[_0xa010('0x1c')]=qs['limit'](_0x33b10e['query'][_0xa010('0x1c')]);_0x2647f4['offset']=qs[_0xa010('0x1b')](_0x33b10e[_0xa010('0x31')][_0xa010('0x1b')]);}return _0x4301d0[_0xa010('0x7c')](_0x2647f4);}})['then'](function(_0x541fca){if(_0x541fca){return _0x541fca?{'count':_0x5305af,'rows':_0x541fca}:null;}})['then'](respondWithResult(_0x408a63,null))[_0xa010('0x41')](handleError(_0x408a63,null));};exports[_0xa010('0x7d')]=function(_0x37dbe2,_0x2e30c3,_0x2dc4db){var _0x378f70,_0x4c62b1;return db[_0xa010('0x2d')]['find']({'where':{'id':_0x37dbe2['params']['id']}})[_0xa010('0x23')](handleEntityNotFound(_0x2e30c3,null))['then'](function(_0x23d90d){if(_0x23d90d){_0x4c62b1=_0x23d90d;return _0x23d90d[_0xa010('0x7d')](_0x37dbe2['body'][_0xa010('0x5d')],_['omit'](_0x37dbe2[_0xa010('0x47')],[_0xa010('0x5d'),'id'])||{});}return null;})[_0xa010('0x5f')](function(_0x1298a9){var _0xebc0a7;_0x378f70=_0x1298a9||[];var _0x182d0a=[];if(_0x1298a9){for(var _0x1a9b36=0x0;_0x1a9b36<_0x1298a9[_0xa010('0x35')];_0x1a9b36+=0x1){var _0x28e2db=_0x1298a9[_0x1a9b36][_0xa010('0x25')]({'plain':!![]});_0xebc0a7=squel[_0xa010('0x62')]()[_0xa010('0x76')]('cm_hopper_black')['fromQuery']([_0xa010('0x69'),'ContactId','ListId',_0xa010('0x57'),_0xa010('0x51'),_0xa010('0x50')],squel[_0xa010('0x71')]()[_0xa010('0x68')](_0xa010('0x69'),_0xa010('0x69'))[_0xa010('0x68')]('id',_0xa010('0x66'))[_0xa010('0x68')](_0x28e2db[_0xa010('0x6b')][_0xa010('0x6c')](),_0xa010('0x67'))[_0xa010('0x68')](_0x37dbe2[_0xa010('0x42')]['id'][_0xa010('0x6c')](),_0xa010('0x57'))[_0xa010('0x68')](_0xa010('0x6a'),_0xa010('0x51'))[_0xa010('0x68')](_0xa010('0x6a'),_0xa010('0x50'))[_0xa010('0x73')](_0xa010('0x6d'))[_0xa010('0x39')](_0xa010('0x77'))[_0xa010('0x39')](_0xa010('0x6e'),_0x28e2db[_0xa010('0x6b')][_0xa010('0x6c')]())[_0xa010('0x39')](_0xa010('0x6f')))[_0xa010('0x6c')]();_0x182d0a['push'](db[_0xa010('0x7a')][_0xa010('0x31')](_0xebc0a7));}return BPromise['all'](_0x182d0a);}})[_0xa010('0x23')](function(){return _0x378f70;})['then'](respondWithResult(_0x2e30c3,null))[_0xa010('0x41')](handleError(_0x2e30c3,null));};exports[_0xa010('0x7e')]=function(_0x5da85d,_0x47fd48,_0x376b97){return db[_0xa010('0x2d')][_0xa010('0x4a')]({'where':{'id':_0x5da85d['params']['id']}})[_0xa010('0x23')](handleEntityNotFound(_0x47fd48,null))[_0xa010('0x23')](function(_0x5f47da){if(_0x5f47da){return _0x5f47da[_0xa010('0x7e')](_0x5da85d[_0xa010('0x31')]['ids']);}})[_0xa010('0x23')](function(_0x39df79){if(_0x39df79){return db[_0xa010('0x59')]['destroy']({'where':{'ListId':_0x5da85d[_0xa010('0x31')][_0xa010('0x5d')],'CampaignId':_0x5da85d[_0xa010('0x42')]['id']}})[_0xa010('0x23')](function(){return _0x39df79;});}})[_0xa010('0x23')](respondWithStatusCode(_0x47fd48,null))['catch'](handleError(_0x47fd48,null));};
\ No newline at end of file
+var _0xd1eb=['findOne','CmHopper','nolimit','getHopperHistories','CmHopperHistory','CampaignId','getHopperFinals','CmHopperFinal','CmHopperBlack','getLists','CmList','addLists','format','ids','dialCheckDuplicateType','insert','into','cm_hopper','fromQuery','phone','scheduledAt','ContactId','ListId','field','NOW()','CmListId','toString','from','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','select','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','CampaignId\x20=\x20?','onlyIfOpen','cm_contacts','COALESCE(phone,\x27\x27)','OrderBy','h.id','cm_contact_has_items','join','h.ListId\x20=\x20?','h.CampaignId=?','push','sequelize','all','removeLists','getBlackLists','addBlackLists','YYYY-MM-DD\x20HH:mm:ss','removeBlackLists','eml-format','rimraf','zip-dir','request-promise','mustache','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','apply','reject','save','update','then','destroy','get','IvrCampaigns','UserProfileResource','stack','name','send','index','map','Campaign','rawAttributes','fieldName','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','options','include','findAll','rows','show','params','keys','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','includeAll','omit','createdAt','updatedAt','role','userProfileId','autoAssociation','getHoppers'];(function(_0x1baf24,_0x265fac){var _0x47e09c=function(_0x262334){while(--_0x262334){_0x1baf24['push'](_0x1baf24['shift']());}};_0x47e09c(++_0x265fac);}(_0xd1eb,0xc3));var _0xbd1e=function(_0x5e52f8,_0x36c55a){_0x5e52f8=_0x5e52f8-0x0;var _0x10a75b=_0xd1eb[_0x5e52f8];return _0x10a75b;};'use strict';var emlformat=require(_0xbd1e('0x0'));var rimraf=require(_0xbd1e('0x1'));var zipdir=require(_0xbd1e('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xbd1e('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xbd1e('0x4'));var util=require(_0xbd1e('0x5'));var path=require(_0xbd1e('0x6'));var sox=require(_0xbd1e('0x7'));var csv=require(_0xbd1e('0x8'));var ejs=require(_0xbd1e('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xbd1e('0xa'));var crypto=require(_0xbd1e('0xb'));var jsforce=require(_0xbd1e('0xc'));var deskjs=require(_0xbd1e('0xd'));var toCsv=require(_0xbd1e('0x8'));var querystring=require(_0xbd1e('0xe'));var Papa=require(_0xbd1e('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xbd1e('0x10'));var as=require(_0xbd1e('0x11'));var hardwareService=require(_0xbd1e('0x12'));var logger=require(_0xbd1e('0x13'))('api');var utils=require(_0xbd1e('0x14'));var config=require(_0xbd1e('0x15'));var licenseUtil=require(_0xbd1e('0x16'));var db=require(_0xbd1e('0x17'))['db'];function respondWithStatusCode(_0x283446,_0xfcab78){_0xfcab78=_0xfcab78||0xcc;return function(_0x2f1f1e){if(_0x2f1f1e){return _0x283446[_0xbd1e('0x18')](_0xfcab78);}return _0x283446[_0xbd1e('0x19')](_0xfcab78)[_0xbd1e('0x1a')]();};}function respondWithResult(_0x9cf4a7,_0x44588a){_0x44588a=_0x44588a||0xc8;return function(_0x1d4a68){if(_0x1d4a68){return _0x9cf4a7[_0xbd1e('0x19')](_0x44588a)[_0xbd1e('0x1b')](_0x1d4a68);}};}function respondWithFilteredResult(_0x1e1484,_0x5526c7){return function(_0xf2f0b4){if(_0xf2f0b4){var _0x5a5dcf=typeof _0x5526c7[_0xbd1e('0x1c')]===_0xbd1e('0x1d')&&typeof _0x5526c7['limit']===_0xbd1e('0x1d');var _0x1734bf=_0xf2f0b4[_0xbd1e('0x1e')];var _0x211978=_0x5a5dcf?0x0:_0x5526c7['offset'];var _0x1fb242=_0x5a5dcf?_0xf2f0b4['count']:_0x5526c7[_0xbd1e('0x1c')]+_0x5526c7[_0xbd1e('0x1f')];var _0x315288;if(_0x1fb242>=_0x1734bf){_0x1fb242=_0x1734bf;_0x315288=0xc8;}else{_0x315288=0xce;}_0x1e1484[_0xbd1e('0x19')](_0x315288);return _0x1e1484[_0xbd1e('0x20')]('Content-Range',_0x211978+'-'+_0x1fb242+'/'+_0x1734bf)[_0xbd1e('0x1b')](_0xf2f0b4);}return null;};}function patchUpdates(_0x3c8e6d){return function(_0x13f2eb){try{jsonpatch[_0xbd1e('0x21')](_0x13f2eb,_0x3c8e6d,!![]);}catch(_0x1249a4){return BPromise[_0xbd1e('0x22')](_0x1249a4);}return _0x13f2eb[_0xbd1e('0x23')]();};}function saveUpdates(_0x20196f,_0x208932){return function(_0x37d13c){if(_0x37d13c){return _0x37d13c[_0xbd1e('0x24')](_0x20196f)[_0xbd1e('0x25')](function(_0x4bd84a){return _0x4bd84a;});}return null;};}function removeEntity(_0x499ec0,_0x389c79){return function(_0x3011bd){if(_0x3011bd){return _0x3011bd[_0xbd1e('0x26')]()[_0xbd1e('0x25')](function(){var _0x4a2353=_0x3011bd[_0xbd1e('0x27')]({'plain':!![]});var _0x560217=_0xbd1e('0x28');return db[_0xbd1e('0x29')][_0xbd1e('0x26')]({'where':{'type':_0x560217,'resourceId':_0x4a2353['id']}})['then'](function(){return _0x3011bd;});})[_0xbd1e('0x25')](function(){_0x499ec0['status'](0xcc)[_0xbd1e('0x1a')]();});}};}function handleEntityNotFound(_0x5b4a50,_0x43d648){return function(_0x57caca){if(!_0x57caca){_0x5b4a50['sendStatus'](0x194);}return _0x57caca;};}function handleError(_0x35df17,_0x161f39){_0x161f39=_0x161f39||0x1f4;return function(_0x3feb5e){logger['error'](_0x3feb5e[_0xbd1e('0x2a')]);if(_0x3feb5e['name']){delete _0x3feb5e[_0xbd1e('0x2b')];}_0x35df17['status'](_0x161f39)[_0xbd1e('0x2c')](_0x3feb5e);};}exports[_0xbd1e('0x2d')]=function(_0x17794c,_0x28ebc4){var _0x3c0580={},_0x93e3ba={},_0x1004b0={'count':0x0,'rows':[]};var _0x26184a=_[_0xbd1e('0x2e')](db[_0xbd1e('0x2f')][_0xbd1e('0x30')],function(_0x209b61){return{'name':_0x209b61[_0xbd1e('0x31')],'type':_0x209b61['type'][_0xbd1e('0x32')]};});_0x93e3ba[_0xbd1e('0x33')]=_['map'](_0x26184a,_0xbd1e('0x2b'));_0x93e3ba['query']=_['keys'](_0x17794c[_0xbd1e('0x34')]);_0x93e3ba[_0xbd1e('0x35')]=_[_0xbd1e('0x36')](_0x93e3ba[_0xbd1e('0x33')],_0x93e3ba['query']);_0x3c0580[_0xbd1e('0x37')]=_[_0xbd1e('0x36')](_0x93e3ba[_0xbd1e('0x33')],qs[_0xbd1e('0x38')](_0x17794c[_0xbd1e('0x34')]['fields']));_0x3c0580[_0xbd1e('0x37')]=_0x3c0580[_0xbd1e('0x37')][_0xbd1e('0x39')]?_0x3c0580[_0xbd1e('0x37')]:_0x93e3ba[_0xbd1e('0x33')];if(!_0x17794c[_0xbd1e('0x34')][_0xbd1e('0x3a')]('nolimit')){_0x3c0580['limit']=qs['limit'](_0x17794c['query'][_0xbd1e('0x1f')]);_0x3c0580['offset']=qs[_0xbd1e('0x1c')](_0x17794c[_0xbd1e('0x34')][_0xbd1e('0x1c')]);}_0x3c0580[_0xbd1e('0x3b')]=qs[_0xbd1e('0x3c')](_0x17794c[_0xbd1e('0x34')][_0xbd1e('0x3c')]);_0x3c0580[_0xbd1e('0x3d')]=qs[_0xbd1e('0x35')](_[_0xbd1e('0x3e')](_0x17794c[_0xbd1e('0x34')],_0x93e3ba[_0xbd1e('0x35')]),_0x26184a);if(_0x17794c['query'][_0xbd1e('0x3f')]){_0x3c0580[_0xbd1e('0x3d')]=_[_0xbd1e('0x40')](_0x3c0580[_0xbd1e('0x3d')],{'$or':_['map'](_0x26184a,function(_0x5f0916){if(_0x5f0916['type']!=='VIRTUAL'){var _0x164060={};_0x164060[_0x5f0916[_0xbd1e('0x2b')]]={'$like':'%'+_0x17794c['query'][_0xbd1e('0x3f')]+'%'};return _0x164060;}})});}_0x3c0580=_[_0xbd1e('0x40')]({},_0x3c0580,_0x17794c[_0xbd1e('0x41')]);var _0x9254d9={'where':_0x3c0580[_0xbd1e('0x3d')]};return db['Campaign']['count'](_0x9254d9)['then'](function(_0x86a7ae){_0x1004b0[_0xbd1e('0x1e')]=_0x86a7ae;if(_0x17794c[_0xbd1e('0x34')]['includeAll']){_0x3c0580[_0xbd1e('0x42')]=[{'all':!![]}];}return db['Campaign'][_0xbd1e('0x43')](_0x3c0580);})['then'](function(_0x1ab70b){_0x1004b0[_0xbd1e('0x44')]=_0x1ab70b;return _0x1004b0;})[_0xbd1e('0x25')](respondWithFilteredResult(_0x28ebc4,_0x3c0580))['catch'](handleError(_0x28ebc4,null));};exports[_0xbd1e('0x45')]=function(_0x63e762,_0x2a7a1b){var _0x108840={'raw':![],'where':{'id':_0x63e762[_0xbd1e('0x46')]['id']}},_0x3fed92={};_0x3fed92['model']=_[_0xbd1e('0x47')](db[_0xbd1e('0x2f')]['rawAttributes']);_0x3fed92['query']=_['keys'](_0x63e762[_0xbd1e('0x34')]);_0x3fed92[_0xbd1e('0x35')]=_['intersection'](_0x3fed92[_0xbd1e('0x33')],_0x3fed92[_0xbd1e('0x34')]);_0x108840[_0xbd1e('0x37')]=_[_0xbd1e('0x36')](_0x3fed92[_0xbd1e('0x33')],qs[_0xbd1e('0x38')](_0x63e762['query'][_0xbd1e('0x38')]));_0x108840[_0xbd1e('0x37')]=_0x108840[_0xbd1e('0x37')][_0xbd1e('0x39')]?_0x108840[_0xbd1e('0x37')]:_0x3fed92['model'];if(_0x63e762[_0xbd1e('0x34')]['includeAll']){_0x108840[_0xbd1e('0x42')]=[{'all':!![]}];}_0x108840=_['merge']({},_0x108840,_0x63e762['options']);return db[_0xbd1e('0x2f')][_0xbd1e('0x48')](_0x108840)[_0xbd1e('0x25')](handleEntityNotFound(_0x2a7a1b,null))[_0xbd1e('0x25')](respondWithResult(_0x2a7a1b,null))[_0xbd1e('0x49')](handleError(_0x2a7a1b,null));};exports[_0xbd1e('0x4a')]=function(_0x31c687,_0x1fc9b7){return db['Campaign'][_0xbd1e('0x4a')](_0x31c687[_0xbd1e('0x4b')],{})['then'](function(_0x2196d2){var _0x3904f7=_0x31c687[_0xbd1e('0x4c')][_0xbd1e('0x27')]({'plain':!![]});if(!_0x3904f7)throw new Error(_0xbd1e('0x4d'));if(_0x3904f7['role']===_0xbd1e('0x4c')){var _0x1a2c58=_0x2196d2['get']({'plain':!![]});var _0x4f04fa=_0xbd1e('0x28');return db[_0xbd1e('0x4e')][_0xbd1e('0x48')]({'where':{'name':_0x4f04fa,'userProfileId':_0x3904f7['userProfileId']},'raw':!![]})[_0xbd1e('0x25')](function(_0x3cb005){if(_0x3cb005&&_0x3cb005['autoAssociation']===0x0){return db[_0xbd1e('0x29')][_0xbd1e('0x4a')]({'name':_0x1a2c58[_0xbd1e('0x2b')],'resourceId':_0x1a2c58['id'],'type':_0x3cb005['name'],'sectionId':_0x3cb005['id']},{})[_0xbd1e('0x25')](function(){return _0x2196d2;});}else{return _0x2196d2;}})['catch'](function(_0x190449){logger[_0xbd1e('0x4f')](_0xbd1e('0x50'),_0x190449);throw _0x190449;});}return _0x2196d2;})[_0xbd1e('0x25')](respondWithResult(_0x1fc9b7,0xc9))['catch'](handleError(_0x1fc9b7,null));};exports['clone']=function(_0x337ef8,_0x283ac4){var _0x17899c={'where':{'id':_0x337ef8[_0xbd1e('0x46')]['id']}},_0x5b70fb={};_0x5b70fb[_0xbd1e('0x33')]=_['keys'](db[_0xbd1e('0x2f')][_0xbd1e('0x30')]);_0x17899c[_0xbd1e('0x37')]=_[_0xbd1e('0x36')](_0x5b70fb[_0xbd1e('0x33')],qs[_0xbd1e('0x38')](_0x337ef8[_0xbd1e('0x34')][_0xbd1e('0x38')]));_0x17899c['attributes']=_0x17899c[_0xbd1e('0x37')][_0xbd1e('0x39')]?_0x17899c[_0xbd1e('0x37')]:_0x5b70fb[_0xbd1e('0x33')];if(_0x337ef8['query'][_0xbd1e('0x51')]){_0x17899c[_0xbd1e('0x42')]=[{'all':!![]}];}_0x17899c=_['merge']({},_0x17899c,_0x337ef8[_0xbd1e('0x41')]);return db[_0xbd1e('0x2f')][_0xbd1e('0x48')](_0x17899c)[_0xbd1e('0x25')](handleEntityNotFound(_0x283ac4,null))[_0xbd1e('0x25')](function(_0x26a390){if(_0x26a390){var _0x41d46d=_0x26a390['get']({'plain':!![]});_0x41d46d=qs[_0xbd1e('0x52')](_0x41d46d,['id',_0xbd1e('0x53'),_0xbd1e('0x54')]);_0x337ef8['body']=_[_0xbd1e('0x52')](_0x337ef8[_0xbd1e('0x4b')],['id',_0xbd1e('0x53'),_0xbd1e('0x54')]);return db[_0xbd1e('0x2f')][_0xbd1e('0x4a')](_[_0xbd1e('0x40')](_0x41d46d,_0x337ef8[_0xbd1e('0x4b')]),{'include':_0x337ef8[_0xbd1e('0x34')][_0xbd1e('0x51')]?[{'all':!![]}]:undefined})[_0xbd1e('0x25')](function(_0x80a069){var _0x266221=_0x337ef8[_0xbd1e('0x4c')][_0xbd1e('0x27')]({'plain':!![]});if(!_0x266221)throw new Error(_0xbd1e('0x4d'));if(_0x266221[_0xbd1e('0x55')]===_0xbd1e('0x4c')){var _0x18237c=_0x80a069[_0xbd1e('0x27')]({'plain':!![]});var _0x537d47=_0xbd1e('0x28');return db[_0xbd1e('0x4e')][_0xbd1e('0x48')]({'where':{'name':_0x537d47,'userProfileId':_0x266221[_0xbd1e('0x56')]},'raw':!![]})[_0xbd1e('0x25')](function(_0x555c49){if(_0x555c49&&_0x555c49[_0xbd1e('0x57')]===0x0){return db['UserProfileResource'][_0xbd1e('0x4a')]({'name':_0x18237c['name'],'resourceId':_0x18237c['id'],'type':_0x555c49[_0xbd1e('0x2b')],'sectionId':_0x555c49['id']},{})[_0xbd1e('0x25')](function(){return _0x80a069;});}else{return _0x80a069;}})['catch'](function(_0x4a5471){logger[_0xbd1e('0x4f')](_0xbd1e('0x50'),_0x4a5471);throw _0x4a5471;});}return _0x80a069;});}})[_0xbd1e('0x25')](respondWithResult(_0x283ac4,0xc9))[_0xbd1e('0x49')](handleError(_0x283ac4,null));};exports['update']=function(_0x43e757,_0x1c9fdc){if(_0x43e757[_0xbd1e('0x4b')]['id']){delete _0x43e757['body']['id'];}return db[_0xbd1e('0x2f')]['find']({'where':{'id':_0x43e757[_0xbd1e('0x46')]['id']}})[_0xbd1e('0x25')](handleEntityNotFound(_0x1c9fdc,null))[_0xbd1e('0x25')](saveUpdates(_0x43e757[_0xbd1e('0x4b')],null))[_0xbd1e('0x25')](respondWithResult(_0x1c9fdc,null))[_0xbd1e('0x49')](handleError(_0x1c9fdc,null));};exports[_0xbd1e('0x26')]=function(_0x3c3de5,_0x4df163){return db[_0xbd1e('0x2f')][_0xbd1e('0x48')]({'where':{'id':_0x3c3de5[_0xbd1e('0x46')]['id']}})[_0xbd1e('0x25')](handleEntityNotFound(_0x4df163,null))[_0xbd1e('0x25')](removeEntity(_0x4df163,null))['catch'](handleError(_0x4df163,null));};exports[_0xbd1e('0x58')]=function(_0x11aa66,_0x2a3e98,_0x4ff2b3){var _0x374dd7={'raw':!![],'where':{}};var _0x50729b={};var _0x580303={'count':0x0,'rows':[]};return db[_0xbd1e('0x2f')][_0xbd1e('0x59')]({'where':{'id':_0x11aa66['params']['id']}})[_0xbd1e('0x25')](handleEntityNotFound(_0x2a3e98,null))[_0xbd1e('0x25')](function(_0x590ba0){if(_0x590ba0){_0x50729b[_0xbd1e('0x33')]=_[_0xbd1e('0x47')](db[_0xbd1e('0x5a')]['rawAttributes']);_0x50729b[_0xbd1e('0x34')]=_[_0xbd1e('0x47')](_0x11aa66[_0xbd1e('0x34')]);_0x50729b['filters']=_[_0xbd1e('0x36')](_0x50729b[_0xbd1e('0x33')],_0x50729b['query']);_0x374dd7[_0xbd1e('0x37')]=_[_0xbd1e('0x36')](_0x50729b[_0xbd1e('0x33')],qs[_0xbd1e('0x38')](_0x11aa66['query'][_0xbd1e('0x38')]));_0x374dd7[_0xbd1e('0x37')]=_0x374dd7[_0xbd1e('0x37')]['length']?_0x374dd7['attributes']:_0x50729b[_0xbd1e('0x33')];if(!_0x11aa66['query']['hasOwnProperty'](_0xbd1e('0x5b'))){_0x374dd7[_0xbd1e('0x1f')]=qs['limit'](_0x11aa66[_0xbd1e('0x34')][_0xbd1e('0x1f')]);_0x374dd7[_0xbd1e('0x1c')]=qs[_0xbd1e('0x1c')](_0x11aa66[_0xbd1e('0x34')][_0xbd1e('0x1c')]);}_0x374dd7[_0xbd1e('0x3b')]=qs[_0xbd1e('0x3c')](_0x11aa66[_0xbd1e('0x34')][_0xbd1e('0x3c')]);_0x374dd7[_0xbd1e('0x3d')]=qs[_0xbd1e('0x35')](_[_0xbd1e('0x3e')](_0x11aa66[_0xbd1e('0x34')],_0x50729b[_0xbd1e('0x35')]));_0x374dd7[_0xbd1e('0x3d')]['CampaignId']=_0x590ba0['id'];if(_0x11aa66[_0xbd1e('0x34')]['filter']){_0x374dd7[_0xbd1e('0x3d')]=_[_0xbd1e('0x40')](_0x374dd7['where'],{'$or':_[_0xbd1e('0x2e')](_0x374dd7[_0xbd1e('0x37')],function(_0x18d81f){var _0x390917={};_0x390917[_0x18d81f]={'$like':'%'+_0x11aa66[_0xbd1e('0x34')]['filter']+'%'};return _0x390917;})});}_0x374dd7=_[_0xbd1e('0x40')]({},_0x374dd7,_0x11aa66['options']);return db[_0xbd1e('0x5a')][_0xbd1e('0x1e')]({'where':_0x374dd7['where']})['then'](function(_0x26d2ee){_0x580303[_0xbd1e('0x1e')]=_0x26d2ee;if(_0x11aa66[_0xbd1e('0x34')][_0xbd1e('0x51')]){_0x374dd7[_0xbd1e('0x42')]=[{'all':!![]}];}return db[_0xbd1e('0x5a')][_0xbd1e('0x43')](_0x374dd7);})[_0xbd1e('0x25')](function(_0x3e65ee){_0x580303['rows']=_0x3e65ee;return _0x580303;});}})['then'](respondWithFilteredResult(_0x2a3e98,_0x374dd7))[_0xbd1e('0x49')](handleError(_0x2a3e98,null));};exports[_0xbd1e('0x5c')]=function(_0x5d5f63,_0x2a8d61,_0x2c7bef){var _0x3528ea={'raw':!![],'where':{}};var _0x5393a2={};var _0x5ae4ac={'count':0x0,'rows':[]};return db[_0xbd1e('0x2f')][_0xbd1e('0x59')]({'where':{'id':_0x5d5f63[_0xbd1e('0x46')]['id']}})[_0xbd1e('0x25')](handleEntityNotFound(_0x2a8d61,null))[_0xbd1e('0x25')](function(_0x1b6728){if(_0x1b6728){_0x5393a2[_0xbd1e('0x33')]=_['keys'](db[_0xbd1e('0x5d')]['rawAttributes']);_0x5393a2[_0xbd1e('0x34')]=_[_0xbd1e('0x47')](_0x5d5f63[_0xbd1e('0x34')]);_0x5393a2[_0xbd1e('0x35')]=_[_0xbd1e('0x36')](_0x5393a2[_0xbd1e('0x33')],_0x5393a2[_0xbd1e('0x34')]);_0x3528ea[_0xbd1e('0x37')]=_['intersection'](_0x5393a2['model'],qs[_0xbd1e('0x38')](_0x5d5f63[_0xbd1e('0x34')]['fields']));_0x3528ea[_0xbd1e('0x37')]=_0x3528ea['attributes'][_0xbd1e('0x39')]?_0x3528ea[_0xbd1e('0x37')]:_0x5393a2[_0xbd1e('0x33')];if(!_0x5d5f63[_0xbd1e('0x34')][_0xbd1e('0x3a')](_0xbd1e('0x5b'))){_0x3528ea[_0xbd1e('0x1f')]=qs[_0xbd1e('0x1f')](_0x5d5f63['query'][_0xbd1e('0x1f')]);_0x3528ea[_0xbd1e('0x1c')]=qs[_0xbd1e('0x1c')](_0x5d5f63[_0xbd1e('0x34')][_0xbd1e('0x1c')]);}_0x3528ea['order']=qs[_0xbd1e('0x3c')](_0x5d5f63[_0xbd1e('0x34')][_0xbd1e('0x3c')]);_0x3528ea[_0xbd1e('0x3d')]=qs[_0xbd1e('0x35')](_['pick'](_0x5d5f63[_0xbd1e('0x34')],_0x5393a2[_0xbd1e('0x35')]));_0x3528ea['where'][_0xbd1e('0x5e')]=_0x1b6728['id'];if(_0x5d5f63['query'][_0xbd1e('0x3f')]){_0x3528ea[_0xbd1e('0x3d')]=_[_0xbd1e('0x40')](_0x3528ea[_0xbd1e('0x3d')],{'$or':_[_0xbd1e('0x2e')](_0x3528ea['attributes'],function(_0x4ca3cc){var _0x224be9={};_0x224be9[_0x4ca3cc]={'$like':'%'+_0x5d5f63[_0xbd1e('0x34')][_0xbd1e('0x3f')]+'%'};return _0x224be9;})});}_0x3528ea=_[_0xbd1e('0x40')]({},_0x3528ea,_0x5d5f63[_0xbd1e('0x41')]);return db[_0xbd1e('0x5d')]['count']({'where':_0x3528ea[_0xbd1e('0x3d')]})[_0xbd1e('0x25')](function(_0x4c26ed){_0x5ae4ac[_0xbd1e('0x1e')]=_0x4c26ed;if(_0x5d5f63[_0xbd1e('0x34')][_0xbd1e('0x51')]){_0x3528ea['include']=[{'all':!![]}];}return db['CmHopperHistory']['findAll'](_0x3528ea);})[_0xbd1e('0x25')](function(_0x46fea5){_0x5ae4ac[_0xbd1e('0x44')]=_0x46fea5;return _0x5ae4ac;});}})[_0xbd1e('0x25')](respondWithFilteredResult(_0x2a8d61,_0x3528ea))[_0xbd1e('0x49')](handleError(_0x2a8d61,null));};exports[_0xbd1e('0x5f')]=function(_0x4f3aaf,_0x51e29d,_0x2df9ef){var _0x2ec696={'raw':!![],'where':{}};var _0x2fec5f={};var _0x229553={'count':0x0,'rows':[]};return db[_0xbd1e('0x2f')][_0xbd1e('0x59')]({'where':{'id':_0x4f3aaf['params']['id']}})['then'](handleEntityNotFound(_0x51e29d,null))[_0xbd1e('0x25')](function(_0x4a96fc){if(_0x4a96fc){_0x2fec5f[_0xbd1e('0x33')]=_['keys'](db['CmHopperFinal']['rawAttributes']);_0x2fec5f[_0xbd1e('0x34')]=_[_0xbd1e('0x47')](_0x4f3aaf['query']);_0x2fec5f[_0xbd1e('0x35')]=_[_0xbd1e('0x36')](_0x2fec5f[_0xbd1e('0x33')],_0x2fec5f[_0xbd1e('0x34')]);_0x2ec696[_0xbd1e('0x37')]=_['intersection'](_0x2fec5f[_0xbd1e('0x33')],qs[_0xbd1e('0x38')](_0x4f3aaf[_0xbd1e('0x34')][_0xbd1e('0x38')]));_0x2ec696[_0xbd1e('0x37')]=_0x2ec696[_0xbd1e('0x37')]['length']?_0x2ec696[_0xbd1e('0x37')]:_0x2fec5f[_0xbd1e('0x33')];if(!_0x4f3aaf['query'][_0xbd1e('0x3a')]('nolimit')){_0x2ec696[_0xbd1e('0x1f')]=qs[_0xbd1e('0x1f')](_0x4f3aaf[_0xbd1e('0x34')][_0xbd1e('0x1f')]);_0x2ec696['offset']=qs[_0xbd1e('0x1c')](_0x4f3aaf['query'][_0xbd1e('0x1c')]);}_0x2ec696['order']=qs[_0xbd1e('0x3c')](_0x4f3aaf[_0xbd1e('0x34')][_0xbd1e('0x3c')]);_0x2ec696['where']=qs[_0xbd1e('0x35')](_['pick'](_0x4f3aaf[_0xbd1e('0x34')],_0x2fec5f['filters']));_0x2ec696[_0xbd1e('0x3d')][_0xbd1e('0x5e')]=_0x4a96fc['id'];if(_0x4f3aaf[_0xbd1e('0x34')][_0xbd1e('0x3f')]){_0x2ec696[_0xbd1e('0x3d')]=_['merge'](_0x2ec696[_0xbd1e('0x3d')],{'$or':_['map'](_0x2ec696[_0xbd1e('0x37')],function(_0xdd7b5){var _0x606b2e={};_0x606b2e[_0xdd7b5]={'$like':'%'+_0x4f3aaf[_0xbd1e('0x34')][_0xbd1e('0x3f')]+'%'};return _0x606b2e;})});}_0x2ec696=_['merge']({},_0x2ec696,_0x4f3aaf[_0xbd1e('0x41')]);return db['CmHopperFinal'][_0xbd1e('0x1e')]({'where':_0x2ec696[_0xbd1e('0x3d')]})[_0xbd1e('0x25')](function(_0x350fb3){_0x229553['count']=_0x350fb3;if(_0x4f3aaf[_0xbd1e('0x34')][_0xbd1e('0x51')]){_0x2ec696[_0xbd1e('0x42')]=[{'all':!![]}];}return db[_0xbd1e('0x60')][_0xbd1e('0x43')](_0x2ec696);})[_0xbd1e('0x25')](function(_0x3349d9){_0x229553[_0xbd1e('0x44')]=_0x3349d9;return _0x229553;});}})[_0xbd1e('0x25')](respondWithFilteredResult(_0x51e29d,_0x2ec696))[_0xbd1e('0x49')](handleError(_0x51e29d,null));};exports['getHopperBlacks']=function(_0x28119c,_0x252423,_0x16d4c0){var _0x45b415={'raw':!![],'where':{}};var _0x2d3f95={};var _0x42eb83={'count':0x0,'rows':[]};return db[_0xbd1e('0x2f')][_0xbd1e('0x59')]({'where':{'id':_0x28119c[_0xbd1e('0x46')]['id']}})['then'](handleEntityNotFound(_0x252423,null))[_0xbd1e('0x25')](function(_0x286673){if(_0x286673){_0x2d3f95[_0xbd1e('0x33')]=_[_0xbd1e('0x47')](db['CmHopperBlack']['rawAttributes']);_0x2d3f95[_0xbd1e('0x34')]=_['keys'](_0x28119c['query']);_0x2d3f95[_0xbd1e('0x35')]=_[_0xbd1e('0x36')](_0x2d3f95[_0xbd1e('0x33')],_0x2d3f95[_0xbd1e('0x34')]);_0x45b415[_0xbd1e('0x37')]=_[_0xbd1e('0x36')](_0x2d3f95[_0xbd1e('0x33')],qs[_0xbd1e('0x38')](_0x28119c['query'][_0xbd1e('0x38')]));_0x45b415[_0xbd1e('0x37')]=_0x45b415['attributes'][_0xbd1e('0x39')]?_0x45b415[_0xbd1e('0x37')]:_0x2d3f95['model'];if(!_0x28119c[_0xbd1e('0x34')][_0xbd1e('0x3a')]('nolimit')){_0x45b415[_0xbd1e('0x1f')]=qs[_0xbd1e('0x1f')](_0x28119c['query'][_0xbd1e('0x1f')]);_0x45b415[_0xbd1e('0x1c')]=qs[_0xbd1e('0x1c')](_0x28119c[_0xbd1e('0x34')][_0xbd1e('0x1c')]);}_0x45b415[_0xbd1e('0x3b')]=qs[_0xbd1e('0x3c')](_0x28119c['query'][_0xbd1e('0x3c')]);_0x45b415[_0xbd1e('0x3d')]=qs['filters'](_['pick'](_0x28119c['query'],_0x2d3f95[_0xbd1e('0x35')]));_0x45b415['where']['CampaignId']=_0x286673['id'];if(_0x28119c[_0xbd1e('0x34')][_0xbd1e('0x3f')]){_0x45b415[_0xbd1e('0x3d')]=_[_0xbd1e('0x40')](_0x45b415['where'],{'$or':_[_0xbd1e('0x2e')](_0x45b415[_0xbd1e('0x37')],function(_0x1a83b2){var _0x41a672={};_0x41a672[_0x1a83b2]={'$like':'%'+_0x28119c[_0xbd1e('0x34')][_0xbd1e('0x3f')]+'%'};return _0x41a672;})});}_0x45b415=_[_0xbd1e('0x40')]({},_0x45b415,_0x28119c[_0xbd1e('0x41')]);return db[_0xbd1e('0x61')]['count']({'where':_0x45b415[_0xbd1e('0x3d')]})[_0xbd1e('0x25')](function(_0x25b1cf){_0x42eb83[_0xbd1e('0x1e')]=_0x25b1cf;if(_0x28119c[_0xbd1e('0x34')]['includeAll']){_0x45b415[_0xbd1e('0x42')]=[{'all':!![]}];}return db[_0xbd1e('0x61')]['findAll'](_0x45b415);})[_0xbd1e('0x25')](function(_0x4b635d){_0x42eb83[_0xbd1e('0x44')]=_0x4b635d;return _0x42eb83;});}})[_0xbd1e('0x25')](respondWithFilteredResult(_0x252423,_0x45b415))['catch'](handleError(_0x252423,null));};exports[_0xbd1e('0x62')]=function(_0x4576dd,_0x366f13,_0x20f8b1){var _0x28ea64={};var _0x5b7592={};var _0x106899;var _0x5b8d30;return db[_0xbd1e('0x2f')]['findOne']({'where':{'id':_0x4576dd[_0xbd1e('0x46')]['id']}})['then'](handleEntityNotFound(_0x366f13,null))[_0xbd1e('0x25')](function(_0x220d55){if(_0x220d55){_0x106899=_0x220d55;_0x5b7592[_0xbd1e('0x33')]=_[_0xbd1e('0x47')](db[_0xbd1e('0x63')]['rawAttributes']);_0x5b7592[_0xbd1e('0x34')]=_['keys'](_0x4576dd[_0xbd1e('0x34')]);_0x5b7592[_0xbd1e('0x35')]=_['intersection'](_0x5b7592['model'],_0x5b7592[_0xbd1e('0x34')]);_0x28ea64[_0xbd1e('0x37')]=_[_0xbd1e('0x36')](_0x5b7592[_0xbd1e('0x33')],qs['fields'](_0x4576dd[_0xbd1e('0x34')][_0xbd1e('0x38')]));_0x28ea64[_0xbd1e('0x37')]=_0x28ea64['attributes'][_0xbd1e('0x39')]?_0x28ea64[_0xbd1e('0x37')]:_0x5b7592['model'];_0x28ea64[_0xbd1e('0x3b')]=qs['sort'](_0x4576dd[_0xbd1e('0x34')]['sort']);_0x28ea64[_0xbd1e('0x3d')]=qs[_0xbd1e('0x35')](_[_0xbd1e('0x3e')](_0x4576dd['query'],_0x5b7592['filters']));if(_0x4576dd[_0xbd1e('0x34')][_0xbd1e('0x3f')]){_0x28ea64[_0xbd1e('0x3d')]=_[_0xbd1e('0x40')](_0x28ea64[_0xbd1e('0x3d')],{'$or':_[_0xbd1e('0x2e')](_0x28ea64['attributes'],function(_0x24ce7d){var _0x24e9b4={};_0x24e9b4[_0x24ce7d]={'$like':'%'+_0x4576dd[_0xbd1e('0x34')]['filter']+'%'};return _0x24e9b4;})});}_0x28ea64=_[_0xbd1e('0x40')]({},_0x28ea64,_0x4576dd[_0xbd1e('0x41')]);return _0x106899[_0xbd1e('0x62')](_0x28ea64);}})[_0xbd1e('0x25')](function(_0x1c2e0a){if(_0x1c2e0a){_0x5b8d30=_0x1c2e0a['length'];if(!_0x4576dd[_0xbd1e('0x34')][_0xbd1e('0x3a')](_0xbd1e('0x5b'))){_0x28ea64[_0xbd1e('0x1f')]=qs[_0xbd1e('0x1f')](_0x4576dd[_0xbd1e('0x34')][_0xbd1e('0x1f')]);_0x28ea64['offset']=qs['offset'](_0x4576dd[_0xbd1e('0x34')][_0xbd1e('0x1c')]);}return _0x106899[_0xbd1e('0x62')](_0x28ea64);}})[_0xbd1e('0x25')](function(_0x574f74){if(_0x574f74){return _0x574f74?{'count':_0x5b8d30,'rows':_0x574f74}:null;}})[_0xbd1e('0x25')](respondWithResult(_0x366f13,null))[_0xbd1e('0x49')](handleError(_0x366f13,null));};exports[_0xbd1e('0x64')]=function(_0x16180e,_0x44cf7a,_0x39bbab){var _0xa0da91,_0x466e8e;var _0x389535=[];var _0x355edf=moment()[_0xbd1e('0x65')]('YYYY-MM-DD\x20HH:mm:ss');return db[_0xbd1e('0x2f')][_0xbd1e('0x48')]({'where':{'id':_0x16180e['params']['id']}})[_0xbd1e('0x25')](handleEntityNotFound(_0x44cf7a,null))[_0xbd1e('0x25')](function(_0x403188){if(_0x403188){_0x466e8e=_0x403188;return _0x403188['addLists'](_0x16180e[_0xbd1e('0x4b')][_0xbd1e('0x66')],_[_0xbd1e('0x52')](_0x16180e[_0xbd1e('0x4b')],[_0xbd1e('0x66'),'id'])||{});}return null;})['spread'](function(_0x20f7db){var _0x205661;var _0x2910b6;_0xa0da91=_0x20f7db||[];var _0xd658d8=[];if(_0x20f7db){for(var _0x492a7f=0x0;_0x492a7f<_0x20f7db['length'];_0x492a7f+=0x1){var _0x50db07=_0x20f7db[_0x492a7f]['get']({'plain':!![]});_0x466e8e['dialCheckDuplicateType']=_0x16180e['body'][_0xbd1e('0x67')]?_0x16180e[_0xbd1e('0x4b')][_0xbd1e('0x67')]:_0x466e8e[_0xbd1e('0x67')];switch(_0x466e8e[_0xbd1e('0x67')]){case'always':_0x205661=squel[_0xbd1e('0x68')]()[_0xbd1e('0x69')](_0xbd1e('0x6a'))[_0xbd1e('0x6b')]([_0xbd1e('0x6c'),_0xbd1e('0x6d'),_0xbd1e('0x6e'),_0xbd1e('0x6f'),_0xbd1e('0x5e'),_0xbd1e('0x53'),_0xbd1e('0x54')],squel['select']()[_0xbd1e('0x70')]('phone',_0xbd1e('0x6c'))[_0xbd1e('0x70')](_0xbd1e('0x71'),_0xbd1e('0x6d'))['field']('id',_0xbd1e('0x6e'))[_0xbd1e('0x70')](_0x50db07[_0xbd1e('0x72')]['toString'](),'ListId')[_0xbd1e('0x70')](_0x16180e[_0xbd1e('0x46')]['id'][_0xbd1e('0x73')](),'CampaignId')[_0xbd1e('0x70')]('\x27'+_0x355edf+'\x27','createdAt')['field']('\x27'+_0x355edf+'\x27',_0xbd1e('0x54'))[_0xbd1e('0x74')]('cm_contacts')['where'](_0xbd1e('0x75'))[_0xbd1e('0x3d')](_0xbd1e('0x76'),_0x50db07[_0xbd1e('0x72')]['toString']())[_0xbd1e('0x3d')](_0xbd1e('0x77'))[_0xbd1e('0x3d')](_0xbd1e('0x78'),squel[_0xbd1e('0x79')]()[_0xbd1e('0x70')](_0xbd1e('0x7a'))['from'](_0xbd1e('0x7b'))[_0xbd1e('0x3d')](_0xbd1e('0x7c'),_0x16180e['params']['id'][_0xbd1e('0x73')]()))[_0xbd1e('0x3d')](_0xbd1e('0x78'),squel[_0xbd1e('0x79')]()['field']('COALESCE(phone,\x27\x27)')['from']('cm_hopper')[_0xbd1e('0x3d')](_0xbd1e('0x7c'),_0x16180e[_0xbd1e('0x46')]['id'][_0xbd1e('0x73')]())))['toString']();break;case _0xbd1e('0x7d'):_0x205661=squel[_0xbd1e('0x68')]()[_0xbd1e('0x69')](_0xbd1e('0x6a'))[_0xbd1e('0x6b')]([_0xbd1e('0x6c'),_0xbd1e('0x6d'),_0xbd1e('0x6e'),_0xbd1e('0x6f'),_0xbd1e('0x5e'),'createdAt',_0xbd1e('0x54')],squel['select']()['field']('phone',_0xbd1e('0x6c'))['field']('NOW()',_0xbd1e('0x6d'))[_0xbd1e('0x70')]('id',_0xbd1e('0x6e'))[_0xbd1e('0x70')](_0x50db07['CmListId'][_0xbd1e('0x73')](),_0xbd1e('0x6f'))[_0xbd1e('0x70')](_0x16180e[_0xbd1e('0x46')]['id'][_0xbd1e('0x73')](),_0xbd1e('0x5e'))[_0xbd1e('0x70')]('\x27'+_0x355edf+'\x27',_0xbd1e('0x53'))[_0xbd1e('0x70')]('\x27'+_0x355edf+'\x27',_0xbd1e('0x54'))['from'](_0xbd1e('0x7e'))[_0xbd1e('0x3d')](_0xbd1e('0x75'))[_0xbd1e('0x3d')](_0xbd1e('0x76'),_0x50db07[_0xbd1e('0x72')][_0xbd1e('0x73')]())[_0xbd1e('0x3d')]('phone\x20IS\x20NOT\x20NULL')[_0xbd1e('0x3d')](_0xbd1e('0x78'),squel[_0xbd1e('0x79')]()[_0xbd1e('0x70')](_0xbd1e('0x7f'))[_0xbd1e('0x74')]('cm_hopper')[_0xbd1e('0x3d')](_0xbd1e('0x7c'),_0x16180e[_0xbd1e('0x46')]['id'][_0xbd1e('0x73')]())))[_0xbd1e('0x73')]();break;default:_0x205661=squel[_0xbd1e('0x68')]()[_0xbd1e('0x69')](_0xbd1e('0x6a'))[_0xbd1e('0x6b')]([_0xbd1e('0x6c'),_0xbd1e('0x6d'),_0xbd1e('0x6e'),_0xbd1e('0x6f'),_0xbd1e('0x5e'),_0xbd1e('0x53'),_0xbd1e('0x54')],squel[_0xbd1e('0x79')]()['field'](_0xbd1e('0x6c'),_0xbd1e('0x6c'))['field']('NOW()',_0xbd1e('0x6d'))[_0xbd1e('0x70')]('id',_0xbd1e('0x6e'))[_0xbd1e('0x70')](_0x50db07[_0xbd1e('0x72')]['toString'](),_0xbd1e('0x6f'))['field'](_0x16180e[_0xbd1e('0x46')]['id']['toString'](),_0xbd1e('0x5e'))[_0xbd1e('0x70')]('\x27'+_0x355edf+'\x27',_0xbd1e('0x53'))[_0xbd1e('0x70')]('\x27'+_0x355edf+'\x27',_0xbd1e('0x54'))['from'](_0xbd1e('0x7e'))[_0xbd1e('0x3d')](_0xbd1e('0x75'))['where'](_0xbd1e('0x76'),_0x50db07[_0xbd1e('0x72')][_0xbd1e('0x73')]())[_0xbd1e('0x3d')](_0xbd1e('0x77')))[_0xbd1e('0x73')]();}_0x2910b6=squel[_0xbd1e('0x68')]()[_0xbd1e('0x69')]('cm_hopper_additional_phones')[_0xbd1e('0x6b')](['cmHopperId','scheduledAt',_0xbd1e('0x6c'),_0xbd1e('0x80'),_0xbd1e('0x53'),_0xbd1e('0x54')],squel[_0xbd1e('0x79')]()[_0xbd1e('0x70')](_0xbd1e('0x81'),'id')[_0xbd1e('0x70')](_0xbd1e('0x71'),_0xbd1e('0x6d'))[_0xbd1e('0x70')]('ci.item',_0xbd1e('0x6c'))['field']('ci.OrderBY',_0xbd1e('0x80'))[_0xbd1e('0x70')]('\x27'+_0x355edf+'\x27',_0xbd1e('0x53'))[_0xbd1e('0x70')]('\x27'+_0x355edf+'\x27',_0xbd1e('0x54'))[_0xbd1e('0x74')](_0xbd1e('0x82'),'ci')[_0xbd1e('0x83')](_0xbd1e('0x6a'),'h','h.ContactId\x20=\x20ci.CmContactId')[_0xbd1e('0x3d')](_0xbd1e('0x84'),_0x50db07[_0xbd1e('0x72')][_0xbd1e('0x73')]())[_0xbd1e('0x3d')](_0xbd1e('0x85'),_0x16180e['params']['id'][_0xbd1e('0x73')]())[_0xbd1e('0x3d')]('h.createdAt\x20=\x20?',_0x355edf))[_0xbd1e('0x73')]();_0xd658d8[_0xbd1e('0x86')](db[_0xbd1e('0x87')][_0xbd1e('0x34')](_0x205661));_0x389535[_0xbd1e('0x86')](db[_0xbd1e('0x87')][_0xbd1e('0x34')](_0x2910b6));}return BPromise[_0xbd1e('0x88')](_0xd658d8);}})[_0xbd1e('0x25')](function(){return BPromise[_0xbd1e('0x88')](_0x389535);})[_0xbd1e('0x25')](function(){return _0xa0da91;})[_0xbd1e('0x25')](respondWithResult(_0x44cf7a,null))[_0xbd1e('0x49')](handleError(_0x44cf7a,null));};exports[_0xbd1e('0x89')]=function(_0x2a27b5,_0x418248,_0x11c401){return db[_0xbd1e('0x2f')]['find']({'where':{'id':_0x2a27b5[_0xbd1e('0x46')]['id']}})[_0xbd1e('0x25')](handleEntityNotFound(_0x418248,null))['then'](function(_0x11dfd8){if(_0x11dfd8){return _0x11dfd8[_0xbd1e('0x89')](_0x2a27b5['query'][_0xbd1e('0x66')]);}})[_0xbd1e('0x25')](function(_0x171730){if(_0x171730){return db[_0xbd1e('0x5a')][_0xbd1e('0x26')]({'where':{'ListId':_0x2a27b5[_0xbd1e('0x34')][_0xbd1e('0x66')],'CampaignId':_0x2a27b5[_0xbd1e('0x46')]['id']}})[_0xbd1e('0x25')](function(){return _0x171730;});}})[_0xbd1e('0x25')](respondWithStatusCode(_0x418248,null))['catch'](handleError(_0x418248,null));};exports[_0xbd1e('0x8a')]=function(_0x39302b,_0x36b677,_0x2f2421){var _0x2c61d3={};var _0x5c32b4={};var _0x146c02;var _0x2780e6;return db['Campaign'][_0xbd1e('0x59')]({'where':{'id':_0x39302b['params']['id']}})[_0xbd1e('0x25')](handleEntityNotFound(_0x36b677,null))[_0xbd1e('0x25')](function(_0x4c45aa){if(_0x4c45aa){_0x146c02=_0x4c45aa;_0x5c32b4[_0xbd1e('0x33')]=_['keys'](db[_0xbd1e('0x63')][_0xbd1e('0x30')]);_0x5c32b4['query']=_[_0xbd1e('0x47')](_0x39302b['query']);_0x5c32b4[_0xbd1e('0x35')]=_['intersection'](_0x5c32b4[_0xbd1e('0x33')],_0x5c32b4['query']);_0x2c61d3[_0xbd1e('0x37')]=_[_0xbd1e('0x36')](_0x5c32b4['model'],qs[_0xbd1e('0x38')](_0x39302b['query'][_0xbd1e('0x38')]));_0x2c61d3['attributes']=_0x2c61d3[_0xbd1e('0x37')][_0xbd1e('0x39')]?_0x2c61d3[_0xbd1e('0x37')]:_0x5c32b4[_0xbd1e('0x33')];_0x2c61d3[_0xbd1e('0x3b')]=qs[_0xbd1e('0x3c')](_0x39302b[_0xbd1e('0x34')][_0xbd1e('0x3c')]);_0x2c61d3[_0xbd1e('0x3d')]=qs['filters'](_['pick'](_0x39302b[_0xbd1e('0x34')],_0x5c32b4['filters']));if(_0x39302b[_0xbd1e('0x34')][_0xbd1e('0x3f')]){_0x2c61d3[_0xbd1e('0x3d')]=_[_0xbd1e('0x40')](_0x2c61d3[_0xbd1e('0x3d')],{'$or':_[_0xbd1e('0x2e')](_0x2c61d3[_0xbd1e('0x37')],function(_0x3e2095){var _0x26fa87={};_0x26fa87[_0x3e2095]={'$like':'%'+_0x39302b['query'][_0xbd1e('0x3f')]+'%'};return _0x26fa87;})});}_0x2c61d3=_[_0xbd1e('0x40')]({},_0x2c61d3,_0x39302b['options']);return _0x146c02[_0xbd1e('0x8a')](_0x2c61d3);}})[_0xbd1e('0x25')](function(_0x3c1952){if(_0x3c1952){_0x2780e6=_0x3c1952[_0xbd1e('0x39')];if(!_0x39302b[_0xbd1e('0x34')][_0xbd1e('0x3a')](_0xbd1e('0x5b'))){_0x2c61d3[_0xbd1e('0x1f')]=qs[_0xbd1e('0x1f')](_0x39302b[_0xbd1e('0x34')][_0xbd1e('0x1f')]);_0x2c61d3[_0xbd1e('0x1c')]=qs[_0xbd1e('0x1c')](_0x39302b[_0xbd1e('0x34')][_0xbd1e('0x1c')]);}return _0x146c02[_0xbd1e('0x8a')](_0x2c61d3);}})[_0xbd1e('0x25')](function(_0x2dc52f){if(_0x2dc52f){return _0x2dc52f?{'count':_0x2780e6,'rows':_0x2dc52f}:null;}})[_0xbd1e('0x25')](respondWithResult(_0x36b677,null))[_0xbd1e('0x49')](handleError(_0x36b677,null));};exports[_0xbd1e('0x8b')]=function(_0x2d562f,_0x3ec647,_0x186fea){var _0x1f0106,_0x54b9c5;var _0x25abdc=[];var _0x3bded5=moment()[_0xbd1e('0x65')](_0xbd1e('0x8c'));return db[_0xbd1e('0x2f')][_0xbd1e('0x48')]({'where':{'id':_0x2d562f[_0xbd1e('0x46')]['id']}})[_0xbd1e('0x25')](handleEntityNotFound(_0x3ec647,null))[_0xbd1e('0x25')](function(_0x15aca5){if(_0x15aca5){_0x54b9c5=_0x15aca5;return _0x15aca5[_0xbd1e('0x8b')](_0x2d562f[_0xbd1e('0x4b')][_0xbd1e('0x66')],_['omit'](_0x2d562f[_0xbd1e('0x4b')],[_0xbd1e('0x66'),'id'])||{});}return null;})['spread'](function(_0xb79cad){var _0x45698c;var _0x58feee;_0x1f0106=_0xb79cad||[];var _0x115abd=[];if(_0xb79cad){for(var _0x1417c3=0x0;_0x1417c3<_0xb79cad[_0xbd1e('0x39')];_0x1417c3+=0x1){var _0x225fe8=_0xb79cad[_0x1417c3][_0xbd1e('0x27')]({'plain':!![]});_0x45698c=squel['insert']()[_0xbd1e('0x69')]('cm_hopper_black')[_0xbd1e('0x6b')]([_0xbd1e('0x6c'),_0xbd1e('0x6e'),_0xbd1e('0x6f'),_0xbd1e('0x5e'),_0xbd1e('0x53'),_0xbd1e('0x54')],squel[_0xbd1e('0x79')]()[_0xbd1e('0x70')](_0xbd1e('0x6c'),_0xbd1e('0x6c'))[_0xbd1e('0x70')]('id','ContactId')['field'](_0x225fe8[_0xbd1e('0x72')][_0xbd1e('0x73')](),'ListId')['field'](_0x2d562f['params']['id'][_0xbd1e('0x73')](),'CampaignId')[_0xbd1e('0x70')](_0xbd1e('0x71'),_0xbd1e('0x53'))['field']('NOW()','updatedAt')['from'](_0xbd1e('0x7e'))[_0xbd1e('0x3d')]('deletedAt\x20IS\x20NULL')[_0xbd1e('0x3d')](_0xbd1e('0x76'),_0x225fe8[_0xbd1e('0x72')]['toString']())['where'](_0xbd1e('0x77')))['toString']();_0x115abd[_0xbd1e('0x86')](db[_0xbd1e('0x87')][_0xbd1e('0x34')](_0x45698c));}return BPromise['all'](_0x115abd);}})[_0xbd1e('0x25')](function(){return _0x1f0106;})[_0xbd1e('0x25')](respondWithResult(_0x3ec647,null))['catch'](handleError(_0x3ec647,null));};exports[_0xbd1e('0x8d')]=function(_0x5b067b,_0x2f1241,_0x496831){return db['Campaign']['find']({'where':{'id':_0x5b067b[_0xbd1e('0x46')]['id']}})[_0xbd1e('0x25')](handleEntityNotFound(_0x2f1241,null))[_0xbd1e('0x25')](function(_0x239f99){if(_0x239f99){return _0x239f99[_0xbd1e('0x8d')](_0x5b067b[_0xbd1e('0x34')][_0xbd1e('0x66')]);}})['then'](function(_0x52c166){if(_0x52c166){return db[_0xbd1e('0x61')][_0xbd1e('0x26')]({'where':{'ListId':_0x5b067b[_0xbd1e('0x34')][_0xbd1e('0x66')],'CampaignId':_0x5b067b[_0xbd1e('0x46')]['id']}})['then'](function(){return _0x52c166;});}})[_0xbd1e('0x25')](respondWithStatusCode(_0x2f1241,null))['catch'](handleError(_0x2f1241,null));};
\ No newline at end of file