Built motion from commit ddca4d0d.|2.5.47
[motion2.git] / server / api / cmHopperFinal / cmHopperFinal.controller.js
index e8a9181..50bd734 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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(_0x42cae2,_0x284ef8){var _0x5f256f=function(_0x41abc8){while(--_0x41abc8){_0x42cae2['push'](_0x42cae2['shift']());}};_0x5f256f(++_0x284ef8);}(_0x326f,0xd1));var _0xf326=function(_0x4d73b2,_0x268c14){_0x4d73b2=_0x4d73b2-0x0;var _0x176734=_0x326f[_0x4d73b2];return _0x176734;};'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
+var _0x187d=['state\x20=\x20?','calleridnum\x20NOT\x20IN\x20(?)','select','from','cm_hopper','calleridnum','cm_hopper_final','state\x20=\x204','group','moveContactsIvrCampaignHopperFinal','insert','into','CampaignId','CampaignId\x20=\x20?','state','checkContactHopper','CmHopper','findOne','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','undefined','count','offset','limit','set','Content-Range','apply','update','destroy','error','stack','name','index','map','CmHopperFinal','rawAttributes','fieldName','type','query','keys','filters','intersection','model','attributes','length','hasOwnProperty','where','filter','merge','includeAll','include','findAll','then','rows','catch','show','params','fields','options','find','describe','body','uniqueid','countContactsQueueCampaignHopperFinal','COUNT','sequelize','literal','noSuchContacts','`state`\x20=\x203,\x201,\x20null','noAnswerContacts','`state`\x20=\x205,\x201,\x20null','`state`\x20=\x208,\x201,\x20null','dropContacts','`state`\x20=\x2011\x20,\x201,\x20null','abandonedContacts','reCallContacts','`state`\x20=\x2019,\x201,\x20null','answeringMachine','countContactsIvrCampaignHopperFinal','`state`\x20=\x200,\x201,\x20null','congestionContacts','`state`\x20=\x2010\x20,\x201,\x20null','`state`\x20=\x2022,\x201,\x20null','moveContactsQueueCampaignHopperFinal','fromQuery','phone','scheduledAt','ContactId','ListId','VoiceQueueId','createdAt','updatedAt','field','ANY_VALUE(calleridnum)','NOW()','ANY_VALUE(ContactId)','ANY_VALUE(ListId)','ANY_VALUE(VoiceQueueId)','VoiceQueueId\x20=\x20?','toString'];(function(_0x3e5086,_0x48f4a2){var _0xfeb102=function(_0x5a945f){while(--_0x5a945f){_0x3e5086['push'](_0x3e5086['shift']());}};_0xfeb102(++_0x48f4a2);}(_0x187d,0x93));var _0xd187=function(_0x521929,_0x479be5){_0x521929=_0x521929-0x0;var _0x632436=_0x187d[_0x521929];return _0x632436;};'use strict';var emlformat=require(_0xd187('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xd187('0x1'));var jsonpatch=require(_0xd187('0x2'));var rp=require(_0xd187('0x3'));var moment=require(_0xd187('0x4'));var BPromise=require(_0xd187('0x5'));var Mustache=require(_0xd187('0x6'));var util=require('util');var path=require(_0xd187('0x7'));var sox=require(_0xd187('0x8'));var csv=require('to-csv');var ejs=require(_0xd187('0x9'));var fs=require('fs');var fs_extra=require(_0xd187('0xa'));var _=require(_0xd187('0xb'));var squel=require(_0xd187('0xc'));var crypto=require(_0xd187('0xd'));var jsforce=require(_0xd187('0xe'));var deskjs=require(_0xd187('0xf'));var toCsv=require(_0xd187('0x10'));var querystring=require('querystring');var Papa=require(_0xd187('0x11'));var Redis=require(_0xd187('0x12'));var authService=require(_0xd187('0x13'));var qs=require(_0xd187('0x14'));var as=require(_0xd187('0x15'));var hardwareService=require(_0xd187('0x16'));var logger=require('../../config/logger')(_0xd187('0x17'));var utils=require(_0xd187('0x18'));var config=require(_0xd187('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0xd187('0x1a'))['db'];function respondWithStatusCode(_0x4545cf,_0x32ba07){_0x32ba07=_0x32ba07||0xcc;return function(_0x59ee4a){if(_0x59ee4a){return _0x4545cf[_0xd187('0x1b')](_0x32ba07);}return _0x4545cf[_0xd187('0x1c')](_0x32ba07)[_0xd187('0x1d')]();};}function respondWithResult(_0x126d1a,_0x517b25){_0x517b25=_0x517b25||0xc8;return function(_0x39a927){if(_0x39a927){return _0x126d1a[_0xd187('0x1c')](_0x517b25)[_0xd187('0x1e')](_0x39a927);}};}function respondWithFilteredResult(_0x188cfe,_0x4c8f68){return function(_0x245d3e){if(_0x245d3e){var _0x52a208=typeof _0x4c8f68['offset']===_0xd187('0x1f')&&typeof _0x4c8f68['limit']==='undefined';var _0x207b36=_0x245d3e[_0xd187('0x20')];var _0x374fe0=_0x52a208?0x0:_0x4c8f68[_0xd187('0x21')];var _0x21df74=_0x52a208?_0x245d3e[_0xd187('0x20')]:_0x4c8f68[_0xd187('0x21')]+_0x4c8f68[_0xd187('0x22')];var _0x4f2f88;if(_0x21df74>=_0x207b36){_0x21df74=_0x207b36;_0x4f2f88=0xc8;}else{_0x4f2f88=0xce;}_0x188cfe[_0xd187('0x1c')](_0x4f2f88);return _0x188cfe[_0xd187('0x23')](_0xd187('0x24'),_0x374fe0+'-'+_0x21df74+'/'+_0x207b36)[_0xd187('0x1e')](_0x245d3e);}return null;};}function patchUpdates(_0x5204ee){return function(_0x2f7fb3){try{jsonpatch[_0xd187('0x25')](_0x2f7fb3,_0x5204ee,!![]);}catch(_0xc5bba5){return BPromise['reject'](_0xc5bba5);}return _0x2f7fb3['save']();};}function saveUpdates(_0x57cf1d,_0x435d94){return function(_0x33741d){if(_0x33741d){return _0x33741d[_0xd187('0x26')](_0x57cf1d)['then'](function(_0x2c07c8){return _0x2c07c8;});}return null;};}function removeEntity(_0x57186b,_0x145771){return function(_0x5a7a23){if(_0x5a7a23){return _0x5a7a23[_0xd187('0x27')]()['then'](function(){_0x57186b['status'](0xcc)[_0xd187('0x1d')]();});}};}function handleEntityNotFound(_0x4d992b,_0x12da33){return function(_0x598aa4){if(!_0x598aa4){_0x4d992b['sendStatus'](0x194);}return _0x598aa4;};}function handleError(_0x4eac6a,_0x848ddd){_0x848ddd=_0x848ddd||0x1f4;return function(_0xeff822){logger[_0xd187('0x28')](_0xeff822[_0xd187('0x29')]);if(_0xeff822['name']){delete _0xeff822[_0xd187('0x2a')];}_0x4eac6a[_0xd187('0x1c')](_0x848ddd)['send'](_0xeff822);};}exports[_0xd187('0x2b')]=function(_0x1c87ee,_0x34febe){var _0x4c50a5={},_0x15e2e8={},_0x56e292={'count':0x0,'rows':[]};var _0x263e31=_[_0xd187('0x2c')](db[_0xd187('0x2d')][_0xd187('0x2e')],function(_0x489f2e){return{'name':_0x489f2e[_0xd187('0x2f')],'type':_0x489f2e[_0xd187('0x30')]['key']};});_0x15e2e8['model']=_[_0xd187('0x2c')](_0x263e31,_0xd187('0x2a'));_0x15e2e8[_0xd187('0x31')]=_[_0xd187('0x32')](_0x1c87ee[_0xd187('0x31')]);_0x15e2e8[_0xd187('0x33')]=_[_0xd187('0x34')](_0x15e2e8[_0xd187('0x35')],_0x15e2e8['query']);_0x4c50a5[_0xd187('0x36')]=_[_0xd187('0x34')](_0x15e2e8[_0xd187('0x35')],qs['fields'](_0x1c87ee[_0xd187('0x31')]['fields']));_0x4c50a5[_0xd187('0x36')]=_0x4c50a5[_0xd187('0x36')][_0xd187('0x37')]?_0x4c50a5['attributes']:_0x15e2e8['model'];if(!_0x1c87ee[_0xd187('0x31')][_0xd187('0x38')]('nolimit')){_0x4c50a5[_0xd187('0x22')]=qs[_0xd187('0x22')](_0x1c87ee[_0xd187('0x31')]['limit']);_0x4c50a5['offset']=qs[_0xd187('0x21')](_0x1c87ee[_0xd187('0x31')]['offset']);}_0x4c50a5['order']=qs['sort'](_0x1c87ee[_0xd187('0x31')]['sort']);_0x4c50a5[_0xd187('0x39')]=qs[_0xd187('0x33')](_['pick'](_0x1c87ee[_0xd187('0x31')],_0x15e2e8['filters']),_0x263e31);if(_0x1c87ee[_0xd187('0x31')][_0xd187('0x3a')]){_0x4c50a5['where']=_[_0xd187('0x3b')](_0x4c50a5[_0xd187('0x39')],{'$or':_['map'](_0x263e31,function(_0x4399a5){if(_0x4399a5['type']!=='VIRTUAL'){var _0x26b06d={};_0x26b06d[_0x4399a5[_0xd187('0x2a')]]={'$like':'%'+_0x1c87ee[_0xd187('0x31')][_0xd187('0x3a')]+'%'};return _0x26b06d;}})});}_0x4c50a5=_[_0xd187('0x3b')]({},_0x4c50a5,_0x1c87ee['options']);var _0x8860c={'where':_0x4c50a5[_0xd187('0x39')]};return db[_0xd187('0x2d')]['count'](_0x8860c)['then'](function(_0x538c05){_0x56e292['count']=_0x538c05;if(_0x1c87ee[_0xd187('0x31')][_0xd187('0x3c')]){_0x4c50a5[_0xd187('0x3d')]=[{'all':!![]}];}return db[_0xd187('0x2d')][_0xd187('0x3e')](_0x4c50a5);})[_0xd187('0x3f')](function(_0x4699e1){_0x56e292[_0xd187('0x40')]=_0x4699e1;return _0x56e292;})['then'](respondWithFilteredResult(_0x34febe,_0x4c50a5))[_0xd187('0x41')](handleError(_0x34febe,null));};exports[_0xd187('0x42')]=function(_0x31d9d2,_0x51c7fc){var _0x21cbf6={'raw':!![],'where':{'id':_0x31d9d2[_0xd187('0x43')]['id']}},_0x48c100={};_0x48c100[_0xd187('0x35')]=_[_0xd187('0x32')](db[_0xd187('0x2d')][_0xd187('0x2e')]);_0x48c100['query']=_[_0xd187('0x32')](_0x31d9d2[_0xd187('0x31')]);_0x48c100[_0xd187('0x33')]=_[_0xd187('0x34')](_0x48c100['model'],_0x48c100[_0xd187('0x31')]);_0x21cbf6[_0xd187('0x36')]=_['intersection'](_0x48c100[_0xd187('0x35')],qs[_0xd187('0x44')](_0x31d9d2['query']['fields']));_0x21cbf6[_0xd187('0x36')]=_0x21cbf6[_0xd187('0x36')]['length']?_0x21cbf6['attributes']:_0x48c100['model'];if(_0x31d9d2[_0xd187('0x31')][_0xd187('0x3c')]){_0x21cbf6[_0xd187('0x3d')]=[{'all':!![]}];}_0x21cbf6=_[_0xd187('0x3b')]({},_0x21cbf6,_0x31d9d2[_0xd187('0x45')]);return db[_0xd187('0x2d')][_0xd187('0x46')](_0x21cbf6)['then'](handleEntityNotFound(_0x51c7fc,null))[_0xd187('0x3f')](respondWithResult(_0x51c7fc,null))[_0xd187('0x41')](handleError(_0x51c7fc,null));};exports[_0xd187('0x47')]=function(_0x3ce4a1,_0x3f5def){return db[_0xd187('0x2d')][_0xd187('0x47')]()[_0xd187('0x3f')](respondWithResult(_0x3f5def,null))['catch'](handleError(_0x3f5def,null));};exports[_0xd187('0x26')]=function(_0x2657be,_0x4523c8){if(_0x2657be[_0xd187('0x48')][_0xd187('0x49')]){delete _0x2657be['body'][_0xd187('0x49')];}return db[_0xd187('0x2d')]['find']({'where':{'uniqueid':_0x2657be[_0xd187('0x43')]['id']}})[_0xd187('0x3f')](handleEntityNotFound(_0x4523c8,null))['then'](saveUpdates(_0x2657be['body'],null))['then'](respondWithResult(_0x4523c8,null))['catch'](handleError(_0x4523c8,null));};exports[_0xd187('0x4a')]=function(_0x22f432,_0x12d448,_0x1bcc3a){return db[_0xd187('0x2d')][_0xd187('0x3e')]({'raw':![],'where':{'VoiceQueueId':_0x22f432[_0xd187('0x43')]['id']},'attributes':[[db['sequelize']['fn'](_0xd187('0x4b'),db[_0xd187('0x4c')]['fn']('IF',db[_0xd187('0x4c')][_0xd187('0x4d')]('`state`\x20=\x200,\x201,\x20null'))),_0xd187('0x4e')],[db['sequelize']['fn']('COUNT',db[_0xd187('0x4c')]['fn']('IF',db['sequelize'][_0xd187('0x4d')](_0xd187('0x4f')))),_0xd187('0x50')],[db[_0xd187('0x4c')]['fn'](_0xd187('0x4b'),db[_0xd187('0x4c')]['fn']('IF',db[_0xd187('0x4c')][_0xd187('0x4d')](_0xd187('0x51')))),'busyContacts'],[db[_0xd187('0x4c')]['fn'](_0xd187('0x4b'),db['sequelize']['fn']('IF',db[_0xd187('0x4c')][_0xd187('0x4d')](_0xd187('0x52')))),'congestionContacts'],[db[_0xd187('0x4c')]['fn'](_0xd187('0x4b'),db['sequelize']['fn']('IF',db[_0xd187('0x4c')][_0xd187('0x4d')]('`state`\x20=\x2010\x20,\x201,\x20null'))),_0xd187('0x53')],[db['sequelize']['fn'](_0xd187('0x4b'),db[_0xd187('0x4c')]['fn']('IF',db[_0xd187('0x4c')][_0xd187('0x4d')](_0xd187('0x54')))),_0xd187('0x55')],[db[_0xd187('0x4c')]['fn']('COUNT',db[_0xd187('0x4c')]['fn']('IF',db[_0xd187('0x4c')][_0xd187('0x4d')]('`state`\x20=\x2022,\x201,\x20null'))),_0xd187('0x56')],[db[_0xd187('0x4c')]['fn'](_0xd187('0x4b'),db[_0xd187('0x4c')]['fn']('IF',db[_0xd187('0x4c')][_0xd187('0x4d')](_0xd187('0x57')))),_0xd187('0x58')]]})[_0xd187('0x3f')](handleEntityNotFound(_0x12d448,null))[_0xd187('0x3f')](respondWithResult(_0x12d448,null))[_0xd187('0x41')](handleError(_0x12d448,null));};exports[_0xd187('0x59')]=function(_0x23271b,_0x288a04,_0x39934c){return db[_0xd187('0x2d')][_0xd187('0x3e')]({'raw':![],'where':{'CampaignId':_0x23271b[_0xd187('0x43')]['id']},'attributes':[[db[_0xd187('0x4c')]['fn'](_0xd187('0x4b'),db['sequelize']['fn']('IF',db[_0xd187('0x4c')]['literal'](_0xd187('0x5a')))),_0xd187('0x4e')],[db[_0xd187('0x4c')]['fn'](_0xd187('0x4b'),db['sequelize']['fn']('IF',db[_0xd187('0x4c')][_0xd187('0x4d')]('`state`\x20=\x203,\x201,\x20null'))),'noAnswerContacts'],[db[_0xd187('0x4c')]['fn'](_0xd187('0x4b'),db[_0xd187('0x4c')]['fn']('IF',db[_0xd187('0x4c')]['literal'](_0xd187('0x51')))),'busyContacts'],[db[_0xd187('0x4c')]['fn'](_0xd187('0x4b'),db[_0xd187('0x4c')]['fn']('IF',db[_0xd187('0x4c')]['literal'](_0xd187('0x52')))),_0xd187('0x5b')],[db[_0xd187('0x4c')]['fn'](_0xd187('0x4b'),db[_0xd187('0x4c')]['fn']('IF',db['sequelize']['literal'](_0xd187('0x5c')))),_0xd187('0x53')],[db[_0xd187('0x4c')]['fn'](_0xd187('0x4b'),db[_0xd187('0x4c')]['fn']('IF',db[_0xd187('0x4c')][_0xd187('0x4d')](_0xd187('0x54')))),_0xd187('0x55')],[db[_0xd187('0x4c')]['fn'](_0xd187('0x4b'),db[_0xd187('0x4c')]['fn']('IF',db['sequelize'][_0xd187('0x4d')](_0xd187('0x5d')))),'reCallContacts'],[db[_0xd187('0x4c')]['fn'](_0xd187('0x4b'),db['sequelize']['fn']('IF',db['sequelize'][_0xd187('0x4d')](_0xd187('0x57')))),_0xd187('0x58')]]})[_0xd187('0x3f')](handleEntityNotFound(_0x288a04,null))['then'](respondWithResult(_0x288a04,null))[_0xd187('0x41')](handleError(_0x288a04,null));};exports[_0xd187('0x5e')]=function(_0x52e364,_0x569959,_0x3bca83){return db['VoiceQueue'][_0xd187('0x46')]({'where':{'id':_0x52e364[_0xd187('0x43')]['id']}})['then'](handleEntityNotFound(_0x569959,null))[_0xd187('0x3f')](function(_0x570c1c){var _0x317bc3;if(_0x570c1c){_0x317bc3=squel['insert']()['into']('cm_hopper')[_0xd187('0x5f')]([_0xd187('0x60'),_0xd187('0x61'),_0xd187('0x62'),_0xd187('0x63'),_0xd187('0x64'),_0xd187('0x65'),_0xd187('0x66')],squel['select']()[_0xd187('0x67')](_0xd187('0x68'),_0xd187('0x60'))['field'](_0xd187('0x69'),_0xd187('0x61'))[_0xd187('0x67')](_0xd187('0x6a'),'ContactId')[_0xd187('0x67')](_0xd187('0x6b'),'ListId')[_0xd187('0x67')](_0xd187('0x6c'),_0xd187('0x64'))[_0xd187('0x67')]('NOW()',_0xd187('0x65'))[_0xd187('0x67')]('NOW()',_0xd187('0x66'))['from']('cm_hopper_final')['where'](_0xd187('0x6d'),_0x52e364[_0xd187('0x43')]['id'][_0xd187('0x6e')]())[_0xd187('0x39')](_0xd187('0x6f'),_0x52e364[_0xd187('0x48')]['state'][_0xd187('0x6e')]())[_0xd187('0x39')]('calleridnum\x20IS\x20NOT\x20NULL')['where'](_0xd187('0x70'),squel[_0xd187('0x71')]()[_0xd187('0x67')](_0xd187('0x60'))[_0xd187('0x72')](_0xd187('0x73'))['where'](_0xd187('0x6d'),_0x52e364[_0xd187('0x43')]['id'][_0xd187('0x6e')]()))[_0xd187('0x39')](_0xd187('0x70'),squel[_0xd187('0x71')]()[_0xd187('0x67')](_0xd187('0x74'))[_0xd187('0x72')](_0xd187('0x75'))[_0xd187('0x39')](_0xd187('0x6d'),_0x52e364['params']['id']['toString']())[_0xd187('0x39')](_0xd187('0x76')))[_0xd187('0x77')](_0xd187('0x62')))[_0xd187('0x6e')]();return db[_0xd187('0x4c')]['query'](_0x317bc3);}return[];})[_0xd187('0x3f')](respondWithResult(_0x569959,null))['catch'](handleError(_0x569959,null));};exports[_0xd187('0x78')]=function(_0x520f86,_0x5cbfa6,_0x304117){return db['Campaign'][_0xd187('0x46')]({'where':{'id':_0x520f86[_0xd187('0x43')]['id']}})[_0xd187('0x3f')](handleEntityNotFound(_0x5cbfa6,null))[_0xd187('0x3f')](function(_0x1b93db){var _0x13a362;if(_0x1b93db){_0x13a362=squel[_0xd187('0x79')]()[_0xd187('0x7a')](_0xd187('0x73'))[_0xd187('0x5f')]([_0xd187('0x60'),_0xd187('0x61'),_0xd187('0x62'),_0xd187('0x63'),_0xd187('0x7b'),'createdAt',_0xd187('0x66')],squel[_0xd187('0x71')]()[_0xd187('0x67')](_0xd187('0x68'),'phone')[_0xd187('0x67')](_0xd187('0x69'),'scheduledAt')['field'](_0xd187('0x6a'),_0xd187('0x62'))[_0xd187('0x67')](_0xd187('0x6b'),_0xd187('0x63'))[_0xd187('0x67')]('ANY_VALUE(CampaignId)',_0xd187('0x7b'))[_0xd187('0x67')]('NOW()',_0xd187('0x65'))[_0xd187('0x67')](_0xd187('0x69'),_0xd187('0x66'))['from']('cm_hopper_final')[_0xd187('0x39')](_0xd187('0x7c'),_0x520f86[_0xd187('0x43')]['id']['toString']())[_0xd187('0x39')](_0xd187('0x6f'),_0x520f86[_0xd187('0x48')][_0xd187('0x7d')]['toString']())[_0xd187('0x39')]('calleridnum\x20IS\x20NOT\x20NULL')['where']('calleridnum\x20NOT\x20IN\x20(?)',squel['select']()['field']('phone')['from'](_0xd187('0x73'))[_0xd187('0x39')]('CampaignId\x20=\x20?',_0x520f86[_0xd187('0x43')]['id'][_0xd187('0x6e')]()))[_0xd187('0x39')](_0xd187('0x70'),squel[_0xd187('0x71')]()['field'](_0xd187('0x74'))['from'](_0xd187('0x75'))[_0xd187('0x39')](_0xd187('0x7c'),_0x520f86[_0xd187('0x43')]['id'][_0xd187('0x6e')]())[_0xd187('0x39')](_0xd187('0x76')))['group'](_0xd187('0x62')))[_0xd187('0x6e')]();return db['sequelize'][_0xd187('0x31')](_0x13a362);}return[];})[_0xd187('0x3f')](respondWithResult(_0x5cbfa6,null))['catch'](handleError(_0x5cbfa6,null));};exports[_0xd187('0x7e')]=function(_0x3bd1d8,_0x224312,_0x45b522){return db[_0xd187('0x7f')][_0xd187('0x80')]({'where':{'VoiceQueueId':_0x3bd1d8[_0xd187('0x48')][_0xd187('0x64')],'CampaignId':_0x3bd1d8['body'][_0xd187('0x7b')],'ContactId':_0x3bd1d8[_0xd187('0x48')][_0xd187('0x62')]}})[_0xd187('0x3f')](handleEntityNotFound(_0x224312,null))[_0xd187('0x3f')](function(_0x400a9){if(_0x400a9){return _0x400a9;}return null;})['then'](respondWithResult(_0x224312,null))['catch'](handleError(_0x224312,null));};
\ No newline at end of file