Built motion from commit 97153652.|2.6.26
[motion2.git] / server / api / campaign / campaign.controller.js
index 6b5b243..346c5e3 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 _0x380a=['sort','filters','pick','filter','where','VIRTUAL','merge','options','includeAll','include','rows','catch','show','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','omit','createdAt','updatedAt','user','autoAssociation','getHoppers','findOne','CmHopper','CampaignId','findAll','CmHopperHistory','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getLists','CmList','format','ids','dialCheckDuplicateType','insert','scheduledAt','ContactId','ListId','select','field','phone','CmListId','toString','cm_contacts','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','COALESCE(calleridnum,\x27\x27)','cm_hopper_final','CampaignId\x20=\x20?','phone\x20NOT\x20IN\x20(?)','from','cm_hopper','onlyIfOpen','into','fromQuery','NOW()','deletedAt\x20IS\x20NULL','cm_hopper_additional_phones','cmHopperId','OrderBy','ci.item','cm_contact_has_items','join','h.ListId\x20=\x20?','h.CampaignId=?','h.createdAt\x20=\x20?','sequelize','all','removeLists','getBlackLists','addBlackLists','YYYY-MM-DD\x20HH:mm:ss','spread','push','removeBlackLists','eml-format','rimraf','zip-dir','request-promise','mustache','sox','to-csv','ejs','crypto','querystring','papaparse','ioredis','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','undefined','offset','count','limit','set','apply','reject','save','update','then','destroy','get','IvrCampaigns','UserProfileResource','sendStatus','stack','name','send','index','Campaign','rawAttributes','fieldName','type','key','model','map','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order'];(function(_0x1f080f,_0x2da97){var _0x16d826=function(_0x20b1ec){while(--_0x20b1ec){_0x1f080f['push'](_0x1f080f['shift']());}};_0x16d826(++_0x2da97);}(_0x380a,0x16c));var _0xa380=function(_0x47c958,_0x3cfe09){_0x47c958=_0x47c958-0x0;var _0x573eab=_0x380a[_0x47c958];return _0x573eab;};'use strict';var emlformat=require(_0xa380('0x0'));var rimraf=require(_0xa380('0x1'));var zipdir=require(_0xa380('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xa380('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xa380('0x4'));var util=require('util');var path=require('path');var sox=require(_0xa380('0x5'));var csv=require(_0xa380('0x6'));var ejs=require(_0xa380('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require('squel');var crypto=require(_0xa380('0x8'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xa380('0x6'));var querystring=require(_0xa380('0x9'));var Papa=require(_0xa380('0xa'));var Redis=require(_0xa380('0xb'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xa380('0xc'));var logger=require(_0xa380('0xd'))('api');var utils=require(_0xa380('0xe'));var config=require(_0xa380('0xf'));var licenseUtil=require(_0xa380('0x10'));var db=require(_0xa380('0x11'))['db'];function respondWithStatusCode(_0x36c941,_0x35256a){_0x35256a=_0x35256a||0xcc;return function(_0x1a0bd2){if(_0x1a0bd2){return _0x36c941['sendStatus'](_0x35256a);}return _0x36c941[_0xa380('0x12')](_0x35256a)[_0xa380('0x13')]();};}function respondWithResult(_0x25c2d9,_0x48df05){_0x48df05=_0x48df05||0xc8;return function(_0x480fe3){if(_0x480fe3){return _0x25c2d9[_0xa380('0x12')](_0x48df05)[_0xa380('0x14')](_0x480fe3);}};}function respondWithFilteredResult(_0x2ad901,_0x4734de){return function(_0x2c085a){if(_0x2c085a){var _0x3a713e=typeof _0x4734de['offset']===_0xa380('0x15')&&typeof _0x4734de['limit']===_0xa380('0x15');var _0x2ab7af=_0x2c085a['count'];var _0x8eaa53=_0x3a713e?0x0:_0x4734de[_0xa380('0x16')];var _0x226613=_0x3a713e?_0x2c085a[_0xa380('0x17')]:_0x4734de['offset']+_0x4734de[_0xa380('0x18')];var _0x3779bc;if(_0x226613>=_0x2ab7af){_0x226613=_0x2ab7af;_0x3779bc=0xc8;}else{_0x3779bc=0xce;}_0x2ad901[_0xa380('0x12')](_0x3779bc);return _0x2ad901[_0xa380('0x19')]('Content-Range',_0x8eaa53+'-'+_0x226613+'/'+_0x2ab7af)['json'](_0x2c085a);}return null;};}function patchUpdates(_0x528650){return function(_0x2c4895){try{jsonpatch[_0xa380('0x1a')](_0x2c4895,_0x528650,!![]);}catch(_0x4a5766){return BPromise[_0xa380('0x1b')](_0x4a5766);}return _0x2c4895[_0xa380('0x1c')]();};}function saveUpdates(_0x9d2294,_0x315e39){return function(_0x250acf){if(_0x250acf){return _0x250acf[_0xa380('0x1d')](_0x9d2294)[_0xa380('0x1e')](function(_0x3c950e){return _0x3c950e;});}return null;};}function removeEntity(_0x3df22b,_0x291695){return function(_0x425ddd){if(_0x425ddd){return _0x425ddd[_0xa380('0x1f')]()[_0xa380('0x1e')](function(){var _0x5cc7f6=_0x425ddd[_0xa380('0x20')]({'plain':!![]});var _0x1d603c=_0xa380('0x21');return db[_0xa380('0x22')][_0xa380('0x1f')]({'where':{'type':_0x1d603c,'resourceId':_0x5cc7f6['id']}})['then'](function(){return _0x425ddd;});})['then'](function(){_0x3df22b[_0xa380('0x12')](0xcc)[_0xa380('0x13')]();});}};}function handleEntityNotFound(_0xa0c142,_0xc80edd){return function(_0x39f423){if(!_0x39f423){_0xa0c142[_0xa380('0x23')](0x194);}return _0x39f423;};}function handleError(_0x4a60d4,_0x3e5879){_0x3e5879=_0x3e5879||0x1f4;return function(_0x1dd99b){logger['error'](_0x1dd99b[_0xa380('0x24')]);if(_0x1dd99b[_0xa380('0x25')]){delete _0x1dd99b[_0xa380('0x25')];}_0x4a60d4[_0xa380('0x12')](_0x3e5879)[_0xa380('0x26')](_0x1dd99b);};}exports[_0xa380('0x27')]=function(_0x1fce2b,_0x3618f7){var _0x35a330={},_0xba971c={},_0x14fa7f={'count':0x0,'rows':[]};var _0x318eb3=_['map'](db[_0xa380('0x28')][_0xa380('0x29')],function(_0x416c21){return{'name':_0x416c21[_0xa380('0x2a')],'type':_0x416c21[_0xa380('0x2b')][_0xa380('0x2c')]};});_0xba971c[_0xa380('0x2d')]=_[_0xa380('0x2e')](_0x318eb3,_0xa380('0x25'));_0xba971c[_0xa380('0x2f')]=_[_0xa380('0x30')](_0x1fce2b[_0xa380('0x2f')]);_0xba971c['filters']=_[_0xa380('0x31')](_0xba971c[_0xa380('0x2d')],_0xba971c[_0xa380('0x2f')]);_0x35a330[_0xa380('0x32')]=_[_0xa380('0x31')](_0xba971c[_0xa380('0x2d')],qs[_0xa380('0x33')](_0x1fce2b[_0xa380('0x2f')]['fields']));_0x35a330[_0xa380('0x32')]=_0x35a330[_0xa380('0x32')][_0xa380('0x34')]?_0x35a330[_0xa380('0x32')]:_0xba971c[_0xa380('0x2d')];if(!_0x1fce2b[_0xa380('0x2f')][_0xa380('0x35')](_0xa380('0x36'))){_0x35a330['limit']=qs[_0xa380('0x18')](_0x1fce2b[_0xa380('0x2f')][_0xa380('0x18')]);_0x35a330[_0xa380('0x16')]=qs[_0xa380('0x16')](_0x1fce2b[_0xa380('0x2f')][_0xa380('0x16')]);}_0x35a330[_0xa380('0x37')]=qs[_0xa380('0x38')](_0x1fce2b[_0xa380('0x2f')][_0xa380('0x38')]);_0x35a330['where']=qs[_0xa380('0x39')](_[_0xa380('0x3a')](_0x1fce2b[_0xa380('0x2f')],_0xba971c[_0xa380('0x39')]),_0x318eb3);if(_0x1fce2b['query'][_0xa380('0x3b')]){_0x35a330[_0xa380('0x3c')]=_['merge'](_0x35a330['where'],{'$or':_['map'](_0x318eb3,function(_0x437538){if(_0x437538[_0xa380('0x2b')]!==_0xa380('0x3d')){var _0x370e46={};_0x370e46[_0x437538[_0xa380('0x25')]]={'$like':'%'+_0x1fce2b['query']['filter']+'%'};return _0x370e46;}})});}_0x35a330=_[_0xa380('0x3e')]({},_0x35a330,_0x1fce2b[_0xa380('0x3f')]);var _0x251b50={'where':_0x35a330[_0xa380('0x3c')]};return db[_0xa380('0x28')][_0xa380('0x17')](_0x251b50)[_0xa380('0x1e')](function(_0x212a20){_0x14fa7f[_0xa380('0x17')]=_0x212a20;if(_0x1fce2b[_0xa380('0x2f')][_0xa380('0x40')]){_0x35a330[_0xa380('0x41')]=[{'all':!![]}];}return db['Campaign']['findAll'](_0x35a330);})[_0xa380('0x1e')](function(_0x261563){_0x14fa7f[_0xa380('0x42')]=_0x261563;return _0x14fa7f;})[_0xa380('0x1e')](respondWithFilteredResult(_0x3618f7,_0x35a330))[_0xa380('0x43')](handleError(_0x3618f7,null));};exports[_0xa380('0x44')]=function(_0x36646e,_0x100181){var _0x271e1e={'raw':![],'where':{'id':_0x36646e['params']['id']}},_0xe2f9f1={};_0xe2f9f1[_0xa380('0x2d')]=_[_0xa380('0x30')](db['Campaign'][_0xa380('0x29')]);_0xe2f9f1['query']=_[_0xa380('0x30')](_0x36646e[_0xa380('0x2f')]);_0xe2f9f1[_0xa380('0x39')]=_[_0xa380('0x31')](_0xe2f9f1['model'],_0xe2f9f1[_0xa380('0x2f')]);_0x271e1e['attributes']=_[_0xa380('0x31')](_0xe2f9f1[_0xa380('0x2d')],qs[_0xa380('0x33')](_0x36646e[_0xa380('0x2f')][_0xa380('0x33')]));_0x271e1e[_0xa380('0x32')]=_0x271e1e[_0xa380('0x32')][_0xa380('0x34')]?_0x271e1e[_0xa380('0x32')]:_0xe2f9f1[_0xa380('0x2d')];if(_0x36646e[_0xa380('0x2f')]['includeAll']){_0x271e1e['include']=[{'all':!![]}];}_0x271e1e=_[_0xa380('0x3e')]({},_0x271e1e,_0x36646e[_0xa380('0x3f')]);return db[_0xa380('0x28')]['find'](_0x271e1e)['then'](handleEntityNotFound(_0x100181,null))[_0xa380('0x1e')](respondWithResult(_0x100181,null))[_0xa380('0x43')](handleError(_0x100181,null));};exports[_0xa380('0x45')]=function(_0x1f8fca,_0x1f5820){return db[_0xa380('0x28')][_0xa380('0x45')](_0x1f8fca[_0xa380('0x46')],{})['then'](function(_0xc271c1){var _0x19af6a=_0x1f8fca['user'][_0xa380('0x20')]({'plain':!![]});if(!_0x19af6a)throw new Error(_0xa380('0x47'));if(_0x19af6a[_0xa380('0x48')]==='user'){var _0x29b140=_0xc271c1['get']({'plain':!![]});var _0x4794e=_0xa380('0x21');return db[_0xa380('0x49')][_0xa380('0x4a')]({'where':{'name':_0x4794e,'userProfileId':_0x19af6a[_0xa380('0x4b')]},'raw':!![]})[_0xa380('0x1e')](function(_0x33e25e){if(_0x33e25e&&_0x33e25e['autoAssociation']===0x0){return db[_0xa380('0x22')][_0xa380('0x45')]({'name':_0x29b140['name'],'resourceId':_0x29b140['id'],'type':_0x33e25e['name'],'sectionId':_0x33e25e['id']},{})[_0xa380('0x1e')](function(){return _0xc271c1;});}else{return _0xc271c1;}})['catch'](function(_0x16c479){logger[_0xa380('0x4c')](_0xa380('0x4d'),_0x16c479);throw _0x16c479;});}return _0xc271c1;})['then'](respondWithResult(_0x1f5820,0xc9))['catch'](handleError(_0x1f5820,null));};exports['clone']=function(_0x5bf9f1,_0x43ad25){var _0x281abe={'where':{'id':_0x5bf9f1[_0xa380('0x4e')]['id']}},_0x82fc25={};_0x82fc25[_0xa380('0x2d')]=_['keys'](db[_0xa380('0x28')]['rawAttributes']);_0x281abe[_0xa380('0x32')]=_['intersection'](_0x82fc25[_0xa380('0x2d')],qs[_0xa380('0x33')](_0x5bf9f1[_0xa380('0x2f')][_0xa380('0x33')]));_0x281abe['attributes']=_0x281abe[_0xa380('0x32')][_0xa380('0x34')]?_0x281abe[_0xa380('0x32')]:_0x82fc25[_0xa380('0x2d')];if(_0x5bf9f1['query'][_0xa380('0x40')]){_0x281abe['include']=[{'all':!![]}];}_0x281abe=_[_0xa380('0x3e')]({},_0x281abe,_0x5bf9f1[_0xa380('0x3f')]);return db[_0xa380('0x28')][_0xa380('0x4a')](_0x281abe)[_0xa380('0x1e')](handleEntityNotFound(_0x43ad25,null))[_0xa380('0x1e')](function(_0x519534){if(_0x519534){var _0x3cb89e=_0x519534['get']({'plain':!![]});_0x3cb89e=qs[_0xa380('0x4f')](_0x3cb89e,['id',_0xa380('0x50'),_0xa380('0x51')]);_0x5bf9f1[_0xa380('0x46')]=_[_0xa380('0x4f')](_0x5bf9f1[_0xa380('0x46')],['id',_0xa380('0x50'),_0xa380('0x51')]);return db[_0xa380('0x28')][_0xa380('0x45')](_['merge'](_0x3cb89e,_0x5bf9f1[_0xa380('0x46')]),{'include':_0x5bf9f1[_0xa380('0x2f')][_0xa380('0x40')]?[{'all':!![]}]:undefined})[_0xa380('0x1e')](function(_0x502d68){var _0x4f415f=_0x5bf9f1[_0xa380('0x52')][_0xa380('0x20')]({'plain':!![]});if(!_0x4f415f)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x4f415f['role']==='user'){var _0x2dd487=_0x502d68[_0xa380('0x20')]({'plain':!![]});var _0x2cf982='IvrCampaigns';return db[_0xa380('0x49')]['find']({'where':{'name':_0x2cf982,'userProfileId':_0x4f415f['userProfileId']},'raw':!![]})[_0xa380('0x1e')](function(_0x533937){if(_0x533937&&_0x533937[_0xa380('0x53')]===0x0){return db[_0xa380('0x22')][_0xa380('0x45')]({'name':_0x2dd487[_0xa380('0x25')],'resourceId':_0x2dd487['id'],'type':_0x533937[_0xa380('0x25')],'sectionId':_0x533937['id']},{})[_0xa380('0x1e')](function(){return _0x502d68;});}else{return _0x502d68;}})[_0xa380('0x43')](function(_0x367c4b){logger[_0xa380('0x4c')](_0xa380('0x4d'),_0x367c4b);throw _0x367c4b;});}return _0x502d68;});}})[_0xa380('0x1e')](respondWithResult(_0x43ad25,0xc9))[_0xa380('0x43')](handleError(_0x43ad25,null));};exports['update']=function(_0x5f4df6,_0x18335b){if(_0x5f4df6[_0xa380('0x46')]['id']){delete _0x5f4df6[_0xa380('0x46')]['id'];}return db[_0xa380('0x28')][_0xa380('0x4a')]({'where':{'id':_0x5f4df6[_0xa380('0x4e')]['id']}})['then'](handleEntityNotFound(_0x18335b,null))[_0xa380('0x1e')](saveUpdates(_0x5f4df6[_0xa380('0x46')],null))[_0xa380('0x1e')](respondWithResult(_0x18335b,null))[_0xa380('0x43')](handleError(_0x18335b,null));};exports[_0xa380('0x1f')]=function(_0x250bb7,_0x537953){return db[_0xa380('0x28')]['find']({'where':{'id':_0x250bb7[_0xa380('0x4e')]['id']}})[_0xa380('0x1e')](handleEntityNotFound(_0x537953,null))['then'](removeEntity(_0x537953,null))[_0xa380('0x43')](handleError(_0x537953,null));};exports[_0xa380('0x54')]=function(_0x5325b4,_0x2366cf,_0x5173a1){var _0x5eb552={'raw':!![],'where':{}};var _0x411582={};var _0x32e553={'count':0x0,'rows':[]};return db[_0xa380('0x28')][_0xa380('0x55')]({'where':{'id':_0x5325b4[_0xa380('0x4e')]['id']}})['then'](handleEntityNotFound(_0x2366cf,null))[_0xa380('0x1e')](function(_0x2a2f62){if(_0x2a2f62){_0x411582['model']=_[_0xa380('0x30')](db[_0xa380('0x56')][_0xa380('0x29')]);_0x411582['query']=_[_0xa380('0x30')](_0x5325b4['query']);_0x411582[_0xa380('0x39')]=_[_0xa380('0x31')](_0x411582[_0xa380('0x2d')],_0x411582['query']);_0x5eb552[_0xa380('0x32')]=_[_0xa380('0x31')](_0x411582[_0xa380('0x2d')],qs['fields'](_0x5325b4[_0xa380('0x2f')][_0xa380('0x33')]));_0x5eb552[_0xa380('0x32')]=_0x5eb552[_0xa380('0x32')][_0xa380('0x34')]?_0x5eb552['attributes']:_0x411582['model'];if(!_0x5325b4[_0xa380('0x2f')][_0xa380('0x35')]('nolimit')){_0x5eb552[_0xa380('0x18')]=qs[_0xa380('0x18')](_0x5325b4['query'][_0xa380('0x18')]);_0x5eb552[_0xa380('0x16')]=qs[_0xa380('0x16')](_0x5325b4[_0xa380('0x2f')][_0xa380('0x16')]);}_0x5eb552[_0xa380('0x37')]=qs[_0xa380('0x38')](_0x5325b4[_0xa380('0x2f')]['sort']);_0x5eb552[_0xa380('0x3c')]=qs[_0xa380('0x39')](_[_0xa380('0x3a')](_0x5325b4['query'],_0x411582['filters']));_0x5eb552[_0xa380('0x3c')][_0xa380('0x57')]=_0x2a2f62['id'];if(_0x5325b4[_0xa380('0x2f')][_0xa380('0x3b')]){_0x5eb552[_0xa380('0x3c')]=_['merge'](_0x5eb552['where'],{'$or':_[_0xa380('0x2e')](_0x5eb552['attributes'],function(_0x59f6a8){var _0x1d95c8={};_0x1d95c8[_0x59f6a8]={'$like':'%'+_0x5325b4[_0xa380('0x2f')][_0xa380('0x3b')]+'%'};return _0x1d95c8;})});}_0x5eb552=_[_0xa380('0x3e')]({},_0x5eb552,_0x5325b4[_0xa380('0x3f')]);return db[_0xa380('0x56')][_0xa380('0x17')]({'where':_0x5eb552[_0xa380('0x3c')]})['then'](function(_0x3b178a){_0x32e553[_0xa380('0x17')]=_0x3b178a;if(_0x5325b4[_0xa380('0x2f')][_0xa380('0x40')]){_0x5eb552['include']=[{'all':!![]}];}return db[_0xa380('0x56')][_0xa380('0x58')](_0x5eb552);})[_0xa380('0x1e')](function(_0x3d5a62){_0x32e553[_0xa380('0x42')]=_0x3d5a62;return _0x32e553;});}})[_0xa380('0x1e')](respondWithFilteredResult(_0x2366cf,_0x5eb552))[_0xa380('0x43')](handleError(_0x2366cf,null));};exports['getHopperHistories']=function(_0x3ef209,_0x5638cc,_0x11e968){var _0x1e5486={'raw':!![],'where':{}};var _0x57ca79={};var _0x43872e={'count':0x0,'rows':[]};return db[_0xa380('0x28')][_0xa380('0x55')]({'where':{'id':_0x3ef209[_0xa380('0x4e')]['id']}})['then'](handleEntityNotFound(_0x5638cc,null))[_0xa380('0x1e')](function(_0x3b0b1b){if(_0x3b0b1b){_0x57ca79[_0xa380('0x2d')]=_[_0xa380('0x30')](db[_0xa380('0x59')][_0xa380('0x29')]);_0x57ca79['query']=_[_0xa380('0x30')](_0x3ef209[_0xa380('0x2f')]);_0x57ca79[_0xa380('0x39')]=_[_0xa380('0x31')](_0x57ca79[_0xa380('0x2d')],_0x57ca79['query']);_0x1e5486['attributes']=_[_0xa380('0x31')](_0x57ca79[_0xa380('0x2d')],qs[_0xa380('0x33')](_0x3ef209[_0xa380('0x2f')][_0xa380('0x33')]));_0x1e5486[_0xa380('0x32')]=_0x1e5486[_0xa380('0x32')][_0xa380('0x34')]?_0x1e5486[_0xa380('0x32')]:_0x57ca79[_0xa380('0x2d')];if(!_0x3ef209[_0xa380('0x2f')]['hasOwnProperty'](_0xa380('0x36'))){_0x1e5486[_0xa380('0x18')]=qs[_0xa380('0x18')](_0x3ef209[_0xa380('0x2f')][_0xa380('0x18')]);_0x1e5486['offset']=qs[_0xa380('0x16')](_0x3ef209['query'][_0xa380('0x16')]);}_0x1e5486[_0xa380('0x37')]=qs[_0xa380('0x38')](_0x3ef209[_0xa380('0x2f')]['sort']);_0x1e5486[_0xa380('0x3c')]=qs['filters'](_[_0xa380('0x3a')](_0x3ef209[_0xa380('0x2f')],_0x57ca79[_0xa380('0x39')]));_0x1e5486[_0xa380('0x3c')]['CampaignId']=_0x3b0b1b['id'];if(_0x3ef209[_0xa380('0x2f')][_0xa380('0x3b')]){_0x1e5486['where']=_['merge'](_0x1e5486['where'],{'$or':_[_0xa380('0x2e')](_0x1e5486['attributes'],function(_0x11f39c){var _0x11c2ad={};_0x11c2ad[_0x11f39c]={'$like':'%'+_0x3ef209[_0xa380('0x2f')]['filter']+'%'};return _0x11c2ad;})});}_0x1e5486=_[_0xa380('0x3e')]({},_0x1e5486,_0x3ef209[_0xa380('0x3f')]);return db[_0xa380('0x59')][_0xa380('0x17')]({'where':_0x1e5486[_0xa380('0x3c')]})[_0xa380('0x1e')](function(_0x2a5dd7){_0x43872e[_0xa380('0x17')]=_0x2a5dd7;if(_0x3ef209['query'][_0xa380('0x40')]){_0x1e5486[_0xa380('0x41')]=[{'all':!![]}];}return db[_0xa380('0x59')][_0xa380('0x58')](_0x1e5486);})[_0xa380('0x1e')](function(_0x204e75){_0x43872e['rows']=_0x204e75;return _0x43872e;});}})['then'](respondWithFilteredResult(_0x5638cc,_0x1e5486))[_0xa380('0x43')](handleError(_0x5638cc,null));};exports[_0xa380('0x5a')]=function(_0x4cb583,_0x6b4641,_0x159abd){var _0x1727fc={'raw':!![],'where':{}};var _0x154d8b={};var _0x23fdb7={'count':0x0,'rows':[]};return db[_0xa380('0x28')][_0xa380('0x55')]({'where':{'id':_0x4cb583['params']['id']}})[_0xa380('0x1e')](handleEntityNotFound(_0x6b4641,null))[_0xa380('0x1e')](function(_0x4d14ec){if(_0x4d14ec){_0x154d8b[_0xa380('0x2d')]=_[_0xa380('0x30')](db[_0xa380('0x5b')][_0xa380('0x29')]);_0x154d8b[_0xa380('0x2f')]=_[_0xa380('0x30')](_0x4cb583['query']);_0x154d8b['filters']=_['intersection'](_0x154d8b[_0xa380('0x2d')],_0x154d8b[_0xa380('0x2f')]);_0x1727fc[_0xa380('0x32')]=_[_0xa380('0x31')](_0x154d8b[_0xa380('0x2d')],qs[_0xa380('0x33')](_0x4cb583[_0xa380('0x2f')][_0xa380('0x33')]));_0x1727fc[_0xa380('0x32')]=_0x1727fc[_0xa380('0x32')]['length']?_0x1727fc[_0xa380('0x32')]:_0x154d8b['model'];if(!_0x4cb583[_0xa380('0x2f')][_0xa380('0x35')](_0xa380('0x36'))){_0x1727fc[_0xa380('0x18')]=qs[_0xa380('0x18')](_0x4cb583['query']['limit']);_0x1727fc[_0xa380('0x16')]=qs[_0xa380('0x16')](_0x4cb583['query'][_0xa380('0x16')]);}_0x1727fc[_0xa380('0x37')]=qs[_0xa380('0x38')](_0x4cb583[_0xa380('0x2f')][_0xa380('0x38')]);_0x1727fc[_0xa380('0x3c')]=qs[_0xa380('0x39')](_[_0xa380('0x3a')](_0x4cb583['query'],_0x154d8b[_0xa380('0x39')]));_0x1727fc[_0xa380('0x3c')][_0xa380('0x57')]=_0x4d14ec['id'];if(_0x4cb583[_0xa380('0x2f')][_0xa380('0x3b')]){_0x1727fc['where']=_[_0xa380('0x3e')](_0x1727fc[_0xa380('0x3c')],{'$or':_[_0xa380('0x2e')](_0x1727fc[_0xa380('0x32')],function(_0x45a8df){var _0x5cb2d6={};_0x5cb2d6[_0x45a8df]={'$like':'%'+_0x4cb583[_0xa380('0x2f')][_0xa380('0x3b')]+'%'};return _0x5cb2d6;})});}_0x1727fc=_[_0xa380('0x3e')]({},_0x1727fc,_0x4cb583[_0xa380('0x3f')]);return db[_0xa380('0x5b')][_0xa380('0x17')]({'where':_0x1727fc[_0xa380('0x3c')]})[_0xa380('0x1e')](function(_0x3608e0){_0x23fdb7[_0xa380('0x17')]=_0x3608e0;if(_0x4cb583['query']['includeAll']){_0x1727fc[_0xa380('0x41')]=[{'all':!![]}];}return db[_0xa380('0x5b')][_0xa380('0x58')](_0x1727fc);})[_0xa380('0x1e')](function(_0x9e0edc){_0x23fdb7[_0xa380('0x42')]=_0x9e0edc;return _0x23fdb7;});}})[_0xa380('0x1e')](respondWithFilteredResult(_0x6b4641,_0x1727fc))[_0xa380('0x43')](handleError(_0x6b4641,null));};exports[_0xa380('0x5c')]=function(_0x307a9e,_0x3b6c02,_0x1c2331){var _0x2fba8b={'raw':!![],'where':{}};var _0x7c522c={};var _0x5c0439={'count':0x0,'rows':[]};return db['Campaign']['findOne']({'where':{'id':_0x307a9e[_0xa380('0x4e')]['id']}})[_0xa380('0x1e')](handleEntityNotFound(_0x3b6c02,null))[_0xa380('0x1e')](function(_0xddcc4e){if(_0xddcc4e){_0x7c522c[_0xa380('0x2d')]=_['keys'](db[_0xa380('0x5d')][_0xa380('0x29')]);_0x7c522c[_0xa380('0x2f')]=_['keys'](_0x307a9e[_0xa380('0x2f')]);_0x7c522c['filters']=_['intersection'](_0x7c522c[_0xa380('0x2d')],_0x7c522c['query']);_0x2fba8b[_0xa380('0x32')]=_[_0xa380('0x31')](_0x7c522c[_0xa380('0x2d')],qs['fields'](_0x307a9e[_0xa380('0x2f')][_0xa380('0x33')]));_0x2fba8b[_0xa380('0x32')]=_0x2fba8b['attributes']['length']?_0x2fba8b[_0xa380('0x32')]:_0x7c522c[_0xa380('0x2d')];if(!_0x307a9e[_0xa380('0x2f')][_0xa380('0x35')]('nolimit')){_0x2fba8b[_0xa380('0x18')]=qs[_0xa380('0x18')](_0x307a9e[_0xa380('0x2f')]['limit']);_0x2fba8b[_0xa380('0x16')]=qs[_0xa380('0x16')](_0x307a9e[_0xa380('0x2f')][_0xa380('0x16')]);}_0x2fba8b[_0xa380('0x37')]=qs['sort'](_0x307a9e[_0xa380('0x2f')][_0xa380('0x38')]);_0x2fba8b[_0xa380('0x3c')]=qs[_0xa380('0x39')](_[_0xa380('0x3a')](_0x307a9e[_0xa380('0x2f')],_0x7c522c[_0xa380('0x39')]));_0x2fba8b[_0xa380('0x3c')]['CampaignId']=_0xddcc4e['id'];if(_0x307a9e[_0xa380('0x2f')][_0xa380('0x3b')]){_0x2fba8b['where']=_[_0xa380('0x3e')](_0x2fba8b['where'],{'$or':_[_0xa380('0x2e')](_0x2fba8b[_0xa380('0x32')],function(_0x4feaf7){var _0x45cacc={};_0x45cacc[_0x4feaf7]={'$like':'%'+_0x307a9e[_0xa380('0x2f')][_0xa380('0x3b')]+'%'};return _0x45cacc;})});}_0x2fba8b=_['merge']({},_0x2fba8b,_0x307a9e['options']);return db['CmHopperBlack']['count']({'where':_0x2fba8b[_0xa380('0x3c')]})[_0xa380('0x1e')](function(_0x45d232){_0x5c0439['count']=_0x45d232;if(_0x307a9e['query'][_0xa380('0x40')]){_0x2fba8b[_0xa380('0x41')]=[{'all':!![]}];}return db['CmHopperBlack']['findAll'](_0x2fba8b);})['then'](function(_0x33b2cb){_0x5c0439['rows']=_0x33b2cb;return _0x5c0439;});}})[_0xa380('0x1e')](respondWithFilteredResult(_0x3b6c02,_0x2fba8b))[_0xa380('0x43')](handleError(_0x3b6c02,null));};exports[_0xa380('0x5e')]=function(_0x19c446,_0xf59c2d,_0x279bd7){var _0x32127e={};var _0x29ee91={};var _0x16d0d2;var _0x22903f;return db[_0xa380('0x28')]['findOne']({'where':{'id':_0x19c446[_0xa380('0x4e')]['id']}})[_0xa380('0x1e')](handleEntityNotFound(_0xf59c2d,null))[_0xa380('0x1e')](function(_0x43d6b0){if(_0x43d6b0){_0x16d0d2=_0x43d6b0;_0x29ee91['model']=_[_0xa380('0x30')](db[_0xa380('0x5f')]['rawAttributes']);_0x29ee91[_0xa380('0x2f')]=_[_0xa380('0x30')](_0x19c446[_0xa380('0x2f')]);_0x29ee91[_0xa380('0x39')]=_[_0xa380('0x31')](_0x29ee91[_0xa380('0x2d')],_0x29ee91[_0xa380('0x2f')]);_0x32127e[_0xa380('0x32')]=_['intersection'](_0x29ee91['model'],qs[_0xa380('0x33')](_0x19c446[_0xa380('0x2f')]['fields']));_0x32127e['attributes']=_0x32127e['attributes'][_0xa380('0x34')]?_0x32127e['attributes']:_0x29ee91[_0xa380('0x2d')];_0x32127e[_0xa380('0x37')]=qs[_0xa380('0x38')](_0x19c446['query'][_0xa380('0x38')]);_0x32127e[_0xa380('0x3c')]=qs[_0xa380('0x39')](_[_0xa380('0x3a')](_0x19c446[_0xa380('0x2f')],_0x29ee91['filters']));if(_0x19c446['query'][_0xa380('0x3b')]){_0x32127e[_0xa380('0x3c')]=_[_0xa380('0x3e')](_0x32127e['where'],{'$or':_[_0xa380('0x2e')](_0x32127e[_0xa380('0x32')],function(_0x3a3710){var _0xe85d05={};_0xe85d05[_0x3a3710]={'$like':'%'+_0x19c446[_0xa380('0x2f')][_0xa380('0x3b')]+'%'};return _0xe85d05;})});}_0x32127e=_[_0xa380('0x3e')]({},_0x32127e,_0x19c446[_0xa380('0x3f')]);return _0x16d0d2[_0xa380('0x5e')](_0x32127e);}})[_0xa380('0x1e')](function(_0x180d2f){if(_0x180d2f){_0x22903f=_0x180d2f['length'];if(!_0x19c446[_0xa380('0x2f')][_0xa380('0x35')](_0xa380('0x36'))){_0x32127e[_0xa380('0x18')]=qs[_0xa380('0x18')](_0x19c446[_0xa380('0x2f')]['limit']);_0x32127e[_0xa380('0x16')]=qs['offset'](_0x19c446[_0xa380('0x2f')][_0xa380('0x16')]);}return _0x16d0d2[_0xa380('0x5e')](_0x32127e);}})['then'](function(_0x22b41f){if(_0x22b41f){return _0x22b41f?{'count':_0x22903f,'rows':_0x22b41f}:null;}})[_0xa380('0x1e')](respondWithResult(_0xf59c2d,null))['catch'](handleError(_0xf59c2d,null));};exports['addLists']=function(_0x7baf7e,_0xab8f31,_0x27ec2e){var _0x3fb79e,_0x1ef73f;var _0x4b7ac2=[];var _0xc69a8e=moment()[_0xa380('0x60')]('YYYY-MM-DD\x20HH:mm:ss');return db[_0xa380('0x28')][_0xa380('0x4a')]({'where':{'id':_0x7baf7e[_0xa380('0x4e')]['id']}})[_0xa380('0x1e')](handleEntityNotFound(_0xab8f31,null))[_0xa380('0x1e')](function(_0x25bcde){if(_0x25bcde){_0x1ef73f=_0x25bcde;return _0x25bcde['addLists'](_0x7baf7e[_0xa380('0x46')][_0xa380('0x61')],_[_0xa380('0x4f')](_0x7baf7e[_0xa380('0x46')],[_0xa380('0x61'),'id'])||{});}return null;})['spread'](function(_0xb2a855){var _0x1f8d56;var _0x3a85d4;_0x3fb79e=_0xb2a855||[];var _0x1aaca6=[];if(_0xb2a855){for(var _0x2cfdb8=0x0;_0x2cfdb8<_0xb2a855[_0xa380('0x34')];_0x2cfdb8+=0x1){var _0x126e13=_0xb2a855[_0x2cfdb8][_0xa380('0x20')]({'plain':!![]});_0x1ef73f[_0xa380('0x62')]=_0x7baf7e[_0xa380('0x46')][_0xa380('0x62')]?_0x7baf7e[_0xa380('0x46')][_0xa380('0x62')]:_0x1ef73f[_0xa380('0x62')];switch(_0x1ef73f[_0xa380('0x62')]){case'always':_0x1f8d56=squel[_0xa380('0x63')]()['into']('cm_hopper')['fromQuery'](['phone',_0xa380('0x64'),_0xa380('0x65'),_0xa380('0x66'),_0xa380('0x57'),_0xa380('0x50'),'updatedAt'],squel[_0xa380('0x67')]()[_0xa380('0x68')](_0xa380('0x69'),'phone')[_0xa380('0x68')]('NOW()',_0xa380('0x64'))['field']('id',_0xa380('0x65'))[_0xa380('0x68')](_0x126e13[_0xa380('0x6a')][_0xa380('0x6b')](),_0xa380('0x66'))[_0xa380('0x68')](_0x7baf7e['params']['id'][_0xa380('0x6b')](),_0xa380('0x57'))['field']('\x27'+_0xc69a8e+'\x27',_0xa380('0x50'))[_0xa380('0x68')]('\x27'+_0xc69a8e+'\x27',_0xa380('0x51'))['from'](_0xa380('0x6c'))[_0xa380('0x3c')]('deletedAt\x20IS\x20NULL')[_0xa380('0x3c')](_0xa380('0x6d'),_0x126e13[_0xa380('0x6a')][_0xa380('0x6b')]())[_0xa380('0x3c')](_0xa380('0x6e'))[_0xa380('0x3c')]('phone\x20NOT\x20IN\x20(?)',squel[_0xa380('0x67')]()['field'](_0xa380('0x6f'))['from'](_0xa380('0x70'))['where'](_0xa380('0x71'),_0x7baf7e[_0xa380('0x4e')]['id'][_0xa380('0x6b')]()))[_0xa380('0x3c')](_0xa380('0x72'),squel['select']()['field']('COALESCE(phone,\x27\x27)')[_0xa380('0x73')](_0xa380('0x74'))[_0xa380('0x3c')](_0xa380('0x71'),_0x7baf7e[_0xa380('0x4e')]['id'][_0xa380('0x6b')]())))[_0xa380('0x6b')]();break;case _0xa380('0x75'):_0x1f8d56=squel[_0xa380('0x63')]()[_0xa380('0x76')](_0xa380('0x74'))[_0xa380('0x77')](['phone','scheduledAt','ContactId',_0xa380('0x66'),_0xa380('0x57'),_0xa380('0x50'),_0xa380('0x51')],squel[_0xa380('0x67')]()[_0xa380('0x68')](_0xa380('0x69'),_0xa380('0x69'))[_0xa380('0x68')](_0xa380('0x78'),_0xa380('0x64'))[_0xa380('0x68')]('id',_0xa380('0x65'))[_0xa380('0x68')](_0x126e13[_0xa380('0x6a')]['toString'](),_0xa380('0x66'))['field'](_0x7baf7e[_0xa380('0x4e')]['id']['toString'](),'CampaignId')[_0xa380('0x68')]('\x27'+_0xc69a8e+'\x27','createdAt')[_0xa380('0x68')]('\x27'+_0xc69a8e+'\x27',_0xa380('0x51'))[_0xa380('0x73')](_0xa380('0x6c'))[_0xa380('0x3c')](_0xa380('0x79'))[_0xa380('0x3c')](_0xa380('0x6d'),_0x126e13[_0xa380('0x6a')][_0xa380('0x6b')]())['where'](_0xa380('0x6e'))[_0xa380('0x3c')](_0xa380('0x72'),squel[_0xa380('0x67')]()[_0xa380('0x68')]('COALESCE(phone,\x27\x27)')[_0xa380('0x73')](_0xa380('0x74'))['where'](_0xa380('0x71'),_0x7baf7e[_0xa380('0x4e')]['id'][_0xa380('0x6b')]())))[_0xa380('0x6b')]();break;default:_0x1f8d56=squel[_0xa380('0x63')]()[_0xa380('0x76')](_0xa380('0x74'))['fromQuery']([_0xa380('0x69'),_0xa380('0x64'),_0xa380('0x65'),_0xa380('0x66'),_0xa380('0x57'),_0xa380('0x50'),'updatedAt'],squel['select']()[_0xa380('0x68')](_0xa380('0x69'),_0xa380('0x69'))[_0xa380('0x68')](_0xa380('0x78'),'scheduledAt')[_0xa380('0x68')]('id',_0xa380('0x65'))['field'](_0x126e13[_0xa380('0x6a')][_0xa380('0x6b')](),_0xa380('0x66'))[_0xa380('0x68')](_0x7baf7e[_0xa380('0x4e')]['id'][_0xa380('0x6b')](),_0xa380('0x57'))[_0xa380('0x68')]('\x27'+_0xc69a8e+'\x27',_0xa380('0x50'))[_0xa380('0x68')]('\x27'+_0xc69a8e+'\x27',_0xa380('0x51'))[_0xa380('0x73')](_0xa380('0x6c'))[_0xa380('0x3c')](_0xa380('0x79'))[_0xa380('0x3c')](_0xa380('0x6d'),_0x126e13[_0xa380('0x6a')][_0xa380('0x6b')]())['where']('phone\x20IS\x20NOT\x20NULL'))[_0xa380('0x6b')]();}_0x3a85d4=squel[_0xa380('0x63')]()[_0xa380('0x76')](_0xa380('0x7a'))[_0xa380('0x77')]([_0xa380('0x7b'),_0xa380('0x64'),'phone',_0xa380('0x7c'),_0xa380('0x50'),_0xa380('0x51')],squel[_0xa380('0x67')]()['field']('h.id','id')[_0xa380('0x68')]('NOW()',_0xa380('0x64'))[_0xa380('0x68')](_0xa380('0x7d'),_0xa380('0x69'))[_0xa380('0x68')]('ci.OrderBY',_0xa380('0x7c'))[_0xa380('0x68')]('\x27'+_0xc69a8e+'\x27',_0xa380('0x50'))[_0xa380('0x68')]('\x27'+_0xc69a8e+'\x27',_0xa380('0x51'))[_0xa380('0x73')](_0xa380('0x7e'),'ci')[_0xa380('0x7f')](_0xa380('0x74'),'h','h.ContactId\x20=\x20ci.CmContactId')['where'](_0xa380('0x80'),_0x126e13[_0xa380('0x6a')]['toString']())[_0xa380('0x3c')](_0xa380('0x81'),_0x7baf7e[_0xa380('0x4e')]['id'][_0xa380('0x6b')]())[_0xa380('0x3c')](_0xa380('0x82'),_0xc69a8e))[_0xa380('0x6b')]();_0x1aaca6['push'](db[_0xa380('0x83')][_0xa380('0x2f')](_0x1f8d56));_0x4b7ac2['push'](db[_0xa380('0x83')][_0xa380('0x2f')](_0x3a85d4));}return BPromise[_0xa380('0x84')](_0x1aaca6);}})[_0xa380('0x1e')](function(){return BPromise[_0xa380('0x84')](_0x4b7ac2);})[_0xa380('0x1e')](function(){return _0x3fb79e;})['then'](respondWithResult(_0xab8f31,null))[_0xa380('0x43')](handleError(_0xab8f31,null));};exports[_0xa380('0x85')]=function(_0x7a1c27,_0xc336da,_0x26eeaa){return db[_0xa380('0x28')]['find']({'where':{'id':_0x7a1c27[_0xa380('0x4e')]['id']}})[_0xa380('0x1e')](handleEntityNotFound(_0xc336da,null))[_0xa380('0x1e')](function(_0x271a69){if(_0x271a69){return _0x271a69['removeLists'](_0x7a1c27[_0xa380('0x2f')][_0xa380('0x61')]);}})[_0xa380('0x1e')](function(_0x452b45){if(_0x452b45){return db[_0xa380('0x56')]['destroy']({'where':{'ListId':_0x7a1c27[_0xa380('0x2f')][_0xa380('0x61')],'CampaignId':_0x7a1c27[_0xa380('0x4e')]['id']}})[_0xa380('0x1e')](function(){return _0x452b45;});}})['then'](respondWithStatusCode(_0xc336da,null))['catch'](handleError(_0xc336da,null));};exports[_0xa380('0x86')]=function(_0x568d4f,_0x3ab73f,_0x151742){var _0x18ba86={};var _0x34856d={};var _0x2dfd5b;var _0x3d7f4d;return db[_0xa380('0x28')][_0xa380('0x55')]({'where':{'id':_0x568d4f[_0xa380('0x4e')]['id']}})['then'](handleEntityNotFound(_0x3ab73f,null))[_0xa380('0x1e')](function(_0x257e31){if(_0x257e31){_0x2dfd5b=_0x257e31;_0x34856d[_0xa380('0x2d')]=_[_0xa380('0x30')](db[_0xa380('0x5f')]['rawAttributes']);_0x34856d[_0xa380('0x2f')]=_[_0xa380('0x30')](_0x568d4f[_0xa380('0x2f')]);_0x34856d[_0xa380('0x39')]=_['intersection'](_0x34856d[_0xa380('0x2d')],_0x34856d[_0xa380('0x2f')]);_0x18ba86[_0xa380('0x32')]=_[_0xa380('0x31')](_0x34856d[_0xa380('0x2d')],qs[_0xa380('0x33')](_0x568d4f[_0xa380('0x2f')][_0xa380('0x33')]));_0x18ba86[_0xa380('0x32')]=_0x18ba86[_0xa380('0x32')][_0xa380('0x34')]?_0x18ba86[_0xa380('0x32')]:_0x34856d[_0xa380('0x2d')];_0x18ba86[_0xa380('0x37')]=qs[_0xa380('0x38')](_0x568d4f[_0xa380('0x2f')][_0xa380('0x38')]);_0x18ba86[_0xa380('0x3c')]=qs[_0xa380('0x39')](_[_0xa380('0x3a')](_0x568d4f[_0xa380('0x2f')],_0x34856d['filters']));if(_0x568d4f['query'][_0xa380('0x3b')]){_0x18ba86[_0xa380('0x3c')]=_[_0xa380('0x3e')](_0x18ba86[_0xa380('0x3c')],{'$or':_['map'](_0x18ba86[_0xa380('0x32')],function(_0x47662d){var _0x4b5e6e={};_0x4b5e6e[_0x47662d]={'$like':'%'+_0x568d4f['query']['filter']+'%'};return _0x4b5e6e;})});}_0x18ba86=_[_0xa380('0x3e')]({},_0x18ba86,_0x568d4f[_0xa380('0x3f')]);return _0x2dfd5b[_0xa380('0x86')](_0x18ba86);}})[_0xa380('0x1e')](function(_0x4cd7e9){if(_0x4cd7e9){_0x3d7f4d=_0x4cd7e9[_0xa380('0x34')];if(!_0x568d4f[_0xa380('0x2f')][_0xa380('0x35')](_0xa380('0x36'))){_0x18ba86[_0xa380('0x18')]=qs[_0xa380('0x18')](_0x568d4f[_0xa380('0x2f')]['limit']);_0x18ba86[_0xa380('0x16')]=qs[_0xa380('0x16')](_0x568d4f[_0xa380('0x2f')][_0xa380('0x16')]);}return _0x2dfd5b[_0xa380('0x86')](_0x18ba86);}})['then'](function(_0x13ed9a){if(_0x13ed9a){return _0x13ed9a?{'count':_0x3d7f4d,'rows':_0x13ed9a}:null;}})[_0xa380('0x1e')](respondWithResult(_0x3ab73f,null))[_0xa380('0x43')](handleError(_0x3ab73f,null));};exports[_0xa380('0x87')]=function(_0x17b81d,_0x4d9a3f,_0x542de1){var _0xe45fbd,_0x51bd76;var _0x375e4b=[];var _0x35ec01=moment()['format'](_0xa380('0x88'));return db[_0xa380('0x28')]['find']({'where':{'id':_0x17b81d['params']['id']}})[_0xa380('0x1e')](handleEntityNotFound(_0x4d9a3f,null))[_0xa380('0x1e')](function(_0x43b116){if(_0x43b116){_0x51bd76=_0x43b116;return _0x43b116[_0xa380('0x87')](_0x17b81d[_0xa380('0x46')]['ids'],_['omit'](_0x17b81d['body'],[_0xa380('0x61'),'id'])||{});}return null;})[_0xa380('0x89')](function(_0x5e6237){var _0x38690e;var _0x1a97b0;_0xe45fbd=_0x5e6237||[];var _0x47d253=[];if(_0x5e6237){for(var _0x1fe4ad=0x0;_0x1fe4ad<_0x5e6237[_0xa380('0x34')];_0x1fe4ad+=0x1){var _0x19e04a=_0x5e6237[_0x1fe4ad][_0xa380('0x20')]({'plain':!![]});_0x38690e=squel[_0xa380('0x63')]()[_0xa380('0x76')]('cm_hopper_black')['fromQuery']([_0xa380('0x69'),_0xa380('0x65'),_0xa380('0x66'),_0xa380('0x57'),_0xa380('0x50'),'updatedAt'],squel[_0xa380('0x67')]()[_0xa380('0x68')](_0xa380('0x69'),_0xa380('0x69'))[_0xa380('0x68')]('id','ContactId')['field'](_0x19e04a[_0xa380('0x6a')][_0xa380('0x6b')](),'ListId')[_0xa380('0x68')](_0x17b81d[_0xa380('0x4e')]['id'][_0xa380('0x6b')](),_0xa380('0x57'))[_0xa380('0x68')]('NOW()',_0xa380('0x50'))[_0xa380('0x68')](_0xa380('0x78'),_0xa380('0x51'))[_0xa380('0x73')](_0xa380('0x6c'))[_0xa380('0x3c')](_0xa380('0x79'))[_0xa380('0x3c')](_0xa380('0x6d'),_0x19e04a[_0xa380('0x6a')][_0xa380('0x6b')]())[_0xa380('0x3c')](_0xa380('0x6e')))['toString']();_0x47d253[_0xa380('0x8a')](db[_0xa380('0x83')][_0xa380('0x2f')](_0x38690e));}return BPromise[_0xa380('0x84')](_0x47d253);}})['then'](function(){return _0xe45fbd;})[_0xa380('0x1e')](respondWithResult(_0x4d9a3f,null))[_0xa380('0x43')](handleError(_0x4d9a3f,null));};exports[_0xa380('0x8b')]=function(_0x5a157b,_0x1673c2,_0x43a7da){return db[_0xa380('0x28')][_0xa380('0x4a')]({'where':{'id':_0x5a157b[_0xa380('0x4e')]['id']}})[_0xa380('0x1e')](handleEntityNotFound(_0x1673c2,null))['then'](function(_0x1d6bbb){if(_0x1d6bbb){return _0x1d6bbb[_0xa380('0x8b')](_0x5a157b[_0xa380('0x2f')][_0xa380('0x61')]);}})['then'](function(_0x59f023){if(_0x59f023){return db['CmHopperBlack']['destroy']({'where':{'ListId':_0x5a157b[_0xa380('0x2f')]['ids'],'CampaignId':_0x5a157b['params']['id']}})['then'](function(){return _0x59f023;});}})[_0xa380('0x1e')](respondWithStatusCode(_0x1673c2,null))[_0xa380('0x43')](handleError(_0x1673c2,null));};
\ No newline at end of file