Built motion from commit b5996064.|2.6.21
[motion2.git] / server / api / campaign / campaign.controller.js
index 10b8943..d3b3fa1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb4e6=['limit','set','Content-Range','apply','reject','update','destroy','then','get','UserProfileResource','error','name','send','index','map','Campaign','rawAttributes','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','merge','VIRTUAL','filter','options','count','includeAll','include','catch','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','omit','createdAt','updatedAt','IvrCampaigns','getHoppers','CmHopper','CampaignId','findAll','rows','findOne','CmHopperHistory','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getLists','CmList','addLists','ids','spread','dialCheckDuplicateType','always','insert','into','cm_hopper','fromQuery','phone','scheduledAt','ListId','select','field','CmListId','toString','NOW()','from','deletedAt\x20IS\x20NULL','ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','phone\x20NOT\x20IN\x20(?)','COALESCE(calleridnum,\x27\x27)','CampaignId\x20=\x20?','COALESCE(phone,\x27\x27)','ContactId','cm_contacts','push','sequelize','all','removeLists','getBlackLists','addBlackLists','cm_hopper_black','removeBlackLists','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','lodash','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../mysqldb','sendStatus','status','end','json','offset'];(function(_0x597768,_0x30c6b5){var _0x366166=function(_0x2640f0){while(--_0x2640f0){_0x597768['push'](_0x597768['shift']());}};_0x366166(++_0x30c6b5);}(_0xb4e6,0x1f4));var _0x6b4e=function(_0x210603,_0x4adbac){_0x210603=_0x210603-0x0;var _0x1bcb7d=_0xb4e6[_0x210603];return _0x1bcb7d;};'use strict';var pdf=require(_0x6b4e('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x6b4e('0x1'));var zipdir=require(_0x6b4e('0x2'));var jsonpatch=require(_0x6b4e('0x3'));var rp=require(_0x6b4e('0x4'));var moment=require(_0x6b4e('0x5'));var BPromise=require(_0x6b4e('0x6'));var Mustache=require(_0x6b4e('0x7'));var util=require('util');var path=require(_0x6b4e('0x8'));var sox=require(_0x6b4e('0x9'));var csv=require(_0x6b4e('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x6b4e('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x6b4e('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x6b4e('0xd'));var Papa=require(_0x6b4e('0xe'));var Redis=require(_0x6b4e('0xf'));var authService=require(_0x6b4e('0x10'));var qs=require(_0x6b4e('0x11'));var as=require(_0x6b4e('0x12'));var hardwareService=require(_0x6b4e('0x13'));var logger=require('../../config/logger')(_0x6b4e('0x14'));var utils=require(_0x6b4e('0x15'));var config=require('../../config/environment');var db=require(_0x6b4e('0x16'))['db'];function respondWithStatusCode(_0x9cd7da,_0x432399){_0x432399=_0x432399||0xcc;return function(_0x2b2ce0){if(_0x2b2ce0){return _0x9cd7da[_0x6b4e('0x17')](_0x432399);}return _0x9cd7da[_0x6b4e('0x18')](_0x432399)[_0x6b4e('0x19')]();};}function respondWithResult(_0x531eec,_0x36f8a5){_0x36f8a5=_0x36f8a5||0xc8;return function(_0x29bdee){if(_0x29bdee){return _0x531eec['status'](_0x36f8a5)[_0x6b4e('0x1a')](_0x29bdee);}};}function respondWithFilteredResult(_0x4b62ad,_0x355f10){return function(_0x2195c1){if(_0x2195c1){var _0x3ba513=_0x2195c1['count'],_0x42e265=_0x355f10['offset'],_0x28c3ba=_0x355f10[_0x6b4e('0x1b')]+_0x355f10[_0x6b4e('0x1c')],_0x135568;if(_0x28c3ba>=_0x3ba513){_0x28c3ba=_0x3ba513;_0x135568=0xc8;}else{_0x135568=0xce;}_0x4b62ad[_0x6b4e('0x18')](_0x135568);return _0x4b62ad[_0x6b4e('0x1d')](_0x6b4e('0x1e'),_0x42e265+'-'+_0x28c3ba+'/'+_0x3ba513)[_0x6b4e('0x1a')](_0x2195c1);}return null;};}function patchUpdates(_0xbba4e9){return function(_0x2eaf01){try{jsonpatch[_0x6b4e('0x1f')](_0x2eaf01,_0xbba4e9,!![]);}catch(_0x20a178){return BPromise[_0x6b4e('0x20')](_0x20a178);}return _0x2eaf01['save']();};}function saveUpdates(_0x378233,_0x248fea){return function(_0x31fb9d){if(_0x31fb9d){return _0x31fb9d[_0x6b4e('0x21')](_0x378233)['then'](function(_0x1b48b5){return _0x1b48b5;});}return null;};}function removeEntity(_0x507703,_0x2503a5){return function(_0x163dea){if(_0x163dea){return _0x163dea[_0x6b4e('0x22')]()[_0x6b4e('0x23')](function(){var _0xa06ccd=_0x163dea[_0x6b4e('0x24')]({'plain':!![]});var _0x3e636f='IvrCampaigns';return db[_0x6b4e('0x25')]['destroy']({'where':{'type':_0x3e636f,'resourceId':_0xa06ccd['id']}})[_0x6b4e('0x23')](function(){return _0x163dea;});})[_0x6b4e('0x23')](function(){_0x507703[_0x6b4e('0x18')](0xcc)[_0x6b4e('0x19')]();});}};}function handleEntityNotFound(_0x4ec9cc,_0xec7d35){return function(_0x3f72d7){if(!_0x3f72d7){_0x4ec9cc['sendStatus'](0x194);}return _0x3f72d7;};}function handleError(_0x32102f,_0x381ff0){_0x381ff0=_0x381ff0||0x1f4;return function(_0x3513b2){logger[_0x6b4e('0x26')](_0x3513b2['stack']);if(_0x3513b2[_0x6b4e('0x27')]){delete _0x3513b2[_0x6b4e('0x27')];}_0x32102f['status'](_0x381ff0)[_0x6b4e('0x28')](_0x3513b2);};}exports[_0x6b4e('0x29')]=function(_0x2f1129,_0x143de5){var _0x4a6c90={},_0x445278={},_0x4007b6={'count':0x0,'rows':[]};var _0x47ab11=_[_0x6b4e('0x2a')](db[_0x6b4e('0x2b')][_0x6b4e('0x2c')],function(_0x53c242){return{'name':_0x53c242['fieldName'],'type':_0x53c242[_0x6b4e('0x2d')][_0x6b4e('0x2e')]};});_0x445278[_0x6b4e('0x2f')]=_['map'](_0x47ab11,_0x6b4e('0x27'));_0x445278[_0x6b4e('0x30')]=_[_0x6b4e('0x31')](_0x2f1129['query']);_0x445278['filters']=_[_0x6b4e('0x32')](_0x445278['model'],_0x445278[_0x6b4e('0x30')]);_0x4a6c90[_0x6b4e('0x33')]=_['intersection'](_0x445278[_0x6b4e('0x2f')],qs[_0x6b4e('0x34')](_0x2f1129[_0x6b4e('0x30')][_0x6b4e('0x34')]));_0x4a6c90['attributes']=_0x4a6c90['attributes'][_0x6b4e('0x35')]?_0x4a6c90[_0x6b4e('0x33')]:_0x445278[_0x6b4e('0x2f')];if(!_0x2f1129[_0x6b4e('0x30')][_0x6b4e('0x36')](_0x6b4e('0x37'))){_0x4a6c90[_0x6b4e('0x1c')]=qs[_0x6b4e('0x1c')](_0x2f1129[_0x6b4e('0x30')][_0x6b4e('0x1c')]);_0x4a6c90[_0x6b4e('0x1b')]=qs[_0x6b4e('0x1b')](_0x2f1129[_0x6b4e('0x30')]['offset']);}_0x4a6c90[_0x6b4e('0x38')]=qs[_0x6b4e('0x39')](_0x2f1129[_0x6b4e('0x30')]['sort']);_0x4a6c90[_0x6b4e('0x3a')]=qs['filters'](_[_0x6b4e('0x3b')](_0x2f1129[_0x6b4e('0x30')],_0x445278[_0x6b4e('0x3c')]));if(_0x2f1129['query']['filter']){_0x4a6c90[_0x6b4e('0x3a')]=_[_0x6b4e('0x3d')](_0x4a6c90['where'],{'$or':_['map'](_0x47ab11,function(_0x2362e1){if(_0x2362e1[_0x6b4e('0x2d')]!==_0x6b4e('0x3e')){var _0x39097d={};_0x39097d[_0x2362e1[_0x6b4e('0x27')]]={'$like':'%'+_0x2f1129[_0x6b4e('0x30')][_0x6b4e('0x3f')]+'%'};return _0x39097d;}})});}_0x4a6c90=_[_0x6b4e('0x3d')]({},_0x4a6c90,_0x2f1129[_0x6b4e('0x40')]);var _0x2b61c4={'where':_0x4a6c90[_0x6b4e('0x3a')]};return db['Campaign'][_0x6b4e('0x41')](_0x2b61c4)[_0x6b4e('0x23')](function(_0x5d5d55){_0x4007b6[_0x6b4e('0x41')]=_0x5d5d55;if(_0x2f1129[_0x6b4e('0x30')][_0x6b4e('0x42')]){_0x4a6c90[_0x6b4e('0x43')]=[{'all':!![]}];}return db[_0x6b4e('0x2b')]['findAll'](_0x4a6c90);})['then'](function(_0x210691){_0x4007b6['rows']=_0x210691;return _0x4007b6;})[_0x6b4e('0x23')](respondWithFilteredResult(_0x143de5,_0x4a6c90))[_0x6b4e('0x44')](handleError(_0x143de5,null));};exports['show']=function(_0xf70c24,_0x50f0e7){var _0x3dec0f={'raw':![],'where':{'id':_0xf70c24[_0x6b4e('0x45')]['id']}},_0x4fbd96={};_0x4fbd96[_0x6b4e('0x2f')]=_[_0x6b4e('0x31')](db[_0x6b4e('0x2b')]['rawAttributes']);_0x4fbd96[_0x6b4e('0x30')]=_[_0x6b4e('0x31')](_0xf70c24[_0x6b4e('0x30')]);_0x4fbd96['filters']=_[_0x6b4e('0x32')](_0x4fbd96[_0x6b4e('0x2f')],_0x4fbd96[_0x6b4e('0x30')]);_0x3dec0f[_0x6b4e('0x33')]=_[_0x6b4e('0x32')](_0x4fbd96[_0x6b4e('0x2f')],qs[_0x6b4e('0x34')](_0xf70c24[_0x6b4e('0x30')][_0x6b4e('0x34')]));_0x3dec0f['attributes']=_0x3dec0f[_0x6b4e('0x33')][_0x6b4e('0x35')]?_0x3dec0f[_0x6b4e('0x33')]:_0x4fbd96[_0x6b4e('0x2f')];if(_0xf70c24[_0x6b4e('0x30')]['includeAll']){_0x3dec0f[_0x6b4e('0x43')]=[{'all':!![]}];}_0x3dec0f=_['merge']({},_0x3dec0f,_0xf70c24[_0x6b4e('0x40')]);return db[_0x6b4e('0x2b')][_0x6b4e('0x46')](_0x3dec0f)[_0x6b4e('0x23')](handleEntityNotFound(_0x50f0e7,null))['then'](respondWithResult(_0x50f0e7,null))[_0x6b4e('0x44')](handleError(_0x50f0e7,null));};exports[_0x6b4e('0x47')]=function(_0x1d0eb3,_0x5b9da3){return db[_0x6b4e('0x2b')][_0x6b4e('0x47')](_0x1d0eb3[_0x6b4e('0x48')],{})[_0x6b4e('0x23')](function(_0x2016e5){var _0x33c797=_0x1d0eb3[_0x6b4e('0x49')][_0x6b4e('0x24')]({'plain':!![]});if(!_0x33c797)throw new Error(_0x6b4e('0x4a'));if(_0x33c797[_0x6b4e('0x4b')]==='user'){var _0x2106fb=_0x2016e5[_0x6b4e('0x24')]({'plain':!![]});var _0x1f691f='IvrCampaigns';return db[_0x6b4e('0x4c')][_0x6b4e('0x46')]({'where':{'name':_0x1f691f,'userProfileId':_0x33c797[_0x6b4e('0x4d')]},'raw':!![]})[_0x6b4e('0x23')](function(_0x73c6be){if(_0x73c6be&&_0x73c6be[_0x6b4e('0x4e')]===0x0){return db[_0x6b4e('0x25')][_0x6b4e('0x47')]({'name':_0x2106fb[_0x6b4e('0x27')],'resourceId':_0x2106fb['id'],'type':_0x73c6be[_0x6b4e('0x27')],'sectionId':_0x73c6be['id']},{})[_0x6b4e('0x23')](function(){return _0x2016e5;});}else{return _0x2016e5;}})['catch'](function(_0x4e183b){logger[_0x6b4e('0x26')](_0x6b4e('0x4f'),_0x4e183b);throw _0x4e183b;});}return _0x2016e5;})[_0x6b4e('0x23')](respondWithResult(_0x5b9da3,0xc9))[_0x6b4e('0x44')](handleError(_0x5b9da3,null));};exports['clone']=function(_0x1450de,_0x31071f){var _0xf2e6d5={'where':{'id':_0x1450de[_0x6b4e('0x45')]['id']}},_0x59db52={};_0x59db52[_0x6b4e('0x2f')]=_[_0x6b4e('0x31')](db[_0x6b4e('0x2b')][_0x6b4e('0x2c')]);_0xf2e6d5['attributes']=_[_0x6b4e('0x32')](_0x59db52['model'],qs[_0x6b4e('0x34')](_0x1450de[_0x6b4e('0x30')]['fields']));_0xf2e6d5[_0x6b4e('0x33')]=_0xf2e6d5['attributes'][_0x6b4e('0x35')]?_0xf2e6d5[_0x6b4e('0x33')]:_0x59db52[_0x6b4e('0x2f')];if(_0x1450de[_0x6b4e('0x30')][_0x6b4e('0x42')]){_0xf2e6d5['include']=[{'all':!![]}];}_0xf2e6d5=_[_0x6b4e('0x3d')]({},_0xf2e6d5,_0x1450de[_0x6b4e('0x40')]);return db[_0x6b4e('0x2b')]['find'](_0xf2e6d5)['then'](handleEntityNotFound(_0x31071f,null))[_0x6b4e('0x23')](function(_0x15ec6f){if(_0x15ec6f){var _0x5d46b9=_0x15ec6f[_0x6b4e('0x24')]({'plain':!![]});_0x5d46b9=qs[_0x6b4e('0x50')](_0x5d46b9,['id',_0x6b4e('0x51'),_0x6b4e('0x52')]);_0x1450de[_0x6b4e('0x48')]=_['omit'](_0x1450de['body'],['id',_0x6b4e('0x51'),_0x6b4e('0x52')]);return db[_0x6b4e('0x2b')][_0x6b4e('0x47')](_[_0x6b4e('0x3d')](_0x5d46b9,_0x1450de[_0x6b4e('0x48')]),{'include':_0x1450de[_0x6b4e('0x30')][_0x6b4e('0x42')]?[{'all':!![]}]:undefined})[_0x6b4e('0x23')](function(_0x5bedab){var _0x322fa4=_0x1450de[_0x6b4e('0x49')][_0x6b4e('0x24')]({'plain':!![]});if(!_0x322fa4)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x322fa4['role']===_0x6b4e('0x49')){var _0x38b1a6=_0x5bedab[_0x6b4e('0x24')]({'plain':!![]});var _0x158c28=_0x6b4e('0x53');return db['UserProfileSection'][_0x6b4e('0x46')]({'where':{'name':_0x158c28,'userProfileId':_0x322fa4[_0x6b4e('0x4d')]},'raw':!![]})[_0x6b4e('0x23')](function(_0x5383fc){if(_0x5383fc&&_0x5383fc[_0x6b4e('0x4e')]===0x0){return db[_0x6b4e('0x25')][_0x6b4e('0x47')]({'name':_0x38b1a6['name'],'resourceId':_0x38b1a6['id'],'type':_0x5383fc[_0x6b4e('0x27')],'sectionId':_0x5383fc['id']},{})[_0x6b4e('0x23')](function(){return _0x5bedab;});}else{return _0x5bedab;}})['catch'](function(_0x177470){logger[_0x6b4e('0x26')](_0x6b4e('0x4f'),_0x177470);throw _0x177470;});}return _0x5bedab;});}})[_0x6b4e('0x23')](respondWithResult(_0x31071f,0xc9))[_0x6b4e('0x44')](handleError(_0x31071f,null));};exports[_0x6b4e('0x21')]=function(_0x2ada5d,_0x5d8433){if(_0x2ada5d[_0x6b4e('0x48')]['id']){delete _0x2ada5d[_0x6b4e('0x48')]['id'];}return db[_0x6b4e('0x2b')][_0x6b4e('0x46')]({'where':{'id':_0x2ada5d[_0x6b4e('0x45')]['id']}})['then'](handleEntityNotFound(_0x5d8433,null))[_0x6b4e('0x23')](saveUpdates(_0x2ada5d[_0x6b4e('0x48')],null))[_0x6b4e('0x23')](respondWithResult(_0x5d8433,null))[_0x6b4e('0x44')](handleError(_0x5d8433,null));};exports[_0x6b4e('0x22')]=function(_0x4ed029,_0xa1246f){return db['Campaign'][_0x6b4e('0x46')]({'where':{'id':_0x4ed029[_0x6b4e('0x45')]['id']}})[_0x6b4e('0x23')](handleEntityNotFound(_0xa1246f,null))[_0x6b4e('0x23')](removeEntity(_0xa1246f,null))['catch'](handleError(_0xa1246f,null));};exports[_0x6b4e('0x54')]=function(_0xb14e52,_0x329d25,_0x2bdc10){var _0xc3083={'raw':!![],'where':{}};var _0x15de0d={};var _0x41e901={'count':0x0,'rows':[]};return db['Campaign']['findOne']({'where':{'id':_0xb14e52['params']['id']}})[_0x6b4e('0x23')](handleEntityNotFound(_0x329d25,null))[_0x6b4e('0x23')](function(_0x247319){if(_0x247319){_0x15de0d[_0x6b4e('0x2f')]=_[_0x6b4e('0x31')](db[_0x6b4e('0x55')]['rawAttributes']);_0x15de0d['query']=_[_0x6b4e('0x31')](_0xb14e52[_0x6b4e('0x30')]);_0x15de0d[_0x6b4e('0x3c')]=_[_0x6b4e('0x32')](_0x15de0d['model'],_0x15de0d[_0x6b4e('0x30')]);_0xc3083['attributes']=_[_0x6b4e('0x32')](_0x15de0d[_0x6b4e('0x2f')],qs[_0x6b4e('0x34')](_0xb14e52[_0x6b4e('0x30')]['fields']));_0xc3083[_0x6b4e('0x33')]=_0xc3083['attributes'][_0x6b4e('0x35')]?_0xc3083['attributes']:_0x15de0d[_0x6b4e('0x2f')];if(!_0xb14e52[_0x6b4e('0x30')]['hasOwnProperty'](_0x6b4e('0x37'))){_0xc3083['limit']=qs[_0x6b4e('0x1c')](_0xb14e52[_0x6b4e('0x30')][_0x6b4e('0x1c')]);_0xc3083[_0x6b4e('0x1b')]=qs['offset'](_0xb14e52['query']['offset']);}_0xc3083[_0x6b4e('0x38')]=qs[_0x6b4e('0x39')](_0xb14e52['query'][_0x6b4e('0x39')]);_0xc3083[_0x6b4e('0x3a')]=qs[_0x6b4e('0x3c')](_[_0x6b4e('0x3b')](_0xb14e52[_0x6b4e('0x30')],_0x15de0d[_0x6b4e('0x3c')]));_0xc3083[_0x6b4e('0x3a')][_0x6b4e('0x56')]=_0x247319['id'];if(_0xb14e52[_0x6b4e('0x30')][_0x6b4e('0x3f')]){_0xc3083[_0x6b4e('0x3a')]=_['merge'](_0xc3083[_0x6b4e('0x3a')],{'$or':_[_0x6b4e('0x2a')](_0xc3083[_0x6b4e('0x33')],function(_0x7692bc){var _0x24c2ca={};_0x24c2ca[_0x7692bc]={'$like':'%'+_0xb14e52[_0x6b4e('0x30')][_0x6b4e('0x3f')]+'%'};return _0x24c2ca;})});}_0xc3083=_[_0x6b4e('0x3d')]({},_0xc3083,_0xb14e52[_0x6b4e('0x40')]);return db['CmHopper']['count']({'where':_0xc3083['where']})['then'](function(_0xafb7da){_0x41e901[_0x6b4e('0x41')]=_0xafb7da;if(_0xb14e52[_0x6b4e('0x30')][_0x6b4e('0x42')]){_0xc3083['include']=[{'all':!![]}];}return db[_0x6b4e('0x55')][_0x6b4e('0x57')](_0xc3083);})['then'](function(_0x1ad4bb){_0x41e901[_0x6b4e('0x58')]=_0x1ad4bb;return _0x41e901;});}})[_0x6b4e('0x23')](respondWithFilteredResult(_0x329d25,_0xc3083))[_0x6b4e('0x44')](handleError(_0x329d25,null));};exports['getHopperHistories']=function(_0x3f5dda,_0x3bab0b,_0x4b0a4e){var _0x50bbeb={'raw':!![],'where':{}};var _0x1dc719={};var _0x47af87={'count':0x0,'rows':[]};return db[_0x6b4e('0x2b')][_0x6b4e('0x59')]({'where':{'id':_0x3f5dda['params']['id']}})[_0x6b4e('0x23')](handleEntityNotFound(_0x3bab0b,null))[_0x6b4e('0x23')](function(_0x3b7c3c){if(_0x3b7c3c){_0x1dc719[_0x6b4e('0x2f')]=_[_0x6b4e('0x31')](db['CmHopperHistory']['rawAttributes']);_0x1dc719[_0x6b4e('0x30')]=_[_0x6b4e('0x31')](_0x3f5dda[_0x6b4e('0x30')]);_0x1dc719[_0x6b4e('0x3c')]=_[_0x6b4e('0x32')](_0x1dc719[_0x6b4e('0x2f')],_0x1dc719[_0x6b4e('0x30')]);_0x50bbeb[_0x6b4e('0x33')]=_[_0x6b4e('0x32')](_0x1dc719['model'],qs[_0x6b4e('0x34')](_0x3f5dda[_0x6b4e('0x30')][_0x6b4e('0x34')]));_0x50bbeb[_0x6b4e('0x33')]=_0x50bbeb[_0x6b4e('0x33')][_0x6b4e('0x35')]?_0x50bbeb[_0x6b4e('0x33')]:_0x1dc719[_0x6b4e('0x2f')];if(!_0x3f5dda[_0x6b4e('0x30')][_0x6b4e('0x36')](_0x6b4e('0x37'))){_0x50bbeb[_0x6b4e('0x1c')]=qs['limit'](_0x3f5dda['query'][_0x6b4e('0x1c')]);_0x50bbeb[_0x6b4e('0x1b')]=qs[_0x6b4e('0x1b')](_0x3f5dda[_0x6b4e('0x30')][_0x6b4e('0x1b')]);}_0x50bbeb['order']=qs[_0x6b4e('0x39')](_0x3f5dda[_0x6b4e('0x30')][_0x6b4e('0x39')]);_0x50bbeb['where']=qs[_0x6b4e('0x3c')](_[_0x6b4e('0x3b')](_0x3f5dda[_0x6b4e('0x30')],_0x1dc719[_0x6b4e('0x3c')]));_0x50bbeb[_0x6b4e('0x3a')][_0x6b4e('0x56')]=_0x3b7c3c['id'];if(_0x3f5dda[_0x6b4e('0x30')]['filter']){_0x50bbeb[_0x6b4e('0x3a')]=_[_0x6b4e('0x3d')](_0x50bbeb[_0x6b4e('0x3a')],{'$or':_['map'](_0x50bbeb['attributes'],function(_0x53b303){var _0x3871e5={};_0x3871e5[_0x53b303]={'$like':'%'+_0x3f5dda['query'][_0x6b4e('0x3f')]+'%'};return _0x3871e5;})});}_0x50bbeb=_[_0x6b4e('0x3d')]({},_0x50bbeb,_0x3f5dda[_0x6b4e('0x40')]);return db[_0x6b4e('0x5a')][_0x6b4e('0x41')]({'where':_0x50bbeb[_0x6b4e('0x3a')]})[_0x6b4e('0x23')](function(_0x5d8adf){_0x47af87[_0x6b4e('0x41')]=_0x5d8adf;if(_0x3f5dda['query']['includeAll']){_0x50bbeb[_0x6b4e('0x43')]=[{'all':!![]}];}return db[_0x6b4e('0x5a')][_0x6b4e('0x57')](_0x50bbeb);})['then'](function(_0x230671){_0x47af87['rows']=_0x230671;return _0x47af87;});}})[_0x6b4e('0x23')](respondWithFilteredResult(_0x3bab0b,_0x50bbeb))[_0x6b4e('0x44')](handleError(_0x3bab0b,null));};exports[_0x6b4e('0x5b')]=function(_0x3edadd,_0x3c812a,_0x98ff80){var _0x1a3dd8={'raw':!![],'where':{}};var _0x1e5033={};var _0x4b9b4b={'count':0x0,'rows':[]};return db[_0x6b4e('0x2b')]['findOne']({'where':{'id':_0x3edadd[_0x6b4e('0x45')]['id']}})['then'](handleEntityNotFound(_0x3c812a,null))[_0x6b4e('0x23')](function(_0x53db70){if(_0x53db70){_0x1e5033[_0x6b4e('0x2f')]=_[_0x6b4e('0x31')](db[_0x6b4e('0x5c')][_0x6b4e('0x2c')]);_0x1e5033[_0x6b4e('0x30')]=_[_0x6b4e('0x31')](_0x3edadd[_0x6b4e('0x30')]);_0x1e5033[_0x6b4e('0x3c')]=_[_0x6b4e('0x32')](_0x1e5033[_0x6b4e('0x2f')],_0x1e5033[_0x6b4e('0x30')]);_0x1a3dd8[_0x6b4e('0x33')]=_[_0x6b4e('0x32')](_0x1e5033[_0x6b4e('0x2f')],qs[_0x6b4e('0x34')](_0x3edadd[_0x6b4e('0x30')]['fields']));_0x1a3dd8[_0x6b4e('0x33')]=_0x1a3dd8['attributes'][_0x6b4e('0x35')]?_0x1a3dd8['attributes']:_0x1e5033[_0x6b4e('0x2f')];if(!_0x3edadd[_0x6b4e('0x30')][_0x6b4e('0x36')](_0x6b4e('0x37'))){_0x1a3dd8['limit']=qs[_0x6b4e('0x1c')](_0x3edadd[_0x6b4e('0x30')][_0x6b4e('0x1c')]);_0x1a3dd8[_0x6b4e('0x1b')]=qs['offset'](_0x3edadd[_0x6b4e('0x30')]['offset']);}_0x1a3dd8[_0x6b4e('0x38')]=qs[_0x6b4e('0x39')](_0x3edadd[_0x6b4e('0x30')][_0x6b4e('0x39')]);_0x1a3dd8[_0x6b4e('0x3a')]=qs[_0x6b4e('0x3c')](_[_0x6b4e('0x3b')](_0x3edadd[_0x6b4e('0x30')],_0x1e5033[_0x6b4e('0x3c')]));_0x1a3dd8[_0x6b4e('0x3a')][_0x6b4e('0x56')]=_0x53db70['id'];if(_0x3edadd[_0x6b4e('0x30')][_0x6b4e('0x3f')]){_0x1a3dd8[_0x6b4e('0x3a')]=_[_0x6b4e('0x3d')](_0x1a3dd8[_0x6b4e('0x3a')],{'$or':_['map'](_0x1a3dd8[_0x6b4e('0x33')],function(_0x36b62b){var _0x4633e3={};_0x4633e3[_0x36b62b]={'$like':'%'+_0x3edadd[_0x6b4e('0x30')]['filter']+'%'};return _0x4633e3;})});}_0x1a3dd8=_[_0x6b4e('0x3d')]({},_0x1a3dd8,_0x3edadd[_0x6b4e('0x40')]);return db[_0x6b4e('0x5c')]['count']({'where':_0x1a3dd8[_0x6b4e('0x3a')]})[_0x6b4e('0x23')](function(_0x3c7b22){_0x4b9b4b[_0x6b4e('0x41')]=_0x3c7b22;if(_0x3edadd['query']['includeAll']){_0x1a3dd8[_0x6b4e('0x43')]=[{'all':!![]}];}return db[_0x6b4e('0x5c')]['findAll'](_0x1a3dd8);})[_0x6b4e('0x23')](function(_0x2e6d9d){_0x4b9b4b[_0x6b4e('0x58')]=_0x2e6d9d;return _0x4b9b4b;});}})[_0x6b4e('0x23')](respondWithFilteredResult(_0x3c812a,_0x1a3dd8))[_0x6b4e('0x44')](handleError(_0x3c812a,null));};exports[_0x6b4e('0x5d')]=function(_0x4847ba,_0x92d02e,_0x3c234d){var _0x1122e1={'raw':!![],'where':{}};var _0x14bde0={};var _0x3700a4={'count':0x0,'rows':[]};return db[_0x6b4e('0x2b')][_0x6b4e('0x59')]({'where':{'id':_0x4847ba[_0x6b4e('0x45')]['id']}})[_0x6b4e('0x23')](handleEntityNotFound(_0x92d02e,null))[_0x6b4e('0x23')](function(_0x44c7bb){if(_0x44c7bb){_0x14bde0['model']=_[_0x6b4e('0x31')](db['CmHopperBlack']['rawAttributes']);_0x14bde0[_0x6b4e('0x30')]=_[_0x6b4e('0x31')](_0x4847ba['query']);_0x14bde0['filters']=_[_0x6b4e('0x32')](_0x14bde0[_0x6b4e('0x2f')],_0x14bde0[_0x6b4e('0x30')]);_0x1122e1[_0x6b4e('0x33')]=_[_0x6b4e('0x32')](_0x14bde0['model'],qs[_0x6b4e('0x34')](_0x4847ba[_0x6b4e('0x30')][_0x6b4e('0x34')]));_0x1122e1[_0x6b4e('0x33')]=_0x1122e1[_0x6b4e('0x33')][_0x6b4e('0x35')]?_0x1122e1[_0x6b4e('0x33')]:_0x14bde0[_0x6b4e('0x2f')];if(!_0x4847ba['query'][_0x6b4e('0x36')](_0x6b4e('0x37'))){_0x1122e1[_0x6b4e('0x1c')]=qs[_0x6b4e('0x1c')](_0x4847ba[_0x6b4e('0x30')][_0x6b4e('0x1c')]);_0x1122e1[_0x6b4e('0x1b')]=qs[_0x6b4e('0x1b')](_0x4847ba[_0x6b4e('0x30')][_0x6b4e('0x1b')]);}_0x1122e1['order']=qs[_0x6b4e('0x39')](_0x4847ba[_0x6b4e('0x30')][_0x6b4e('0x39')]);_0x1122e1[_0x6b4e('0x3a')]=qs['filters'](_[_0x6b4e('0x3b')](_0x4847ba['query'],_0x14bde0[_0x6b4e('0x3c')]));_0x1122e1[_0x6b4e('0x3a')][_0x6b4e('0x56')]=_0x44c7bb['id'];if(_0x4847ba[_0x6b4e('0x30')][_0x6b4e('0x3f')]){_0x1122e1[_0x6b4e('0x3a')]=_[_0x6b4e('0x3d')](_0x1122e1[_0x6b4e('0x3a')],{'$or':_[_0x6b4e('0x2a')](_0x1122e1['attributes'],function(_0x1e5221){var _0x4caccf={};_0x4caccf[_0x1e5221]={'$like':'%'+_0x4847ba['query'][_0x6b4e('0x3f')]+'%'};return _0x4caccf;})});}_0x1122e1=_[_0x6b4e('0x3d')]({},_0x1122e1,_0x4847ba['options']);return db[_0x6b4e('0x5e')][_0x6b4e('0x41')]({'where':_0x1122e1[_0x6b4e('0x3a')]})['then'](function(_0x11bbc9){_0x3700a4[_0x6b4e('0x41')]=_0x11bbc9;if(_0x4847ba[_0x6b4e('0x30')][_0x6b4e('0x42')]){_0x1122e1[_0x6b4e('0x43')]=[{'all':!![]}];}return db[_0x6b4e('0x5e')][_0x6b4e('0x57')](_0x1122e1);})[_0x6b4e('0x23')](function(_0x3a64e0){_0x3700a4[_0x6b4e('0x58')]=_0x3a64e0;return _0x3700a4;});}})['then'](respondWithFilteredResult(_0x92d02e,_0x1122e1))[_0x6b4e('0x44')](handleError(_0x92d02e,null));};exports[_0x6b4e('0x5f')]=function(_0x8ca71b,_0x3882f6,_0x46c1d8){var _0x3aba0a={};var _0x409477={};var _0x297fc5;var _0x47dfe5;return db[_0x6b4e('0x2b')]['findOne']({'where':{'id':_0x8ca71b[_0x6b4e('0x45')]['id']}})[_0x6b4e('0x23')](handleEntityNotFound(_0x3882f6,null))[_0x6b4e('0x23')](function(_0x552873){if(_0x552873){_0x297fc5=_0x552873;_0x409477[_0x6b4e('0x2f')]=_[_0x6b4e('0x31')](db[_0x6b4e('0x60')][_0x6b4e('0x2c')]);_0x409477['query']=_['keys'](_0x8ca71b['query']);_0x409477[_0x6b4e('0x3c')]=_['intersection'](_0x409477[_0x6b4e('0x2f')],_0x409477[_0x6b4e('0x30')]);_0x3aba0a[_0x6b4e('0x33')]=_[_0x6b4e('0x32')](_0x409477['model'],qs[_0x6b4e('0x34')](_0x8ca71b[_0x6b4e('0x30')][_0x6b4e('0x34')]));_0x3aba0a[_0x6b4e('0x33')]=_0x3aba0a[_0x6b4e('0x33')]['length']?_0x3aba0a[_0x6b4e('0x33')]:_0x409477['model'];_0x3aba0a[_0x6b4e('0x38')]=qs[_0x6b4e('0x39')](_0x8ca71b['query'][_0x6b4e('0x39')]);_0x3aba0a[_0x6b4e('0x3a')]=qs['filters'](_[_0x6b4e('0x3b')](_0x8ca71b['query'],_0x409477[_0x6b4e('0x3c')]));if(_0x8ca71b['query'][_0x6b4e('0x3f')]){_0x3aba0a[_0x6b4e('0x3a')]=_[_0x6b4e('0x3d')](_0x3aba0a['where'],{'$or':_[_0x6b4e('0x2a')](_0x3aba0a['attributes'],function(_0x2e66d9){var _0x41a2f6={};_0x41a2f6[_0x2e66d9]={'$like':'%'+_0x8ca71b[_0x6b4e('0x30')][_0x6b4e('0x3f')]+'%'};return _0x41a2f6;})});}_0x3aba0a=_['merge']({},_0x3aba0a,_0x8ca71b[_0x6b4e('0x40')]);return _0x297fc5[_0x6b4e('0x5f')](_0x3aba0a);}})[_0x6b4e('0x23')](function(_0x16d53d){if(_0x16d53d){_0x47dfe5=_0x16d53d[_0x6b4e('0x35')];if(!_0x8ca71b[_0x6b4e('0x30')][_0x6b4e('0x36')]('nolimit')){_0x3aba0a['limit']=qs[_0x6b4e('0x1c')](_0x8ca71b['query'][_0x6b4e('0x1c')]);_0x3aba0a[_0x6b4e('0x1b')]=qs['offset'](_0x8ca71b[_0x6b4e('0x30')][_0x6b4e('0x1b')]);}return _0x297fc5[_0x6b4e('0x5f')](_0x3aba0a);}})[_0x6b4e('0x23')](function(_0x2afae3){if(_0x2afae3){return _0x2afae3?{'count':_0x47dfe5,'rows':_0x2afae3}:null;}})[_0x6b4e('0x23')](respondWithResult(_0x3882f6,null))[_0x6b4e('0x44')](handleError(_0x3882f6,null));};exports[_0x6b4e('0x61')]=function(_0x4e4d8b,_0x424202,_0x2c9c21){var _0x28d9e1,_0x2630da;return db['Campaign']['find']({'where':{'id':_0x4e4d8b[_0x6b4e('0x45')]['id']}})[_0x6b4e('0x23')](handleEntityNotFound(_0x424202,null))[_0x6b4e('0x23')](function(_0x5c7944){if(_0x5c7944){_0x2630da=_0x5c7944;return _0x5c7944[_0x6b4e('0x61')](_0x4e4d8b[_0x6b4e('0x48')][_0x6b4e('0x62')],_[_0x6b4e('0x50')](_0x4e4d8b['body'],[_0x6b4e('0x62'),'id'])||{});}return null;})[_0x6b4e('0x63')](function(_0x1873f4){var _0x4625d9;_0x28d9e1=_0x1873f4||[];var _0x42a59a=[];if(_0x1873f4){for(var _0x428ea7=0x0;_0x428ea7<_0x1873f4[_0x6b4e('0x35')];_0x428ea7+=0x1){var _0x560fdd=_0x1873f4[_0x428ea7]['get']({'plain':!![]});_0x2630da[_0x6b4e('0x64')]=_0x4e4d8b[_0x6b4e('0x48')]['dialCheckDuplicateType']?_0x4e4d8b['body'][_0x6b4e('0x64')]:_0x2630da['dialCheckDuplicateType'];switch(_0x2630da[_0x6b4e('0x64')]){case _0x6b4e('0x65'):_0x4625d9=squel[_0x6b4e('0x66')]()[_0x6b4e('0x67')](_0x6b4e('0x68'))[_0x6b4e('0x69')]([_0x6b4e('0x6a'),_0x6b4e('0x6b'),'ContactId',_0x6b4e('0x6c'),_0x6b4e('0x56'),_0x6b4e('0x51'),_0x6b4e('0x52')],squel[_0x6b4e('0x6d')]()[_0x6b4e('0x6e')](_0x6b4e('0x6a'),_0x6b4e('0x6a'))[_0x6b4e('0x6e')]('NOW()','scheduledAt')[_0x6b4e('0x6e')]('id','ContactId')[_0x6b4e('0x6e')](_0x560fdd[_0x6b4e('0x6f')]['toString'](),_0x6b4e('0x6c'))[_0x6b4e('0x6e')](_0x4e4d8b[_0x6b4e('0x45')]['id'][_0x6b4e('0x70')](),_0x6b4e('0x56'))[_0x6b4e('0x6e')]('NOW()','createdAt')[_0x6b4e('0x6e')](_0x6b4e('0x71'),_0x6b4e('0x52'))[_0x6b4e('0x72')]('cm_contacts')[_0x6b4e('0x3a')](_0x6b4e('0x73'))[_0x6b4e('0x3a')](_0x6b4e('0x74'),_0x560fdd[_0x6b4e('0x6f')][_0x6b4e('0x70')]())[_0x6b4e('0x3a')](_0x6b4e('0x75'))['where'](_0x6b4e('0x76'),squel['select']()[_0x6b4e('0x6e')](_0x6b4e('0x77'))['from']('cm_hopper_final')['where'](_0x6b4e('0x78'),_0x4e4d8b[_0x6b4e('0x45')]['id']['toString']()))[_0x6b4e('0x3a')]('phone\x20NOT\x20IN\x20(?)',squel[_0x6b4e('0x6d')]()[_0x6b4e('0x6e')](_0x6b4e('0x79'))[_0x6b4e('0x72')](_0x6b4e('0x68'))[_0x6b4e('0x3a')]('CampaignId\x20=\x20?',_0x4e4d8b[_0x6b4e('0x45')]['id'][_0x6b4e('0x70')]())))['toString']();break;case'onlyIfOpen':_0x4625d9=squel[_0x6b4e('0x66')]()[_0x6b4e('0x67')](_0x6b4e('0x68'))['fromQuery'](['phone',_0x6b4e('0x6b'),'ContactId',_0x6b4e('0x6c'),_0x6b4e('0x56'),_0x6b4e('0x51'),'updatedAt'],squel[_0x6b4e('0x6d')]()[_0x6b4e('0x6e')](_0x6b4e('0x6a'),_0x6b4e('0x6a'))['field'](_0x6b4e('0x71'),_0x6b4e('0x6b'))[_0x6b4e('0x6e')]('id',_0x6b4e('0x7a'))[_0x6b4e('0x6e')](_0x560fdd[_0x6b4e('0x6f')][_0x6b4e('0x70')](),'ListId')[_0x6b4e('0x6e')](_0x4e4d8b[_0x6b4e('0x45')]['id'][_0x6b4e('0x70')](),'CampaignId')[_0x6b4e('0x6e')](_0x6b4e('0x71'),_0x6b4e('0x51'))['field'](_0x6b4e('0x71'),_0x6b4e('0x52'))['from']('cm_contacts')[_0x6b4e('0x3a')](_0x6b4e('0x73'))['where'](_0x6b4e('0x74'),_0x560fdd['CmListId'][_0x6b4e('0x70')]())['where'](_0x6b4e('0x75'))[_0x6b4e('0x3a')]('phone\x20NOT\x20IN\x20(?)',squel[_0x6b4e('0x6d')]()[_0x6b4e('0x6e')]('COALESCE(phone,\x27\x27)')[_0x6b4e('0x72')](_0x6b4e('0x68'))['where'](_0x6b4e('0x78'),_0x4e4d8b[_0x6b4e('0x45')]['id'][_0x6b4e('0x70')]())))[_0x6b4e('0x70')]();break;default:_0x4625d9=squel[_0x6b4e('0x66')]()[_0x6b4e('0x67')]('cm_hopper')['fromQuery']([_0x6b4e('0x6a'),_0x6b4e('0x6b'),_0x6b4e('0x7a'),_0x6b4e('0x6c'),_0x6b4e('0x56'),_0x6b4e('0x51'),_0x6b4e('0x52')],squel['select']()[_0x6b4e('0x6e')](_0x6b4e('0x6a'),'phone')[_0x6b4e('0x6e')]('NOW()',_0x6b4e('0x6b'))[_0x6b4e('0x6e')]('id',_0x6b4e('0x7a'))[_0x6b4e('0x6e')](_0x560fdd['CmListId'][_0x6b4e('0x70')](),'ListId')[_0x6b4e('0x6e')](_0x4e4d8b[_0x6b4e('0x45')]['id'][_0x6b4e('0x70')](),_0x6b4e('0x56'))[_0x6b4e('0x6e')](_0x6b4e('0x71'),_0x6b4e('0x51'))[_0x6b4e('0x6e')]('NOW()','updatedAt')[_0x6b4e('0x72')](_0x6b4e('0x7b'))['where'](_0x6b4e('0x73'))[_0x6b4e('0x3a')](_0x6b4e('0x74'),_0x560fdd[_0x6b4e('0x6f')]['toString']())[_0x6b4e('0x3a')](_0x6b4e('0x75')))['toString']();}_0x42a59a[_0x6b4e('0x7c')](db[_0x6b4e('0x7d')][_0x6b4e('0x30')](_0x4625d9));}return BPromise[_0x6b4e('0x7e')](_0x42a59a);}})[_0x6b4e('0x23')](function(){return _0x28d9e1;})[_0x6b4e('0x23')](respondWithResult(_0x424202,null))[_0x6b4e('0x44')](handleError(_0x424202,null));};exports['removeLists']=function(_0x1674c7,_0x1b4f38,_0x133acf){return db['Campaign'][_0x6b4e('0x46')]({'where':{'id':_0x1674c7[_0x6b4e('0x45')]['id']}})['then'](handleEntityNotFound(_0x1b4f38,null))[_0x6b4e('0x23')](function(_0xb5a15){if(_0xb5a15){return _0xb5a15[_0x6b4e('0x7f')](_0x1674c7['query'][_0x6b4e('0x62')]);}})[_0x6b4e('0x23')](function(_0x388023){if(_0x388023){return db['CmHopper'][_0x6b4e('0x22')]({'where':{'ListId':_0x1674c7[_0x6b4e('0x30')][_0x6b4e('0x62')],'CampaignId':_0x1674c7[_0x6b4e('0x45')]['id']}})['then'](function(){return _0x388023;});}})[_0x6b4e('0x23')](respondWithStatusCode(_0x1b4f38,null))['catch'](handleError(_0x1b4f38,null));};exports[_0x6b4e('0x80')]=function(_0x467dd8,_0x27c72d,_0x18649d){var _0x2a60c4={'raw':!![],'where':{}};var _0x343171={};var _0x44ed89={'count':0x0,'rows':[]};return db[_0x6b4e('0x2b')]['findOne']({'where':{'id':_0x467dd8[_0x6b4e('0x45')]['id']}})[_0x6b4e('0x23')](handleEntityNotFound(_0x27c72d,null))[_0x6b4e('0x23')](function(_0x38ae68){if(_0x38ae68){_0x343171['model']=_['keys'](db[_0x6b4e('0x60')]['rawAttributes']);_0x343171[_0x6b4e('0x30')]=_['keys'](_0x467dd8['query']);_0x343171['filters']=_[_0x6b4e('0x32')](_0x343171[_0x6b4e('0x2f')],_0x343171[_0x6b4e('0x30')]);_0x2a60c4['attributes']=_[_0x6b4e('0x32')](_0x343171[_0x6b4e('0x2f')],qs[_0x6b4e('0x34')](_0x467dd8[_0x6b4e('0x30')][_0x6b4e('0x34')]));_0x2a60c4[_0x6b4e('0x33')]=_0x2a60c4[_0x6b4e('0x33')][_0x6b4e('0x35')]?_0x2a60c4[_0x6b4e('0x33')]:_0x343171['model'];if(!_0x467dd8[_0x6b4e('0x30')]['hasOwnProperty'](_0x6b4e('0x37'))){_0x2a60c4[_0x6b4e('0x1c')]=qs[_0x6b4e('0x1c')](_0x467dd8[_0x6b4e('0x30')][_0x6b4e('0x1c')]);_0x2a60c4[_0x6b4e('0x1b')]=qs['offset'](_0x467dd8[_0x6b4e('0x30')][_0x6b4e('0x1b')]);}_0x2a60c4[_0x6b4e('0x38')]=qs[_0x6b4e('0x39')](_0x467dd8[_0x6b4e('0x30')][_0x6b4e('0x39')]);_0x2a60c4['where']=qs[_0x6b4e('0x3c')](_[_0x6b4e('0x3b')](_0x467dd8[_0x6b4e('0x30')],_0x343171[_0x6b4e('0x3c')]));_0x2a60c4['where']['CampaignId']=_0x38ae68['id'];if(_0x467dd8['query'][_0x6b4e('0x3f')]){_0x2a60c4[_0x6b4e('0x3a')]=_[_0x6b4e('0x3d')](_0x2a60c4[_0x6b4e('0x3a')],{'$or':_[_0x6b4e('0x2a')](_0x2a60c4[_0x6b4e('0x33')],function(_0x4c440b){var _0x298c39={};_0x298c39[_0x4c440b]={'$like':'%'+_0x467dd8[_0x6b4e('0x30')]['filter']+'%'};return _0x298c39;})});}_0x2a60c4=_['merge']({},_0x2a60c4,_0x467dd8[_0x6b4e('0x40')]);return db['CmList'][_0x6b4e('0x41')]({'where':_0x2a60c4['where']})[_0x6b4e('0x23')](function(_0x5312af){_0x44ed89['count']=_0x5312af;if(_0x467dd8[_0x6b4e('0x30')]['includeAll']){_0x2a60c4[_0x6b4e('0x43')]=[{'all':!![]}];}return db['CmList'][_0x6b4e('0x57')](_0x2a60c4);})[_0x6b4e('0x23')](function(_0x6d498e){_0x44ed89[_0x6b4e('0x58')]=_0x6d498e;return _0x44ed89;});}})['then'](respondWithFilteredResult(_0x27c72d,_0x2a60c4))[_0x6b4e('0x44')](handleError(_0x27c72d,null));};exports[_0x6b4e('0x81')]=function(_0x31ae39,_0x4d54fc,_0x505985){var _0x233ad5,_0x4e6c09;return db[_0x6b4e('0x2b')][_0x6b4e('0x46')]({'where':{'id':_0x31ae39['params']['id']}})['then'](handleEntityNotFound(_0x4d54fc,null))[_0x6b4e('0x23')](function(_0xbc35b5){if(_0xbc35b5){_0x4e6c09=_0xbc35b5;return _0xbc35b5[_0x6b4e('0x81')](_0x31ae39['body']['ids'],_[_0x6b4e('0x50')](_0x31ae39[_0x6b4e('0x48')],['ids','id'])||{});}return null;})[_0x6b4e('0x63')](function(_0x4b533f){var _0x43e75a;_0x233ad5=_0x4b533f||[];var _0x5b31fe=[];if(_0x4b533f){for(var _0x388958=0x0;_0x388958<_0x4b533f[_0x6b4e('0x35')];_0x388958+=0x1){var _0x4934c9=_0x4b533f[_0x388958][_0x6b4e('0x24')]({'plain':!![]});_0x43e75a=squel['insert']()[_0x6b4e('0x67')](_0x6b4e('0x82'))[_0x6b4e('0x69')](['phone','ContactId',_0x6b4e('0x6c'),_0x6b4e('0x56'),'createdAt',_0x6b4e('0x52')],squel[_0x6b4e('0x6d')]()['field'](_0x6b4e('0x6a'),_0x6b4e('0x6a'))[_0x6b4e('0x6e')]('id',_0x6b4e('0x7a'))[_0x6b4e('0x6e')](_0x4934c9[_0x6b4e('0x6f')][_0x6b4e('0x70')](),_0x6b4e('0x6c'))['field'](_0x31ae39['params']['id'][_0x6b4e('0x70')](),_0x6b4e('0x56'))['field']('NOW()',_0x6b4e('0x51'))[_0x6b4e('0x6e')](_0x6b4e('0x71'),_0x6b4e('0x52'))[_0x6b4e('0x72')](_0x6b4e('0x7b'))[_0x6b4e('0x3a')](_0x6b4e('0x73'))[_0x6b4e('0x3a')](_0x6b4e('0x74'),_0x4934c9[_0x6b4e('0x6f')]['toString']())[_0x6b4e('0x3a')]('phone\x20IS\x20NOT\x20NULL'))[_0x6b4e('0x70')]();_0x5b31fe[_0x6b4e('0x7c')](db[_0x6b4e('0x7d')][_0x6b4e('0x30')](_0x43e75a));}return BPromise['all'](_0x5b31fe);}})[_0x6b4e('0x23')](function(){return _0x233ad5;})[_0x6b4e('0x23')](respondWithResult(_0x4d54fc,null))[_0x6b4e('0x44')](handleError(_0x4d54fc,null));};exports[_0x6b4e('0x83')]=function(_0x1c0eaa,_0x2a2bf1,_0x15254c){return db[_0x6b4e('0x2b')][_0x6b4e('0x46')]({'where':{'id':_0x1c0eaa['params']['id']}})[_0x6b4e('0x23')](handleEntityNotFound(_0x2a2bf1,null))['then'](function(_0x1266f4){if(_0x1266f4){return _0x1266f4['removeBlackLists'](_0x1c0eaa[_0x6b4e('0x30')][_0x6b4e('0x62')]);}})[_0x6b4e('0x23')](function(_0x5e9fe3){if(_0x5e9fe3){return db[_0x6b4e('0x5e')][_0x6b4e('0x22')]({'where':{'ListId':_0x1c0eaa[_0x6b4e('0x30')][_0x6b4e('0x62')],'CampaignId':_0x1c0eaa[_0x6b4e('0x45')]['id']}})['then'](function(){return _0x5e9fe3;});}})[_0x6b4e('0x23')](respondWithStatusCode(_0x2a2bf1,null))[_0x6b4e('0x44')](handleError(_0x2a2bf1,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