Built motion from commit b5996064.|2.6.21
[motion2.git] / server / api / campaign / campaign.controller.js
index 6b5b243..d3b3fa1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x74ec=['CampaignId\x20=\x20?','onlyIfOpen','into','fromQuery','ContactId','push','all','removeLists','getBlackLists','addBlackLists','cm_hopper_black','sequelize','removeBlackLists','eml-format','moment','bluebird','mustache','path','to-csv','ejs','fs-extra','lodash','crypto','desk.js','querystring','papaparse','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','end','status','json','offset','undefined','limit','count','Content-Range','apply','reject','update','then','destroy','UserProfileResource','sendStatus','error','stack','name','send','map','Campaign','fieldName','type','model','query','keys','filters','intersection','attributes','length','hasOwnProperty','order','sort','where','pick','filter','merge','options','rawAttributes','fields','includeAll','include','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','autoAssociation','clone','params','omit','createdAt','updatedAt','IvrCampaigns','userProfileId','getHoppers','nolimit','CampaignId','CmHopper','rows','getHopperHistories','findOne','CmHopperHistory','findAll','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getLists','CmList','addLists','ids','spread','dialCheckDuplicateType','always','insert','scheduledAt','ListId','select','phone','field','NOW()','toString','from','cm_contacts','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','CmListId','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','COALESCE(calleridnum,\x27\x27)','COALESCE(phone,\x27\x27)','cm_hopper'];(function(_0x465fa3,_0x16ac1e){var _0x5ccce6=function(_0x55fac4){while(--_0x55fac4){_0x465fa3['push'](_0x465fa3['shift']());}};_0x5ccce6(++_0x16ac1e);}(_0x74ec,0x113));var _0xc74e=function(_0x333243,_0x3883df){_0x333243=_0x333243-0x0;var _0x11a7b6=_0x74ec[_0x333243];return _0x11a7b6;};'use strict';var emlformat=require(_0xc74e('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xc74e('0x1'));var BPromise=require(_0xc74e('0x2'));var Mustache=require(_0xc74e('0x3'));var util=require('util');var path=require(_0xc74e('0x4'));var sox=require('sox');var csv=require(_0xc74e('0x5'));var ejs=require(_0xc74e('0x6'));var fs=require('fs');var fs_extra=require(_0xc74e('0x7'));var _=require(_0xc74e('0x8'));var squel=require('squel');var crypto=require(_0xc74e('0x9'));var jsforce=require('jsforce');var deskjs=require(_0xc74e('0xa'));var toCsv=require(_0xc74e('0x5'));var querystring=require(_0xc74e('0xb'));var Papa=require(_0xc74e('0xc'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xc74e('0xd'));var hardwareService=require(_0xc74e('0xe'));var logger=require(_0xc74e('0xf'))(_0xc74e('0x10'));var utils=require(_0xc74e('0x11'));var config=require(_0xc74e('0x12'));var licenseUtil=require(_0xc74e('0x13'));var db=require(_0xc74e('0x14'))['db'];function respondWithStatusCode(_0x14beba,_0x354865){_0x354865=_0x354865||0xcc;return function(_0xb56077){if(_0xb56077){return _0x14beba['sendStatus'](_0x354865);}return _0x14beba['status'](_0x354865)[_0xc74e('0x15')]();};}function respondWithResult(_0x554f3e,_0xcadefb){_0xcadefb=_0xcadefb||0xc8;return function(_0x11c1c8){if(_0x11c1c8){return _0x554f3e[_0xc74e('0x16')](_0xcadefb)[_0xc74e('0x17')](_0x11c1c8);}};}function respondWithFilteredResult(_0x22bea6,_0x11e685){return function(_0x27f6ea){if(_0x27f6ea){var _0x4cc858=typeof _0x11e685[_0xc74e('0x18')]===_0xc74e('0x19')&&typeof _0x11e685[_0xc74e('0x1a')]===_0xc74e('0x19');var _0x1cb927=_0x27f6ea[_0xc74e('0x1b')];var _0x258518=_0x4cc858?0x0:_0x11e685[_0xc74e('0x18')];var _0x40962a=_0x4cc858?_0x27f6ea[_0xc74e('0x1b')]:_0x11e685['offset']+_0x11e685[_0xc74e('0x1a')];var _0x5d49af;if(_0x40962a>=_0x1cb927){_0x40962a=_0x1cb927;_0x5d49af=0xc8;}else{_0x5d49af=0xce;}_0x22bea6[_0xc74e('0x16')](_0x5d49af);return _0x22bea6['set'](_0xc74e('0x1c'),_0x258518+'-'+_0x40962a+'/'+_0x1cb927)[_0xc74e('0x17')](_0x27f6ea);}return null;};}function patchUpdates(_0x2e51da){return function(_0x1ea07d){try{jsonpatch[_0xc74e('0x1d')](_0x1ea07d,_0x2e51da,!![]);}catch(_0x24c991){return BPromise[_0xc74e('0x1e')](_0x24c991);}return _0x1ea07d['save']();};}function saveUpdates(_0x54c937,_0x43eebc){return function(_0x1a516f){if(_0x1a516f){return _0x1a516f[_0xc74e('0x1f')](_0x54c937)[_0xc74e('0x20')](function(_0x66e4f4){return _0x66e4f4;});}return null;};}function removeEntity(_0x3a3147,_0x35e824){return function(_0x2ad924){if(_0x2ad924){return _0x2ad924[_0xc74e('0x21')]()[_0xc74e('0x20')](function(){var _0x5aee6c=_0x2ad924['get']({'plain':!![]});var _0x109aab='IvrCampaigns';return db[_0xc74e('0x22')][_0xc74e('0x21')]({'where':{'type':_0x109aab,'resourceId':_0x5aee6c['id']}})[_0xc74e('0x20')](function(){return _0x2ad924;});})[_0xc74e('0x20')](function(){_0x3a3147[_0xc74e('0x16')](0xcc)[_0xc74e('0x15')]();});}};}function handleEntityNotFound(_0x3fb32a,_0x363fb6){return function(_0x3eeccc){if(!_0x3eeccc){_0x3fb32a[_0xc74e('0x23')](0x194);}return _0x3eeccc;};}function handleError(_0x4bf807,_0x28158b){_0x28158b=_0x28158b||0x1f4;return function(_0x54eeb8){logger[_0xc74e('0x24')](_0x54eeb8[_0xc74e('0x25')]);if(_0x54eeb8['name']){delete _0x54eeb8[_0xc74e('0x26')];}_0x4bf807[_0xc74e('0x16')](_0x28158b)[_0xc74e('0x27')](_0x54eeb8);};}exports['index']=function(_0x27035c,_0x4af01a){var _0x3733f8={},_0x1ece80={},_0x1354af={'count':0x0,'rows':[]};var _0x113a63=_[_0xc74e('0x28')](db[_0xc74e('0x29')]['rawAttributes'],function(_0x500ebc){return{'name':_0x500ebc[_0xc74e('0x2a')],'type':_0x500ebc[_0xc74e('0x2b')]['key']};});_0x1ece80[_0xc74e('0x2c')]=_[_0xc74e('0x28')](_0x113a63,_0xc74e('0x26'));_0x1ece80[_0xc74e('0x2d')]=_[_0xc74e('0x2e')](_0x27035c[_0xc74e('0x2d')]);_0x1ece80[_0xc74e('0x2f')]=_[_0xc74e('0x30')](_0x1ece80['model'],_0x1ece80[_0xc74e('0x2d')]);_0x3733f8[_0xc74e('0x31')]=_[_0xc74e('0x30')](_0x1ece80['model'],qs['fields'](_0x27035c[_0xc74e('0x2d')]['fields']));_0x3733f8[_0xc74e('0x31')]=_0x3733f8[_0xc74e('0x31')][_0xc74e('0x32')]?_0x3733f8[_0xc74e('0x31')]:_0x1ece80['model'];if(!_0x27035c[_0xc74e('0x2d')][_0xc74e('0x33')]('nolimit')){_0x3733f8[_0xc74e('0x1a')]=qs[_0xc74e('0x1a')](_0x27035c[_0xc74e('0x2d')]['limit']);_0x3733f8[_0xc74e('0x18')]=qs['offset'](_0x27035c[_0xc74e('0x2d')][_0xc74e('0x18')]);}_0x3733f8[_0xc74e('0x34')]=qs[_0xc74e('0x35')](_0x27035c[_0xc74e('0x2d')][_0xc74e('0x35')]);_0x3733f8[_0xc74e('0x36')]=qs[_0xc74e('0x2f')](_[_0xc74e('0x37')](_0x27035c[_0xc74e('0x2d')],_0x1ece80[_0xc74e('0x2f')]),_0x113a63);if(_0x27035c[_0xc74e('0x2d')][_0xc74e('0x38')]){_0x3733f8['where']=_[_0xc74e('0x39')](_0x3733f8['where'],{'$or':_['map'](_0x113a63,function(_0x18ad53){if(_0x18ad53[_0xc74e('0x2b')]!=='VIRTUAL'){var _0x1200ae={};_0x1200ae[_0x18ad53[_0xc74e('0x26')]]={'$like':'%'+_0x27035c['query'][_0xc74e('0x38')]+'%'};return _0x1200ae;}})});}_0x3733f8=_[_0xc74e('0x39')]({},_0x3733f8,_0x27035c[_0xc74e('0x3a')]);var _0x37a2fc={'where':_0x3733f8[_0xc74e('0x36')]};return db[_0xc74e('0x29')][_0xc74e('0x1b')](_0x37a2fc)[_0xc74e('0x20')](function(_0x3087b7){_0x1354af[_0xc74e('0x1b')]=_0x3087b7;if(_0x27035c[_0xc74e('0x2d')]['includeAll']){_0x3733f8['include']=[{'all':!![]}];}return db[_0xc74e('0x29')]['findAll'](_0x3733f8);})['then'](function(_0x3a0443){_0x1354af['rows']=_0x3a0443;return _0x1354af;})[_0xc74e('0x20')](respondWithFilteredResult(_0x4af01a,_0x3733f8))['catch'](handleError(_0x4af01a,null));};exports['show']=function(_0x335e43,_0x4f8e71){var _0xef1bf0={'raw':![],'where':{'id':_0x335e43['params']['id']}},_0x59197f={};_0x59197f[_0xc74e('0x2c')]=_[_0xc74e('0x2e')](db[_0xc74e('0x29')][_0xc74e('0x3b')]);_0x59197f[_0xc74e('0x2d')]=_['keys'](_0x335e43['query']);_0x59197f[_0xc74e('0x2f')]=_[_0xc74e('0x30')](_0x59197f[_0xc74e('0x2c')],_0x59197f[_0xc74e('0x2d')]);_0xef1bf0[_0xc74e('0x31')]=_['intersection'](_0x59197f[_0xc74e('0x2c')],qs[_0xc74e('0x3c')](_0x335e43[_0xc74e('0x2d')]['fields']));_0xef1bf0[_0xc74e('0x31')]=_0xef1bf0['attributes'][_0xc74e('0x32')]?_0xef1bf0[_0xc74e('0x31')]:_0x59197f['model'];if(_0x335e43['query'][_0xc74e('0x3d')]){_0xef1bf0[_0xc74e('0x3e')]=[{'all':!![]}];}_0xef1bf0=_[_0xc74e('0x39')]({},_0xef1bf0,_0x335e43['options']);return db['Campaign']['find'](_0xef1bf0)[_0xc74e('0x20')](handleEntityNotFound(_0x4f8e71,null))[_0xc74e('0x20')](respondWithResult(_0x4f8e71,null))[_0xc74e('0x3f')](handleError(_0x4f8e71,null));};exports[_0xc74e('0x40')]=function(_0x244ad7,_0x3e655d){return db[_0xc74e('0x29')][_0xc74e('0x40')](_0x244ad7[_0xc74e('0x41')],{})[_0xc74e('0x20')](function(_0x4c9b6c){var _0x5d94ce=_0x244ad7[_0xc74e('0x42')][_0xc74e('0x43')]({'plain':!![]});if(!_0x5d94ce)throw new Error(_0xc74e('0x44'));if(_0x5d94ce[_0xc74e('0x45')]==='user'){var _0x522b47=_0x4c9b6c[_0xc74e('0x43')]({'plain':!![]});var _0x28f901='IvrCampaigns';return db[_0xc74e('0x46')][_0xc74e('0x47')]({'where':{'name':_0x28f901,'userProfileId':_0x5d94ce['userProfileId']},'raw':!![]})['then'](function(_0x40c8b7){if(_0x40c8b7&&_0x40c8b7[_0xc74e('0x48')]===0x0){return db[_0xc74e('0x22')][_0xc74e('0x40')]({'name':_0x522b47[_0xc74e('0x26')],'resourceId':_0x522b47['id'],'type':_0x40c8b7['name'],'sectionId':_0x40c8b7['id']},{})[_0xc74e('0x20')](function(){return _0x4c9b6c;});}else{return _0x4c9b6c;}})[_0xc74e('0x3f')](function(_0x548e63){logger[_0xc74e('0x24')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x548e63);throw _0x548e63;});}return _0x4c9b6c;})[_0xc74e('0x20')](respondWithResult(_0x3e655d,0xc9))[_0xc74e('0x3f')](handleError(_0x3e655d,null));};exports[_0xc74e('0x49')]=function(_0x44896a,_0x22c8a6){var _0x4d0631={'where':{'id':_0x44896a[_0xc74e('0x4a')]['id']}},_0x4137e1={};_0x4137e1['model']=_[_0xc74e('0x2e')](db[_0xc74e('0x29')]['rawAttributes']);_0x4d0631[_0xc74e('0x31')]=_[_0xc74e('0x30')](_0x4137e1[_0xc74e('0x2c')],qs[_0xc74e('0x3c')](_0x44896a[_0xc74e('0x2d')][_0xc74e('0x3c')]));_0x4d0631[_0xc74e('0x31')]=_0x4d0631[_0xc74e('0x31')][_0xc74e('0x32')]?_0x4d0631[_0xc74e('0x31')]:_0x4137e1['model'];if(_0x44896a['query']['includeAll']){_0x4d0631['include']=[{'all':!![]}];}_0x4d0631=_['merge']({},_0x4d0631,_0x44896a[_0xc74e('0x3a')]);return db['Campaign']['find'](_0x4d0631)['then'](handleEntityNotFound(_0x22c8a6,null))[_0xc74e('0x20')](function(_0xd59384){if(_0xd59384){var _0x36f0af=_0xd59384['get']({'plain':!![]});_0x36f0af=qs[_0xc74e('0x4b')](_0x36f0af,['id',_0xc74e('0x4c'),_0xc74e('0x4d')]);_0x44896a[_0xc74e('0x41')]=_[_0xc74e('0x4b')](_0x44896a[_0xc74e('0x41')],['id',_0xc74e('0x4c'),_0xc74e('0x4d')]);return db[_0xc74e('0x29')][_0xc74e('0x40')](_[_0xc74e('0x39')](_0x36f0af,_0x44896a[_0xc74e('0x41')]),{'include':_0x44896a[_0xc74e('0x2d')][_0xc74e('0x3d')]?[{'all':!![]}]:undefined})[_0xc74e('0x20')](function(_0x2a36e2){var _0x172687=_0x44896a[_0xc74e('0x42')][_0xc74e('0x43')]({'plain':!![]});if(!_0x172687)throw new Error(_0xc74e('0x44'));if(_0x172687[_0xc74e('0x45')]===_0xc74e('0x42')){var _0x42f84a=_0x2a36e2[_0xc74e('0x43')]({'plain':!![]});var _0x35fef3=_0xc74e('0x4e');return db[_0xc74e('0x46')][_0xc74e('0x47')]({'where':{'name':_0x35fef3,'userProfileId':_0x172687[_0xc74e('0x4f')]},'raw':!![]})[_0xc74e('0x20')](function(_0x447066){if(_0x447066&&_0x447066[_0xc74e('0x48')]===0x0){return db[_0xc74e('0x22')]['create']({'name':_0x42f84a['name'],'resourceId':_0x42f84a['id'],'type':_0x447066[_0xc74e('0x26')],'sectionId':_0x447066['id']},{})[_0xc74e('0x20')](function(){return _0x2a36e2;});}else{return _0x2a36e2;}})[_0xc74e('0x3f')](function(_0x5ef3e4){logger[_0xc74e('0x24')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x5ef3e4);throw _0x5ef3e4;});}return _0x2a36e2;});}})[_0xc74e('0x20')](respondWithResult(_0x22c8a6,0xc9))['catch'](handleError(_0x22c8a6,null));};exports[_0xc74e('0x1f')]=function(_0x48990f,_0x2317e5){if(_0x48990f[_0xc74e('0x41')]['id']){delete _0x48990f[_0xc74e('0x41')]['id'];}return db[_0xc74e('0x29')][_0xc74e('0x47')]({'where':{'id':_0x48990f[_0xc74e('0x4a')]['id']}})[_0xc74e('0x20')](handleEntityNotFound(_0x2317e5,null))[_0xc74e('0x20')](saveUpdates(_0x48990f[_0xc74e('0x41')],null))[_0xc74e('0x20')](respondWithResult(_0x2317e5,null))['catch'](handleError(_0x2317e5,null));};exports[_0xc74e('0x21')]=function(_0x376fde,_0x195bd0){return db['Campaign'][_0xc74e('0x47')]({'where':{'id':_0x376fde[_0xc74e('0x4a')]['id']}})[_0xc74e('0x20')](handleEntityNotFound(_0x195bd0,null))[_0xc74e('0x20')](removeEntity(_0x195bd0,null))[_0xc74e('0x3f')](handleError(_0x195bd0,null));};exports[_0xc74e('0x50')]=function(_0x5053ad,_0x43b00f,_0x20c16c){var _0x355d5b={'raw':!![],'where':{}};var _0x3644b0={};var _0x2f081b={'count':0x0,'rows':[]};return db[_0xc74e('0x29')]['findOne']({'where':{'id':_0x5053ad['params']['id']}})[_0xc74e('0x20')](handleEntityNotFound(_0x43b00f,null))[_0xc74e('0x20')](function(_0x1eeaa5){if(_0x1eeaa5){_0x3644b0[_0xc74e('0x2c')]=_[_0xc74e('0x2e')](db['CmHopper'][_0xc74e('0x3b')]);_0x3644b0[_0xc74e('0x2d')]=_[_0xc74e('0x2e')](_0x5053ad[_0xc74e('0x2d')]);_0x3644b0[_0xc74e('0x2f')]=_[_0xc74e('0x30')](_0x3644b0['model'],_0x3644b0[_0xc74e('0x2d')]);_0x355d5b['attributes']=_['intersection'](_0x3644b0['model'],qs[_0xc74e('0x3c')](_0x5053ad['query'][_0xc74e('0x3c')]));_0x355d5b['attributes']=_0x355d5b['attributes'][_0xc74e('0x32')]?_0x355d5b[_0xc74e('0x31')]:_0x3644b0[_0xc74e('0x2c')];if(!_0x5053ad['query'][_0xc74e('0x33')](_0xc74e('0x51'))){_0x355d5b['limit']=qs[_0xc74e('0x1a')](_0x5053ad[_0xc74e('0x2d')]['limit']);_0x355d5b['offset']=qs[_0xc74e('0x18')](_0x5053ad[_0xc74e('0x2d')][_0xc74e('0x18')]);}_0x355d5b[_0xc74e('0x34')]=qs[_0xc74e('0x35')](_0x5053ad[_0xc74e('0x2d')][_0xc74e('0x35')]);_0x355d5b[_0xc74e('0x36')]=qs[_0xc74e('0x2f')](_[_0xc74e('0x37')](_0x5053ad[_0xc74e('0x2d')],_0x3644b0[_0xc74e('0x2f')]));_0x355d5b[_0xc74e('0x36')][_0xc74e('0x52')]=_0x1eeaa5['id'];if(_0x5053ad[_0xc74e('0x2d')][_0xc74e('0x38')]){_0x355d5b[_0xc74e('0x36')]=_[_0xc74e('0x39')](_0x355d5b[_0xc74e('0x36')],{'$or':_[_0xc74e('0x28')](_0x355d5b[_0xc74e('0x31')],function(_0x293a30){var _0x248f55={};_0x248f55[_0x293a30]={'$like':'%'+_0x5053ad[_0xc74e('0x2d')][_0xc74e('0x38')]+'%'};return _0x248f55;})});}_0x355d5b=_[_0xc74e('0x39')]({},_0x355d5b,_0x5053ad[_0xc74e('0x3a')]);return db[_0xc74e('0x53')][_0xc74e('0x1b')]({'where':_0x355d5b['where']})['then'](function(_0x1832e6){_0x2f081b['count']=_0x1832e6;if(_0x5053ad[_0xc74e('0x2d')][_0xc74e('0x3d')]){_0x355d5b[_0xc74e('0x3e')]=[{'all':!![]}];}return db[_0xc74e('0x53')]['findAll'](_0x355d5b);})[_0xc74e('0x20')](function(_0x4f3fb8){_0x2f081b[_0xc74e('0x54')]=_0x4f3fb8;return _0x2f081b;});}})['then'](respondWithFilteredResult(_0x43b00f,_0x355d5b))['catch'](handleError(_0x43b00f,null));};exports[_0xc74e('0x55')]=function(_0x457e3d,_0x589728,_0x26d693){var _0x1611a7={'raw':!![],'where':{}};var _0x6cb672={};var _0x1a7197={'count':0x0,'rows':[]};return db[_0xc74e('0x29')][_0xc74e('0x56')]({'where':{'id':_0x457e3d[_0xc74e('0x4a')]['id']}})[_0xc74e('0x20')](handleEntityNotFound(_0x589728,null))[_0xc74e('0x20')](function(_0x3ce8e5){if(_0x3ce8e5){_0x6cb672[_0xc74e('0x2c')]=_[_0xc74e('0x2e')](db[_0xc74e('0x57')][_0xc74e('0x3b')]);_0x6cb672['query']=_[_0xc74e('0x2e')](_0x457e3d[_0xc74e('0x2d')]);_0x6cb672[_0xc74e('0x2f')]=_[_0xc74e('0x30')](_0x6cb672[_0xc74e('0x2c')],_0x6cb672[_0xc74e('0x2d')]);_0x1611a7[_0xc74e('0x31')]=_['intersection'](_0x6cb672[_0xc74e('0x2c')],qs['fields'](_0x457e3d[_0xc74e('0x2d')][_0xc74e('0x3c')]));_0x1611a7[_0xc74e('0x31')]=_0x1611a7['attributes']['length']?_0x1611a7['attributes']:_0x6cb672[_0xc74e('0x2c')];if(!_0x457e3d[_0xc74e('0x2d')][_0xc74e('0x33')]('nolimit')){_0x1611a7['limit']=qs['limit'](_0x457e3d[_0xc74e('0x2d')]['limit']);_0x1611a7[_0xc74e('0x18')]=qs[_0xc74e('0x18')](_0x457e3d['query'][_0xc74e('0x18')]);}_0x1611a7[_0xc74e('0x34')]=qs[_0xc74e('0x35')](_0x457e3d[_0xc74e('0x2d')]['sort']);_0x1611a7[_0xc74e('0x36')]=qs[_0xc74e('0x2f')](_[_0xc74e('0x37')](_0x457e3d[_0xc74e('0x2d')],_0x6cb672[_0xc74e('0x2f')]));_0x1611a7[_0xc74e('0x36')][_0xc74e('0x52')]=_0x3ce8e5['id'];if(_0x457e3d['query'][_0xc74e('0x38')]){_0x1611a7[_0xc74e('0x36')]=_[_0xc74e('0x39')](_0x1611a7[_0xc74e('0x36')],{'$or':_[_0xc74e('0x28')](_0x1611a7[_0xc74e('0x31')],function(_0x471495){var _0x237a2b={};_0x237a2b[_0x471495]={'$like':'%'+_0x457e3d['query'][_0xc74e('0x38')]+'%'};return _0x237a2b;})});}_0x1611a7=_[_0xc74e('0x39')]({},_0x1611a7,_0x457e3d['options']);return db['CmHopperHistory']['count']({'where':_0x1611a7[_0xc74e('0x36')]})[_0xc74e('0x20')](function(_0x42fb78){_0x1a7197['count']=_0x42fb78;if(_0x457e3d[_0xc74e('0x2d')][_0xc74e('0x3d')]){_0x1611a7[_0xc74e('0x3e')]=[{'all':!![]}];}return db[_0xc74e('0x57')][_0xc74e('0x58')](_0x1611a7);})[_0xc74e('0x20')](function(_0xfe4444){_0x1a7197['rows']=_0xfe4444;return _0x1a7197;});}})[_0xc74e('0x20')](respondWithFilteredResult(_0x589728,_0x1611a7))[_0xc74e('0x3f')](handleError(_0x589728,null));};exports[_0xc74e('0x59')]=function(_0x4b17cb,_0x6dc8b0,_0x5de45c){var _0x31645c={'raw':!![],'where':{}};var _0x5716cb={};var _0x37d8c4={'count':0x0,'rows':[]};return db[_0xc74e('0x29')]['findOne']({'where':{'id':_0x4b17cb['params']['id']}})['then'](handleEntityNotFound(_0x6dc8b0,null))['then'](function(_0x1799df){if(_0x1799df){_0x5716cb[_0xc74e('0x2c')]=_[_0xc74e('0x2e')](db[_0xc74e('0x5a')][_0xc74e('0x3b')]);_0x5716cb['query']=_[_0xc74e('0x2e')](_0x4b17cb[_0xc74e('0x2d')]);_0x5716cb['filters']=_[_0xc74e('0x30')](_0x5716cb[_0xc74e('0x2c')],_0x5716cb['query']);_0x31645c[_0xc74e('0x31')]=_[_0xc74e('0x30')](_0x5716cb[_0xc74e('0x2c')],qs[_0xc74e('0x3c')](_0x4b17cb[_0xc74e('0x2d')]['fields']));_0x31645c[_0xc74e('0x31')]=_0x31645c[_0xc74e('0x31')]['length']?_0x31645c[_0xc74e('0x31')]:_0x5716cb[_0xc74e('0x2c')];if(!_0x4b17cb['query']['hasOwnProperty']('nolimit')){_0x31645c[_0xc74e('0x1a')]=qs[_0xc74e('0x1a')](_0x4b17cb['query'][_0xc74e('0x1a')]);_0x31645c[_0xc74e('0x18')]=qs[_0xc74e('0x18')](_0x4b17cb[_0xc74e('0x2d')][_0xc74e('0x18')]);}_0x31645c[_0xc74e('0x34')]=qs['sort'](_0x4b17cb[_0xc74e('0x2d')][_0xc74e('0x35')]);_0x31645c[_0xc74e('0x36')]=qs[_0xc74e('0x2f')](_['pick'](_0x4b17cb[_0xc74e('0x2d')],_0x5716cb[_0xc74e('0x2f')]));_0x31645c[_0xc74e('0x36')]['CampaignId']=_0x1799df['id'];if(_0x4b17cb[_0xc74e('0x2d')][_0xc74e('0x38')]){_0x31645c['where']=_['merge'](_0x31645c['where'],{'$or':_[_0xc74e('0x28')](_0x31645c['attributes'],function(_0x2daad0){var _0x20e1c9={};_0x20e1c9[_0x2daad0]={'$like':'%'+_0x4b17cb['query'][_0xc74e('0x38')]+'%'};return _0x20e1c9;})});}_0x31645c=_[_0xc74e('0x39')]({},_0x31645c,_0x4b17cb[_0xc74e('0x3a')]);return db['CmHopperFinal']['count']({'where':_0x31645c[_0xc74e('0x36')]})[_0xc74e('0x20')](function(_0x27206b){_0x37d8c4[_0xc74e('0x1b')]=_0x27206b;if(_0x4b17cb[_0xc74e('0x2d')]['includeAll']){_0x31645c[_0xc74e('0x3e')]=[{'all':!![]}];}return db[_0xc74e('0x5a')][_0xc74e('0x58')](_0x31645c);})['then'](function(_0x30bd44){_0x37d8c4[_0xc74e('0x54')]=_0x30bd44;return _0x37d8c4;});}})['then'](respondWithFilteredResult(_0x6dc8b0,_0x31645c))[_0xc74e('0x3f')](handleError(_0x6dc8b0,null));};exports[_0xc74e('0x5b')]=function(_0x84eecc,_0x4f1de0,_0xeffaa3){var _0x457267={'raw':!![],'where':{}};var _0x3d7fb7={};var _0x13e983={'count':0x0,'rows':[]};return db[_0xc74e('0x29')]['findOne']({'where':{'id':_0x84eecc[_0xc74e('0x4a')]['id']}})[_0xc74e('0x20')](handleEntityNotFound(_0x4f1de0,null))['then'](function(_0x1a9aa6){if(_0x1a9aa6){_0x3d7fb7[_0xc74e('0x2c')]=_[_0xc74e('0x2e')](db[_0xc74e('0x5c')][_0xc74e('0x3b')]);_0x3d7fb7['query']=_[_0xc74e('0x2e')](_0x84eecc[_0xc74e('0x2d')]);_0x3d7fb7[_0xc74e('0x2f')]=_['intersection'](_0x3d7fb7['model'],_0x3d7fb7['query']);_0x457267[_0xc74e('0x31')]=_[_0xc74e('0x30')](_0x3d7fb7[_0xc74e('0x2c')],qs[_0xc74e('0x3c')](_0x84eecc[_0xc74e('0x2d')]['fields']));_0x457267['attributes']=_0x457267[_0xc74e('0x31')][_0xc74e('0x32')]?_0x457267['attributes']:_0x3d7fb7[_0xc74e('0x2c')];if(!_0x84eecc[_0xc74e('0x2d')][_0xc74e('0x33')](_0xc74e('0x51'))){_0x457267['limit']=qs['limit'](_0x84eecc[_0xc74e('0x2d')][_0xc74e('0x1a')]);_0x457267[_0xc74e('0x18')]=qs[_0xc74e('0x18')](_0x84eecc[_0xc74e('0x2d')]['offset']);}_0x457267[_0xc74e('0x34')]=qs['sort'](_0x84eecc[_0xc74e('0x2d')][_0xc74e('0x35')]);_0x457267['where']=qs[_0xc74e('0x2f')](_['pick'](_0x84eecc[_0xc74e('0x2d')],_0x3d7fb7['filters']));_0x457267[_0xc74e('0x36')]['CampaignId']=_0x1a9aa6['id'];if(_0x84eecc[_0xc74e('0x2d')][_0xc74e('0x38')]){_0x457267[_0xc74e('0x36')]=_[_0xc74e('0x39')](_0x457267[_0xc74e('0x36')],{'$or':_[_0xc74e('0x28')](_0x457267[_0xc74e('0x31')],function(_0x5c398b){var _0x5e110f={};_0x5e110f[_0x5c398b]={'$like':'%'+_0x84eecc['query']['filter']+'%'};return _0x5e110f;})});}_0x457267=_['merge']({},_0x457267,_0x84eecc[_0xc74e('0x3a')]);return db[_0xc74e('0x5c')][_0xc74e('0x1b')]({'where':_0x457267[_0xc74e('0x36')]})[_0xc74e('0x20')](function(_0x1a38ce){_0x13e983[_0xc74e('0x1b')]=_0x1a38ce;if(_0x84eecc['query']['includeAll']){_0x457267[_0xc74e('0x3e')]=[{'all':!![]}];}return db[_0xc74e('0x5c')][_0xc74e('0x58')](_0x457267);})[_0xc74e('0x20')](function(_0x977926){_0x13e983[_0xc74e('0x54')]=_0x977926;return _0x13e983;});}})[_0xc74e('0x20')](respondWithFilteredResult(_0x4f1de0,_0x457267))['catch'](handleError(_0x4f1de0,null));};exports[_0xc74e('0x5d')]=function(_0xe3518c,_0x15073c,_0x2d9e19){var _0x349faa={};var _0x59c88c={};var _0x4c5e48;var _0x3becb0;return db['Campaign'][_0xc74e('0x56')]({'where':{'id':_0xe3518c[_0xc74e('0x4a')]['id']}})[_0xc74e('0x20')](handleEntityNotFound(_0x15073c,null))['then'](function(_0x39a5c7){if(_0x39a5c7){_0x4c5e48=_0x39a5c7;_0x59c88c[_0xc74e('0x2c')]=_[_0xc74e('0x2e')](db[_0xc74e('0x5e')][_0xc74e('0x3b')]);_0x59c88c['query']=_['keys'](_0xe3518c[_0xc74e('0x2d')]);_0x59c88c['filters']=_[_0xc74e('0x30')](_0x59c88c['model'],_0x59c88c[_0xc74e('0x2d')]);_0x349faa['attributes']=_[_0xc74e('0x30')](_0x59c88c[_0xc74e('0x2c')],qs[_0xc74e('0x3c')](_0xe3518c[_0xc74e('0x2d')]['fields']));_0x349faa['attributes']=_0x349faa[_0xc74e('0x31')][_0xc74e('0x32')]?_0x349faa['attributes']:_0x59c88c[_0xc74e('0x2c')];_0x349faa[_0xc74e('0x34')]=qs[_0xc74e('0x35')](_0xe3518c['query'][_0xc74e('0x35')]);_0x349faa[_0xc74e('0x36')]=qs['filters'](_['pick'](_0xe3518c[_0xc74e('0x2d')],_0x59c88c[_0xc74e('0x2f')]));if(_0xe3518c[_0xc74e('0x2d')]['filter']){_0x349faa[_0xc74e('0x36')]=_['merge'](_0x349faa[_0xc74e('0x36')],{'$or':_[_0xc74e('0x28')](_0x349faa['attributes'],function(_0x907098){var _0x2ab86f={};_0x2ab86f[_0x907098]={'$like':'%'+_0xe3518c[_0xc74e('0x2d')][_0xc74e('0x38')]+'%'};return _0x2ab86f;})});}_0x349faa=_[_0xc74e('0x39')]({},_0x349faa,_0xe3518c[_0xc74e('0x3a')]);return _0x4c5e48[_0xc74e('0x5d')](_0x349faa);}})[_0xc74e('0x20')](function(_0x3e146a){if(_0x3e146a){_0x3becb0=_0x3e146a[_0xc74e('0x32')];if(!_0xe3518c['query']['hasOwnProperty']('nolimit')){_0x349faa['limit']=qs[_0xc74e('0x1a')](_0xe3518c[_0xc74e('0x2d')]['limit']);_0x349faa[_0xc74e('0x18')]=qs['offset'](_0xe3518c[_0xc74e('0x2d')]['offset']);}return _0x4c5e48['getLists'](_0x349faa);}})[_0xc74e('0x20')](function(_0xf4e71c){if(_0xf4e71c){return _0xf4e71c?{'count':_0x3becb0,'rows':_0xf4e71c}:null;}})[_0xc74e('0x20')](respondWithResult(_0x15073c,null))[_0xc74e('0x3f')](handleError(_0x15073c,null));};exports['addLists']=function(_0x88c54d,_0x10ce76,_0x5a5efa){var _0x3d1965,_0x1c9fac;return db[_0xc74e('0x29')][_0xc74e('0x47')]({'where':{'id':_0x88c54d[_0xc74e('0x4a')]['id']}})[_0xc74e('0x20')](handleEntityNotFound(_0x10ce76,null))[_0xc74e('0x20')](function(_0x57d373){if(_0x57d373){_0x1c9fac=_0x57d373;return _0x57d373[_0xc74e('0x5f')](_0x88c54d[_0xc74e('0x41')][_0xc74e('0x60')],_[_0xc74e('0x4b')](_0x88c54d[_0xc74e('0x41')],[_0xc74e('0x60'),'id'])||{});}return null;})[_0xc74e('0x61')](function(_0x106fc2){var _0x3b0f5e;_0x3d1965=_0x106fc2||[];var _0x18395c=[];if(_0x106fc2){for(var _0x107cc5=0x0;_0x107cc5<_0x106fc2['length'];_0x107cc5+=0x1){var _0x424b18=_0x106fc2[_0x107cc5][_0xc74e('0x43')]({'plain':!![]});_0x1c9fac[_0xc74e('0x62')]=_0x88c54d['body'][_0xc74e('0x62')]?_0x88c54d[_0xc74e('0x41')]['dialCheckDuplicateType']:_0x1c9fac[_0xc74e('0x62')];switch(_0x1c9fac[_0xc74e('0x62')]){case _0xc74e('0x63'):_0x3b0f5e=squel[_0xc74e('0x64')]()['into']('cm_hopper')['fromQuery'](['phone',_0xc74e('0x65'),'ContactId',_0xc74e('0x66'),'CampaignId',_0xc74e('0x4c'),_0xc74e('0x4d')],squel[_0xc74e('0x67')]()['field']('phone',_0xc74e('0x68'))[_0xc74e('0x69')](_0xc74e('0x6a'),_0xc74e('0x65'))[_0xc74e('0x69')]('id','ContactId')[_0xc74e('0x69')](_0x424b18['CmListId']['toString'](),_0xc74e('0x66'))[_0xc74e('0x69')](_0x88c54d['params']['id'][_0xc74e('0x6b')](),'CampaignId')[_0xc74e('0x69')](_0xc74e('0x6a'),_0xc74e('0x4c'))[_0xc74e('0x69')](_0xc74e('0x6a'),'updatedAt')[_0xc74e('0x6c')](_0xc74e('0x6d'))[_0xc74e('0x36')](_0xc74e('0x6e'))[_0xc74e('0x36')](_0xc74e('0x6f'),_0x424b18[_0xc74e('0x70')]['toString']())[_0xc74e('0x36')](_0xc74e('0x71'))[_0xc74e('0x36')](_0xc74e('0x72'),squel[_0xc74e('0x67')]()[_0xc74e('0x69')](_0xc74e('0x73'))[_0xc74e('0x6c')]('cm_hopper_final')['where']('CampaignId\x20=\x20?',_0x88c54d[_0xc74e('0x4a')]['id'][_0xc74e('0x6b')]()))[_0xc74e('0x36')](_0xc74e('0x72'),squel['select']()[_0xc74e('0x69')](_0xc74e('0x74'))['from'](_0xc74e('0x75'))[_0xc74e('0x36')](_0xc74e('0x76'),_0x88c54d['params']['id'][_0xc74e('0x6b')]())))[_0xc74e('0x6b')]();break;case _0xc74e('0x77'):_0x3b0f5e=squel[_0xc74e('0x64')]()[_0xc74e('0x78')](_0xc74e('0x75'))[_0xc74e('0x79')](['phone',_0xc74e('0x65'),_0xc74e('0x7a'),_0xc74e('0x66'),_0xc74e('0x52'),_0xc74e('0x4c'),_0xc74e('0x4d')],squel[_0xc74e('0x67')]()[_0xc74e('0x69')](_0xc74e('0x68'),_0xc74e('0x68'))['field']('NOW()',_0xc74e('0x65'))[_0xc74e('0x69')]('id',_0xc74e('0x7a'))['field'](_0x424b18[_0xc74e('0x70')][_0xc74e('0x6b')](),'ListId')[_0xc74e('0x69')](_0x88c54d[_0xc74e('0x4a')]['id'][_0xc74e('0x6b')](),_0xc74e('0x52'))['field'](_0xc74e('0x6a'),_0xc74e('0x4c'))[_0xc74e('0x69')]('NOW()',_0xc74e('0x4d'))[_0xc74e('0x6c')](_0xc74e('0x6d'))[_0xc74e('0x36')]('deletedAt\x20IS\x20NULL')['where'](_0xc74e('0x6f'),_0x424b18[_0xc74e('0x70')][_0xc74e('0x6b')]())[_0xc74e('0x36')]('phone\x20IS\x20NOT\x20NULL')['where'](_0xc74e('0x72'),squel[_0xc74e('0x67')]()[_0xc74e('0x69')](_0xc74e('0x74'))[_0xc74e('0x6c')](_0xc74e('0x75'))['where'](_0xc74e('0x76'),_0x88c54d[_0xc74e('0x4a')]['id'][_0xc74e('0x6b')]())))['toString']();break;default:_0x3b0f5e=squel[_0xc74e('0x64')]()[_0xc74e('0x78')]('cm_hopper')[_0xc74e('0x79')]([_0xc74e('0x68'),_0xc74e('0x65'),_0xc74e('0x7a'),_0xc74e('0x66'),_0xc74e('0x52'),_0xc74e('0x4c'),_0xc74e('0x4d')],squel[_0xc74e('0x67')]()['field'](_0xc74e('0x68'),_0xc74e('0x68'))[_0xc74e('0x69')](_0xc74e('0x6a'),_0xc74e('0x65'))[_0xc74e('0x69')]('id',_0xc74e('0x7a'))['field'](_0x424b18[_0xc74e('0x70')]['toString'](),_0xc74e('0x66'))[_0xc74e('0x69')](_0x88c54d['params']['id'][_0xc74e('0x6b')](),_0xc74e('0x52'))[_0xc74e('0x69')]('NOW()',_0xc74e('0x4c'))[_0xc74e('0x69')]('NOW()',_0xc74e('0x4d'))[_0xc74e('0x6c')](_0xc74e('0x6d'))['where'](_0xc74e('0x6e'))['where'](_0xc74e('0x6f'),_0x424b18[_0xc74e('0x70')][_0xc74e('0x6b')]())[_0xc74e('0x36')](_0xc74e('0x71')))['toString']();}_0x18395c[_0xc74e('0x7b')](db['sequelize'][_0xc74e('0x2d')](_0x3b0f5e));}return BPromise[_0xc74e('0x7c')](_0x18395c);}})[_0xc74e('0x20')](function(){return _0x3d1965;})[_0xc74e('0x20')](respondWithResult(_0x10ce76,null))[_0xc74e('0x3f')](handleError(_0x10ce76,null));};exports[_0xc74e('0x7d')]=function(_0x1a6da7,_0x127998,_0x5483a8){return db['Campaign'][_0xc74e('0x47')]({'where':{'id':_0x1a6da7[_0xc74e('0x4a')]['id']}})[_0xc74e('0x20')](handleEntityNotFound(_0x127998,null))[_0xc74e('0x20')](function(_0xf8c10f){if(_0xf8c10f){return _0xf8c10f['removeLists'](_0x1a6da7[_0xc74e('0x2d')][_0xc74e('0x60')]);}})[_0xc74e('0x20')](function(_0x24f2da){if(_0x24f2da){return db[_0xc74e('0x53')][_0xc74e('0x21')]({'where':{'ListId':_0x1a6da7[_0xc74e('0x2d')][_0xc74e('0x60')],'CampaignId':_0x1a6da7[_0xc74e('0x4a')]['id']}})['then'](function(){return _0x24f2da;});}})[_0xc74e('0x20')](respondWithStatusCode(_0x127998,null))[_0xc74e('0x3f')](handleError(_0x127998,null));};exports[_0xc74e('0x7e')]=function(_0x5b2bf8,_0x15a139,_0x17be25){var _0x2ba161={};var _0x5d0ac2={};var _0x255466;var _0x2ddab3;return db[_0xc74e('0x29')][_0xc74e('0x56')]({'where':{'id':_0x5b2bf8[_0xc74e('0x4a')]['id']}})[_0xc74e('0x20')](handleEntityNotFound(_0x15a139,null))[_0xc74e('0x20')](function(_0x32be2b){if(_0x32be2b){_0x255466=_0x32be2b;_0x5d0ac2[_0xc74e('0x2c')]=_[_0xc74e('0x2e')](db['CmList'][_0xc74e('0x3b')]);_0x5d0ac2[_0xc74e('0x2d')]=_['keys'](_0x5b2bf8[_0xc74e('0x2d')]);_0x5d0ac2[_0xc74e('0x2f')]=_[_0xc74e('0x30')](_0x5d0ac2[_0xc74e('0x2c')],_0x5d0ac2[_0xc74e('0x2d')]);_0x2ba161[_0xc74e('0x31')]=_[_0xc74e('0x30')](_0x5d0ac2[_0xc74e('0x2c')],qs[_0xc74e('0x3c')](_0x5b2bf8[_0xc74e('0x2d')][_0xc74e('0x3c')]));_0x2ba161['attributes']=_0x2ba161[_0xc74e('0x31')][_0xc74e('0x32')]?_0x2ba161[_0xc74e('0x31')]:_0x5d0ac2[_0xc74e('0x2c')];_0x2ba161[_0xc74e('0x34')]=qs['sort'](_0x5b2bf8[_0xc74e('0x2d')][_0xc74e('0x35')]);_0x2ba161[_0xc74e('0x36')]=qs[_0xc74e('0x2f')](_[_0xc74e('0x37')](_0x5b2bf8[_0xc74e('0x2d')],_0x5d0ac2[_0xc74e('0x2f')]));if(_0x5b2bf8['query']['filter']){_0x2ba161[_0xc74e('0x36')]=_[_0xc74e('0x39')](_0x2ba161[_0xc74e('0x36')],{'$or':_['map'](_0x2ba161['attributes'],function(_0x20843e){var _0x57578e={};_0x57578e[_0x20843e]={'$like':'%'+_0x5b2bf8['query']['filter']+'%'};return _0x57578e;})});}_0x2ba161=_[_0xc74e('0x39')]({},_0x2ba161,_0x5b2bf8[_0xc74e('0x3a')]);return _0x255466['getBlackLists'](_0x2ba161);}})[_0xc74e('0x20')](function(_0x42a60d){if(_0x42a60d){_0x2ddab3=_0x42a60d[_0xc74e('0x32')];if(!_0x5b2bf8['query'][_0xc74e('0x33')](_0xc74e('0x51'))){_0x2ba161['limit']=qs[_0xc74e('0x1a')](_0x5b2bf8[_0xc74e('0x2d')][_0xc74e('0x1a')]);_0x2ba161[_0xc74e('0x18')]=qs[_0xc74e('0x18')](_0x5b2bf8[_0xc74e('0x2d')][_0xc74e('0x18')]);}return _0x255466['getBlackLists'](_0x2ba161);}})[_0xc74e('0x20')](function(_0x126923){if(_0x126923){return _0x126923?{'count':_0x2ddab3,'rows':_0x126923}:null;}})['then'](respondWithResult(_0x15a139,null))['catch'](handleError(_0x15a139,null));};exports[_0xc74e('0x7f')]=function(_0x474c35,_0x3fdd93,_0xf5692e){var _0x476895,_0x2a8ec1;return db[_0xc74e('0x29')][_0xc74e('0x47')]({'where':{'id':_0x474c35[_0xc74e('0x4a')]['id']}})[_0xc74e('0x20')](handleEntityNotFound(_0x3fdd93,null))['then'](function(_0x5a549d){if(_0x5a549d){_0x2a8ec1=_0x5a549d;return _0x5a549d[_0xc74e('0x7f')](_0x474c35[_0xc74e('0x41')][_0xc74e('0x60')],_['omit'](_0x474c35[_0xc74e('0x41')],[_0xc74e('0x60'),'id'])||{});}return null;})[_0xc74e('0x61')](function(_0x9c20b5){var _0x411c21;_0x476895=_0x9c20b5||[];var _0x479c04=[];if(_0x9c20b5){for(var _0x95cdc2=0x0;_0x95cdc2<_0x9c20b5[_0xc74e('0x32')];_0x95cdc2+=0x1){var _0x509443=_0x9c20b5[_0x95cdc2][_0xc74e('0x43')]({'plain':!![]});_0x411c21=squel[_0xc74e('0x64')]()[_0xc74e('0x78')](_0xc74e('0x80'))['fromQuery']([_0xc74e('0x68'),_0xc74e('0x7a'),'ListId','CampaignId','createdAt',_0xc74e('0x4d')],squel[_0xc74e('0x67')]()[_0xc74e('0x69')]('phone',_0xc74e('0x68'))[_0xc74e('0x69')]('id','ContactId')[_0xc74e('0x69')](_0x509443[_0xc74e('0x70')]['toString'](),_0xc74e('0x66'))[_0xc74e('0x69')](_0x474c35[_0xc74e('0x4a')]['id'][_0xc74e('0x6b')](),'CampaignId')[_0xc74e('0x69')](_0xc74e('0x6a'),_0xc74e('0x4c'))[_0xc74e('0x69')]('NOW()','updatedAt')[_0xc74e('0x6c')](_0xc74e('0x6d'))[_0xc74e('0x36')](_0xc74e('0x6e'))[_0xc74e('0x36')](_0xc74e('0x6f'),_0x509443['CmListId'][_0xc74e('0x6b')]())[_0xc74e('0x36')](_0xc74e('0x71')))[_0xc74e('0x6b')]();_0x479c04[_0xc74e('0x7b')](db[_0xc74e('0x81')][_0xc74e('0x2d')](_0x411c21));}return BPromise['all'](_0x479c04);}})[_0xc74e('0x20')](function(){return _0x476895;})[_0xc74e('0x20')](respondWithResult(_0x3fdd93,null))[_0xc74e('0x3f')](handleError(_0x3fdd93,null));};exports[_0xc74e('0x82')]=function(_0x3d3e2a,_0x5fbe52,_0x235515){return db['Campaign'][_0xc74e('0x47')]({'where':{'id':_0x3d3e2a[_0xc74e('0x4a')]['id']}})['then'](handleEntityNotFound(_0x5fbe52,null))[_0xc74e('0x20')](function(_0x4c7f11){if(_0x4c7f11){return _0x4c7f11['removeBlackLists'](_0x3d3e2a['query'][_0xc74e('0x60')]);}})['then'](function(_0x560b7e){if(_0x560b7e){return db[_0xc74e('0x5c')][_0xc74e('0x21')]({'where':{'ListId':_0x3d3e2a[_0xc74e('0x2d')][_0xc74e('0x60')],'CampaignId':_0x3d3e2a[_0xc74e('0x4a')]['id']}})[_0xc74e('0x20')](function(){return _0x560b7e;});}})['then'](respondWithStatusCode(_0x5fbe52,null))['catch'](handleError(_0x5fbe52,null));};
\ No newline at end of file
+var _0x1646=['COALESCE(phone,\x27\x27)','cm_contacts','cm_hopper_additional_phones','OrderBy','h.id','cm_contact_has_items','join','h.ContactId\x20=\x20ci.CmContactId','h.ListId\x20=\x20?','h.CampaignId=?','h.createdAt\x20=\x20?','push','sequelize','all','removeLists','getBlackLists','CmList','format','removeBlackLists','eml-format','rimraf','zip-dir','fast-json-patch','moment','mustache','path','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','offset','limit','undefined','count','set','Content-Range','apply','reject','save','then','destroy','get','IvrCampaigns','UserProfileResource','error','name','send','index','map','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','nolimit','order','sort','where','pick','merge','VIRTUAL','options','Campaign','includeAll','findAll','catch','params','length','include','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','createdAt','updatedAt','UserProfileSection','getHoppers','findOne','hasOwnProperty','CampaignId','filter','CmHopper','rows','getHopperHistories','CmHopperHistory','CmHopperFinal','getHopperBlacks','CmHopperBlack','getLists','addLists','YYYY-MM-DD\x20HH:mm:ss','ids','spread','dialCheckDuplicateType','insert','into','cm_hopper','fromQuery','phone','scheduledAt','ContactId','ListId','select','field','NOW()','from','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','CmListId','toString','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','CampaignId\x20=\x20?','onlyIfOpen'];(function(_0xbf91ee,_0x4ec327){var _0x4a1360=function(_0x38a8cc){while(--_0x38a8cc){_0xbf91ee['push'](_0xbf91ee['shift']());}};_0x4a1360(++_0x4ec327);}(_0x1646,0x1bd));var _0x6164=function(_0x1e2321,_0x3ae1c5){_0x1e2321=_0x1e2321-0x0;var _0x1d346d=_0x1646[_0x1e2321];return _0x1d346d;};'use strict';var emlformat=require(_0x6164('0x0'));var rimraf=require(_0x6164('0x1'));var zipdir=require(_0x6164('0x2'));var jsonpatch=require(_0x6164('0x3'));var rp=require('request-promise');var moment=require(_0x6164('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x6164('0x5'));var util=require('util');var path=require(_0x6164('0x6'));var sox=require('sox');var csv=require(_0x6164('0x7'));var ejs=require(_0x6164('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x6164('0x9'));var squel=require('squel');var crypto=require(_0x6164('0xa'));var jsforce=require(_0x6164('0xb'));var deskjs=require(_0x6164('0xc'));var toCsv=require(_0x6164('0x7'));var querystring=require(_0x6164('0xd'));var Papa=require(_0x6164('0xe'));var Redis=require(_0x6164('0xf'));var authService=require('../../components/auth/service');var qs=require(_0x6164('0x10'));var as=require(_0x6164('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x6164('0x12'))(_0x6164('0x13'));var utils=require(_0x6164('0x14'));var config=require(_0x6164('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0x6164('0x16'))['db'];function respondWithStatusCode(_0x3355f4,_0x18a5e0){_0x18a5e0=_0x18a5e0||0xcc;return function(_0x517845){if(_0x517845){return _0x3355f4[_0x6164('0x17')](_0x18a5e0);}return _0x3355f4[_0x6164('0x18')](_0x18a5e0)['end']();};}function respondWithResult(_0x284b3a,_0x26b7c9){_0x26b7c9=_0x26b7c9||0xc8;return function(_0x48094c){if(_0x48094c){return _0x284b3a[_0x6164('0x18')](_0x26b7c9)['json'](_0x48094c);}};}function respondWithFilteredResult(_0x2054b0,_0x3df16a){return function(_0x1baab0){if(_0x1baab0){var _0x1c67ee=typeof _0x3df16a[_0x6164('0x19')]==='undefined'&&typeof _0x3df16a[_0x6164('0x1a')]===_0x6164('0x1b');var _0x17c82b=_0x1baab0['count'];var _0x38ebb6=_0x1c67ee?0x0:_0x3df16a[_0x6164('0x19')];var _0xb4412b=_0x1c67ee?_0x1baab0[_0x6164('0x1c')]:_0x3df16a[_0x6164('0x19')]+_0x3df16a[_0x6164('0x1a')];var _0x412f19;if(_0xb4412b>=_0x17c82b){_0xb4412b=_0x17c82b;_0x412f19=0xc8;}else{_0x412f19=0xce;}_0x2054b0['status'](_0x412f19);return _0x2054b0[_0x6164('0x1d')](_0x6164('0x1e'),_0x38ebb6+'-'+_0xb4412b+'/'+_0x17c82b)['json'](_0x1baab0);}return null;};}function patchUpdates(_0x1a5638){return function(_0x12c811){try{jsonpatch[_0x6164('0x1f')](_0x12c811,_0x1a5638,!![]);}catch(_0x3bb40b){return BPromise[_0x6164('0x20')](_0x3bb40b);}return _0x12c811[_0x6164('0x21')]();};}function saveUpdates(_0x4d7aad,_0x56c2a3){return function(_0x6b62bc){if(_0x6b62bc){return _0x6b62bc['update'](_0x4d7aad)[_0x6164('0x22')](function(_0x4d6403){return _0x4d6403;});}return null;};}function removeEntity(_0x35b6bf,_0xcab43b){return function(_0xb10252){if(_0xb10252){return _0xb10252[_0x6164('0x23')]()[_0x6164('0x22')](function(){var _0x43fb5b=_0xb10252[_0x6164('0x24')]({'plain':!![]});var _0x14e315=_0x6164('0x25');return db[_0x6164('0x26')]['destroy']({'where':{'type':_0x14e315,'resourceId':_0x43fb5b['id']}})[_0x6164('0x22')](function(){return _0xb10252;});})[_0x6164('0x22')](function(){_0x35b6bf[_0x6164('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4d0921,_0xd80f16){return function(_0x40c7fe){if(!_0x40c7fe){_0x4d0921[_0x6164('0x17')](0x194);}return _0x40c7fe;};}function handleError(_0x5d5ade,_0x148e86){_0x148e86=_0x148e86||0x1f4;return function(_0x876e6b){logger[_0x6164('0x27')](_0x876e6b['stack']);if(_0x876e6b[_0x6164('0x28')]){delete _0x876e6b['name'];}_0x5d5ade[_0x6164('0x18')](_0x148e86)[_0x6164('0x29')](_0x876e6b);};}exports[_0x6164('0x2a')]=function(_0x295c5b,_0x1548a3){var _0x2a3791={},_0x290c47={},_0x80589a={'count':0x0,'rows':[]};var _0x34af72=_[_0x6164('0x2b')](db['Campaign'][_0x6164('0x2c')],function(_0x42fa3f){return{'name':_0x42fa3f['fieldName'],'type':_0x42fa3f[_0x6164('0x2d')][_0x6164('0x2e')]};});_0x290c47[_0x6164('0x2f')]=_[_0x6164('0x2b')](_0x34af72,_0x6164('0x28'));_0x290c47[_0x6164('0x30')]=_[_0x6164('0x31')](_0x295c5b[_0x6164('0x30')]);_0x290c47[_0x6164('0x32')]=_[_0x6164('0x33')](_0x290c47['model'],_0x290c47[_0x6164('0x30')]);_0x2a3791[_0x6164('0x34')]=_[_0x6164('0x33')](_0x290c47[_0x6164('0x2f')],qs[_0x6164('0x35')](_0x295c5b[_0x6164('0x30')][_0x6164('0x35')]));_0x2a3791[_0x6164('0x34')]=_0x2a3791[_0x6164('0x34')]['length']?_0x2a3791[_0x6164('0x34')]:_0x290c47[_0x6164('0x2f')];if(!_0x295c5b['query']['hasOwnProperty'](_0x6164('0x36'))){_0x2a3791[_0x6164('0x1a')]=qs[_0x6164('0x1a')](_0x295c5b[_0x6164('0x30')][_0x6164('0x1a')]);_0x2a3791[_0x6164('0x19')]=qs[_0x6164('0x19')](_0x295c5b['query']['offset']);}_0x2a3791[_0x6164('0x37')]=qs['sort'](_0x295c5b[_0x6164('0x30')][_0x6164('0x38')]);_0x2a3791[_0x6164('0x39')]=qs[_0x6164('0x32')](_[_0x6164('0x3a')](_0x295c5b['query'],_0x290c47[_0x6164('0x32')]),_0x34af72);if(_0x295c5b['query']['filter']){_0x2a3791[_0x6164('0x39')]=_[_0x6164('0x3b')](_0x2a3791[_0x6164('0x39')],{'$or':_['map'](_0x34af72,function(_0x4fe1fa){if(_0x4fe1fa[_0x6164('0x2d')]!==_0x6164('0x3c')){var _0x4e0273={};_0x4e0273[_0x4fe1fa[_0x6164('0x28')]]={'$like':'%'+_0x295c5b[_0x6164('0x30')]['filter']+'%'};return _0x4e0273;}})});}_0x2a3791=_['merge']({},_0x2a3791,_0x295c5b[_0x6164('0x3d')]);var _0x114b65={'where':_0x2a3791[_0x6164('0x39')]};return db[_0x6164('0x3e')][_0x6164('0x1c')](_0x114b65)['then'](function(_0x306d50){_0x80589a[_0x6164('0x1c')]=_0x306d50;if(_0x295c5b[_0x6164('0x30')][_0x6164('0x3f')]){_0x2a3791['include']=[{'all':!![]}];}return db[_0x6164('0x3e')][_0x6164('0x40')](_0x2a3791);})[_0x6164('0x22')](function(_0x4abcf4){_0x80589a['rows']=_0x4abcf4;return _0x80589a;})['then'](respondWithFilteredResult(_0x1548a3,_0x2a3791))[_0x6164('0x41')](handleError(_0x1548a3,null));};exports['show']=function(_0x5f1f44,_0x378c91){var _0xb4001e={'raw':![],'where':{'id':_0x5f1f44[_0x6164('0x42')]['id']}},_0x169cb6={};_0x169cb6['model']=_[_0x6164('0x31')](db[_0x6164('0x3e')][_0x6164('0x2c')]);_0x169cb6[_0x6164('0x30')]=_['keys'](_0x5f1f44[_0x6164('0x30')]);_0x169cb6[_0x6164('0x32')]=_[_0x6164('0x33')](_0x169cb6[_0x6164('0x2f')],_0x169cb6['query']);_0xb4001e[_0x6164('0x34')]=_['intersection'](_0x169cb6[_0x6164('0x2f')],qs['fields'](_0x5f1f44[_0x6164('0x30')][_0x6164('0x35')]));_0xb4001e['attributes']=_0xb4001e[_0x6164('0x34')][_0x6164('0x43')]?_0xb4001e[_0x6164('0x34')]:_0x169cb6[_0x6164('0x2f')];if(_0x5f1f44[_0x6164('0x30')][_0x6164('0x3f')]){_0xb4001e[_0x6164('0x44')]=[{'all':!![]}];}_0xb4001e=_[_0x6164('0x3b')]({},_0xb4001e,_0x5f1f44[_0x6164('0x3d')]);return db[_0x6164('0x3e')][_0x6164('0x45')](_0xb4001e)[_0x6164('0x22')](handleEntityNotFound(_0x378c91,null))['then'](respondWithResult(_0x378c91,null))['catch'](handleError(_0x378c91,null));};exports[_0x6164('0x46')]=function(_0x561cfa,_0x2249a2){return db[_0x6164('0x3e')][_0x6164('0x46')](_0x561cfa[_0x6164('0x47')],{})[_0x6164('0x22')](function(_0x2c182b){var _0x84399a=_0x561cfa[_0x6164('0x48')][_0x6164('0x24')]({'plain':!![]});if(!_0x84399a)throw new Error(_0x6164('0x49'));if(_0x84399a[_0x6164('0x4a')]===_0x6164('0x48')){var _0x5aa935=_0x2c182b[_0x6164('0x24')]({'plain':!![]});var _0x4bf915=_0x6164('0x25');return db['UserProfileSection'][_0x6164('0x45')]({'where':{'name':_0x4bf915,'userProfileId':_0x84399a[_0x6164('0x4b')]},'raw':!![]})[_0x6164('0x22')](function(_0xf038ea){if(_0xf038ea&&_0xf038ea[_0x6164('0x4c')]===0x0){return db['UserProfileResource'][_0x6164('0x46')]({'name':_0x5aa935[_0x6164('0x28')],'resourceId':_0x5aa935['id'],'type':_0xf038ea[_0x6164('0x28')],'sectionId':_0xf038ea['id']},{})[_0x6164('0x22')](function(){return _0x2c182b;});}else{return _0x2c182b;}})['catch'](function(_0x3ccf12){logger['error'](_0x6164('0x4d'),_0x3ccf12);throw _0x3ccf12;});}return _0x2c182b;})['then'](respondWithResult(_0x2249a2,0xc9))[_0x6164('0x41')](handleError(_0x2249a2,null));};exports[_0x6164('0x4e')]=function(_0x2272c4,_0x164668){var _0x2ab311={'where':{'id':_0x2272c4['params']['id']}},_0x4a16a6={};_0x4a16a6[_0x6164('0x2f')]=_['keys'](db[_0x6164('0x3e')][_0x6164('0x2c')]);_0x2ab311[_0x6164('0x34')]=_[_0x6164('0x33')](_0x4a16a6[_0x6164('0x2f')],qs[_0x6164('0x35')](_0x2272c4[_0x6164('0x30')]['fields']));_0x2ab311[_0x6164('0x34')]=_0x2ab311['attributes'][_0x6164('0x43')]?_0x2ab311['attributes']:_0x4a16a6['model'];if(_0x2272c4['query'][_0x6164('0x3f')]){_0x2ab311[_0x6164('0x44')]=[{'all':!![]}];}_0x2ab311=_[_0x6164('0x3b')]({},_0x2ab311,_0x2272c4[_0x6164('0x3d')]);return db[_0x6164('0x3e')][_0x6164('0x45')](_0x2ab311)['then'](handleEntityNotFound(_0x164668,null))[_0x6164('0x22')](function(_0x16e6b8){if(_0x16e6b8){var _0x378006=_0x16e6b8[_0x6164('0x24')]({'plain':!![]});_0x378006=qs[_0x6164('0x4f')](_0x378006,['id',_0x6164('0x50'),_0x6164('0x51')]);_0x2272c4['body']=_[_0x6164('0x4f')](_0x2272c4['body'],['id',_0x6164('0x50'),_0x6164('0x51')]);return db[_0x6164('0x3e')]['create'](_['merge'](_0x378006,_0x2272c4['body']),{'include':_0x2272c4[_0x6164('0x30')][_0x6164('0x3f')]?[{'all':!![]}]:undefined})[_0x6164('0x22')](function(_0x2b8ae1){var _0x2914b2=_0x2272c4[_0x6164('0x48')][_0x6164('0x24')]({'plain':!![]});if(!_0x2914b2)throw new Error(_0x6164('0x49'));if(_0x2914b2['role']===_0x6164('0x48')){var _0x569bf0=_0x2b8ae1[_0x6164('0x24')]({'plain':!![]});var _0x58d61f=_0x6164('0x25');return db[_0x6164('0x52')][_0x6164('0x45')]({'where':{'name':_0x58d61f,'userProfileId':_0x2914b2[_0x6164('0x4b')]},'raw':!![]})[_0x6164('0x22')](function(_0x4a17da){if(_0x4a17da&&_0x4a17da[_0x6164('0x4c')]===0x0){return db[_0x6164('0x26')][_0x6164('0x46')]({'name':_0x569bf0[_0x6164('0x28')],'resourceId':_0x569bf0['id'],'type':_0x4a17da['name'],'sectionId':_0x4a17da['id']},{})['then'](function(){return _0x2b8ae1;});}else{return _0x2b8ae1;}})[_0x6164('0x41')](function(_0x13e549){logger[_0x6164('0x27')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x13e549);throw _0x13e549;});}return _0x2b8ae1;});}})[_0x6164('0x22')](respondWithResult(_0x164668,0xc9))[_0x6164('0x41')](handleError(_0x164668,null));};exports['update']=function(_0x5552ec,_0x309ba0){if(_0x5552ec[_0x6164('0x47')]['id']){delete _0x5552ec[_0x6164('0x47')]['id'];}return db[_0x6164('0x3e')][_0x6164('0x45')]({'where':{'id':_0x5552ec['params']['id']}})['then'](handleEntityNotFound(_0x309ba0,null))[_0x6164('0x22')](saveUpdates(_0x5552ec['body'],null))[_0x6164('0x22')](respondWithResult(_0x309ba0,null))['catch'](handleError(_0x309ba0,null));};exports[_0x6164('0x23')]=function(_0x2335ea,_0x2826a6){return db[_0x6164('0x3e')]['find']({'where':{'id':_0x2335ea[_0x6164('0x42')]['id']}})['then'](handleEntityNotFound(_0x2826a6,null))[_0x6164('0x22')](removeEntity(_0x2826a6,null))[_0x6164('0x41')](handleError(_0x2826a6,null));};exports[_0x6164('0x53')]=function(_0xdee56d,_0x3cf94f,_0x1339c0){var _0x299dec={'raw':!![],'where':{}};var _0x4a2eea={};var _0x5dcbd3={'count':0x0,'rows':[]};return db[_0x6164('0x3e')][_0x6164('0x54')]({'where':{'id':_0xdee56d['params']['id']}})[_0x6164('0x22')](handleEntityNotFound(_0x3cf94f,null))[_0x6164('0x22')](function(_0x3eab0c){if(_0x3eab0c){_0x4a2eea['model']=_[_0x6164('0x31')](db['CmHopper']['rawAttributes']);_0x4a2eea[_0x6164('0x30')]=_[_0x6164('0x31')](_0xdee56d[_0x6164('0x30')]);_0x4a2eea[_0x6164('0x32')]=_[_0x6164('0x33')](_0x4a2eea[_0x6164('0x2f')],_0x4a2eea['query']);_0x299dec[_0x6164('0x34')]=_['intersection'](_0x4a2eea[_0x6164('0x2f')],qs[_0x6164('0x35')](_0xdee56d[_0x6164('0x30')][_0x6164('0x35')]));_0x299dec[_0x6164('0x34')]=_0x299dec['attributes'][_0x6164('0x43')]?_0x299dec['attributes']:_0x4a2eea['model'];if(!_0xdee56d['query'][_0x6164('0x55')]('nolimit')){_0x299dec[_0x6164('0x1a')]=qs[_0x6164('0x1a')](_0xdee56d[_0x6164('0x30')][_0x6164('0x1a')]);_0x299dec[_0x6164('0x19')]=qs[_0x6164('0x19')](_0xdee56d[_0x6164('0x30')][_0x6164('0x19')]);}_0x299dec[_0x6164('0x37')]=qs[_0x6164('0x38')](_0xdee56d['query'][_0x6164('0x38')]);_0x299dec['where']=qs[_0x6164('0x32')](_[_0x6164('0x3a')](_0xdee56d[_0x6164('0x30')],_0x4a2eea[_0x6164('0x32')]));_0x299dec['where'][_0x6164('0x56')]=_0x3eab0c['id'];if(_0xdee56d['query'][_0x6164('0x57')]){_0x299dec['where']=_[_0x6164('0x3b')](_0x299dec['where'],{'$or':_[_0x6164('0x2b')](_0x299dec['attributes'],function(_0xff0ad8){var _0x82f208={};_0x82f208[_0xff0ad8]={'$like':'%'+_0xdee56d[_0x6164('0x30')][_0x6164('0x57')]+'%'};return _0x82f208;})});}_0x299dec=_[_0x6164('0x3b')]({},_0x299dec,_0xdee56d[_0x6164('0x3d')]);return db[_0x6164('0x58')][_0x6164('0x1c')]({'where':_0x299dec[_0x6164('0x39')]})['then'](function(_0x3e124e){_0x5dcbd3[_0x6164('0x1c')]=_0x3e124e;if(_0xdee56d[_0x6164('0x30')][_0x6164('0x3f')]){_0x299dec[_0x6164('0x44')]=[{'all':!![]}];}return db[_0x6164('0x58')][_0x6164('0x40')](_0x299dec);})[_0x6164('0x22')](function(_0x31f83d){_0x5dcbd3[_0x6164('0x59')]=_0x31f83d;return _0x5dcbd3;});}})[_0x6164('0x22')](respondWithFilteredResult(_0x3cf94f,_0x299dec))[_0x6164('0x41')](handleError(_0x3cf94f,null));};exports[_0x6164('0x5a')]=function(_0x582810,_0x2d37c9,_0x14fd1f){var _0x5e033b={'raw':!![],'where':{}};var _0x1060c4={};var _0x275885={'count':0x0,'rows':[]};return db[_0x6164('0x3e')][_0x6164('0x54')]({'where':{'id':_0x582810[_0x6164('0x42')]['id']}})[_0x6164('0x22')](handleEntityNotFound(_0x2d37c9,null))[_0x6164('0x22')](function(_0x5725ef){if(_0x5725ef){_0x1060c4[_0x6164('0x2f')]=_['keys'](db['CmHopperHistory'][_0x6164('0x2c')]);_0x1060c4[_0x6164('0x30')]=_[_0x6164('0x31')](_0x582810[_0x6164('0x30')]);_0x1060c4['filters']=_[_0x6164('0x33')](_0x1060c4['model'],_0x1060c4['query']);_0x5e033b[_0x6164('0x34')]=_[_0x6164('0x33')](_0x1060c4[_0x6164('0x2f')],qs['fields'](_0x582810[_0x6164('0x30')][_0x6164('0x35')]));_0x5e033b['attributes']=_0x5e033b['attributes'][_0x6164('0x43')]?_0x5e033b[_0x6164('0x34')]:_0x1060c4[_0x6164('0x2f')];if(!_0x582810[_0x6164('0x30')]['hasOwnProperty'](_0x6164('0x36'))){_0x5e033b[_0x6164('0x1a')]=qs[_0x6164('0x1a')](_0x582810['query'][_0x6164('0x1a')]);_0x5e033b['offset']=qs['offset'](_0x582810[_0x6164('0x30')][_0x6164('0x19')]);}_0x5e033b[_0x6164('0x37')]=qs[_0x6164('0x38')](_0x582810[_0x6164('0x30')][_0x6164('0x38')]);_0x5e033b[_0x6164('0x39')]=qs[_0x6164('0x32')](_[_0x6164('0x3a')](_0x582810[_0x6164('0x30')],_0x1060c4['filters']));_0x5e033b[_0x6164('0x39')][_0x6164('0x56')]=_0x5725ef['id'];if(_0x582810[_0x6164('0x30')]['filter']){_0x5e033b['where']=_[_0x6164('0x3b')](_0x5e033b[_0x6164('0x39')],{'$or':_[_0x6164('0x2b')](_0x5e033b['attributes'],function(_0x455da1){var _0x3287e6={};_0x3287e6[_0x455da1]={'$like':'%'+_0x582810[_0x6164('0x30')][_0x6164('0x57')]+'%'};return _0x3287e6;})});}_0x5e033b=_[_0x6164('0x3b')]({},_0x5e033b,_0x582810[_0x6164('0x3d')]);return db[_0x6164('0x5b')]['count']({'where':_0x5e033b[_0x6164('0x39')]})[_0x6164('0x22')](function(_0x4fc0b0){_0x275885[_0x6164('0x1c')]=_0x4fc0b0;if(_0x582810[_0x6164('0x30')][_0x6164('0x3f')]){_0x5e033b['include']=[{'all':!![]}];}return db[_0x6164('0x5b')][_0x6164('0x40')](_0x5e033b);})[_0x6164('0x22')](function(_0x28971c){_0x275885[_0x6164('0x59')]=_0x28971c;return _0x275885;});}})[_0x6164('0x22')](respondWithFilteredResult(_0x2d37c9,_0x5e033b))[_0x6164('0x41')](handleError(_0x2d37c9,null));};exports['getHopperFinals']=function(_0x32443c,_0x2d9713,_0x170d62){var _0x436b01={'raw':!![],'where':{}};var _0xb2dc60={};var _0x364eb7={'count':0x0,'rows':[]};return db[_0x6164('0x3e')][_0x6164('0x54')]({'where':{'id':_0x32443c[_0x6164('0x42')]['id']}})[_0x6164('0x22')](handleEntityNotFound(_0x2d9713,null))[_0x6164('0x22')](function(_0x4afde7){if(_0x4afde7){_0xb2dc60['model']=_[_0x6164('0x31')](db['CmHopperFinal'][_0x6164('0x2c')]);_0xb2dc60[_0x6164('0x30')]=_[_0x6164('0x31')](_0x32443c['query']);_0xb2dc60[_0x6164('0x32')]=_[_0x6164('0x33')](_0xb2dc60[_0x6164('0x2f')],_0xb2dc60['query']);_0x436b01['attributes']=_[_0x6164('0x33')](_0xb2dc60[_0x6164('0x2f')],qs['fields'](_0x32443c[_0x6164('0x30')]['fields']));_0x436b01[_0x6164('0x34')]=_0x436b01[_0x6164('0x34')]['length']?_0x436b01[_0x6164('0x34')]:_0xb2dc60[_0x6164('0x2f')];if(!_0x32443c[_0x6164('0x30')][_0x6164('0x55')](_0x6164('0x36'))){_0x436b01[_0x6164('0x1a')]=qs[_0x6164('0x1a')](_0x32443c[_0x6164('0x30')][_0x6164('0x1a')]);_0x436b01['offset']=qs['offset'](_0x32443c[_0x6164('0x30')][_0x6164('0x19')]);}_0x436b01[_0x6164('0x37')]=qs[_0x6164('0x38')](_0x32443c[_0x6164('0x30')][_0x6164('0x38')]);_0x436b01[_0x6164('0x39')]=qs[_0x6164('0x32')](_[_0x6164('0x3a')](_0x32443c[_0x6164('0x30')],_0xb2dc60[_0x6164('0x32')]));_0x436b01[_0x6164('0x39')][_0x6164('0x56')]=_0x4afde7['id'];if(_0x32443c[_0x6164('0x30')][_0x6164('0x57')]){_0x436b01[_0x6164('0x39')]=_['merge'](_0x436b01[_0x6164('0x39')],{'$or':_['map'](_0x436b01[_0x6164('0x34')],function(_0xd4b270){var _0x1b93fd={};_0x1b93fd[_0xd4b270]={'$like':'%'+_0x32443c[_0x6164('0x30')][_0x6164('0x57')]+'%'};return _0x1b93fd;})});}_0x436b01=_[_0x6164('0x3b')]({},_0x436b01,_0x32443c[_0x6164('0x3d')]);return db['CmHopperFinal'][_0x6164('0x1c')]({'where':_0x436b01[_0x6164('0x39')]})[_0x6164('0x22')](function(_0x13dc51){_0x364eb7[_0x6164('0x1c')]=_0x13dc51;if(_0x32443c[_0x6164('0x30')]['includeAll']){_0x436b01['include']=[{'all':!![]}];}return db[_0x6164('0x5c')]['findAll'](_0x436b01);})[_0x6164('0x22')](function(_0x48eb6a){_0x364eb7[_0x6164('0x59')]=_0x48eb6a;return _0x364eb7;});}})[_0x6164('0x22')](respondWithFilteredResult(_0x2d9713,_0x436b01))['catch'](handleError(_0x2d9713,null));};exports[_0x6164('0x5d')]=function(_0x2ee62f,_0xd286f2,_0x3c4384){var _0x2bd8c8={'raw':!![],'where':{}};var _0x1f1a5a={};var _0x244d7e={'count':0x0,'rows':[]};return db[_0x6164('0x3e')][_0x6164('0x54')]({'where':{'id':_0x2ee62f[_0x6164('0x42')]['id']}})['then'](handleEntityNotFound(_0xd286f2,null))[_0x6164('0x22')](function(_0x596642){if(_0x596642){_0x1f1a5a[_0x6164('0x2f')]=_[_0x6164('0x31')](db[_0x6164('0x5e')][_0x6164('0x2c')]);_0x1f1a5a[_0x6164('0x30')]=_[_0x6164('0x31')](_0x2ee62f[_0x6164('0x30')]);_0x1f1a5a[_0x6164('0x32')]=_['intersection'](_0x1f1a5a[_0x6164('0x2f')],_0x1f1a5a[_0x6164('0x30')]);_0x2bd8c8[_0x6164('0x34')]=_[_0x6164('0x33')](_0x1f1a5a[_0x6164('0x2f')],qs[_0x6164('0x35')](_0x2ee62f['query']['fields']));_0x2bd8c8[_0x6164('0x34')]=_0x2bd8c8[_0x6164('0x34')][_0x6164('0x43')]?_0x2bd8c8[_0x6164('0x34')]:_0x1f1a5a[_0x6164('0x2f')];if(!_0x2ee62f[_0x6164('0x30')][_0x6164('0x55')](_0x6164('0x36'))){_0x2bd8c8[_0x6164('0x1a')]=qs[_0x6164('0x1a')](_0x2ee62f[_0x6164('0x30')]['limit']);_0x2bd8c8[_0x6164('0x19')]=qs[_0x6164('0x19')](_0x2ee62f['query'][_0x6164('0x19')]);}_0x2bd8c8[_0x6164('0x37')]=qs[_0x6164('0x38')](_0x2ee62f[_0x6164('0x30')]['sort']);_0x2bd8c8[_0x6164('0x39')]=qs[_0x6164('0x32')](_['pick'](_0x2ee62f[_0x6164('0x30')],_0x1f1a5a[_0x6164('0x32')]));_0x2bd8c8[_0x6164('0x39')][_0x6164('0x56')]=_0x596642['id'];if(_0x2ee62f['query'][_0x6164('0x57')]){_0x2bd8c8[_0x6164('0x39')]=_[_0x6164('0x3b')](_0x2bd8c8[_0x6164('0x39')],{'$or':_[_0x6164('0x2b')](_0x2bd8c8['attributes'],function(_0x297e31){var _0x479eb0={};_0x479eb0[_0x297e31]={'$like':'%'+_0x2ee62f['query'][_0x6164('0x57')]+'%'};return _0x479eb0;})});}_0x2bd8c8=_[_0x6164('0x3b')]({},_0x2bd8c8,_0x2ee62f['options']);return db[_0x6164('0x5e')][_0x6164('0x1c')]({'where':_0x2bd8c8[_0x6164('0x39')]})[_0x6164('0x22')](function(_0x5064e8){_0x244d7e['count']=_0x5064e8;if(_0x2ee62f['query'][_0x6164('0x3f')]){_0x2bd8c8[_0x6164('0x44')]=[{'all':!![]}];}return db[_0x6164('0x5e')]['findAll'](_0x2bd8c8);})[_0x6164('0x22')](function(_0x39793f){_0x244d7e[_0x6164('0x59')]=_0x39793f;return _0x244d7e;});}})[_0x6164('0x22')](respondWithFilteredResult(_0xd286f2,_0x2bd8c8))[_0x6164('0x41')](handleError(_0xd286f2,null));};exports[_0x6164('0x5f')]=function(_0x5f19b3,_0x889291,_0x3be38b){var _0x5f270d={};var _0x4bb75e={};var _0x382af1;var _0x5c7175;return db['Campaign'][_0x6164('0x54')]({'where':{'id':_0x5f19b3[_0x6164('0x42')]['id']}})[_0x6164('0x22')](handleEntityNotFound(_0x889291,null))[_0x6164('0x22')](function(_0x3083f6){if(_0x3083f6){_0x382af1=_0x3083f6;_0x4bb75e[_0x6164('0x2f')]=_[_0x6164('0x31')](db['CmList'][_0x6164('0x2c')]);_0x4bb75e[_0x6164('0x30')]=_[_0x6164('0x31')](_0x5f19b3[_0x6164('0x30')]);_0x4bb75e['filters']=_[_0x6164('0x33')](_0x4bb75e[_0x6164('0x2f')],_0x4bb75e[_0x6164('0x30')]);_0x5f270d[_0x6164('0x34')]=_[_0x6164('0x33')](_0x4bb75e['model'],qs[_0x6164('0x35')](_0x5f19b3[_0x6164('0x30')][_0x6164('0x35')]));_0x5f270d['attributes']=_0x5f270d[_0x6164('0x34')][_0x6164('0x43')]?_0x5f270d[_0x6164('0x34')]:_0x4bb75e[_0x6164('0x2f')];_0x5f270d[_0x6164('0x37')]=qs[_0x6164('0x38')](_0x5f19b3[_0x6164('0x30')][_0x6164('0x38')]);_0x5f270d[_0x6164('0x39')]=qs[_0x6164('0x32')](_[_0x6164('0x3a')](_0x5f19b3[_0x6164('0x30')],_0x4bb75e[_0x6164('0x32')]));if(_0x5f19b3[_0x6164('0x30')][_0x6164('0x57')]){_0x5f270d[_0x6164('0x39')]=_[_0x6164('0x3b')](_0x5f270d[_0x6164('0x39')],{'$or':_[_0x6164('0x2b')](_0x5f270d[_0x6164('0x34')],function(_0x1026e9){var _0xc96b2={};_0xc96b2[_0x1026e9]={'$like':'%'+_0x5f19b3[_0x6164('0x30')][_0x6164('0x57')]+'%'};return _0xc96b2;})});}_0x5f270d=_[_0x6164('0x3b')]({},_0x5f270d,_0x5f19b3[_0x6164('0x3d')]);return _0x382af1['getLists'](_0x5f270d);}})[_0x6164('0x22')](function(_0x50d3e9){if(_0x50d3e9){_0x5c7175=_0x50d3e9[_0x6164('0x43')];if(!_0x5f19b3[_0x6164('0x30')]['hasOwnProperty']('nolimit')){_0x5f270d[_0x6164('0x1a')]=qs[_0x6164('0x1a')](_0x5f19b3[_0x6164('0x30')][_0x6164('0x1a')]);_0x5f270d[_0x6164('0x19')]=qs[_0x6164('0x19')](_0x5f19b3[_0x6164('0x30')][_0x6164('0x19')]);}return _0x382af1[_0x6164('0x5f')](_0x5f270d);}})['then'](function(_0x55245f){if(_0x55245f){return _0x55245f?{'count':_0x5c7175,'rows':_0x55245f}:null;}})[_0x6164('0x22')](respondWithResult(_0x889291,null))[_0x6164('0x41')](handleError(_0x889291,null));};exports[_0x6164('0x60')]=function(_0x3b8430,_0x319e59,_0x3c9b9d){var _0x2cb1ec,_0x17bc6b;var _0x1f041c=[];var _0x547b0e=moment()['format'](_0x6164('0x61'));return db[_0x6164('0x3e')][_0x6164('0x45')]({'where':{'id':_0x3b8430[_0x6164('0x42')]['id']}})['then'](handleEntityNotFound(_0x319e59,null))[_0x6164('0x22')](function(_0x3c40a9){if(_0x3c40a9){_0x17bc6b=_0x3c40a9;return _0x3c40a9[_0x6164('0x60')](_0x3b8430['body'][_0x6164('0x62')],_[_0x6164('0x4f')](_0x3b8430[_0x6164('0x47')],[_0x6164('0x62'),'id'])||{});}return null;})[_0x6164('0x63')](function(_0x249cec){var _0x11a592;var _0x1b60a1;_0x2cb1ec=_0x249cec||[];var _0x1038c8=[];if(_0x249cec){for(var _0x42ab5e=0x0;_0x42ab5e<_0x249cec[_0x6164('0x43')];_0x42ab5e+=0x1){var _0x3ae278=_0x249cec[_0x42ab5e][_0x6164('0x24')]({'plain':!![]});_0x17bc6b[_0x6164('0x64')]=_0x3b8430['body'][_0x6164('0x64')]?_0x3b8430[_0x6164('0x47')][_0x6164('0x64')]:_0x17bc6b['dialCheckDuplicateType'];switch(_0x17bc6b[_0x6164('0x64')]){case'always':_0x11a592=squel[_0x6164('0x65')]()[_0x6164('0x66')](_0x6164('0x67'))[_0x6164('0x68')]([_0x6164('0x69'),_0x6164('0x6a'),_0x6164('0x6b'),_0x6164('0x6c'),_0x6164('0x56'),_0x6164('0x50'),_0x6164('0x51')],squel[_0x6164('0x6d')]()[_0x6164('0x6e')]('phone',_0x6164('0x69'))[_0x6164('0x6e')](_0x6164('0x6f'),_0x6164('0x6a'))[_0x6164('0x6e')]('id',_0x6164('0x6b'))['field'](_0x3ae278['CmListId']['toString'](),_0x6164('0x6c'))[_0x6164('0x6e')](_0x3b8430[_0x6164('0x42')]['id']['toString'](),_0x6164('0x56'))['field']('\x27'+_0x547b0e+'\x27',_0x6164('0x50'))[_0x6164('0x6e')]('\x27'+_0x547b0e+'\x27',_0x6164('0x51'))[_0x6164('0x70')]('cm_contacts')[_0x6164('0x39')](_0x6164('0x71'))['where'](_0x6164('0x72'),_0x3ae278[_0x6164('0x73')][_0x6164('0x74')]())['where'](_0x6164('0x75'))[_0x6164('0x39')](_0x6164('0x76'),squel[_0x6164('0x6d')]()[_0x6164('0x6e')](_0x6164('0x77'))[_0x6164('0x70')](_0x6164('0x78'))[_0x6164('0x39')](_0x6164('0x79'),_0x3b8430['params']['id'][_0x6164('0x74')]()))['where'](_0x6164('0x76'),squel[_0x6164('0x6d')]()['field']('COALESCE(phone,\x27\x27)')['from']('cm_hopper')[_0x6164('0x39')]('CampaignId\x20=\x20?',_0x3b8430[_0x6164('0x42')]['id']['toString']())))[_0x6164('0x74')]();break;case _0x6164('0x7a'):_0x11a592=squel[_0x6164('0x65')]()[_0x6164('0x66')]('cm_hopper')[_0x6164('0x68')]([_0x6164('0x69'),_0x6164('0x6a'),_0x6164('0x6b'),_0x6164('0x6c'),_0x6164('0x56'),'createdAt','updatedAt'],squel['select']()[_0x6164('0x6e')](_0x6164('0x69'),'phone')[_0x6164('0x6e')](_0x6164('0x6f'),_0x6164('0x6a'))[_0x6164('0x6e')]('id',_0x6164('0x6b'))[_0x6164('0x6e')](_0x3ae278[_0x6164('0x73')][_0x6164('0x74')](),'ListId')['field'](_0x3b8430[_0x6164('0x42')]['id'][_0x6164('0x74')](),_0x6164('0x56'))[_0x6164('0x6e')]('\x27'+_0x547b0e+'\x27',_0x6164('0x50'))[_0x6164('0x6e')]('\x27'+_0x547b0e+'\x27',_0x6164('0x51'))[_0x6164('0x70')]('cm_contacts')[_0x6164('0x39')]('deletedAt\x20IS\x20NULL')['where'](_0x6164('0x72'),_0x3ae278[_0x6164('0x73')][_0x6164('0x74')]())['where'](_0x6164('0x75'))[_0x6164('0x39')](_0x6164('0x76'),squel[_0x6164('0x6d')]()['field'](_0x6164('0x7b'))[_0x6164('0x70')]('cm_hopper')[_0x6164('0x39')](_0x6164('0x79'),_0x3b8430[_0x6164('0x42')]['id']['toString']())))[_0x6164('0x74')]();break;default:_0x11a592=squel[_0x6164('0x65')]()[_0x6164('0x66')](_0x6164('0x67'))[_0x6164('0x68')]([_0x6164('0x69'),_0x6164('0x6a'),'ContactId',_0x6164('0x6c'),_0x6164('0x56'),_0x6164('0x50'),_0x6164('0x51')],squel[_0x6164('0x6d')]()['field'](_0x6164('0x69'),_0x6164('0x69'))[_0x6164('0x6e')]('NOW()',_0x6164('0x6a'))[_0x6164('0x6e')]('id','ContactId')[_0x6164('0x6e')](_0x3ae278[_0x6164('0x73')][_0x6164('0x74')](),_0x6164('0x6c'))[_0x6164('0x6e')](_0x3b8430[_0x6164('0x42')]['id'][_0x6164('0x74')](),_0x6164('0x56'))[_0x6164('0x6e')]('\x27'+_0x547b0e+'\x27','createdAt')[_0x6164('0x6e')]('\x27'+_0x547b0e+'\x27',_0x6164('0x51'))[_0x6164('0x70')](_0x6164('0x7c'))[_0x6164('0x39')](_0x6164('0x71'))[_0x6164('0x39')](_0x6164('0x72'),_0x3ae278['CmListId'][_0x6164('0x74')]())[_0x6164('0x39')](_0x6164('0x75')))['toString']();}_0x1b60a1=squel['insert']()[_0x6164('0x66')](_0x6164('0x7d'))[_0x6164('0x68')](['cmHopperId',_0x6164('0x6a'),_0x6164('0x69'),_0x6164('0x7e'),_0x6164('0x50'),_0x6164('0x51')],squel['select']()['field'](_0x6164('0x7f'),'id')[_0x6164('0x6e')]('NOW()',_0x6164('0x6a'))[_0x6164('0x6e')]('ci.item',_0x6164('0x69'))[_0x6164('0x6e')]('ci.OrderBY',_0x6164('0x7e'))[_0x6164('0x6e')]('\x27'+_0x547b0e+'\x27',_0x6164('0x50'))['field']('\x27'+_0x547b0e+'\x27',_0x6164('0x51'))[_0x6164('0x70')](_0x6164('0x80'),'ci')[_0x6164('0x81')]('cm_hopper','h',_0x6164('0x82'))['where'](_0x6164('0x83'),_0x3ae278[_0x6164('0x73')][_0x6164('0x74')]())[_0x6164('0x39')](_0x6164('0x84'),_0x3b8430[_0x6164('0x42')]['id']['toString']())[_0x6164('0x39')](_0x6164('0x85'),_0x547b0e))[_0x6164('0x74')]();_0x1038c8['push'](db['sequelize'][_0x6164('0x30')](_0x11a592));_0x1f041c[_0x6164('0x86')](db[_0x6164('0x87')][_0x6164('0x30')](_0x1b60a1));}return BPromise[_0x6164('0x88')](_0x1038c8);}})[_0x6164('0x22')](function(){return BPromise[_0x6164('0x88')](_0x1f041c);})[_0x6164('0x22')](function(){return _0x2cb1ec;})['then'](respondWithResult(_0x319e59,null))['catch'](handleError(_0x319e59,null));};exports['removeLists']=function(_0x3beb6c,_0x3379b1,_0x495b0a){return db[_0x6164('0x3e')][_0x6164('0x45')]({'where':{'id':_0x3beb6c[_0x6164('0x42')]['id']}})[_0x6164('0x22')](handleEntityNotFound(_0x3379b1,null))['then'](function(_0x4b1f0f){if(_0x4b1f0f){return _0x4b1f0f[_0x6164('0x89')](_0x3beb6c['query'][_0x6164('0x62')]);}})[_0x6164('0x22')](function(_0x4fc349){if(_0x4fc349){return db[_0x6164('0x58')][_0x6164('0x23')]({'where':{'ListId':_0x3beb6c['query'][_0x6164('0x62')],'CampaignId':_0x3beb6c['params']['id']}})[_0x6164('0x22')](function(){return _0x4fc349;});}})[_0x6164('0x22')](respondWithStatusCode(_0x3379b1,null))['catch'](handleError(_0x3379b1,null));};exports[_0x6164('0x8a')]=function(_0xd9fb35,_0x5a5614,_0x1abd98){var _0x4d94ac={};var _0x2e9853={};var _0x2ac7b2;var _0x5b3455;return db[_0x6164('0x3e')]['findOne']({'where':{'id':_0xd9fb35[_0x6164('0x42')]['id']}})['then'](handleEntityNotFound(_0x5a5614,null))['then'](function(_0x4783f7){if(_0x4783f7){_0x2ac7b2=_0x4783f7;_0x2e9853['model']=_['keys'](db[_0x6164('0x8b')][_0x6164('0x2c')]);_0x2e9853[_0x6164('0x30')]=_['keys'](_0xd9fb35[_0x6164('0x30')]);_0x2e9853['filters']=_[_0x6164('0x33')](_0x2e9853['model'],_0x2e9853['query']);_0x4d94ac['attributes']=_['intersection'](_0x2e9853[_0x6164('0x2f')],qs[_0x6164('0x35')](_0xd9fb35[_0x6164('0x30')][_0x6164('0x35')]));_0x4d94ac[_0x6164('0x34')]=_0x4d94ac[_0x6164('0x34')][_0x6164('0x43')]?_0x4d94ac[_0x6164('0x34')]:_0x2e9853['model'];_0x4d94ac[_0x6164('0x37')]=qs[_0x6164('0x38')](_0xd9fb35[_0x6164('0x30')][_0x6164('0x38')]);_0x4d94ac[_0x6164('0x39')]=qs[_0x6164('0x32')](_[_0x6164('0x3a')](_0xd9fb35[_0x6164('0x30')],_0x2e9853[_0x6164('0x32')]));if(_0xd9fb35['query'][_0x6164('0x57')]){_0x4d94ac['where']=_['merge'](_0x4d94ac['where'],{'$or':_[_0x6164('0x2b')](_0x4d94ac[_0x6164('0x34')],function(_0x20eccb){var _0x1de21f={};_0x1de21f[_0x20eccb]={'$like':'%'+_0xd9fb35[_0x6164('0x30')][_0x6164('0x57')]+'%'};return _0x1de21f;})});}_0x4d94ac=_[_0x6164('0x3b')]({},_0x4d94ac,_0xd9fb35['options']);return _0x2ac7b2[_0x6164('0x8a')](_0x4d94ac);}})[_0x6164('0x22')](function(_0x504bdf){if(_0x504bdf){_0x5b3455=_0x504bdf[_0x6164('0x43')];if(!_0xd9fb35['query'][_0x6164('0x55')](_0x6164('0x36'))){_0x4d94ac['limit']=qs['limit'](_0xd9fb35[_0x6164('0x30')][_0x6164('0x1a')]);_0x4d94ac[_0x6164('0x19')]=qs[_0x6164('0x19')](_0xd9fb35[_0x6164('0x30')][_0x6164('0x19')]);}return _0x2ac7b2[_0x6164('0x8a')](_0x4d94ac);}})[_0x6164('0x22')](function(_0x18541f){if(_0x18541f){return _0x18541f?{'count':_0x5b3455,'rows':_0x18541f}:null;}})[_0x6164('0x22')](respondWithResult(_0x5a5614,null))[_0x6164('0x41')](handleError(_0x5a5614,null));};exports['addBlackLists']=function(_0x1dd204,_0x37a79c,_0x28ec60){var _0x40de8f,_0x19ef83;var _0x343948=[];var _0x42a05c=moment()[_0x6164('0x8c')](_0x6164('0x61'));return db[_0x6164('0x3e')][_0x6164('0x45')]({'where':{'id':_0x1dd204[_0x6164('0x42')]['id']}})[_0x6164('0x22')](handleEntityNotFound(_0x37a79c,null))['then'](function(_0x1d375c){if(_0x1d375c){_0x19ef83=_0x1d375c;return _0x1d375c['addBlackLists'](_0x1dd204[_0x6164('0x47')]['ids'],_[_0x6164('0x4f')](_0x1dd204['body'],[_0x6164('0x62'),'id'])||{});}return null;})[_0x6164('0x63')](function(_0x5e7ad8){var _0x37f51d;var _0x85e047;_0x40de8f=_0x5e7ad8||[];var _0x2c31e1=[];if(_0x5e7ad8){for(var _0x42342b=0x0;_0x42342b<_0x5e7ad8[_0x6164('0x43')];_0x42342b+=0x1){var _0x486845=_0x5e7ad8[_0x42342b][_0x6164('0x24')]({'plain':!![]});_0x37f51d=squel[_0x6164('0x65')]()[_0x6164('0x66')]('cm_hopper_black')['fromQuery']([_0x6164('0x69'),_0x6164('0x6b'),_0x6164('0x6c'),_0x6164('0x56'),_0x6164('0x50'),_0x6164('0x51')],squel[_0x6164('0x6d')]()[_0x6164('0x6e')](_0x6164('0x69'),_0x6164('0x69'))[_0x6164('0x6e')]('id',_0x6164('0x6b'))[_0x6164('0x6e')](_0x486845[_0x6164('0x73')][_0x6164('0x74')](),_0x6164('0x6c'))['field'](_0x1dd204[_0x6164('0x42')]['id']['toString'](),_0x6164('0x56'))[_0x6164('0x6e')](_0x6164('0x6f'),'createdAt')['field']('NOW()',_0x6164('0x51'))['from'](_0x6164('0x7c'))['where'](_0x6164('0x71'))[_0x6164('0x39')](_0x6164('0x72'),_0x486845[_0x6164('0x73')][_0x6164('0x74')]())[_0x6164('0x39')](_0x6164('0x75')))['toString']();_0x2c31e1[_0x6164('0x86')](db[_0x6164('0x87')]['query'](_0x37f51d));}return BPromise['all'](_0x2c31e1);}})[_0x6164('0x22')](function(){return _0x40de8f;})[_0x6164('0x22')](respondWithResult(_0x37a79c,null))[_0x6164('0x41')](handleError(_0x37a79c,null));};exports[_0x6164('0x8d')]=function(_0xeeb379,_0x2e8f35,_0x463944){return db[_0x6164('0x3e')]['find']({'where':{'id':_0xeeb379[_0x6164('0x42')]['id']}})[_0x6164('0x22')](handleEntityNotFound(_0x2e8f35,null))[_0x6164('0x22')](function(_0x226610){if(_0x226610){return _0x226610[_0x6164('0x8d')](_0xeeb379[_0x6164('0x30')]['ids']);}})[_0x6164('0x22')](function(_0x360431){if(_0x360431){return db['CmHopperBlack'][_0x6164('0x23')]({'where':{'ListId':_0xeeb379[_0x6164('0x30')][_0x6164('0x62')],'CampaignId':_0xeeb379['params']['id']}})[_0x6164('0x22')](function(){return _0x360431;});}})[_0x6164('0x22')](respondWithStatusCode(_0x2e8f35,null))[_0x6164('0x41')](handleError(_0x2e8f35,null));};
\ No newline at end of file