Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / api / cmHopper / cmHopper.rpc.js
index 3228c4d..3662aaf 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xff83=['UserId','push','MoveContactManagedDialer','CmHopperFinal','create','COUNT','literal','`scheduledat`\x20>=\x20','format','\x22%s\x22','\x20,\x201,\x20null','CountReScheduled','GetContactRecallMe','GetCmHopperPreview','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','then','info','CmHopper,\x20%s,\x20%s','request\x20sent','debug','CmHopper,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','GetCmHopper','CmHopper','findAll','options','limit','include','map','model','attributes','ShowCmHopper','find','CreateCmHopper','body','raw','UpdateCmHopper','update','where','DestroyCmHopper','destroy','GetContactDialer','CmContact','describe','sequelize','transaction','order','UPDATE','keys','User','Agent','name','voicePause','length','includes'];(function(_0xb7a7d2,_0x5ba4bd){var _0x4fc367=function(_0x5eeaec){while(--_0x5eeaec){_0xb7a7d2['push'](_0xb7a7d2['shift']());}};_0x4fc367(++_0x5ba4bd);}(_0xff83,0x167));var _0x3ff8=function(_0x4154a6,_0x2c0b8e){_0x4154a6=_0x4154a6-0x0;var _0x3b2786=_0xff83[_0x4154a6];return _0x3b2786;};'use strict';var _=require(_0x3ff8('0x0'));var util=require(_0x3ff8('0x1'));var moment=require('moment');var BPromise=require(_0x3ff8('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x3ff8('0x3'));var db=require(_0x3ff8('0x4'))['db'];var utils=require(_0x3ff8('0x5'));var logger=require('../../config/logger')(_0x3ff8('0x6'));var config=require(_0x3ff8('0x7'));var jayson=require(_0x3ff8('0x8'));var client=jayson[_0x3ff8('0x9')][_0x3ff8('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x5f39f0,_0x83a2e8,_0x50407c){return new BPromise(function(_0x5aba9b,_0x18f6e5){return client['request'](_0x5f39f0,_0x50407c)[_0x3ff8('0xb')](function(_0x161423){logger[_0x3ff8('0xc')](_0x3ff8('0xd'),_0x83a2e8,_0x3ff8('0xe'));logger[_0x3ff8('0xf')](_0x3ff8('0x10'),_0x83a2e8,_0x3ff8('0xe'),JSON[_0x3ff8('0x11')](_0x161423));if(_0x161423[_0x3ff8('0x12')]){if(_0x161423[_0x3ff8('0x12')][_0x3ff8('0x13')]===0x1f4){logger[_0x3ff8('0x12')](_0x3ff8('0xd'),_0x83a2e8,_0x161423[_0x3ff8('0x12')]['message']);return _0x18f6e5(_0x161423[_0x3ff8('0x12')][_0x3ff8('0x14')]);}logger['error'](_0x3ff8('0xd'),_0x83a2e8,_0x161423['error'][_0x3ff8('0x14')]);return _0x5aba9b(_0x161423[_0x3ff8('0x12')]['message']);}else{logger['info'](_0x3ff8('0xd'),_0x83a2e8,_0x3ff8('0xe'));_0x5aba9b(_0x161423['result'][_0x3ff8('0x14')]);}})[_0x3ff8('0x15')](function(_0x31b77d){logger[_0x3ff8('0x12')](_0x3ff8('0xd'),_0x83a2e8,_0x31b77d);_0x18f6e5(_0x31b77d);});});}exports[_0x3ff8('0x16')]=function(_0x1fc663){var _0x19ec36=this;return new Promise(function(_0x3f8ed3,_0x3aa9b7){return db[_0x3ff8('0x17')][_0x3ff8('0x18')]({'raw':_0x1fc663[_0x3ff8('0x19')]?_0x1fc663[_0x3ff8('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x1fc663[_0x3ff8('0x19')]?_0x1fc663[_0x3ff8('0x19')]['where']||null:null,'attributes':_0x1fc663[_0x3ff8('0x19')]?_0x1fc663[_0x3ff8('0x19')]['attributes']||null:null,'limit':_0x1fc663[_0x3ff8('0x19')]?_0x1fc663[_0x3ff8('0x19')][_0x3ff8('0x1a')]||null:null,'include':_0x1fc663[_0x3ff8('0x19')]?_0x1fc663[_0x3ff8('0x19')][_0x3ff8('0x1b')]?_[_0x3ff8('0x1c')](_0x1fc663[_0x3ff8('0x19')]['include'],function(_0x34c8ce){return{'model':db[_0x34c8ce[_0x3ff8('0x1d')]],'as':_0x34c8ce['as'],'attributes':_0x34c8ce[_0x3ff8('0x1e')],'include':_0x34c8ce[_0x3ff8('0x1b')]?_['map'](_0x34c8ce[_0x3ff8('0x1b')],function(_0x5087bf){return{'model':db[_0x5087bf[_0x3ff8('0x1d')]],'as':_0x5087bf['as'],'attributes':_0x5087bf[_0x3ff8('0x1e')],'include':_0x5087bf[_0x3ff8('0x1b')]?_['map'](_0x5087bf[_0x3ff8('0x1b')],function(_0xbf1208){return{'model':db[_0xbf1208[_0x3ff8('0x1d')]],'as':_0xbf1208['as'],'attributes':_0xbf1208[_0x3ff8('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x3ff8('0xb')](function(_0x383594){logger['info']('GetCmHopper',_0x1fc663);logger[_0x3ff8('0xf')](_0x3ff8('0x16'),_0x1fc663,JSON['stringify'](_0x383594));_0x3f8ed3(_0x383594);})[_0x3ff8('0x15')](function(_0x427ec8){logger[_0x3ff8('0x12')]('GetCmHopper',_0x427ec8[_0x3ff8('0x14')],_0x1fc663);_0x3aa9b7(_0x19ec36[_0x3ff8('0x12')](0x1f4,_0x427ec8['message']));});});};exports[_0x3ff8('0x1f')]=function(_0x3ad76e){var _0x39dc62=this;return new Promise(function(_0x463ca5,_0x128229){return db[_0x3ff8('0x17')][_0x3ff8('0x20')]({'raw':_0x3ad76e[_0x3ff8('0x19')]?_0x3ad76e[_0x3ff8('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x3ad76e[_0x3ff8('0x19')]?_0x3ad76e[_0x3ff8('0x19')]['where']||null:null,'attributes':_0x3ad76e['options']?_0x3ad76e[_0x3ff8('0x19')][_0x3ff8('0x1e')]||null:null,'include':_0x3ad76e['options']?_0x3ad76e['options'][_0x3ff8('0x1b')]?_[_0x3ff8('0x1c')](_0x3ad76e[_0x3ff8('0x19')]['include'],function(_0x5b5fde){return{'model':db[_0x5b5fde[_0x3ff8('0x1d')]],'as':_0x5b5fde['as'],'attributes':_0x5b5fde[_0x3ff8('0x1e')],'include':_0x5b5fde['include']?_[_0x3ff8('0x1c')](_0x5b5fde['include'],function(_0x1246cd){return{'model':db[_0x1246cd['model']],'as':_0x1246cd['as'],'attributes':_0x1246cd[_0x3ff8('0x1e')],'include':_0x1246cd[_0x3ff8('0x1b')]?_['map'](_0x1246cd[_0x3ff8('0x1b')],function(_0x2c923a){return{'model':db[_0x2c923a[_0x3ff8('0x1d')]],'as':_0x2c923a['as'],'attributes':_0x2c923a[_0x3ff8('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5659d9){logger['info'](_0x3ff8('0x1f'),_0x3ad76e);logger[_0x3ff8('0xf')](_0x3ff8('0x1f'),_0x3ad76e,JSON[_0x3ff8('0x11')](_0x5659d9));_0x463ca5(_0x5659d9);})[_0x3ff8('0x15')](function(_0x2f1ea0){logger[_0x3ff8('0x12')](_0x3ff8('0x1f'),_0x2f1ea0[_0x3ff8('0x14')],_0x3ad76e);_0x128229(_0x39dc62[_0x3ff8('0x12')](0x1f4,_0x2f1ea0[_0x3ff8('0x14')]));});});};exports[_0x3ff8('0x21')]=function(_0x788c85){var _0x5c1bf0=this;return new Promise(function(_0x88f898,_0x56cf37){return db[_0x3ff8('0x17')]['create'](_0x788c85[_0x3ff8('0x22')],{'raw':_0x788c85['options']?_0x788c85[_0x3ff8('0x19')][_0x3ff8('0x23')]===undefined?!![]:![]:!![]})[_0x3ff8('0xb')](function(_0x39b159){logger['info']('CreateCmHopper',_0x788c85);logger['debug']('CreateCmHopper',_0x788c85,JSON[_0x3ff8('0x11')](_0x39b159));_0x88f898(_0x39b159);})[_0x3ff8('0x15')](function(_0x5c99de){logger[_0x3ff8('0x12')](_0x3ff8('0x21'),_0x5c99de[_0x3ff8('0x14')],_0x788c85);_0x56cf37(_0x5c1bf0['error'](0x1f4,_0x5c99de[_0x3ff8('0x14')]));});});};exports[_0x3ff8('0x24')]=function(_0x4ceb6f){var _0x3684d5=this;return new Promise(function(_0x434938,_0x338099){return db[_0x3ff8('0x17')][_0x3ff8('0x25')](_0x4ceb6f[_0x3ff8('0x22')],{'raw':_0x4ceb6f[_0x3ff8('0x19')]?_0x4ceb6f[_0x3ff8('0x19')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4ceb6f[_0x3ff8('0x19')]?_0x4ceb6f['options'][_0x3ff8('0x26')]||null:null,'attributes':_0x4ceb6f['options']?_0x4ceb6f[_0x3ff8('0x19')][_0x3ff8('0x1e')]||null:null,'limit':_0x4ceb6f['options']?_0x4ceb6f['options'][_0x3ff8('0x1a')]||null:null})['then'](function(_0x42e323){logger[_0x3ff8('0xc')](_0x3ff8('0x24'),_0x4ceb6f);logger[_0x3ff8('0xf')](_0x3ff8('0x24'),_0x4ceb6f,JSON[_0x3ff8('0x11')](_0x42e323));_0x434938(_0x42e323);})[_0x3ff8('0x15')](function(_0x3803dd){logger[_0x3ff8('0x12')]('UpdateCmHopper',_0x3803dd['message'],_0x4ceb6f);_0x338099(_0x3684d5[_0x3ff8('0x12')](0x1f4,_0x3803dd[_0x3ff8('0x14')]));});});};exports[_0x3ff8('0x27')]=function(_0xa1aa9d){var _0x118130=this;return new Promise(function(_0x309b1a,_0x2484a2){return db[_0x3ff8('0x17')][_0x3ff8('0x28')]({'where':_0xa1aa9d[_0x3ff8('0x19')]?_0xa1aa9d[_0x3ff8('0x19')][_0x3ff8('0x26')]||null:null})[_0x3ff8('0xb')](function(_0x9bc85){logger[_0x3ff8('0xc')](_0x3ff8('0x27'),_0xa1aa9d);logger[_0x3ff8('0xf')](_0x3ff8('0x27'),_0xa1aa9d,JSON[_0x3ff8('0x11')](_0x9bc85));_0x309b1a(_0x9bc85);})[_0x3ff8('0x15')](function(_0x511cf8){logger[_0x3ff8('0x12')]('DestroyCmHopper',_0x511cf8[_0x3ff8('0x14')],_0xa1aa9d);_0x2484a2(_0x118130['error'](0x1f4,_0x511cf8[_0x3ff8('0x14')]));});});};exports[_0x3ff8('0x29')]=function(_0x45243c){var _0xb8aeff=this;return new Promise(function(_0x212221,_0x3f6a23){return db[_0x3ff8('0x2a')][_0x3ff8('0x2b')]()[_0x3ff8('0xb')](function(_0x2b9849){return db[_0x3ff8('0x2c')][_0x3ff8('0x2d')](function(_0xdc3102){return db['CmHopper'][_0x3ff8('0x18')]({'where':_0x45243c[_0x3ff8('0x19')]?_0x45243c[_0x3ff8('0x19')]['where']||null:null,'attributes':_0x45243c[_0x3ff8('0x19')]?_0x45243c[_0x3ff8('0x19')][_0x3ff8('0x1e')]||null:null,'limit':_0x45243c[_0x3ff8('0x19')]?_0x45243c[_0x3ff8('0x19')][_0x3ff8('0x1a')]||null:null,'order':_0x45243c[_0x3ff8('0x19')]?_0x45243c[_0x3ff8('0x19')][_0x3ff8('0x2e')]||null:null,'transaction':_0xdc3102,'lock':_0xdc3102['LOCK'][_0x3ff8('0x2f')],'include':[{'model':db[_0x3ff8('0x2a')],'as':'Contact','attributes':_[_0x3ff8('0x30')](_0x2b9849)},{'model':db[_0x3ff8('0x31')],'as':_0x3ff8('0x32'),'attributes':['id',_0x3ff8('0x33'),_0x3ff8('0x34')]}]})['then'](function(_0x41a527){var _0x3b36e4=[];var _0x561321=[];for(var _0x1f5a0a=0x0;_0x1f5a0a<_0x41a527[_0x3ff8('0x35')];_0x1f5a0a+=0x1){if(!_0x561321[_0x3ff8('0x36')](_0x41a527[_0x1f5a0a][_0x3ff8('0x37')])){_0x561321[_0x3ff8('0x38')](_0x41a527[_0x1f5a0a][_0x3ff8('0x37')]);_0x3b36e4['push'](_0x41a527[_0x1f5a0a][_0x3ff8('0x25')](_0x45243c[_0x3ff8('0x22')],{'transaction':_0xdc3102}));}}return BPromise['all'](_0x3b36e4);});})['then'](function(_0xd32aab){logger[_0x3ff8('0xc')]('GetContactDialer',_0x45243c);logger[_0x3ff8('0xf')]('GetContactDialer',_0x45243c,JSON[_0x3ff8('0x11')](_0xd32aab));_0x212221(_0xd32aab);})[_0x3ff8('0x15')](function(_0x3fb4c3){logger[_0x3ff8('0x12')]('GetContactDialer',_0x3fb4c3[_0x3ff8('0x14')],_0x45243c);_0x3f6a23(_0xb8aeff[_0x3ff8('0x12')](0x1f4,_0x3fb4c3['message']));});});});};exports[_0x3ff8('0x39')]=function(_0x7255af){var _0x1eaddc=this;return new Promise(function(_0x17ca4c,_0x1419e3){return db[_0x3ff8('0x2c')][_0x3ff8('0x2d')](function(_0x5871f6){return db[_0x3ff8('0x3a')][_0x3ff8('0x3b')](_0x7255af['body'],{'raw':_0x7255af[_0x3ff8('0x19')]?_0x7255af[_0x3ff8('0x19')][_0x3ff8('0x23')]===undefined?!![]:![]:!![],'transaction':_0x5871f6})[_0x3ff8('0xb')](function(){return db[_0x3ff8('0x17')]['destroy']({'where':_0x7255af[_0x3ff8('0x19')]?_0x7255af['options'][_0x3ff8('0x26')]||null:null,'transaction':_0x5871f6});});})[_0x3ff8('0xb')](function(_0x46249a){logger['info']('MoveContactManagedDialer',_0x7255af);logger[_0x3ff8('0xf')](_0x3ff8('0x39'),_0x7255af,JSON[_0x3ff8('0x11')](_0x46249a));_0x17ca4c(_0x46249a);})[_0x3ff8('0x15')](function(_0x25a98b){logger[_0x3ff8('0x12')](_0x3ff8('0x39'),_0x25a98b['message'],_0x7255af);_0x1419e3(_0x1eaddc[_0x3ff8('0x12')](0x1f4,_0x25a98b[_0x3ff8('0x14')]));});});};exports['CountReScheduled']=function(_0x5df866){var _0x6d9541=this;return new Promise(function(_0x5b1eea,_0x596b42){return db['CmHopper'][_0x3ff8('0x18')]({'raw':_0x5df866[_0x3ff8('0x19')]?_0x5df866[_0x3ff8('0x19')][_0x3ff8('0x23')]===undefined?!![]:![]:!![],'where':_0x5df866[_0x3ff8('0x19')]?_0x5df866[_0x3ff8('0x19')][_0x3ff8('0x26')]||null:null,'attributes':[[db[_0x3ff8('0x2c')]['fn'](_0x3ff8('0x3c'),db[_0x3ff8('0x2c')]['fn']('IF',db[_0x3ff8('0x2c')][_0x3ff8('0x3d')](_0x3ff8('0x3e')+util[_0x3ff8('0x3f')](_0x3ff8('0x40'),moment()['format']('YYYY-MM-DD\x20HH:mm:ss'))+_0x3ff8('0x41')))),'contactsRescheduled']]})[_0x3ff8('0xb')](function(_0x597b25){logger[_0x3ff8('0xc')]('CountReScheduled',_0x5df866);logger[_0x3ff8('0xf')](_0x3ff8('0x42'),_0x5df866,JSON[_0x3ff8('0x11')](_0x597b25));_0x5b1eea(_0x597b25);})[_0x3ff8('0x15')](function(_0x3fa201){logger[_0x3ff8('0x12')](_0x3ff8('0x42'),_0x3fa201[_0x3ff8('0x14')],_0x5df866);_0x596b42(_0x6d9541[_0x3ff8('0x12')](0x1f4,_0x3fa201[_0x3ff8('0x14')]));});});};exports['GetContactRecallMe']=function(_0x55a963){var _0x50fd13=this;return new Promise(function(_0x5103ef,_0x26b58b){return db['CmContact'][_0x3ff8('0x2b')]()[_0x3ff8('0xb')](function(_0x12e793){return db[_0x3ff8('0x2c')][_0x3ff8('0x2d')](function(_0x452789){return db[_0x3ff8('0x17')]['findAll']({'where':_0x55a963[_0x3ff8('0x19')]?_0x55a963[_0x3ff8('0x19')][_0x3ff8('0x26')]||null:null,'attributes':_0x55a963['options']?_0x55a963[_0x3ff8('0x19')][_0x3ff8('0x1e')]||null:null,'limit':0x1,'order':_0x55a963[_0x3ff8('0x19')]?_0x55a963[_0x3ff8('0x19')][_0x3ff8('0x2e')]||null:null,'group':db[_0x3ff8('0x17')]['UserId'],'transaction':_0x452789,'lock':_0x452789['LOCK'][_0x3ff8('0x2f')],'include':_0x55a963[_0x3ff8('0x19')]?_0x55a963[_0x3ff8('0x19')][_0x3ff8('0x1b')]?_['map'](_0x55a963['options'][_0x3ff8('0x1b')],function(_0x3a2fad){return{'model':db[_0x3a2fad[_0x3ff8('0x1d')]],'as':_0x3a2fad['as'],'attributes':_0x3a2fad[_0x3ff8('0x1e')],'include':_0x3a2fad['include']?_[_0x3ff8('0x1c')](_0x3a2fad['include'],function(_0x4d7222){return{'model':db[_0x4d7222[_0x3ff8('0x1d')]],'as':_0x4d7222['as'],'attributes':_0x4d7222[_0x3ff8('0x1e')],'include':_0x4d7222[_0x3ff8('0x1b')]?_['map'](_0x4d7222[_0x3ff8('0x1b')],function(_0x11e868){return{'model':db[_0x11e868['model']],'as':_0x11e868['as'],'attributes':_0x11e868[_0x3ff8('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x3ff8('0xb')](function(_0x2b8988){var _0x33a3b0=[];for(var _0x5ababe=0x0;_0x5ababe<_0x2b8988[_0x3ff8('0x35')];_0x5ababe+=0x1){_0x33a3b0[_0x3ff8('0x38')](_0x2b8988[_0x5ababe]['update'](_0x55a963['body'],{'transaction':_0x452789}));}return BPromise['all'](_0x33a3b0);});})['then'](function(_0x1ac946){logger['info'](_0x3ff8('0x43'),_0x55a963);logger[_0x3ff8('0xf')](_0x3ff8('0x43'),_0x55a963,JSON[_0x3ff8('0x11')](_0x1ac946));_0x5103ef(_0x1ac946);})[_0x3ff8('0x15')](function(_0x2a184a){logger[_0x3ff8('0x12')]('GetContactRecallMe',_0x2a184a[_0x3ff8('0x14')],_0x55a963);_0x26b58b(_0x50fd13[_0x3ff8('0x12')](0x1f4,_0x2a184a[_0x3ff8('0x14')]));});});});};exports[_0x3ff8('0x44')]=function(_0x3b2098){var _0x1506d5=this;return new Promise(function(_0x201120,_0x2d5dd3){db[_0x3ff8('0x2a')][_0x3ff8('0x2b')]()[_0x3ff8('0xb')](function(_0x342d2f){return db[_0x3ff8('0x17')][_0x3ff8('0x18')]({'raw':_0x3b2098[_0x3ff8('0x19')]?_0x3b2098[_0x3ff8('0x19')][_0x3ff8('0x23')]===undefined?!![]:![]:!![],'where':_0x3b2098[_0x3ff8('0x19')]?_0x3b2098['options'][_0x3ff8('0x26')]||null:null,'attributes':_0x3b2098[_0x3ff8('0x19')]?_0x3b2098['options'][_0x3ff8('0x1e')]||null:null,'limit':_0x3b2098[_0x3ff8('0x19')]?_0x3b2098['options']['limit']||null:null,'include':_0x3b2098[_0x3ff8('0x19')]?_0x3b2098[_0x3ff8('0x19')]['include']?_['map'](_0x3b2098['options'][_0x3ff8('0x1b')],function(_0x2889ad){return{'model':db[_0x2889ad['model']],'as':_0x2889ad['as'],'attributes':_0x2889ad['as']==='Contact'?_[_0x3ff8('0x30')](_0x342d2f):_0x2889ad['attributes'],'include':_0x2889ad[_0x3ff8('0x1b')]?_['map'](_0x2889ad['include'],function(_0x43fd60){return{'model':db[_0x43fd60[_0x3ff8('0x1d')]],'as':_0x43fd60['as'],'attributes':_0x43fd60[_0x3ff8('0x1e')],'include':_0x43fd60[_0x3ff8('0x1b')]?_['map'](_0x43fd60['include'],function(_0x2af6b2){return{'model':db[_0x2af6b2['model']],'as':_0x2af6b2['as'],'attributes':_0x2af6b2['attributes']};}):[]};}):[]};}):[]:[]})[_0x3ff8('0xb')](function(_0x4adff9){logger[_0x3ff8('0xc')](_0x3ff8('0x16'),_0x3b2098);logger[_0x3ff8('0xf')]('GetCmHopper',_0x3b2098,JSON[_0x3ff8('0x11')](_0x4adff9));_0x201120(_0x4adff9);})['catch'](function(_0x3ba466){logger[_0x3ff8('0x12')](_0x3ff8('0x16'),_0x3ba466[_0x3ff8('0x14')],_0x3b2098);_0x2d5dd3(_0x1506d5[_0x3ff8('0x12')](0x1f4,_0x3ba466[_0x3ff8('0x14')]));});});});};
\ No newline at end of file
+var _0x51d0=['format','YYYY-MM-DD\x20HH:mm:ss','contactsRescheduled','GetContactRecallMe','lodash','util','moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','CmHopper,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','catch','GetCmHopper','findAll','options','raw','where','attributes','limit','include','map','model','ShowCmHopper','CmHopper','find','CreateCmHopper','update','body','UpdateCmHopper','DestroyCmHopper','CmContact','describe','sequelize','transaction','order','LOCK','UPDATE','Contact','keys','Agent','name','voicePause','length','includes','UserId','push','all','GetContactDialer','MoveContactManagedDialer','CmHopperFinal','CountReScheduled','COUNT','literal','`scheduledat`\x20>=\x20'];(function(_0x35124b,_0x5d6083){var _0x310f95=function(_0x53b25f){while(--_0x53b25f){_0x35124b['push'](_0x35124b['shift']());}};_0x310f95(++_0x5d6083);}(_0x51d0,0x8e));var _0x051d=function(_0x474bc0,_0x26989c){_0x474bc0=_0x474bc0-0x0;var _0x4b24cf=_0x51d0[_0x474bc0];return _0x4b24cf;};'use strict';var _=require(_0x051d('0x0'));var util=require(_0x051d('0x1'));var moment=require(_0x051d('0x2'));var BPromise=require('bluebird');var rs=require(_0x051d('0x3'));var fs=require('fs');var Redis=require(_0x051d('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x051d('0x5'));var logger=require(_0x051d('0x6'))(_0x051d('0x7'));var config=require(_0x051d('0x8'));var jayson=require(_0x051d('0x9'));var client=jayson[_0x051d('0xa')][_0x051d('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x437b11,_0x8f2acd,_0x1d178d){return new BPromise(function(_0x31559c,_0x4de7a9){return client[_0x051d('0xc')](_0x437b11,_0x1d178d)[_0x051d('0xd')](function(_0x13c25b){logger[_0x051d('0xe')](_0x051d('0xf'),_0x8f2acd,_0x051d('0x10'));logger[_0x051d('0x11')]('CmHopper,\x20%s,\x20%s,\x20%s',_0x8f2acd,_0x051d('0x10'),JSON[_0x051d('0x12')](_0x13c25b));if(_0x13c25b['error']){if(_0x13c25b[_0x051d('0x13')]['code']===0x1f4){logger[_0x051d('0x13')](_0x051d('0xf'),_0x8f2acd,_0x13c25b[_0x051d('0x13')][_0x051d('0x14')]);return _0x4de7a9(_0x13c25b[_0x051d('0x13')][_0x051d('0x14')]);}logger[_0x051d('0x13')](_0x051d('0xf'),_0x8f2acd,_0x13c25b[_0x051d('0x13')][_0x051d('0x14')]);return _0x31559c(_0x13c25b[_0x051d('0x13')][_0x051d('0x14')]);}else{logger[_0x051d('0xe')](_0x051d('0xf'),_0x8f2acd,_0x051d('0x10'));_0x31559c(_0x13c25b[_0x051d('0x15')]['message']);}})[_0x051d('0x16')](function(_0x3efaa5){logger[_0x051d('0x13')](_0x051d('0xf'),_0x8f2acd,_0x3efaa5);_0x4de7a9(_0x3efaa5);});});}exports[_0x051d('0x17')]=function(_0x10cce3){var _0x44a498=this;return new Promise(function(_0x53e68d,_0x4f304d){return db['CmHopper'][_0x051d('0x18')]({'raw':_0x10cce3[_0x051d('0x19')]?_0x10cce3[_0x051d('0x19')][_0x051d('0x1a')]===undefined?!![]:![]:!![],'where':_0x10cce3['options']?_0x10cce3['options'][_0x051d('0x1b')]||null:null,'attributes':_0x10cce3[_0x051d('0x19')]?_0x10cce3[_0x051d('0x19')][_0x051d('0x1c')]||null:null,'limit':_0x10cce3[_0x051d('0x19')]?_0x10cce3[_0x051d('0x19')][_0x051d('0x1d')]||null:null,'include':_0x10cce3[_0x051d('0x19')]?_0x10cce3[_0x051d('0x19')][_0x051d('0x1e')]?_[_0x051d('0x1f')](_0x10cce3['options'][_0x051d('0x1e')],function(_0x2221fc){return{'model':db[_0x2221fc[_0x051d('0x20')]],'as':_0x2221fc['as'],'attributes':_0x2221fc[_0x051d('0x1c')],'include':_0x2221fc['include']?_[_0x051d('0x1f')](_0x2221fc[_0x051d('0x1e')],function(_0x51adee){return{'model':db[_0x51adee[_0x051d('0x20')]],'as':_0x51adee['as'],'attributes':_0x51adee[_0x051d('0x1c')],'include':_0x51adee[_0x051d('0x1e')]?_[_0x051d('0x1f')](_0x51adee[_0x051d('0x1e')],function(_0x5679b4){return{'model':db[_0x5679b4[_0x051d('0x20')]],'as':_0x5679b4['as'],'attributes':_0x5679b4[_0x051d('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x051d('0xd')](function(_0x54473c){logger['info'](_0x051d('0x17'),_0x10cce3);logger[_0x051d('0x11')]('GetCmHopper',_0x10cce3,JSON[_0x051d('0x12')](_0x54473c));_0x53e68d(_0x54473c);})['catch'](function(_0x1f9aef){logger['error'](_0x051d('0x17'),_0x1f9aef[_0x051d('0x14')],_0x10cce3);_0x4f304d(_0x44a498['error'](0x1f4,_0x1f9aef[_0x051d('0x14')]));});});};exports[_0x051d('0x21')]=function(_0x1f8971){var _0x426def=this;return new Promise(function(_0x10ce42,_0x36b6e8){return db[_0x051d('0x22')][_0x051d('0x23')]({'raw':_0x1f8971['options']?_0x1f8971[_0x051d('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x1f8971[_0x051d('0x19')]?_0x1f8971[_0x051d('0x19')][_0x051d('0x1b')]||null:null,'attributes':_0x1f8971[_0x051d('0x19')]?_0x1f8971[_0x051d('0x19')]['attributes']||null:null,'include':_0x1f8971[_0x051d('0x19')]?_0x1f8971[_0x051d('0x19')]['include']?_['map'](_0x1f8971['options'][_0x051d('0x1e')],function(_0x2d7d1b){return{'model':db[_0x2d7d1b['model']],'as':_0x2d7d1b['as'],'attributes':_0x2d7d1b['attributes'],'include':_0x2d7d1b[_0x051d('0x1e')]?_['map'](_0x2d7d1b[_0x051d('0x1e')],function(_0x4a834d){return{'model':db[_0x4a834d['model']],'as':_0x4a834d['as'],'attributes':_0x4a834d[_0x051d('0x1c')],'include':_0x4a834d[_0x051d('0x1e')]?_[_0x051d('0x1f')](_0x4a834d[_0x051d('0x1e')],function(_0x3cee83){return{'model':db[_0x3cee83[_0x051d('0x20')]],'as':_0x3cee83['as'],'attributes':_0x3cee83[_0x051d('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x35379b){logger[_0x051d('0xe')](_0x051d('0x21'),_0x1f8971);logger[_0x051d('0x11')](_0x051d('0x21'),_0x1f8971,JSON[_0x051d('0x12')](_0x35379b));_0x10ce42(_0x35379b);})[_0x051d('0x16')](function(_0x46b3af){logger['error'](_0x051d('0x21'),_0x46b3af[_0x051d('0x14')],_0x1f8971);_0x36b6e8(_0x426def[_0x051d('0x13')](0x1f4,_0x46b3af['message']));});});};exports[_0x051d('0x24')]=function(_0x1206f6){var _0x128be0=this;return new Promise(function(_0x321e23,_0x42dfbf){return db[_0x051d('0x22')]['create'](_0x1206f6['body'],{'raw':_0x1206f6[_0x051d('0x19')]?_0x1206f6[_0x051d('0x19')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x15c595){logger[_0x051d('0xe')](_0x051d('0x24'),_0x1206f6);logger['debug'](_0x051d('0x24'),_0x1206f6,JSON['stringify'](_0x15c595));_0x321e23(_0x15c595);})['catch'](function(_0x596704){logger[_0x051d('0x13')](_0x051d('0x24'),_0x596704[_0x051d('0x14')],_0x1206f6);_0x42dfbf(_0x128be0['error'](0x1f4,_0x596704[_0x051d('0x14')]));});});};exports['UpdateCmHopper']=function(_0xfdfb62){var _0x38247f=this;return new Promise(function(_0x569371,_0x1c201a){return db[_0x051d('0x22')][_0x051d('0x25')](_0xfdfb62[_0x051d('0x26')],{'raw':_0xfdfb62['options']?_0xfdfb62['options'][_0x051d('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xfdfb62[_0x051d('0x19')]?_0xfdfb62[_0x051d('0x19')]['where']||null:null,'attributes':_0xfdfb62[_0x051d('0x19')]?_0xfdfb62[_0x051d('0x19')]['attributes']||null:null,'limit':_0xfdfb62['options']?_0xfdfb62[_0x051d('0x19')]['limit']||null:null})[_0x051d('0xd')](function(_0x51b502){logger[_0x051d('0xe')](_0x051d('0x27'),_0xfdfb62);logger[_0x051d('0x11')](_0x051d('0x27'),_0xfdfb62,JSON[_0x051d('0x12')](_0x51b502));_0x569371(_0x51b502);})['catch'](function(_0x248a6b){logger[_0x051d('0x13')](_0x051d('0x27'),_0x248a6b[_0x051d('0x14')],_0xfdfb62);_0x1c201a(_0x38247f[_0x051d('0x13')](0x1f4,_0x248a6b['message']));});});};exports['DestroyCmHopper']=function(_0x4fa97b){var _0x3e4a45=this;return new Promise(function(_0x4ec335,_0x57f879){return db['CmHopper']['destroy']({'where':_0x4fa97b[_0x051d('0x19')]?_0x4fa97b[_0x051d('0x19')][_0x051d('0x1b')]||null:null})[_0x051d('0xd')](function(_0x94d628){logger[_0x051d('0xe')](_0x051d('0x28'),_0x4fa97b);logger[_0x051d('0x11')](_0x051d('0x28'),_0x4fa97b,JSON['stringify'](_0x94d628));_0x4ec335(_0x94d628);})['catch'](function(_0x2e2b55){logger[_0x051d('0x13')](_0x051d('0x28'),_0x2e2b55[_0x051d('0x14')],_0x4fa97b);_0x57f879(_0x3e4a45[_0x051d('0x13')](0x1f4,_0x2e2b55[_0x051d('0x14')]));});});};exports['GetContactDialer']=function(_0x5560a2){var _0xcae4a3=this;return new Promise(function(_0x334f68,_0x1b9a48){return db[_0x051d('0x29')][_0x051d('0x2a')]()[_0x051d('0xd')](function(_0x18ffa2){return db[_0x051d('0x2b')][_0x051d('0x2c')](function(_0x1e6ba9){return db[_0x051d('0x22')][_0x051d('0x18')]({'where':_0x5560a2[_0x051d('0x19')]?_0x5560a2[_0x051d('0x19')]['where']||null:null,'attributes':_0x5560a2[_0x051d('0x19')]?_0x5560a2[_0x051d('0x19')][_0x051d('0x1c')]||null:null,'limit':_0x5560a2[_0x051d('0x19')]?_0x5560a2[_0x051d('0x19')][_0x051d('0x1d')]||null:null,'order':_0x5560a2[_0x051d('0x19')]?_0x5560a2[_0x051d('0x19')][_0x051d('0x2d')]||null:null,'transaction':_0x1e6ba9,'lock':_0x1e6ba9[_0x051d('0x2e')][_0x051d('0x2f')],'include':[{'model':db[_0x051d('0x29')],'as':_0x051d('0x30'),'attributes':_[_0x051d('0x31')](_0x18ffa2)},{'model':db['User'],'as':_0x051d('0x32'),'attributes':['id',_0x051d('0x33'),_0x051d('0x34')]}]})[_0x051d('0xd')](function(_0xca9327){var _0x19e33e=[];var _0x178a66=[];for(var _0x5b5557=0x0;_0x5b5557<_0xca9327[_0x051d('0x35')];_0x5b5557+=0x1){if(!_0x178a66[_0x051d('0x36')](_0xca9327[_0x5b5557][_0x051d('0x37')])){_0x178a66[_0x051d('0x38')](_0xca9327[_0x5b5557]['UserId']);_0x19e33e[_0x051d('0x38')](_0xca9327[_0x5b5557][_0x051d('0x25')](_0x5560a2[_0x051d('0x26')],{'transaction':_0x1e6ba9}));}}return BPromise[_0x051d('0x39')](_0x19e33e);});})['then'](function(_0x3f2258){logger[_0x051d('0xe')]('GetContactDialer',_0x5560a2);logger[_0x051d('0x11')](_0x051d('0x3a'),_0x5560a2,JSON['stringify'](_0x3f2258));_0x334f68(_0x3f2258);})[_0x051d('0x16')](function(_0x17ce79){logger[_0x051d('0x13')](_0x051d('0x3a'),_0x17ce79[_0x051d('0x14')],_0x5560a2);_0x1b9a48(_0xcae4a3[_0x051d('0x13')](0x1f4,_0x17ce79[_0x051d('0x14')]));});});});};exports[_0x051d('0x3b')]=function(_0x1a4d2d){var _0x25d8bf=this;return new Promise(function(_0x3b9a14,_0x4c7e47){return db['sequelize'][_0x051d('0x2c')](function(_0x30a013){return db[_0x051d('0x3c')]['create'](_0x1a4d2d[_0x051d('0x26')],{'raw':_0x1a4d2d[_0x051d('0x19')]?_0x1a4d2d[_0x051d('0x19')][_0x051d('0x1a')]===undefined?!![]:![]:!![],'transaction':_0x30a013})[_0x051d('0xd')](function(){return db[_0x051d('0x22')]['destroy']({'where':_0x1a4d2d[_0x051d('0x19')]?_0x1a4d2d[_0x051d('0x19')][_0x051d('0x1b')]||null:null,'transaction':_0x30a013});});})[_0x051d('0xd')](function(_0x3b2f53){logger[_0x051d('0xe')](_0x051d('0x3b'),_0x1a4d2d);logger[_0x051d('0x11')]('MoveContactManagedDialer',_0x1a4d2d,JSON['stringify'](_0x3b2f53));_0x3b9a14(_0x3b2f53);})[_0x051d('0x16')](function(_0x44dc76){logger[_0x051d('0x13')](_0x051d('0x3b'),_0x44dc76[_0x051d('0x14')],_0x1a4d2d);_0x4c7e47(_0x25d8bf['error'](0x1f4,_0x44dc76[_0x051d('0x14')]));});});};exports[_0x051d('0x3d')]=function(_0x4d84f5){var _0x33000d=this;return new Promise(function(_0x22d3bd,_0xfdee44){return db[_0x051d('0x22')][_0x051d('0x18')]({'raw':_0x4d84f5[_0x051d('0x19')]?_0x4d84f5[_0x051d('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x4d84f5['options']?_0x4d84f5['options'][_0x051d('0x1b')]||null:null,'attributes':[[db[_0x051d('0x2b')]['fn'](_0x051d('0x3e'),db[_0x051d('0x2b')]['fn']('IF',db['sequelize'][_0x051d('0x3f')](_0x051d('0x40')+util[_0x051d('0x41')]('\x22%s\x22',moment()[_0x051d('0x41')](_0x051d('0x42')))+'\x20,\x201,\x20null'))),_0x051d('0x43')]]})['then'](function(_0x30fb00){logger['info'](_0x051d('0x3d'),_0x4d84f5);logger[_0x051d('0x11')](_0x051d('0x3d'),_0x4d84f5,JSON[_0x051d('0x12')](_0x30fb00));_0x22d3bd(_0x30fb00);})[_0x051d('0x16')](function(_0x2e7d6f){logger['error']('CountReScheduled',_0x2e7d6f[_0x051d('0x14')],_0x4d84f5);_0xfdee44(_0x33000d['error'](0x1f4,_0x2e7d6f['message']));});});};exports[_0x051d('0x44')]=function(_0x459ae4){var _0x20f86d=this;return new Promise(function(_0x17b651,_0x18aa82){return db[_0x051d('0x29')][_0x051d('0x2a')]()['then'](function(_0x1d77d7){return db[_0x051d('0x2b')][_0x051d('0x2c')](function(_0x8913de){return db[_0x051d('0x22')][_0x051d('0x18')]({'where':_0x459ae4[_0x051d('0x19')]?_0x459ae4[_0x051d('0x19')][_0x051d('0x1b')]||null:null,'attributes':_0x459ae4[_0x051d('0x19')]?_0x459ae4[_0x051d('0x19')][_0x051d('0x1c')]||null:null,'limit':0x1,'order':_0x459ae4[_0x051d('0x19')]?_0x459ae4[_0x051d('0x19')][_0x051d('0x2d')]||null:null,'group':db[_0x051d('0x22')][_0x051d('0x37')],'transaction':_0x8913de,'lock':_0x8913de['LOCK'][_0x051d('0x2f')],'include':_0x459ae4[_0x051d('0x19')]?_0x459ae4[_0x051d('0x19')][_0x051d('0x1e')]?_[_0x051d('0x1f')](_0x459ae4['options'][_0x051d('0x1e')],function(_0x1c05b4){return{'model':db[_0x1c05b4['model']],'as':_0x1c05b4['as'],'attributes':_0x1c05b4[_0x051d('0x1c')],'include':_0x1c05b4[_0x051d('0x1e')]?_['map'](_0x1c05b4[_0x051d('0x1e')],function(_0x9f3d2b){return{'model':db[_0x9f3d2b[_0x051d('0x20')]],'as':_0x9f3d2b['as'],'attributes':_0x9f3d2b[_0x051d('0x1c')],'include':_0x9f3d2b[_0x051d('0x1e')]?_[_0x051d('0x1f')](_0x9f3d2b[_0x051d('0x1e')],function(_0x1bd19e){return{'model':db[_0x1bd19e['model']],'as':_0x1bd19e['as'],'attributes':_0x1bd19e[_0x051d('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x051d('0xd')](function(_0x8d297f){var _0x4b28f2=[];for(var _0x2798b0=0x0;_0x2798b0<_0x8d297f['length'];_0x2798b0+=0x1){_0x4b28f2[_0x051d('0x38')](_0x8d297f[_0x2798b0][_0x051d('0x25')](_0x459ae4[_0x051d('0x26')],{'transaction':_0x8913de}));}return BPromise[_0x051d('0x39')](_0x4b28f2);});})[_0x051d('0xd')](function(_0x1b6f73){logger[_0x051d('0xe')](_0x051d('0x44'),_0x459ae4);logger[_0x051d('0x11')](_0x051d('0x44'),_0x459ae4,JSON[_0x051d('0x12')](_0x1b6f73));_0x17b651(_0x1b6f73);})[_0x051d('0x16')](function(_0x58c497){logger[_0x051d('0x13')](_0x051d('0x44'),_0x58c497[_0x051d('0x14')],_0x459ae4);_0x18aa82(_0x20f86d[_0x051d('0x13')](0x1f4,_0x58c497['message']));});});});};exports['GetCmHopperPreview']=function(_0x275b5d){var _0x5648d4=this;return new Promise(function(_0x3a3700,_0x55e537){db[_0x051d('0x29')]['describe']()[_0x051d('0xd')](function(_0x3ae4b0){return db[_0x051d('0x22')][_0x051d('0x18')]({'raw':_0x275b5d[_0x051d('0x19')]?_0x275b5d[_0x051d('0x19')][_0x051d('0x1a')]===undefined?!![]:![]:!![],'where':_0x275b5d['options']?_0x275b5d['options'][_0x051d('0x1b')]||null:null,'attributes':_0x275b5d[_0x051d('0x19')]?_0x275b5d[_0x051d('0x19')][_0x051d('0x1c')]||null:null,'limit':_0x275b5d[_0x051d('0x19')]?_0x275b5d[_0x051d('0x19')][_0x051d('0x1d')]||null:null,'include':_0x275b5d['options']?_0x275b5d[_0x051d('0x19')]['include']?_['map'](_0x275b5d['options'][_0x051d('0x1e')],function(_0x19c8fa){return{'model':db[_0x19c8fa[_0x051d('0x20')]],'as':_0x19c8fa['as'],'attributes':_0x19c8fa['as']===_0x051d('0x30')?_[_0x051d('0x31')](_0x3ae4b0):_0x19c8fa[_0x051d('0x1c')],'include':_0x19c8fa[_0x051d('0x1e')]?_[_0x051d('0x1f')](_0x19c8fa[_0x051d('0x1e')],function(_0x2b776c){return{'model':db[_0x2b776c[_0x051d('0x20')]],'as':_0x2b776c['as'],'attributes':_0x2b776c[_0x051d('0x1c')],'include':_0x2b776c['include']?_[_0x051d('0x1f')](_0x2b776c[_0x051d('0x1e')],function(_0x29a889){return{'model':db[_0x29a889[_0x051d('0x20')]],'as':_0x29a889['as'],'attributes':_0x29a889['attributes']};}):[]};}):[]};}):[]:[]})[_0x051d('0xd')](function(_0x4dab2a){logger[_0x051d('0xe')](_0x051d('0x17'),_0x275b5d);logger[_0x051d('0x11')](_0x051d('0x17'),_0x275b5d,JSON[_0x051d('0x12')](_0x4dab2a));_0x3a3700(_0x4dab2a);})[_0x051d('0x16')](function(_0x5ae783){logger[_0x051d('0x13')](_0x051d('0x17'),_0x5ae783[_0x051d('0x14')],_0x275b5d);_0x55e537(_0x5648d4[_0x051d('0x13')](0x1f4,_0x5ae783[_0x051d('0x14')]));});});});};
\ No newline at end of file