f4ab665f6166a4f343b984a6fc2eec594d35de2b
[motion2.git] / server / api / campaign / campaign.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xc792=['ListId\x20=\x20?','phone\x20IS\x20NOT\x20NULL','select','cm_hopper_final','CampaignId\x20=\x20?','phone\x20NOT\x20IN\x20(?)','COALESCE(phone,\x27\x27)','insert','all','removeLists','ids','getBlackLists','addBlackLists','spread','cm_hopper_black','sequelize','removeBlackLists','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','util','path','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','destroy','get','IvrCampaigns','error','stack','send','index','map','Campaign','fieldName','type','key','model','name','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','include','findAll','rows','catch','show','keys','rawAttributes','includeAll','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','find','omit','createdAt','updatedAt','UserProfileSection','autoAssociation','UserProfileResource','getHoppers','CmHopper','getHopperHistories','findOne','CmHopperHistory','CampaignId','getHopperFinals','CmHopperFinal','getHopperBlacks','CmHopperBlack','getLists','CmList','addLists','dialCheckDuplicateType','into','cm_hopper','fromQuery','phone','scheduledAt','ListId','field','NOW()','ContactId','CmListId','toString','from','cm_contacts','deletedAt\x20IS\x20NULL'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0xc792,0x123));var _0x2c79=function(_0x25d312,_0xcf3ea1){_0x25d312=_0x25d312-0x0;var _0x5a2879=_0xc792[_0x25d312];return _0x5a2879;};'use strict';var emlformat=require(_0x2c79('0x0'));var rimraf=require(_0x2c79('0x1'));var zipdir=require(_0x2c79('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x2c79('0x3'));var moment=require(_0x2c79('0x4'));var BPromise=require(_0x2c79('0x5'));var Mustache=require('mustache');var util=require(_0x2c79('0x6'));var path=require(_0x2c79('0x7'));var sox=require('sox');var csv=require(_0x2c79('0x8'));var ejs=require(_0x2c79('0x9'));var fs=require('fs');var fs_extra=require(_0x2c79('0xa'));var _=require(_0x2c79('0xb'));var squel=require(_0x2c79('0xc'));var crypto=require('crypto');var jsforce=require(_0x2c79('0xd'));var deskjs=require(_0x2c79('0xe'));var toCsv=require(_0x2c79('0x8'));var querystring=require('querystring');var Papa=require(_0x2c79('0xf'));var Redis=require(_0x2c79('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x2c79('0x11'));var as=require(_0x2c79('0x12'));var hardwareService=require(_0x2c79('0x13'));var logger=require(_0x2c79('0x14'))(_0x2c79('0x15'));var utils=require(_0x2c79('0x16'));var config=require(_0x2c79('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0x2c79('0x18'))['db'];function respondWithStatusCode(_0x28a261,_0x4e5aea){_0x4e5aea=_0x4e5aea||0xcc;return function(_0x33346c){if(_0x33346c){return _0x28a261[_0x2c79('0x19')](_0x4e5aea);}return _0x28a261[_0x2c79('0x1a')](_0x4e5aea)[_0x2c79('0x1b')]();};}function respondWithResult(_0x43795d,_0x4b9c6f){_0x4b9c6f=_0x4b9c6f||0xc8;return function(_0x393ed9){if(_0x393ed9){return _0x43795d[_0x2c79('0x1a')](_0x4b9c6f)[_0x2c79('0x1c')](_0x393ed9);}};}function respondWithFilteredResult(_0x734994,_0x289010){return function(_0x5e8512){if(_0x5e8512){var _0x150060=typeof _0x289010[_0x2c79('0x1d')]===_0x2c79('0x1e')&&typeof _0x289010[_0x2c79('0x1f')]===_0x2c79('0x1e');var _0x3e1a2b=_0x5e8512[_0x2c79('0x20')];var _0x406c2a=_0x150060?0x0:_0x289010[_0x2c79('0x1d')];var _0x1cdddd=_0x150060?_0x5e8512[_0x2c79('0x20')]:_0x289010[_0x2c79('0x1d')]+_0x289010[_0x2c79('0x1f')];var _0x110fd2;if(_0x1cdddd>=_0x3e1a2b){_0x1cdddd=_0x3e1a2b;_0x110fd2=0xc8;}else{_0x110fd2=0xce;}_0x734994['status'](_0x110fd2);return _0x734994[_0x2c79('0x21')](_0x2c79('0x22'),_0x406c2a+'-'+_0x1cdddd+'/'+_0x3e1a2b)[_0x2c79('0x1c')](_0x5e8512);}return null;};}function patchUpdates(_0x58b2cf){return function(_0x1eb830){try{jsonpatch['apply'](_0x1eb830,_0x58b2cf,!![]);}catch(_0x595fa2){return BPromise[_0x2c79('0x23')](_0x595fa2);}return _0x1eb830[_0x2c79('0x24')]();};}function saveUpdates(_0x9768ed,_0x50ed5b){return function(_0x15e83e){if(_0x15e83e){return _0x15e83e[_0x2c79('0x25')](_0x9768ed)[_0x2c79('0x26')](function(_0x48eb70){return _0x48eb70;});}return null;};}function removeEntity(_0x4190ee,_0x1c9ea4){return function(_0x54f004){if(_0x54f004){return _0x54f004[_0x2c79('0x27')]()[_0x2c79('0x26')](function(){var _0x32b602=_0x54f004[_0x2c79('0x28')]({'plain':!![]});var _0x9b2229=_0x2c79('0x29');return db['UserProfileResource'][_0x2c79('0x27')]({'where':{'type':_0x9b2229,'resourceId':_0x32b602['id']}})[_0x2c79('0x26')](function(){return _0x54f004;});})[_0x2c79('0x26')](function(){_0x4190ee[_0x2c79('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x38db9b,_0x5a7bb6){return function(_0x4a7dcb){if(!_0x4a7dcb){_0x38db9b['sendStatus'](0x194);}return _0x4a7dcb;};}function handleError(_0x5f18d4,_0x5ed121){_0x5ed121=_0x5ed121||0x1f4;return function(_0xdc830e){logger[_0x2c79('0x2a')](_0xdc830e[_0x2c79('0x2b')]);if(_0xdc830e['name']){delete _0xdc830e['name'];}_0x5f18d4[_0x2c79('0x1a')](_0x5ed121)[_0x2c79('0x2c')](_0xdc830e);};}exports[_0x2c79('0x2d')]=function(_0x55a6c1,_0x43743a){var _0x2336d9={},_0x348a3e={},_0x514337={'count':0x0,'rows':[]};var _0x4e5c08=_[_0x2c79('0x2e')](db[_0x2c79('0x2f')]['rawAttributes'],function(_0x3e3496){return{'name':_0x3e3496[_0x2c79('0x30')],'type':_0x3e3496[_0x2c79('0x31')][_0x2c79('0x32')]};});_0x348a3e[_0x2c79('0x33')]=_[_0x2c79('0x2e')](_0x4e5c08,_0x2c79('0x34'));_0x348a3e[_0x2c79('0x35')]=_['keys'](_0x55a6c1[_0x2c79('0x35')]);_0x348a3e[_0x2c79('0x36')]=_[_0x2c79('0x37')](_0x348a3e[_0x2c79('0x33')],_0x348a3e['query']);_0x2336d9[_0x2c79('0x38')]=_[_0x2c79('0x37')](_0x348a3e['model'],qs[_0x2c79('0x39')](_0x55a6c1[_0x2c79('0x35')]['fields']));_0x2336d9['attributes']=_0x2336d9[_0x2c79('0x38')][_0x2c79('0x3a')]?_0x2336d9[_0x2c79('0x38')]:_0x348a3e[_0x2c79('0x33')];if(!_0x55a6c1['query'][_0x2c79('0x3b')](_0x2c79('0x3c'))){_0x2336d9['limit']=qs['limit'](_0x55a6c1[_0x2c79('0x35')]['limit']);_0x2336d9[_0x2c79('0x1d')]=qs[_0x2c79('0x1d')](_0x55a6c1['query'][_0x2c79('0x1d')]);}_0x2336d9[_0x2c79('0x3d')]=qs[_0x2c79('0x3e')](_0x55a6c1['query'][_0x2c79('0x3e')]);_0x2336d9[_0x2c79('0x3f')]=qs[_0x2c79('0x36')](_[_0x2c79('0x40')](_0x55a6c1[_0x2c79('0x35')],_0x348a3e[_0x2c79('0x36')]),_0x4e5c08);if(_0x55a6c1[_0x2c79('0x35')][_0x2c79('0x41')]){_0x2336d9[_0x2c79('0x3f')]=_['merge'](_0x2336d9[_0x2c79('0x3f')],{'$or':_['map'](_0x4e5c08,function(_0x36fc4d){if(_0x36fc4d[_0x2c79('0x31')]!==_0x2c79('0x42')){var _0x100c09={};_0x100c09[_0x36fc4d[_0x2c79('0x34')]]={'$like':'%'+_0x55a6c1['query'][_0x2c79('0x41')]+'%'};return _0x100c09;}})});}_0x2336d9=_[_0x2c79('0x43')]({},_0x2336d9,_0x55a6c1['options']);var _0x4fe7d1={'where':_0x2336d9['where']};return db['Campaign'][_0x2c79('0x20')](_0x4fe7d1)[_0x2c79('0x26')](function(_0x2d22f7){_0x514337[_0x2c79('0x20')]=_0x2d22f7;if(_0x55a6c1[_0x2c79('0x35')]['includeAll']){_0x2336d9[_0x2c79('0x44')]=[{'all':!![]}];}return db[_0x2c79('0x2f')][_0x2c79('0x45')](_0x2336d9);})['then'](function(_0xb446e8){_0x514337[_0x2c79('0x46')]=_0xb446e8;return _0x514337;})[_0x2c79('0x26')](respondWithFilteredResult(_0x43743a,_0x2336d9))[_0x2c79('0x47')](handleError(_0x43743a,null));};exports[_0x2c79('0x48')]=function(_0x323cdd,_0x5a3389){var _0xf7f290={'raw':![],'where':{'id':_0x323cdd['params']['id']}},_0x3e8dfa={};_0x3e8dfa[_0x2c79('0x33')]=_[_0x2c79('0x49')](db[_0x2c79('0x2f')][_0x2c79('0x4a')]);_0x3e8dfa[_0x2c79('0x35')]=_[_0x2c79('0x49')](_0x323cdd[_0x2c79('0x35')]);_0x3e8dfa[_0x2c79('0x36')]=_[_0x2c79('0x37')](_0x3e8dfa['model'],_0x3e8dfa[_0x2c79('0x35')]);_0xf7f290['attributes']=_[_0x2c79('0x37')](_0x3e8dfa[_0x2c79('0x33')],qs[_0x2c79('0x39')](_0x323cdd[_0x2c79('0x35')]['fields']));_0xf7f290['attributes']=_0xf7f290['attributes'][_0x2c79('0x3a')]?_0xf7f290['attributes']:_0x3e8dfa[_0x2c79('0x33')];if(_0x323cdd[_0x2c79('0x35')][_0x2c79('0x4b')]){_0xf7f290[_0x2c79('0x44')]=[{'all':!![]}];}_0xf7f290=_[_0x2c79('0x43')]({},_0xf7f290,_0x323cdd[_0x2c79('0x4c')]);return db['Campaign']['find'](_0xf7f290)[_0x2c79('0x26')](handleEntityNotFound(_0x5a3389,null))['then'](respondWithResult(_0x5a3389,null))[_0x2c79('0x47')](handleError(_0x5a3389,null));};exports[_0x2c79('0x4d')]=function(_0x42caa7,_0x5e347c){return db[_0x2c79('0x2f')]['create'](_0x42caa7[_0x2c79('0x4e')],{})[_0x2c79('0x26')](function(_0x1a4123){var _0x1411ad=_0x42caa7[_0x2c79('0x4f')][_0x2c79('0x28')]({'plain':!![]});if(!_0x1411ad)throw new Error(_0x2c79('0x50'));if(_0x1411ad[_0x2c79('0x51')]==='user'){var _0x57844b=_0x1a4123[_0x2c79('0x28')]({'plain':!![]});var _0x2819be=_0x2c79('0x29');return db['UserProfileSection']['find']({'where':{'name':_0x2819be,'userProfileId':_0x1411ad[_0x2c79('0x52')]},'raw':!![]})[_0x2c79('0x26')](function(_0x59250d){if(_0x59250d&&_0x59250d['autoAssociation']===0x0){return db['UserProfileResource'][_0x2c79('0x4d')]({'name':_0x57844b[_0x2c79('0x34')],'resourceId':_0x57844b['id'],'type':_0x59250d[_0x2c79('0x34')],'sectionId':_0x59250d['id']},{})[_0x2c79('0x26')](function(){return _0x1a4123;});}else{return _0x1a4123;}})[_0x2c79('0x47')](function(_0x11f29e){logger[_0x2c79('0x2a')](_0x2c79('0x53'),_0x11f29e);throw _0x11f29e;});}return _0x1a4123;})[_0x2c79('0x26')](respondWithResult(_0x5e347c,0xc9))[_0x2c79('0x47')](handleError(_0x5e347c,null));};exports['clone']=function(_0x314d09,_0x282a55){var _0x110901={'where':{'id':_0x314d09[_0x2c79('0x54')]['id']}},_0x8547b0={};_0x8547b0[_0x2c79('0x33')]=_['keys'](db['Campaign']['rawAttributes']);_0x110901[_0x2c79('0x38')]=_[_0x2c79('0x37')](_0x8547b0[_0x2c79('0x33')],qs[_0x2c79('0x39')](_0x314d09['query']['fields']));_0x110901[_0x2c79('0x38')]=_0x110901[_0x2c79('0x38')]['length']?_0x110901[_0x2c79('0x38')]:_0x8547b0[_0x2c79('0x33')];if(_0x314d09[_0x2c79('0x35')]['includeAll']){_0x110901[_0x2c79('0x44')]=[{'all':!![]}];}_0x110901=_[_0x2c79('0x43')]({},_0x110901,_0x314d09[_0x2c79('0x4c')]);return db[_0x2c79('0x2f')][_0x2c79('0x55')](_0x110901)['then'](handleEntityNotFound(_0x282a55,null))[_0x2c79('0x26')](function(_0x42737d){if(_0x42737d){var _0x4143e2=_0x42737d[_0x2c79('0x28')]({'plain':!![]});_0x4143e2=qs[_0x2c79('0x56')](_0x4143e2,['id',_0x2c79('0x57'),_0x2c79('0x58')]);_0x314d09['body']=_[_0x2c79('0x56')](_0x314d09[_0x2c79('0x4e')],['id',_0x2c79('0x57'),_0x2c79('0x58')]);return db['Campaign'][_0x2c79('0x4d')](_['merge'](_0x4143e2,_0x314d09[_0x2c79('0x4e')]),{'include':_0x314d09[_0x2c79('0x35')]['includeAll']?[{'all':!![]}]:undefined})[_0x2c79('0x26')](function(_0x44ad57){var _0x500ab4=_0x314d09[_0x2c79('0x4f')][_0x2c79('0x28')]({'plain':!![]});if(!_0x500ab4)throw new Error(_0x2c79('0x50'));if(_0x500ab4[_0x2c79('0x51')]==='user'){var _0x487cef=_0x44ad57[_0x2c79('0x28')]({'plain':!![]});var _0x317fd3='IvrCampaigns';return db[_0x2c79('0x59')]['find']({'where':{'name':_0x317fd3,'userProfileId':_0x500ab4[_0x2c79('0x52')]},'raw':!![]})['then'](function(_0x6e316){if(_0x6e316&&_0x6e316[_0x2c79('0x5a')]===0x0){return db[_0x2c79('0x5b')][_0x2c79('0x4d')]({'name':_0x487cef[_0x2c79('0x34')],'resourceId':_0x487cef['id'],'type':_0x6e316[_0x2c79('0x34')],'sectionId':_0x6e316['id']},{})[_0x2c79('0x26')](function(){return _0x44ad57;});}else{return _0x44ad57;}})[_0x2c79('0x47')](function(_0x5abba0){logger[_0x2c79('0x2a')](_0x2c79('0x53'),_0x5abba0);throw _0x5abba0;});}return _0x44ad57;});}})['then'](respondWithResult(_0x282a55,0xc9))['catch'](handleError(_0x282a55,null));};exports[_0x2c79('0x25')]=function(_0x229e40,_0x1bbfcf){if(_0x229e40[_0x2c79('0x4e')]['id']){delete _0x229e40[_0x2c79('0x4e')]['id'];}return db['Campaign']['find']({'where':{'id':_0x229e40['params']['id']}})[_0x2c79('0x26')](handleEntityNotFound(_0x1bbfcf,null))[_0x2c79('0x26')](saveUpdates(_0x229e40[_0x2c79('0x4e')],null))[_0x2c79('0x26')](respondWithResult(_0x1bbfcf,null))['catch'](handleError(_0x1bbfcf,null));};exports[_0x2c79('0x27')]=function(_0x3426d2,_0x2da896){return db[_0x2c79('0x2f')][_0x2c79('0x55')]({'where':{'id':_0x3426d2[_0x2c79('0x54')]['id']}})[_0x2c79('0x26')](handleEntityNotFound(_0x2da896,null))[_0x2c79('0x26')](removeEntity(_0x2da896,null))[_0x2c79('0x47')](handleError(_0x2da896,null));};exports[_0x2c79('0x5c')]=function(_0x4c586a,_0x3a7040,_0x1c2c0f){var _0xbd6eff={'raw':!![],'where':{}};var _0x258e9e={};var _0x1d7ddd={'count':0x0,'rows':[]};return db[_0x2c79('0x2f')]['findOne']({'where':{'id':_0x4c586a[_0x2c79('0x54')]['id']}})[_0x2c79('0x26')](handleEntityNotFound(_0x3a7040,null))[_0x2c79('0x26')](function(_0xa161f7){if(_0xa161f7){_0x258e9e[_0x2c79('0x33')]=_[_0x2c79('0x49')](db[_0x2c79('0x5d')]['rawAttributes']);_0x258e9e[_0x2c79('0x35')]=_[_0x2c79('0x49')](_0x4c586a[_0x2c79('0x35')]);_0x258e9e[_0x2c79('0x36')]=_[_0x2c79('0x37')](_0x258e9e['model'],_0x258e9e[_0x2c79('0x35')]);_0xbd6eff['attributes']=_[_0x2c79('0x37')](_0x258e9e[_0x2c79('0x33')],qs['fields'](_0x4c586a['query'][_0x2c79('0x39')]));_0xbd6eff['attributes']=_0xbd6eff[_0x2c79('0x38')][_0x2c79('0x3a')]?_0xbd6eff[_0x2c79('0x38')]:_0x258e9e['model'];if(!_0x4c586a['query'][_0x2c79('0x3b')](_0x2c79('0x3c'))){_0xbd6eff['limit']=qs[_0x2c79('0x1f')](_0x4c586a['query'][_0x2c79('0x1f')]);_0xbd6eff[_0x2c79('0x1d')]=qs[_0x2c79('0x1d')](_0x4c586a['query'][_0x2c79('0x1d')]);}_0xbd6eff[_0x2c79('0x3d')]=qs[_0x2c79('0x3e')](_0x4c586a[_0x2c79('0x35')][_0x2c79('0x3e')]);_0xbd6eff[_0x2c79('0x3f')]=qs['filters'](_[_0x2c79('0x40')](_0x4c586a[_0x2c79('0x35')],_0x258e9e[_0x2c79('0x36')]));_0xbd6eff[_0x2c79('0x3f')]['CampaignId']=_0xa161f7['id'];if(_0x4c586a[_0x2c79('0x35')][_0x2c79('0x41')]){_0xbd6eff[_0x2c79('0x3f')]=_[_0x2c79('0x43')](_0xbd6eff[_0x2c79('0x3f')],{'$or':_[_0x2c79('0x2e')](_0xbd6eff[_0x2c79('0x38')],function(_0x5bb45a){var _0x4ae97b={};_0x4ae97b[_0x5bb45a]={'$like':'%'+_0x4c586a[_0x2c79('0x35')]['filter']+'%'};return _0x4ae97b;})});}_0xbd6eff=_[_0x2c79('0x43')]({},_0xbd6eff,_0x4c586a[_0x2c79('0x4c')]);return db[_0x2c79('0x5d')]['count']({'where':_0xbd6eff[_0x2c79('0x3f')]})[_0x2c79('0x26')](function(_0x371908){_0x1d7ddd[_0x2c79('0x20')]=_0x371908;if(_0x4c586a['query'][_0x2c79('0x4b')]){_0xbd6eff[_0x2c79('0x44')]=[{'all':!![]}];}return db[_0x2c79('0x5d')]['findAll'](_0xbd6eff);})[_0x2c79('0x26')](function(_0x24feeb){_0x1d7ddd[_0x2c79('0x46')]=_0x24feeb;return _0x1d7ddd;});}})[_0x2c79('0x26')](respondWithFilteredResult(_0x3a7040,_0xbd6eff))[_0x2c79('0x47')](handleError(_0x3a7040,null));};exports[_0x2c79('0x5e')]=function(_0x2d75c7,_0x22db40,_0x28e948){var _0xd2d44f={'raw':!![],'where':{}};var _0x2dca3e={};var _0x4837a2={'count':0x0,'rows':[]};return db[_0x2c79('0x2f')][_0x2c79('0x5f')]({'where':{'id':_0x2d75c7[_0x2c79('0x54')]['id']}})[_0x2c79('0x26')](handleEntityNotFound(_0x22db40,null))[_0x2c79('0x26')](function(_0x1b2ca3){if(_0x1b2ca3){_0x2dca3e[_0x2c79('0x33')]=_['keys'](db[_0x2c79('0x60')][_0x2c79('0x4a')]);_0x2dca3e[_0x2c79('0x35')]=_['keys'](_0x2d75c7[_0x2c79('0x35')]);_0x2dca3e[_0x2c79('0x36')]=_[_0x2c79('0x37')](_0x2dca3e[_0x2c79('0x33')],_0x2dca3e[_0x2c79('0x35')]);_0xd2d44f[_0x2c79('0x38')]=_[_0x2c79('0x37')](_0x2dca3e['model'],qs[_0x2c79('0x39')](_0x2d75c7[_0x2c79('0x35')][_0x2c79('0x39')]));_0xd2d44f[_0x2c79('0x38')]=_0xd2d44f['attributes'][_0x2c79('0x3a')]?_0xd2d44f['attributes']:_0x2dca3e['model'];if(!_0x2d75c7[_0x2c79('0x35')][_0x2c79('0x3b')]('nolimit')){_0xd2d44f[_0x2c79('0x1f')]=qs[_0x2c79('0x1f')](_0x2d75c7[_0x2c79('0x35')][_0x2c79('0x1f')]);_0xd2d44f[_0x2c79('0x1d')]=qs[_0x2c79('0x1d')](_0x2d75c7[_0x2c79('0x35')][_0x2c79('0x1d')]);}_0xd2d44f[_0x2c79('0x3d')]=qs[_0x2c79('0x3e')](_0x2d75c7['query']['sort']);_0xd2d44f[_0x2c79('0x3f')]=qs[_0x2c79('0x36')](_['pick'](_0x2d75c7['query'],_0x2dca3e['filters']));_0xd2d44f[_0x2c79('0x3f')][_0x2c79('0x61')]=_0x1b2ca3['id'];if(_0x2d75c7[_0x2c79('0x35')][_0x2c79('0x41')]){_0xd2d44f[_0x2c79('0x3f')]=_[_0x2c79('0x43')](_0xd2d44f[_0x2c79('0x3f')],{'$or':_['map'](_0xd2d44f[_0x2c79('0x38')],function(_0x227718){var _0x3c20f4={};_0x3c20f4[_0x227718]={'$like':'%'+_0x2d75c7[_0x2c79('0x35')]['filter']+'%'};return _0x3c20f4;})});}_0xd2d44f=_['merge']({},_0xd2d44f,_0x2d75c7[_0x2c79('0x4c')]);return db[_0x2c79('0x60')]['count']({'where':_0xd2d44f[_0x2c79('0x3f')]})[_0x2c79('0x26')](function(_0x1f9c42){_0x4837a2[_0x2c79('0x20')]=_0x1f9c42;if(_0x2d75c7['query'][_0x2c79('0x4b')]){_0xd2d44f[_0x2c79('0x44')]=[{'all':!![]}];}return db[_0x2c79('0x60')]['findAll'](_0xd2d44f);})['then'](function(_0x3b47c9){_0x4837a2[_0x2c79('0x46')]=_0x3b47c9;return _0x4837a2;});}})[_0x2c79('0x26')](respondWithFilteredResult(_0x22db40,_0xd2d44f))[_0x2c79('0x47')](handleError(_0x22db40,null));};exports[_0x2c79('0x62')]=function(_0x4cc535,_0x4c07ad,_0x20c8f5){var _0x40e3af={'raw':!![],'where':{}};var _0x484015={};var _0x46b314={'count':0x0,'rows':[]};return db[_0x2c79('0x2f')][_0x2c79('0x5f')]({'where':{'id':_0x4cc535[_0x2c79('0x54')]['id']}})[_0x2c79('0x26')](handleEntityNotFound(_0x4c07ad,null))[_0x2c79('0x26')](function(_0xe18a01){if(_0xe18a01){_0x484015[_0x2c79('0x33')]=_[_0x2c79('0x49')](db['CmHopperFinal'][_0x2c79('0x4a')]);_0x484015['query']=_[_0x2c79('0x49')](_0x4cc535[_0x2c79('0x35')]);_0x484015['filters']=_[_0x2c79('0x37')](_0x484015[_0x2c79('0x33')],_0x484015[_0x2c79('0x35')]);_0x40e3af[_0x2c79('0x38')]=_[_0x2c79('0x37')](_0x484015['model'],qs[_0x2c79('0x39')](_0x4cc535['query'][_0x2c79('0x39')]));_0x40e3af['attributes']=_0x40e3af[_0x2c79('0x38')][_0x2c79('0x3a')]?_0x40e3af[_0x2c79('0x38')]:_0x484015[_0x2c79('0x33')];if(!_0x4cc535['query'][_0x2c79('0x3b')]('nolimit')){_0x40e3af[_0x2c79('0x1f')]=qs[_0x2c79('0x1f')](_0x4cc535[_0x2c79('0x35')]['limit']);_0x40e3af[_0x2c79('0x1d')]=qs[_0x2c79('0x1d')](_0x4cc535[_0x2c79('0x35')][_0x2c79('0x1d')]);}_0x40e3af[_0x2c79('0x3d')]=qs[_0x2c79('0x3e')](_0x4cc535[_0x2c79('0x35')]['sort']);_0x40e3af[_0x2c79('0x3f')]=qs['filters'](_['pick'](_0x4cc535[_0x2c79('0x35')],_0x484015[_0x2c79('0x36')]));_0x40e3af['where']['CampaignId']=_0xe18a01['id'];if(_0x4cc535['query']['filter']){_0x40e3af[_0x2c79('0x3f')]=_[_0x2c79('0x43')](_0x40e3af[_0x2c79('0x3f')],{'$or':_[_0x2c79('0x2e')](_0x40e3af['attributes'],function(_0x2b970f){var _0x58d576={};_0x58d576[_0x2b970f]={'$like':'%'+_0x4cc535[_0x2c79('0x35')][_0x2c79('0x41')]+'%'};return _0x58d576;})});}_0x40e3af=_[_0x2c79('0x43')]({},_0x40e3af,_0x4cc535[_0x2c79('0x4c')]);return db[_0x2c79('0x63')][_0x2c79('0x20')]({'where':_0x40e3af[_0x2c79('0x3f')]})[_0x2c79('0x26')](function(_0x443775){_0x46b314['count']=_0x443775;if(_0x4cc535[_0x2c79('0x35')][_0x2c79('0x4b')]){_0x40e3af[_0x2c79('0x44')]=[{'all':!![]}];}return db[_0x2c79('0x63')][_0x2c79('0x45')](_0x40e3af);})[_0x2c79('0x26')](function(_0x2f9da0){_0x46b314['rows']=_0x2f9da0;return _0x46b314;});}})[_0x2c79('0x26')](respondWithFilteredResult(_0x4c07ad,_0x40e3af))['catch'](handleError(_0x4c07ad,null));};exports[_0x2c79('0x64')]=function(_0x2c07a8,_0x2c78f7,_0x1d48af){var _0x5d2978={'raw':!![],'where':{}};var _0x2f651e={};var _0x17d77c={'count':0x0,'rows':[]};return db['Campaign'][_0x2c79('0x5f')]({'where':{'id':_0x2c07a8[_0x2c79('0x54')]['id']}})[_0x2c79('0x26')](handleEntityNotFound(_0x2c78f7,null))[_0x2c79('0x26')](function(_0x418c73){if(_0x418c73){_0x2f651e['model']=_[_0x2c79('0x49')](db[_0x2c79('0x65')]['rawAttributes']);_0x2f651e[_0x2c79('0x35')]=_[_0x2c79('0x49')](_0x2c07a8[_0x2c79('0x35')]);_0x2f651e[_0x2c79('0x36')]=_[_0x2c79('0x37')](_0x2f651e[_0x2c79('0x33')],_0x2f651e[_0x2c79('0x35')]);_0x5d2978[_0x2c79('0x38')]=_[_0x2c79('0x37')](_0x2f651e[_0x2c79('0x33')],qs[_0x2c79('0x39')](_0x2c07a8['query']['fields']));_0x5d2978[_0x2c79('0x38')]=_0x5d2978[_0x2c79('0x38')][_0x2c79('0x3a')]?_0x5d2978['attributes']:_0x2f651e['model'];if(!_0x2c07a8[_0x2c79('0x35')][_0x2c79('0x3b')](_0x2c79('0x3c'))){_0x5d2978[_0x2c79('0x1f')]=qs[_0x2c79('0x1f')](_0x2c07a8['query'][_0x2c79('0x1f')]);_0x5d2978['offset']=qs[_0x2c79('0x1d')](_0x2c07a8[_0x2c79('0x35')][_0x2c79('0x1d')]);}_0x5d2978['order']=qs[_0x2c79('0x3e')](_0x2c07a8[_0x2c79('0x35')][_0x2c79('0x3e')]);_0x5d2978[_0x2c79('0x3f')]=qs[_0x2c79('0x36')](_[_0x2c79('0x40')](_0x2c07a8[_0x2c79('0x35')],_0x2f651e[_0x2c79('0x36')]));_0x5d2978[_0x2c79('0x3f')]['CampaignId']=_0x418c73['id'];if(_0x2c07a8[_0x2c79('0x35')][_0x2c79('0x41')]){_0x5d2978[_0x2c79('0x3f')]=_[_0x2c79('0x43')](_0x5d2978[_0x2c79('0x3f')],{'$or':_[_0x2c79('0x2e')](_0x5d2978[_0x2c79('0x38')],function(_0x3b8325){var _0x1efdc9={};_0x1efdc9[_0x3b8325]={'$like':'%'+_0x2c07a8['query'][_0x2c79('0x41')]+'%'};return _0x1efdc9;})});}_0x5d2978=_[_0x2c79('0x43')]({},_0x5d2978,_0x2c07a8[_0x2c79('0x4c')]);return db[_0x2c79('0x65')][_0x2c79('0x20')]({'where':_0x5d2978[_0x2c79('0x3f')]})['then'](function(_0x56366f){_0x17d77c[_0x2c79('0x20')]=_0x56366f;if(_0x2c07a8[_0x2c79('0x35')]['includeAll']){_0x5d2978[_0x2c79('0x44')]=[{'all':!![]}];}return db[_0x2c79('0x65')][_0x2c79('0x45')](_0x5d2978);})['then'](function(_0xdbfece){_0x17d77c[_0x2c79('0x46')]=_0xdbfece;return _0x17d77c;});}})['then'](respondWithFilteredResult(_0x2c78f7,_0x5d2978))[_0x2c79('0x47')](handleError(_0x2c78f7,null));};exports[_0x2c79('0x66')]=function(_0xe99577,_0x59101e,_0xa15f1a){var _0x13df96={};var _0x743fd0={};var _0x2afd85;var _0x41b17b;return db[_0x2c79('0x2f')][_0x2c79('0x5f')]({'where':{'id':_0xe99577[_0x2c79('0x54')]['id']}})[_0x2c79('0x26')](handleEntityNotFound(_0x59101e,null))[_0x2c79('0x26')](function(_0xb75eaa){if(_0xb75eaa){_0x2afd85=_0xb75eaa;_0x743fd0[_0x2c79('0x33')]=_[_0x2c79('0x49')](db[_0x2c79('0x67')][_0x2c79('0x4a')]);_0x743fd0[_0x2c79('0x35')]=_[_0x2c79('0x49')](_0xe99577['query']);_0x743fd0[_0x2c79('0x36')]=_['intersection'](_0x743fd0[_0x2c79('0x33')],_0x743fd0['query']);_0x13df96[_0x2c79('0x38')]=_[_0x2c79('0x37')](_0x743fd0[_0x2c79('0x33')],qs[_0x2c79('0x39')](_0xe99577['query']['fields']));_0x13df96[_0x2c79('0x38')]=_0x13df96['attributes'][_0x2c79('0x3a')]?_0x13df96[_0x2c79('0x38')]:_0x743fd0[_0x2c79('0x33')];_0x13df96[_0x2c79('0x3d')]=qs[_0x2c79('0x3e')](_0xe99577[_0x2c79('0x35')]['sort']);_0x13df96[_0x2c79('0x3f')]=qs['filters'](_['pick'](_0xe99577[_0x2c79('0x35')],_0x743fd0[_0x2c79('0x36')]));if(_0xe99577[_0x2c79('0x35')]['filter']){_0x13df96[_0x2c79('0x3f')]=_['merge'](_0x13df96['where'],{'$or':_[_0x2c79('0x2e')](_0x13df96[_0x2c79('0x38')],function(_0x199330){var _0x8b14a6={};_0x8b14a6[_0x199330]={'$like':'%'+_0xe99577[_0x2c79('0x35')][_0x2c79('0x41')]+'%'};return _0x8b14a6;})});}_0x13df96=_[_0x2c79('0x43')]({},_0x13df96,_0xe99577[_0x2c79('0x4c')]);return _0x2afd85[_0x2c79('0x66')](_0x13df96);}})[_0x2c79('0x26')](function(_0x4f114e){if(_0x4f114e){_0x41b17b=_0x4f114e['length'];if(!_0xe99577[_0x2c79('0x35')][_0x2c79('0x3b')](_0x2c79('0x3c'))){_0x13df96[_0x2c79('0x1f')]=qs['limit'](_0xe99577[_0x2c79('0x35')][_0x2c79('0x1f')]);_0x13df96[_0x2c79('0x1d')]=qs['offset'](_0xe99577[_0x2c79('0x35')][_0x2c79('0x1d')]);}return _0x2afd85['getLists'](_0x13df96);}})['then'](function(_0x223ac5){if(_0x223ac5){return _0x223ac5?{'count':_0x41b17b,'rows':_0x223ac5}:null;}})[_0x2c79('0x26')](respondWithResult(_0x59101e,null))[_0x2c79('0x47')](handleError(_0x59101e,null));};exports[_0x2c79('0x68')]=function(_0x515e97,_0x570f15,_0x3a6ec9){var _0x56f3e8,_0x469907;return db[_0x2c79('0x2f')][_0x2c79('0x55')]({'where':{'id':_0x515e97['params']['id']}})[_0x2c79('0x26')](handleEntityNotFound(_0x570f15,null))[_0x2c79('0x26')](function(_0x41c30d){if(_0x41c30d){_0x469907=_0x41c30d;return _0x41c30d[_0x2c79('0x68')](_0x515e97['body']['ids'],_[_0x2c79('0x56')](_0x515e97[_0x2c79('0x4e')],['ids','id'])||{});}return null;})['spread'](function(_0x47953e){var _0x37dd7c;_0x56f3e8=_0x47953e||[];var _0x1f13d6=[];if(_0x47953e){for(var _0x9bbb0d=0x0;_0x9bbb0d<_0x47953e[_0x2c79('0x3a')];_0x9bbb0d+=0x1){var _0x1f5693=_0x47953e[_0x9bbb0d][_0x2c79('0x28')]({'plain':!![]});_0x469907[_0x2c79('0x69')]=_0x515e97[_0x2c79('0x4e')][_0x2c79('0x69')]?_0x515e97[_0x2c79('0x4e')][_0x2c79('0x69')]:_0x469907['dialCheckDuplicateType'];switch(_0x469907[_0x2c79('0x69')]){case'always':_0x37dd7c=squel['insert']()[_0x2c79('0x6a')](_0x2c79('0x6b'))[_0x2c79('0x6c')]([_0x2c79('0x6d'),_0x2c79('0x6e'),'ContactId',_0x2c79('0x6f'),_0x2c79('0x61'),_0x2c79('0x57'),_0x2c79('0x58')],squel['select']()[_0x2c79('0x70')](_0x2c79('0x6d'),_0x2c79('0x6d'))['field'](_0x2c79('0x71'),_0x2c79('0x6e'))[_0x2c79('0x70')]('id',_0x2c79('0x72'))[_0x2c79('0x70')](_0x1f5693[_0x2c79('0x73')][_0x2c79('0x74')](),_0x2c79('0x6f'))[_0x2c79('0x70')](_0x515e97[_0x2c79('0x54')]['id'][_0x2c79('0x74')](),'CampaignId')[_0x2c79('0x70')]('NOW()','createdAt')[_0x2c79('0x70')](_0x2c79('0x71'),_0x2c79('0x58'))[_0x2c79('0x75')](_0x2c79('0x76'))['where'](_0x2c79('0x77'))[_0x2c79('0x3f')](_0x2c79('0x78'),_0x1f5693[_0x2c79('0x73')][_0x2c79('0x74')]())['where'](_0x2c79('0x79'))[_0x2c79('0x3f')]('phone\x20NOT\x20IN\x20(?)',squel[_0x2c79('0x7a')]()[_0x2c79('0x70')]('COALESCE(calleridnum,\x27\x27)')[_0x2c79('0x75')](_0x2c79('0x7b'))[_0x2c79('0x3f')](_0x2c79('0x7c'),_0x515e97[_0x2c79('0x54')]['id']['toString']()))[_0x2c79('0x3f')](_0x2c79('0x7d'),squel[_0x2c79('0x7a')]()[_0x2c79('0x70')](_0x2c79('0x7e'))['from'](_0x2c79('0x6b'))[_0x2c79('0x3f')](_0x2c79('0x7c'),_0x515e97[_0x2c79('0x54')]['id'][_0x2c79('0x74')]())))[_0x2c79('0x74')]();break;case'onlyIfOpen':_0x37dd7c=squel[_0x2c79('0x7f')]()[_0x2c79('0x6a')]('cm_hopper')[_0x2c79('0x6c')](['phone',_0x2c79('0x6e'),_0x2c79('0x72'),_0x2c79('0x6f'),'CampaignId',_0x2c79('0x57'),_0x2c79('0x58')],squel[_0x2c79('0x7a')]()[_0x2c79('0x70')](_0x2c79('0x6d'),_0x2c79('0x6d'))[_0x2c79('0x70')](_0x2c79('0x71'),_0x2c79('0x6e'))['field']('id',_0x2c79('0x72'))[_0x2c79('0x70')](_0x1f5693[_0x2c79('0x73')][_0x2c79('0x74')](),_0x2c79('0x6f'))[_0x2c79('0x70')](_0x515e97[_0x2c79('0x54')]['id'][_0x2c79('0x74')](),_0x2c79('0x61'))[_0x2c79('0x70')]('NOW()','createdAt')['field']('NOW()',_0x2c79('0x58'))[_0x2c79('0x75')](_0x2c79('0x76'))['where']('deletedAt\x20IS\x20NULL')['where']('ListId\x20=\x20?',_0x1f5693['CmListId'][_0x2c79('0x74')]())['where']('phone\x20IS\x20NOT\x20NULL')[_0x2c79('0x3f')]('phone\x20NOT\x20IN\x20(?)',squel['select']()[_0x2c79('0x70')](_0x2c79('0x7e'))[_0x2c79('0x75')]('cm_hopper')['where'](_0x2c79('0x7c'),_0x515e97[_0x2c79('0x54')]['id'][_0x2c79('0x74')]())))['toString']();break;default:_0x37dd7c=squel[_0x2c79('0x7f')]()[_0x2c79('0x6a')]('cm_hopper')['fromQuery'](['phone',_0x2c79('0x6e'),_0x2c79('0x72'),'ListId','CampaignId',_0x2c79('0x57'),'updatedAt'],squel[_0x2c79('0x7a')]()[_0x2c79('0x70')](_0x2c79('0x6d'),_0x2c79('0x6d'))['field']('NOW()',_0x2c79('0x6e'))[_0x2c79('0x70')]('id','ContactId')[_0x2c79('0x70')](_0x1f5693['CmListId']['toString'](),'ListId')['field'](_0x515e97[_0x2c79('0x54')]['id'][_0x2c79('0x74')](),_0x2c79('0x61'))[_0x2c79('0x70')](_0x2c79('0x71'),'createdAt')['field'](_0x2c79('0x71'),_0x2c79('0x58'))[_0x2c79('0x75')]('cm_contacts')[_0x2c79('0x3f')](_0x2c79('0x77'))['where'](_0x2c79('0x78'),_0x1f5693[_0x2c79('0x73')][_0x2c79('0x74')]())[_0x2c79('0x3f')](_0x2c79('0x79')))[_0x2c79('0x74')]();}_0x1f13d6['push'](db['sequelize'][_0x2c79('0x35')](_0x37dd7c));}return BPromise[_0x2c79('0x80')](_0x1f13d6);}})['then'](function(){return _0x56f3e8;})[_0x2c79('0x26')](respondWithResult(_0x570f15,null))['catch'](handleError(_0x570f15,null));};exports[_0x2c79('0x81')]=function(_0x3f7a50,_0x340049,_0x3980ed){return db['Campaign']['find']({'where':{'id':_0x3f7a50[_0x2c79('0x54')]['id']}})[_0x2c79('0x26')](handleEntityNotFound(_0x340049,null))[_0x2c79('0x26')](function(_0x5757dd){if(_0x5757dd){return _0x5757dd[_0x2c79('0x81')](_0x3f7a50[_0x2c79('0x35')][_0x2c79('0x82')]);}})[_0x2c79('0x26')](function(_0x2c4f8d){if(_0x2c4f8d){return db['CmHopper'][_0x2c79('0x27')]({'where':{'ListId':_0x3f7a50[_0x2c79('0x35')][_0x2c79('0x82')],'CampaignId':_0x3f7a50[_0x2c79('0x54')]['id']}})['then'](function(){return _0x2c4f8d;});}})['then'](respondWithStatusCode(_0x340049,null))[_0x2c79('0x47')](handleError(_0x340049,null));};exports[_0x2c79('0x83')]=function(_0x361716,_0x38ad40,_0x5c6a03){var _0x57039a={};var _0x37412b={};var _0x3fbb2b;var _0x452b76;return db[_0x2c79('0x2f')]['findOne']({'where':{'id':_0x361716['params']['id']}})['then'](handleEntityNotFound(_0x38ad40,null))[_0x2c79('0x26')](function(_0x202242){if(_0x202242){_0x3fbb2b=_0x202242;_0x37412b['model']=_[_0x2c79('0x49')](db['CmList'][_0x2c79('0x4a')]);_0x37412b['query']=_[_0x2c79('0x49')](_0x361716[_0x2c79('0x35')]);_0x37412b['filters']=_[_0x2c79('0x37')](_0x37412b[_0x2c79('0x33')],_0x37412b['query']);_0x57039a['attributes']=_[_0x2c79('0x37')](_0x37412b[_0x2c79('0x33')],qs[_0x2c79('0x39')](_0x361716[_0x2c79('0x35')]['fields']));_0x57039a[_0x2c79('0x38')]=_0x57039a[_0x2c79('0x38')]['length']?_0x57039a[_0x2c79('0x38')]:_0x37412b[_0x2c79('0x33')];_0x57039a[_0x2c79('0x3d')]=qs[_0x2c79('0x3e')](_0x361716['query'][_0x2c79('0x3e')]);_0x57039a['where']=qs[_0x2c79('0x36')](_['pick'](_0x361716[_0x2c79('0x35')],_0x37412b[_0x2c79('0x36')]));if(_0x361716[_0x2c79('0x35')][_0x2c79('0x41')]){_0x57039a[_0x2c79('0x3f')]=_['merge'](_0x57039a['where'],{'$or':_['map'](_0x57039a[_0x2c79('0x38')],function(_0x3a175b){var _0x4f3f7f={};_0x4f3f7f[_0x3a175b]={'$like':'%'+_0x361716[_0x2c79('0x35')][_0x2c79('0x41')]+'%'};return _0x4f3f7f;})});}_0x57039a=_['merge']({},_0x57039a,_0x361716[_0x2c79('0x4c')]);return _0x3fbb2b[_0x2c79('0x83')](_0x57039a);}})[_0x2c79('0x26')](function(_0x3d9a83){if(_0x3d9a83){_0x452b76=_0x3d9a83[_0x2c79('0x3a')];if(!_0x361716[_0x2c79('0x35')]['hasOwnProperty']('nolimit')){_0x57039a[_0x2c79('0x1f')]=qs[_0x2c79('0x1f')](_0x361716[_0x2c79('0x35')][_0x2c79('0x1f')]);_0x57039a['offset']=qs[_0x2c79('0x1d')](_0x361716[_0x2c79('0x35')][_0x2c79('0x1d')]);}return _0x3fbb2b['getBlackLists'](_0x57039a);}})[_0x2c79('0x26')](function(_0x1aa216){if(_0x1aa216){return _0x1aa216?{'count':_0x452b76,'rows':_0x1aa216}:null;}})[_0x2c79('0x26')](respondWithResult(_0x38ad40,null))[_0x2c79('0x47')](handleError(_0x38ad40,null));};exports[_0x2c79('0x84')]=function(_0x648de,_0x16313c,_0x31f4d8){var _0x5cd72c,_0x26e3c6;return db[_0x2c79('0x2f')][_0x2c79('0x55')]({'where':{'id':_0x648de['params']['id']}})[_0x2c79('0x26')](handleEntityNotFound(_0x16313c,null))[_0x2c79('0x26')](function(_0x5ee756){if(_0x5ee756){_0x26e3c6=_0x5ee756;return _0x5ee756['addBlackLists'](_0x648de[_0x2c79('0x4e')][_0x2c79('0x82')],_[_0x2c79('0x56')](_0x648de[_0x2c79('0x4e')],[_0x2c79('0x82'),'id'])||{});}return null;})[_0x2c79('0x85')](function(_0x780bbc){var _0x4c33bb;_0x5cd72c=_0x780bbc||[];var _0x651dc=[];if(_0x780bbc){for(var _0x5eb121=0x0;_0x5eb121<_0x780bbc[_0x2c79('0x3a')];_0x5eb121+=0x1){var _0x586b23=_0x780bbc[_0x5eb121]['get']({'plain':!![]});_0x4c33bb=squel['insert']()[_0x2c79('0x6a')](_0x2c79('0x86'))[_0x2c79('0x6c')]([_0x2c79('0x6d'),_0x2c79('0x72'),'ListId',_0x2c79('0x61'),'createdAt',_0x2c79('0x58')],squel[_0x2c79('0x7a')]()['field'](_0x2c79('0x6d'),'phone')[_0x2c79('0x70')]('id',_0x2c79('0x72'))['field'](_0x586b23[_0x2c79('0x73')][_0x2c79('0x74')](),_0x2c79('0x6f'))[_0x2c79('0x70')](_0x648de[_0x2c79('0x54')]['id'][_0x2c79('0x74')](),_0x2c79('0x61'))[_0x2c79('0x70')](_0x2c79('0x71'),_0x2c79('0x57'))[_0x2c79('0x70')]('NOW()',_0x2c79('0x58'))['from']('cm_contacts')[_0x2c79('0x3f')](_0x2c79('0x77'))['where'](_0x2c79('0x78'),_0x586b23['CmListId'][_0x2c79('0x74')]())['where'](_0x2c79('0x79')))[_0x2c79('0x74')]();_0x651dc['push'](db[_0x2c79('0x87')][_0x2c79('0x35')](_0x4c33bb));}return BPromise['all'](_0x651dc);}})[_0x2c79('0x26')](function(){return _0x5cd72c;})[_0x2c79('0x26')](respondWithResult(_0x16313c,null))['catch'](handleError(_0x16313c,null));};exports[_0x2c79('0x88')]=function(_0x527991,_0x18cbe6,_0x51b133){return db[_0x2c79('0x2f')][_0x2c79('0x55')]({'where':{'id':_0x527991['params']['id']}})[_0x2c79('0x26')](handleEntityNotFound(_0x18cbe6,null))[_0x2c79('0x26')](function(_0x500408){if(_0x500408){return _0x500408[_0x2c79('0x88')](_0x527991[_0x2c79('0x35')]['ids']);}})[_0x2c79('0x26')](function(_0xa6b1bc){if(_0xa6b1bc){return db[_0x2c79('0x65')]['destroy']({'where':{'ListId':_0x527991[_0x2c79('0x35')]['ids'],'CampaignId':_0x527991[_0x2c79('0x54')]['id']}})[_0x2c79('0x26')](function(){return _0xa6b1bc;});}})[_0x2c79('0x26')](respondWithStatusCode(_0x18cbe6,null))['catch'](handleError(_0x18cbe6,null));};