Built motion from commit f74363e9.|2.6.34
[motion2.git] / server / api / cmHopperFinal / cmHopperFinal.controller.js
index ff52f6f..522dc27 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc2c7=['`state`\x20=\x205,\x201,\x20null','congestionContacts','`state`\x20=\x2011\x20,\x201,\x20null','`state`\x20=\x2019,\x201,\x20null','answeringMachine','moveContactsQueueCampaignHopperFinal','VoiceQueue','insert','into','cm_hopper','fromQuery','phone','scheduledAt','ContactId','VoiceQueueId','createdAt','select','field','NOW()','ANY_VALUE(ContactId)','ANY_VALUE(ListId)','ListId','ANY_VALUE(VoiceQueueId)','updatedAt','from','cm_hopper_final','VoiceQueueId\x20=\x20?','state\x20=\x20?','state','toString','calleridnum\x20IS\x20NOT\x20NULL','calleridnum\x20NOT\x20IN\x20(?)','group','moveContactsIvrCampaignHopperFinal','Campaign','ANY_VALUE(calleridnum)','CampaignId','CampaignId\x20=\x20?','calleridnum','state\x20=\x204','checkContactHopper','CmHopper','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','to-csv','ejs','fs-extra','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','count','set','Content-Range','reject','save','update','destroy','then','error','name','send','index','map','CmHopperFinal','rawAttributes','fieldName','type','key','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','keys','find','uniqueid','params','body','countContactsQueueCampaignHopperFinal','sequelize','`state`\x20=\x200,\x201,\x20null','noSuchContacts','COUNT','literal','`state`\x20=\x203,\x201,\x20null','noAnswerContacts','busyContacts','`state`\x20=\x208,\x201,\x20null','`state`\x20=\x2010\x20,\x201,\x20null','dropContacts','abandonedContacts','`state`\x20=\x2022,\x201,\x20null','reCallContacts','countContactsIvrCampaignHopperFinal'];(function(_0x89a3fc,_0x48349e){var _0x2dfe51=function(_0x50f58c){while(--_0x50f58c){_0x89a3fc['push'](_0x89a3fc['shift']());}};_0x2dfe51(++_0x48349e);}(_0xc2c7,0x134));var _0x7c2c=function(_0x340f7a,_0x519dff){_0x340f7a=_0x340f7a-0x0;var _0xbe84be=_0xc2c7[_0x340f7a];return _0xbe84be;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x7c2c('0x0'));var zipdir=require(_0x7c2c('0x1'));var jsonpatch=require(_0x7c2c('0x2'));var rp=require(_0x7c2c('0x3'));var moment=require(_0x7c2c('0x4'));var BPromise=require(_0x7c2c('0x5'));var Mustache=require(_0x7c2c('0x6'));var util=require(_0x7c2c('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0x7c2c('0x8'));var ejs=require(_0x7c2c('0x9'));var fs=require('fs');var fs_extra=require(_0x7c2c('0xa'));var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x7c2c('0xb'));var deskjs=require(_0x7c2c('0xc'));var toCsv=require(_0x7c2c('0x8'));var querystring=require(_0x7c2c('0xd'));var Papa=require(_0x7c2c('0xe'));var Redis=require('ioredis');var authService=require(_0x7c2c('0xf'));var qs=require(_0x7c2c('0x10'));var as=require(_0x7c2c('0x11'));var hardwareService=require(_0x7c2c('0x12'));var logger=require(_0x7c2c('0x13'))(_0x7c2c('0x14'));var utils=require(_0x7c2c('0x15'));var config=require(_0x7c2c('0x16'));var licenseUtil=require(_0x7c2c('0x17'));var db=require(_0x7c2c('0x18'))['db'];function respondWithStatusCode(_0xae8441,_0x45847d){_0x45847d=_0x45847d||0xcc;return function(_0x68398a){if(_0x68398a){return _0xae8441[_0x7c2c('0x19')](_0x45847d);}return _0xae8441[_0x7c2c('0x1a')](_0x45847d)[_0x7c2c('0x1b')]();};}function respondWithResult(_0x4c4aaf,_0x5b5729){_0x5b5729=_0x5b5729||0xc8;return function(_0x102778){if(_0x102778){return _0x4c4aaf[_0x7c2c('0x1a')](_0x5b5729)[_0x7c2c('0x1c')](_0x102778);}};}function respondWithFilteredResult(_0x5ae94f,_0x11424c){return function(_0x206ecd){if(_0x206ecd){var _0x5e55e0=typeof _0x11424c[_0x7c2c('0x1d')]==='undefined'&&typeof _0x11424c[_0x7c2c('0x1e')]==='undefined';var _0x342ea2=_0x206ecd[_0x7c2c('0x1f')];var _0x14453f=_0x5e55e0?0x0:_0x11424c[_0x7c2c('0x1d')];var _0x17df4a=_0x5e55e0?_0x206ecd[_0x7c2c('0x1f')]:_0x11424c[_0x7c2c('0x1d')]+_0x11424c[_0x7c2c('0x1e')];var _0x2d356e;if(_0x17df4a>=_0x342ea2){_0x17df4a=_0x342ea2;_0x2d356e=0xc8;}else{_0x2d356e=0xce;}_0x5ae94f[_0x7c2c('0x1a')](_0x2d356e);return _0x5ae94f[_0x7c2c('0x20')](_0x7c2c('0x21'),_0x14453f+'-'+_0x17df4a+'/'+_0x342ea2)['json'](_0x206ecd);}return null;};}function patchUpdates(_0x1c5491){return function(_0x4adb62){try{jsonpatch['apply'](_0x4adb62,_0x1c5491,!![]);}catch(_0x15ae33){return BPromise[_0x7c2c('0x22')](_0x15ae33);}return _0x4adb62[_0x7c2c('0x23')]();};}function saveUpdates(_0x38ae30,_0x41552f){return function(_0x1883b5){if(_0x1883b5){return _0x1883b5[_0x7c2c('0x24')](_0x38ae30)['then'](function(_0x10c356){return _0x10c356;});}return null;};}function removeEntity(_0x4dedd8,_0x302c93){return function(_0x57f510){if(_0x57f510){return _0x57f510[_0x7c2c('0x25')]()[_0x7c2c('0x26')](function(){_0x4dedd8[_0x7c2c('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4d6ec7,_0x31a50c){return function(_0x30c53e){if(!_0x30c53e){_0x4d6ec7[_0x7c2c('0x19')](0x194);}return _0x30c53e;};}function handleError(_0x150690,_0x31d8f3){_0x31d8f3=_0x31d8f3||0x1f4;return function(_0xa8e145){logger[_0x7c2c('0x27')](_0xa8e145['stack']);if(_0xa8e145[_0x7c2c('0x28')]){delete _0xa8e145[_0x7c2c('0x28')];}_0x150690[_0x7c2c('0x1a')](_0x31d8f3)[_0x7c2c('0x29')](_0xa8e145);};}exports[_0x7c2c('0x2a')]=function(_0x1f8846,_0xf2bfd1){var _0x26f472={},_0xa040ff={},_0x5769ec={'count':0x0,'rows':[]};var _0x465ad6=_[_0x7c2c('0x2b')](db[_0x7c2c('0x2c')][_0x7c2c('0x2d')],function(_0x53ad23){return{'name':_0x53ad23[_0x7c2c('0x2e')],'type':_0x53ad23[_0x7c2c('0x2f')][_0x7c2c('0x30')]};});_0xa040ff[_0x7c2c('0x31')]=_[_0x7c2c('0x2b')](_0x465ad6,_0x7c2c('0x28'));_0xa040ff[_0x7c2c('0x32')]=_['keys'](_0x1f8846[_0x7c2c('0x32')]);_0xa040ff[_0x7c2c('0x33')]=_[_0x7c2c('0x34')](_0xa040ff[_0x7c2c('0x31')],_0xa040ff[_0x7c2c('0x32')]);_0x26f472['attributes']=_['intersection'](_0xa040ff[_0x7c2c('0x31')],qs['fields'](_0x1f8846['query'][_0x7c2c('0x35')]));_0x26f472[_0x7c2c('0x36')]=_0x26f472[_0x7c2c('0x36')][_0x7c2c('0x37')]?_0x26f472['attributes']:_0xa040ff[_0x7c2c('0x31')];if(!_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x38')](_0x7c2c('0x39'))){_0x26f472[_0x7c2c('0x1e')]=qs[_0x7c2c('0x1e')](_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x1e')]);_0x26f472[_0x7c2c('0x1d')]=qs[_0x7c2c('0x1d')](_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x1d')]);}_0x26f472[_0x7c2c('0x3a')]=qs['sort'](_0x1f8846['query'][_0x7c2c('0x3b')]);_0x26f472['where']=qs['filters'](_['pick'](_0x1f8846[_0x7c2c('0x32')],_0xa040ff[_0x7c2c('0x33')]),_0x465ad6);if(_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x3c')]){_0x26f472[_0x7c2c('0x3d')]=_[_0x7c2c('0x3e')](_0x26f472[_0x7c2c('0x3d')],{'$or':_[_0x7c2c('0x2b')](_0x465ad6,function(_0x2b6520){if(_0x2b6520[_0x7c2c('0x2f')]!==_0x7c2c('0x3f')){var _0x58696a={};_0x58696a[_0x2b6520['name']]={'$like':'%'+_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x3c')]+'%'};return _0x58696a;}})});}_0x26f472=_[_0x7c2c('0x3e')]({},_0x26f472,_0x1f8846[_0x7c2c('0x40')]);var _0x5e8c96={'where':_0x26f472[_0x7c2c('0x3d')]};return db[_0x7c2c('0x2c')][_0x7c2c('0x1f')](_0x5e8c96)[_0x7c2c('0x26')](function(_0x18e288){_0x5769ec[_0x7c2c('0x1f')]=_0x18e288;if(_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x41')]){_0x26f472[_0x7c2c('0x42')]=[{'all':!![]}];}return db['CmHopperFinal'][_0x7c2c('0x43')](_0x26f472);})['then'](function(_0x2c3f40){_0x5769ec[_0x7c2c('0x44')]=_0x2c3f40;return _0x5769ec;})['then'](respondWithFilteredResult(_0xf2bfd1,_0x26f472))[_0x7c2c('0x45')](handleError(_0xf2bfd1,null));};exports['show']=function(_0x3014fb,_0x33b2be){var _0x9b9813={'raw':!![],'where':{'id':_0x3014fb['params']['id']}},_0x26351e={};_0x26351e[_0x7c2c('0x31')]=_['keys'](db['CmHopperFinal'][_0x7c2c('0x2d')]);_0x26351e[_0x7c2c('0x32')]=_[_0x7c2c('0x46')](_0x3014fb['query']);_0x26351e[_0x7c2c('0x33')]=_[_0x7c2c('0x34')](_0x26351e['model'],_0x26351e[_0x7c2c('0x32')]);_0x9b9813['attributes']=_[_0x7c2c('0x34')](_0x26351e[_0x7c2c('0x31')],qs['fields'](_0x3014fb['query'][_0x7c2c('0x35')]));_0x9b9813[_0x7c2c('0x36')]=_0x9b9813['attributes'][_0x7c2c('0x37')]?_0x9b9813['attributes']:_0x26351e['model'];if(_0x3014fb[_0x7c2c('0x32')][_0x7c2c('0x41')]){_0x9b9813[_0x7c2c('0x42')]=[{'all':!![]}];}_0x9b9813=_[_0x7c2c('0x3e')]({},_0x9b9813,_0x3014fb[_0x7c2c('0x40')]);return db[_0x7c2c('0x2c')][_0x7c2c('0x47')](_0x9b9813)[_0x7c2c('0x26')](handleEntityNotFound(_0x33b2be,null))[_0x7c2c('0x26')](respondWithResult(_0x33b2be,null))['catch'](handleError(_0x33b2be,null));};exports['describe']=function(_0xeb067b,_0x3091bd){return db[_0x7c2c('0x2c')]['describe']()['then'](respondWithResult(_0x3091bd,null))[_0x7c2c('0x45')](handleError(_0x3091bd,null));};exports[_0x7c2c('0x24')]=function(_0x39d5af,_0x2b79d5){if(_0x39d5af['body']['uniqueid']){delete _0x39d5af['body'][_0x7c2c('0x48')];}return db[_0x7c2c('0x2c')][_0x7c2c('0x47')]({'where':{'uniqueid':_0x39d5af[_0x7c2c('0x49')]['id']}})[_0x7c2c('0x26')](handleEntityNotFound(_0x2b79d5,null))['then'](saveUpdates(_0x39d5af[_0x7c2c('0x4a')],null))[_0x7c2c('0x26')](respondWithResult(_0x2b79d5,null))['catch'](handleError(_0x2b79d5,null));};exports[_0x7c2c('0x4b')]=function(_0x56e09d,_0xfba6a7,_0x3806f4){return db[_0x7c2c('0x2c')]['findAll']({'raw':![],'where':{'VoiceQueueId':_0x56e09d['params']['id']},'attributes':[[db[_0x7c2c('0x4c')]['fn']('COUNT',db[_0x7c2c('0x4c')]['fn']('IF',db[_0x7c2c('0x4c')]['literal'](_0x7c2c('0x4d')))),_0x7c2c('0x4e')],[db['sequelize']['fn'](_0x7c2c('0x4f'),db[_0x7c2c('0x4c')]['fn']('IF',db['sequelize'][_0x7c2c('0x50')](_0x7c2c('0x51')))),_0x7c2c('0x52')],[db['sequelize']['fn'](_0x7c2c('0x4f'),db['sequelize']['fn']('IF',db[_0x7c2c('0x4c')][_0x7c2c('0x50')]('`state`\x20=\x205,\x201,\x20null'))),_0x7c2c('0x53')],[db[_0x7c2c('0x4c')]['fn'](_0x7c2c('0x4f'),db[_0x7c2c('0x4c')]['fn']('IF',db['sequelize'][_0x7c2c('0x50')](_0x7c2c('0x54')))),'congestionContacts'],[db[_0x7c2c('0x4c')]['fn']('COUNT',db[_0x7c2c('0x4c')]['fn']('IF',db[_0x7c2c('0x4c')][_0x7c2c('0x50')](_0x7c2c('0x55')))),_0x7c2c('0x56')],[db['sequelize']['fn'](_0x7c2c('0x4f'),db[_0x7c2c('0x4c')]['fn']('IF',db['sequelize']['literal']('`state`\x20=\x2011\x20,\x201,\x20null'))),_0x7c2c('0x57')],[db['sequelize']['fn'](_0x7c2c('0x4f'),db['sequelize']['fn']('IF',db[_0x7c2c('0x4c')][_0x7c2c('0x50')](_0x7c2c('0x58')))),_0x7c2c('0x59')],[db[_0x7c2c('0x4c')]['fn'](_0x7c2c('0x4f'),db[_0x7c2c('0x4c')]['fn']('IF',db[_0x7c2c('0x4c')]['literal']('`state`\x20=\x2019,\x201,\x20null'))),'answeringMachine']]})[_0x7c2c('0x26')](handleEntityNotFound(_0xfba6a7,null))[_0x7c2c('0x26')](respondWithResult(_0xfba6a7,null))[_0x7c2c('0x45')](handleError(_0xfba6a7,null));};exports[_0x7c2c('0x5a')]=function(_0x44602a,_0x1ad537,_0x2d04da){return db[_0x7c2c('0x2c')]['findAll']({'raw':![],'where':{'CampaignId':_0x44602a['params']['id']},'attributes':[[db[_0x7c2c('0x4c')]['fn'](_0x7c2c('0x4f'),db['sequelize']['fn']('IF',db[_0x7c2c('0x4c')]['literal']('`state`\x20=\x200,\x201,\x20null'))),_0x7c2c('0x4e')],[db[_0x7c2c('0x4c')]['fn'](_0x7c2c('0x4f'),db[_0x7c2c('0x4c')]['fn']('IF',db[_0x7c2c('0x4c')][_0x7c2c('0x50')](_0x7c2c('0x51')))),_0x7c2c('0x52')],[db[_0x7c2c('0x4c')]['fn'](_0x7c2c('0x4f'),db[_0x7c2c('0x4c')]['fn']('IF',db[_0x7c2c('0x4c')][_0x7c2c('0x50')](_0x7c2c('0x5b')))),'busyContacts'],[db[_0x7c2c('0x4c')]['fn']('COUNT',db['sequelize']['fn']('IF',db['sequelize']['literal'](_0x7c2c('0x54')))),_0x7c2c('0x5c')],[db[_0x7c2c('0x4c')]['fn'](_0x7c2c('0x4f'),db[_0x7c2c('0x4c')]['fn']('IF',db[_0x7c2c('0x4c')]['literal'](_0x7c2c('0x55')))),_0x7c2c('0x56')],[db[_0x7c2c('0x4c')]['fn'](_0x7c2c('0x4f'),db[_0x7c2c('0x4c')]['fn']('IF',db[_0x7c2c('0x4c')]['literal'](_0x7c2c('0x5d')))),_0x7c2c('0x57')],[db['sequelize']['fn'](_0x7c2c('0x4f'),db[_0x7c2c('0x4c')]['fn']('IF',db['sequelize'][_0x7c2c('0x50')](_0x7c2c('0x58')))),'reCallContacts'],[db['sequelize']['fn'](_0x7c2c('0x4f'),db['sequelize']['fn']('IF',db[_0x7c2c('0x4c')]['literal'](_0x7c2c('0x5e')))),_0x7c2c('0x5f')]]})['then'](handleEntityNotFound(_0x1ad537,null))[_0x7c2c('0x26')](respondWithResult(_0x1ad537,null))['catch'](handleError(_0x1ad537,null));};exports[_0x7c2c('0x60')]=function(_0x2b597d,_0x20eb63,_0x56f737){return db[_0x7c2c('0x61')][_0x7c2c('0x47')]({'where':{'id':_0x2b597d[_0x7c2c('0x49')]['id']}})[_0x7c2c('0x26')](handleEntityNotFound(_0x20eb63,null))['then'](function(_0x158352){var _0x1e711e;if(_0x158352){_0x1e711e=squel[_0x7c2c('0x62')]()[_0x7c2c('0x63')](_0x7c2c('0x64'))[_0x7c2c('0x65')]([_0x7c2c('0x66'),_0x7c2c('0x67'),_0x7c2c('0x68'),'ListId',_0x7c2c('0x69'),_0x7c2c('0x6a'),'updatedAt'],squel[_0x7c2c('0x6b')]()['field']('ANY_VALUE(calleridnum)',_0x7c2c('0x66'))[_0x7c2c('0x6c')](_0x7c2c('0x6d'),'scheduledAt')[_0x7c2c('0x6c')](_0x7c2c('0x6e'),_0x7c2c('0x68'))['field'](_0x7c2c('0x6f'),_0x7c2c('0x70'))[_0x7c2c('0x6c')](_0x7c2c('0x71'),'VoiceQueueId')[_0x7c2c('0x6c')]('NOW()',_0x7c2c('0x6a'))['field'](_0x7c2c('0x6d'),_0x7c2c('0x72'))[_0x7c2c('0x73')](_0x7c2c('0x74'))[_0x7c2c('0x3d')](_0x7c2c('0x75'),_0x2b597d[_0x7c2c('0x49')]['id']['toString']())[_0x7c2c('0x3d')](_0x7c2c('0x76'),_0x2b597d[_0x7c2c('0x4a')][_0x7c2c('0x77')][_0x7c2c('0x78')]())[_0x7c2c('0x3d')](_0x7c2c('0x79'))[_0x7c2c('0x3d')]('calleridnum\x20NOT\x20IN\x20(?)',squel[_0x7c2c('0x6b')]()[_0x7c2c('0x6c')](_0x7c2c('0x66'))[_0x7c2c('0x73')](_0x7c2c('0x64'))['where'](_0x7c2c('0x75'),_0x2b597d[_0x7c2c('0x49')]['id']['toString']()))[_0x7c2c('0x3d')](_0x7c2c('0x7a'),squel['select']()[_0x7c2c('0x6c')]('calleridnum')[_0x7c2c('0x73')](_0x7c2c('0x74'))[_0x7c2c('0x3d')](_0x7c2c('0x75'),_0x2b597d[_0x7c2c('0x49')]['id'][_0x7c2c('0x78')]())[_0x7c2c('0x3d')]('state\x20=\x204'))[_0x7c2c('0x7b')](_0x7c2c('0x68')))['toString']();return db[_0x7c2c('0x4c')][_0x7c2c('0x32')](_0x1e711e);}return[];})[_0x7c2c('0x26')](respondWithResult(_0x20eb63,null))[_0x7c2c('0x45')](handleError(_0x20eb63,null));};exports[_0x7c2c('0x7c')]=function(_0x2f249d,_0x136226,_0x354236){return db[_0x7c2c('0x7d')][_0x7c2c('0x47')]({'where':{'id':_0x2f249d[_0x7c2c('0x49')]['id']}})[_0x7c2c('0x26')](handleEntityNotFound(_0x136226,null))[_0x7c2c('0x26')](function(_0xb47bf0){var _0x4d0922;if(_0xb47bf0){_0x4d0922=squel[_0x7c2c('0x62')]()[_0x7c2c('0x63')]('cm_hopper')[_0x7c2c('0x65')]([_0x7c2c('0x66'),_0x7c2c('0x67'),_0x7c2c('0x68'),_0x7c2c('0x70'),'CampaignId',_0x7c2c('0x6a'),_0x7c2c('0x72')],squel[_0x7c2c('0x6b')]()['field'](_0x7c2c('0x7e'),_0x7c2c('0x66'))[_0x7c2c('0x6c')]('NOW()',_0x7c2c('0x67'))['field'](_0x7c2c('0x6e'),'ContactId')['field'](_0x7c2c('0x6f'),_0x7c2c('0x70'))[_0x7c2c('0x6c')]('ANY_VALUE(CampaignId)',_0x7c2c('0x7f'))[_0x7c2c('0x6c')](_0x7c2c('0x6d'),_0x7c2c('0x6a'))['field'](_0x7c2c('0x6d'),'updatedAt')['from']('cm_hopper_final')['where']('CampaignId\x20=\x20?',_0x2f249d[_0x7c2c('0x49')]['id'][_0x7c2c('0x78')]())[_0x7c2c('0x3d')](_0x7c2c('0x76'),_0x2f249d[_0x7c2c('0x4a')]['state'][_0x7c2c('0x78')]())[_0x7c2c('0x3d')](_0x7c2c('0x79'))[_0x7c2c('0x3d')](_0x7c2c('0x7a'),squel[_0x7c2c('0x6b')]()['field']('phone')[_0x7c2c('0x73')](_0x7c2c('0x64'))[_0x7c2c('0x3d')](_0x7c2c('0x80'),_0x2f249d['params']['id'][_0x7c2c('0x78')]()))[_0x7c2c('0x3d')](_0x7c2c('0x7a'),squel[_0x7c2c('0x6b')]()[_0x7c2c('0x6c')](_0x7c2c('0x81'))[_0x7c2c('0x73')](_0x7c2c('0x74'))[_0x7c2c('0x3d')]('CampaignId\x20=\x20?',_0x2f249d[_0x7c2c('0x49')]['id'][_0x7c2c('0x78')]())['where'](_0x7c2c('0x82')))['group'](_0x7c2c('0x68')))['toString']();return db[_0x7c2c('0x4c')][_0x7c2c('0x32')](_0x4d0922);}return[];})[_0x7c2c('0x26')](respondWithResult(_0x136226,null))[_0x7c2c('0x45')](handleError(_0x136226,null));};exports[_0x7c2c('0x83')]=function(_0x309051,_0x3f8683,_0x1eeb00){return db[_0x7c2c('0x84')]['findOne']({'where':{'VoiceQueueId':_0x309051[_0x7c2c('0x4a')][_0x7c2c('0x69')],'CampaignId':_0x309051[_0x7c2c('0x4a')]['CampaignId'],'ContactId':_0x309051[_0x7c2c('0x4a')][_0x7c2c('0x68')]}})['then'](handleEntityNotFound(_0x3f8683,null))[_0x7c2c('0x26')](function(_0x511158){if(_0x511158){return _0x511158;}return null;})[_0x7c2c('0x26')](respondWithResult(_0x3f8683,null))['catch'](handleError(_0x3f8683,null));};
\ No newline at end of file
+var _0x326f=['type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','where','pick','merge','VIRTUAL','options','CmHopperFinal','includeAll','include','rows','catch','show','params','find','describe','uniqueid','body','countContactsQueueCampaignHopperFinal','sequelize','COUNT','literal','`state`\x20=\x200,\x201,\x20null','`state`\x20=\x203,\x201,\x20null','noAnswerContacts','busyContacts','`state`\x20=\x208,\x201,\x20null','congestionContacts','`state`\x20=\x2010\x20,\x201,\x20null','abandonedContacts','`state`\x20=\x2022,\x201,\x20null','`state`\x20=\x2019,\x201,\x20null','answeringMachine','countContactsIvrCampaignHopperFinal','noSuchContacts','dropContacts','`state`\x20=\x2011\x20,\x201,\x20null','reCallContacts','moveContactsQueueCampaignHopperFinal','insert','into','cm_hopper','scheduledAt','ContactId','createdAt','select','field','NOW()','ANY_VALUE(ContactId)','ANY_VALUE(ListId)','ListId','ANY_VALUE(VoiceQueueId)','VoiceQueueId','updatedAt','from','VoiceQueueId\x20=\x20?','state\x20=\x20?','state','calleridnum\x20NOT\x20IN\x20(?)','toString','calleridnum','state\x20=\x204','group','moveContactsIvrCampaignHopperFinal','fromQuery','phone','CampaignId','ANY_VALUE(CampaignId)','cm_hopper_final','calleridnum\x20IS\x20NOT\x20NULL','CampaignId\x20=\x20?','checkContactHopper','CmHopper','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/license/util','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','reject','save','update','destroy','then','stack','name','send','map','rawAttributes','fieldName'];(function(_0x4a9fb1,_0x273043){var _0x348672=function(_0x142b69){while(--_0x142b69){_0x4a9fb1['push'](_0x4a9fb1['shift']());}};_0x348672(++_0x273043);}(_0x326f,0xd1));var _0xf326=function(_0x3780f7,_0x3191fc){_0x3780f7=_0x3780f7-0x0;var _0xe5d186=_0x326f[_0x3780f7];return _0xe5d186;};'use strict';var emlformat=require(_0xf326('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xf326('0x1'));var rp=require(_0xf326('0x2'));var moment=require(_0xf326('0x3'));var BPromise=require(_0xf326('0x4'));var Mustache=require(_0xf326('0x5'));var util=require(_0xf326('0x6'));var path=require(_0xf326('0x7'));var sox=require(_0xf326('0x8'));var csv=require(_0xf326('0x9'));var ejs=require(_0xf326('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xf326('0xb'));var squel=require(_0xf326('0xc'));var crypto=require(_0xf326('0xd'));var jsforce=require(_0xf326('0xe'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xf326('0xf'));var Redis=require(_0xf326('0x10'));var authService=require(_0xf326('0x11'));var qs=require(_0xf326('0x12'));var as=require(_0xf326('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf326('0x14'))('api');var utils=require(_0xf326('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xf326('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3162f9,_0x9ed463){_0x9ed463=_0x9ed463||0xcc;return function(_0x4b3966){if(_0x4b3966){return _0x3162f9[_0xf326('0x17')](_0x9ed463);}return _0x3162f9[_0xf326('0x18')](_0x9ed463)[_0xf326('0x19')]();};}function respondWithResult(_0x17a098,_0x5c8483){_0x5c8483=_0x5c8483||0xc8;return function(_0x45c1b6){if(_0x45c1b6){return _0x17a098['status'](_0x5c8483)['json'](_0x45c1b6);}};}function respondWithFilteredResult(_0xdf21d9,_0x11f6d2){return function(_0x1f2e5a){if(_0x1f2e5a){var _0xa63d1a=typeof _0x11f6d2[_0xf326('0x1a')]===_0xf326('0x1b')&&typeof _0x11f6d2[_0xf326('0x1c')]===_0xf326('0x1b');var _0x5a682a=_0x1f2e5a[_0xf326('0x1d')];var _0x453100=_0xa63d1a?0x0:_0x11f6d2[_0xf326('0x1a')];var _0x31ffb9=_0xa63d1a?_0x1f2e5a[_0xf326('0x1d')]:_0x11f6d2[_0xf326('0x1a')]+_0x11f6d2['limit'];var _0x4a5b6c;if(_0x31ffb9>=_0x5a682a){_0x31ffb9=_0x5a682a;_0x4a5b6c=0xc8;}else{_0x4a5b6c=0xce;}_0xdf21d9['status'](_0x4a5b6c);return _0xdf21d9[_0xf326('0x1e')](_0xf326('0x1f'),_0x453100+'-'+_0x31ffb9+'/'+_0x5a682a)['json'](_0x1f2e5a);}return null;};}function patchUpdates(_0x4cabce){return function(_0x128c68){try{jsonpatch['apply'](_0x128c68,_0x4cabce,!![]);}catch(_0x5b6d3c){return BPromise[_0xf326('0x20')](_0x5b6d3c);}return _0x128c68[_0xf326('0x21')]();};}function saveUpdates(_0x549b46,_0x5aa184){return function(_0x19b8ba){if(_0x19b8ba){return _0x19b8ba[_0xf326('0x22')](_0x549b46)['then'](function(_0x337ed5){return _0x337ed5;});}return null;};}function removeEntity(_0x1b9039,_0x43c53e){return function(_0x295752){if(_0x295752){return _0x295752[_0xf326('0x23')]()[_0xf326('0x24')](function(){_0x1b9039['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x4f31f6,_0x520d85){return function(_0x1a2c4e){if(!_0x1a2c4e){_0x4f31f6[_0xf326('0x17')](0x194);}return _0x1a2c4e;};}function handleError(_0x1ff2b5,_0x148953){_0x148953=_0x148953||0x1f4;return function(_0x410237){logger['error'](_0x410237[_0xf326('0x25')]);if(_0x410237[_0xf326('0x26')]){delete _0x410237[_0xf326('0x26')];}_0x1ff2b5['status'](_0x148953)[_0xf326('0x27')](_0x410237);};}exports['index']=function(_0x4a9abf,_0x6a8e89){var _0x1ae23a={},_0x2fa28e={},_0x5dbe63={'count':0x0,'rows':[]};var _0xc115d9=_[_0xf326('0x28')](db['CmHopperFinal'][_0xf326('0x29')],function(_0x119ab8){return{'name':_0x119ab8[_0xf326('0x2a')],'type':_0x119ab8[_0xf326('0x2b')][_0xf326('0x2c')]};});_0x2fa28e[_0xf326('0x2d')]=_[_0xf326('0x28')](_0xc115d9,_0xf326('0x26'));_0x2fa28e[_0xf326('0x2e')]=_[_0xf326('0x2f')](_0x4a9abf['query']);_0x2fa28e[_0xf326('0x30')]=_[_0xf326('0x31')](_0x2fa28e[_0xf326('0x2d')],_0x2fa28e['query']);_0x1ae23a[_0xf326('0x32')]=_[_0xf326('0x31')](_0x2fa28e[_0xf326('0x2d')],qs['fields'](_0x4a9abf['query'][_0xf326('0x33')]));_0x1ae23a[_0xf326('0x32')]=_0x1ae23a[_0xf326('0x32')][_0xf326('0x34')]?_0x1ae23a[_0xf326('0x32')]:_0x2fa28e[_0xf326('0x2d')];if(!_0x4a9abf[_0xf326('0x2e')][_0xf326('0x35')]('nolimit')){_0x1ae23a[_0xf326('0x1c')]=qs[_0xf326('0x1c')](_0x4a9abf['query'][_0xf326('0x1c')]);_0x1ae23a['offset']=qs[_0xf326('0x1a')](_0x4a9abf['query']['offset']);}_0x1ae23a[_0xf326('0x36')]=qs['sort'](_0x4a9abf[_0xf326('0x2e')]['sort']);_0x1ae23a[_0xf326('0x37')]=qs[_0xf326('0x30')](_[_0xf326('0x38')](_0x4a9abf['query'],_0x2fa28e[_0xf326('0x30')]),_0xc115d9);if(_0x4a9abf[_0xf326('0x2e')]['filter']){_0x1ae23a[_0xf326('0x37')]=_[_0xf326('0x39')](_0x1ae23a[_0xf326('0x37')],{'$or':_[_0xf326('0x28')](_0xc115d9,function(_0x51076c){if(_0x51076c[_0xf326('0x2b')]!==_0xf326('0x3a')){var _0x1e69b1={};_0x1e69b1[_0x51076c[_0xf326('0x26')]]={'$like':'%'+_0x4a9abf[_0xf326('0x2e')]['filter']+'%'};return _0x1e69b1;}})});}_0x1ae23a=_[_0xf326('0x39')]({},_0x1ae23a,_0x4a9abf[_0xf326('0x3b')]);var _0x5cfb97={'where':_0x1ae23a['where']};return db[_0xf326('0x3c')]['count'](_0x5cfb97)['then'](function(_0x22d462){_0x5dbe63['count']=_0x22d462;if(_0x4a9abf[_0xf326('0x2e')][_0xf326('0x3d')]){_0x1ae23a[_0xf326('0x3e')]=[{'all':!![]}];}return db[_0xf326('0x3c')]['findAll'](_0x1ae23a);})[_0xf326('0x24')](function(_0x45d344){_0x5dbe63[_0xf326('0x3f')]=_0x45d344;return _0x5dbe63;})[_0xf326('0x24')](respondWithFilteredResult(_0x6a8e89,_0x1ae23a))[_0xf326('0x40')](handleError(_0x6a8e89,null));};exports[_0xf326('0x41')]=function(_0x2ad841,_0x224a32){var _0x31283b={'raw':!![],'where':{'id':_0x2ad841[_0xf326('0x42')]['id']}},_0x1227d3={};_0x1227d3[_0xf326('0x2d')]=_['keys'](db[_0xf326('0x3c')][_0xf326('0x29')]);_0x1227d3[_0xf326('0x2e')]=_[_0xf326('0x2f')](_0x2ad841[_0xf326('0x2e')]);_0x1227d3[_0xf326('0x30')]=_['intersection'](_0x1227d3[_0xf326('0x2d')],_0x1227d3[_0xf326('0x2e')]);_0x31283b['attributes']=_[_0xf326('0x31')](_0x1227d3[_0xf326('0x2d')],qs[_0xf326('0x33')](_0x2ad841[_0xf326('0x2e')][_0xf326('0x33')]));_0x31283b['attributes']=_0x31283b['attributes'][_0xf326('0x34')]?_0x31283b[_0xf326('0x32')]:_0x1227d3['model'];if(_0x2ad841['query'][_0xf326('0x3d')]){_0x31283b[_0xf326('0x3e')]=[{'all':!![]}];}_0x31283b=_[_0xf326('0x39')]({},_0x31283b,_0x2ad841['options']);return db[_0xf326('0x3c')][_0xf326('0x43')](_0x31283b)[_0xf326('0x24')](handleEntityNotFound(_0x224a32,null))[_0xf326('0x24')](respondWithResult(_0x224a32,null))[_0xf326('0x40')](handleError(_0x224a32,null));};exports[_0xf326('0x44')]=function(_0x12792c,_0x3b90dc){return db[_0xf326('0x3c')][_0xf326('0x44')]()[_0xf326('0x24')](respondWithResult(_0x3b90dc,null))[_0xf326('0x40')](handleError(_0x3b90dc,null));};exports[_0xf326('0x22')]=function(_0x395b1e,_0xeac1a1){if(_0x395b1e['body'][_0xf326('0x45')]){delete _0x395b1e[_0xf326('0x46')][_0xf326('0x45')];}return db[_0xf326('0x3c')]['find']({'where':{'uniqueid':_0x395b1e[_0xf326('0x42')]['id']}})[_0xf326('0x24')](handleEntityNotFound(_0xeac1a1,null))[_0xf326('0x24')](saveUpdates(_0x395b1e[_0xf326('0x46')],null))['then'](respondWithResult(_0xeac1a1,null))[_0xf326('0x40')](handleError(_0xeac1a1,null));};exports[_0xf326('0x47')]=function(_0x145a77,_0x451ac7,_0x39ba25){return db['CmHopperFinal']['findAll']({'raw':![],'where':{'VoiceQueueId':_0x145a77[_0xf326('0x42')]['id']},'attributes':[[db[_0xf326('0x48')]['fn'](_0xf326('0x49'),db['sequelize']['fn']('IF',db[_0xf326('0x48')][_0xf326('0x4a')](_0xf326('0x4b')))),'noSuchContacts'],[db['sequelize']['fn'](_0xf326('0x49'),db['sequelize']['fn']('IF',db[_0xf326('0x48')]['literal'](_0xf326('0x4c')))),_0xf326('0x4d')],[db[_0xf326('0x48')]['fn'](_0xf326('0x49'),db[_0xf326('0x48')]['fn']('IF',db[_0xf326('0x48')][_0xf326('0x4a')]('`state`\x20=\x205,\x201,\x20null'))),_0xf326('0x4e')],[db[_0xf326('0x48')]['fn'](_0xf326('0x49'),db['sequelize']['fn']('IF',db[_0xf326('0x48')][_0xf326('0x4a')](_0xf326('0x4f')))),_0xf326('0x50')],[db[_0xf326('0x48')]['fn']('COUNT',db[_0xf326('0x48')]['fn']('IF',db[_0xf326('0x48')][_0xf326('0x4a')](_0xf326('0x51')))),'dropContacts'],[db[_0xf326('0x48')]['fn'](_0xf326('0x49'),db[_0xf326('0x48')]['fn']('IF',db[_0xf326('0x48')]['literal']('`state`\x20=\x2011\x20,\x201,\x20null'))),_0xf326('0x52')],[db[_0xf326('0x48')]['fn']('COUNT',db[_0xf326('0x48')]['fn']('IF',db[_0xf326('0x48')][_0xf326('0x4a')](_0xf326('0x53')))),'reCallContacts'],[db[_0xf326('0x48')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0xf326('0x48')]['literal'](_0xf326('0x54')))),_0xf326('0x55')]]})[_0xf326('0x24')](handleEntityNotFound(_0x451ac7,null))['then'](respondWithResult(_0x451ac7,null))['catch'](handleError(_0x451ac7,null));};exports[_0xf326('0x56')]=function(_0xa85a42,_0x33b259,_0x5d0177){return db[_0xf326('0x3c')]['findAll']({'raw':![],'where':{'CampaignId':_0xa85a42[_0xf326('0x42')]['id']},'attributes':[[db[_0xf326('0x48')]['fn'](_0xf326('0x49'),db[_0xf326('0x48')]['fn']('IF',db[_0xf326('0x48')][_0xf326('0x4a')](_0xf326('0x4b')))),_0xf326('0x57')],[db[_0xf326('0x48')]['fn'](_0xf326('0x49'),db[_0xf326('0x48')]['fn']('IF',db[_0xf326('0x48')][_0xf326('0x4a')]('`state`\x20=\x203,\x201,\x20null'))),_0xf326('0x4d')],[db['sequelize']['fn'](_0xf326('0x49'),db[_0xf326('0x48')]['fn']('IF',db['sequelize'][_0xf326('0x4a')]('`state`\x20=\x205,\x201,\x20null'))),_0xf326('0x4e')],[db[_0xf326('0x48')]['fn'](_0xf326('0x49'),db[_0xf326('0x48')]['fn']('IF',db[_0xf326('0x48')]['literal']('`state`\x20=\x208,\x201,\x20null'))),_0xf326('0x50')],[db[_0xf326('0x48')]['fn'](_0xf326('0x49'),db[_0xf326('0x48')]['fn']('IF',db[_0xf326('0x48')]['literal'](_0xf326('0x51')))),_0xf326('0x58')],[db['sequelize']['fn']('COUNT',db['sequelize']['fn']('IF',db[_0xf326('0x48')][_0xf326('0x4a')](_0xf326('0x59')))),_0xf326('0x52')],[db[_0xf326('0x48')]['fn'](_0xf326('0x49'),db[_0xf326('0x48')]['fn']('IF',db['sequelize'][_0xf326('0x4a')](_0xf326('0x53')))),_0xf326('0x5a')],[db[_0xf326('0x48')]['fn']('COUNT',db[_0xf326('0x48')]['fn']('IF',db['sequelize']['literal'](_0xf326('0x54')))),'answeringMachine']]})[_0xf326('0x24')](handleEntityNotFound(_0x33b259,null))[_0xf326('0x24')](respondWithResult(_0x33b259,null))[_0xf326('0x40')](handleError(_0x33b259,null));};exports[_0xf326('0x5b')]=function(_0x17cd36,_0x541491,_0x4a053c){return db['VoiceQueue'][_0xf326('0x43')]({'where':{'id':_0x17cd36[_0xf326('0x42')]['id']}})[_0xf326('0x24')](handleEntityNotFound(_0x541491,null))[_0xf326('0x24')](function(_0xec5857){var _0x5e874b;if(_0xec5857){_0x5e874b=squel[_0xf326('0x5c')]()[_0xf326('0x5d')](_0xf326('0x5e'))['fromQuery'](['phone',_0xf326('0x5f'),_0xf326('0x60'),'ListId','VoiceQueueId',_0xf326('0x61'),'updatedAt'],squel[_0xf326('0x62')]()['field']('ANY_VALUE(calleridnum)','phone')[_0xf326('0x63')](_0xf326('0x64'),_0xf326('0x5f'))['field'](_0xf326('0x65'),_0xf326('0x60'))[_0xf326('0x63')](_0xf326('0x66'),_0xf326('0x67'))[_0xf326('0x63')](_0xf326('0x68'),_0xf326('0x69'))[_0xf326('0x63')]('NOW()',_0xf326('0x61'))['field'](_0xf326('0x64'),_0xf326('0x6a'))[_0xf326('0x6b')]('cm_hopper_final')[_0xf326('0x37')](_0xf326('0x6c'),_0x17cd36[_0xf326('0x42')]['id']['toString']())[_0xf326('0x37')](_0xf326('0x6d'),_0x17cd36[_0xf326('0x46')][_0xf326('0x6e')]['toString']())[_0xf326('0x37')]('calleridnum\x20IS\x20NOT\x20NULL')['where'](_0xf326('0x6f'),squel[_0xf326('0x62')]()['field']('phone')['from'](_0xf326('0x5e'))['where'](_0xf326('0x6c'),_0x17cd36[_0xf326('0x42')]['id'][_0xf326('0x70')]()))[_0xf326('0x37')](_0xf326('0x6f'),squel[_0xf326('0x62')]()['field'](_0xf326('0x71'))[_0xf326('0x6b')]('cm_hopper_final')['where'](_0xf326('0x6c'),_0x17cd36['params']['id'][_0xf326('0x70')]())[_0xf326('0x37')](_0xf326('0x72')))[_0xf326('0x73')](_0xf326('0x60')))[_0xf326('0x70')]();return db[_0xf326('0x48')][_0xf326('0x2e')](_0x5e874b);}return[];})[_0xf326('0x24')](respondWithResult(_0x541491,null))['catch'](handleError(_0x541491,null));};exports[_0xf326('0x74')]=function(_0x26bbb1,_0x4ac90e,_0x3c82cf){return db['Campaign'][_0xf326('0x43')]({'where':{'id':_0x26bbb1[_0xf326('0x42')]['id']}})[_0xf326('0x24')](handleEntityNotFound(_0x4ac90e,null))['then'](function(_0x2b4414){var _0x1c86c8;if(_0x2b4414){_0x1c86c8=squel[_0xf326('0x5c')]()[_0xf326('0x5d')](_0xf326('0x5e'))[_0xf326('0x75')]([_0xf326('0x76'),_0xf326('0x5f'),_0xf326('0x60'),_0xf326('0x67'),_0xf326('0x77'),_0xf326('0x61'),_0xf326('0x6a')],squel[_0xf326('0x62')]()[_0xf326('0x63')]('ANY_VALUE(calleridnum)',_0xf326('0x76'))[_0xf326('0x63')]('NOW()',_0xf326('0x5f'))[_0xf326('0x63')]('ANY_VALUE(ContactId)',_0xf326('0x60'))[_0xf326('0x63')](_0xf326('0x66'),_0xf326('0x67'))[_0xf326('0x63')](_0xf326('0x78'),_0xf326('0x77'))['field'](_0xf326('0x64'),_0xf326('0x61'))[_0xf326('0x63')](_0xf326('0x64'),_0xf326('0x6a'))[_0xf326('0x6b')](_0xf326('0x79'))[_0xf326('0x37')]('CampaignId\x20=\x20?',_0x26bbb1[_0xf326('0x42')]['id'][_0xf326('0x70')]())['where'](_0xf326('0x6d'),_0x26bbb1['body'][_0xf326('0x6e')][_0xf326('0x70')]())[_0xf326('0x37')](_0xf326('0x7a'))[_0xf326('0x37')](_0xf326('0x6f'),squel[_0xf326('0x62')]()[_0xf326('0x63')](_0xf326('0x76'))[_0xf326('0x6b')](_0xf326('0x5e'))[_0xf326('0x37')](_0xf326('0x7b'),_0x26bbb1[_0xf326('0x42')]['id']['toString']()))[_0xf326('0x37')](_0xf326('0x6f'),squel[_0xf326('0x62')]()[_0xf326('0x63')](_0xf326('0x71'))['from'](_0xf326('0x79'))[_0xf326('0x37')](_0xf326('0x7b'),_0x26bbb1[_0xf326('0x42')]['id'][_0xf326('0x70')]())['where']('state\x20=\x204'))[_0xf326('0x73')]('ContactId'))[_0xf326('0x70')]();return db[_0xf326('0x48')][_0xf326('0x2e')](_0x1c86c8);}return[];})['then'](respondWithResult(_0x4ac90e,null))['catch'](handleError(_0x4ac90e,null));};exports[_0xf326('0x7c')]=function(_0x2d92e4,_0x167ac9,_0x34870c){return db[_0xf326('0x7d')]['findOne']({'where':{'VoiceQueueId':_0x2d92e4[_0xf326('0x46')][_0xf326('0x69')],'CampaignId':_0x2d92e4[_0xf326('0x46')]['CampaignId'],'ContactId':_0x2d92e4['body']['ContactId']}})[_0xf326('0x24')](handleEntityNotFound(_0x167ac9,null))[_0xf326('0x24')](function(_0x2d275d){if(_0x2d275d){return _0x2d275d;}return null;})[_0xf326('0x24')](respondWithResult(_0x167ac9,null))[_0xf326('0x40')](handleError(_0x167ac9,null));};
\ No newline at end of file