Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / cmHopper / cmHopper.rpc.js
index b229da8..0bdd8af 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7d37=['log','req\x20value','phone\x20value','phone','findOne','getcontactbyohone','getContactByPhone','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','http','request','then','info','request\x20sent','CmHopper,\x20%s,\x20%s,\x20%s','stringify','error','code','CmHopper,\x20%s,\x20%s','message','catch','GetCmHopper','CmHopper','findAll','options','raw','where','attributes','limit','include','map','model','debug','ShowCmHopper','create','body','CreateCmHopper','UpdateCmHopper','DestroyCmHopper','destroy','GetContactDialer','CmContact','transaction','LOCK','UPDATE','Contact','User','Agent','voicePause','length','includes','UserId','update','sequelize','CmHopperFinal','MoveContactManagedDialer','CountReScheduled','COUNT','`scheduledat`\x20>=\x20','format','\x22%s\x22','YYYY-MM-DD\x20HH:mm:ss','\x20,\x201,\x20null','GetContactRecallMe','order','push','all','GetCmHopperPreview','describe','keys','GetContactByPhone'];(function(_0x51d129,_0x175d7d){var _0x44c377=function(_0x5ee454){while(--_0x5ee454){_0x51d129['push'](_0x51d129['shift']());}};_0x44c377(++_0x175d7d);}(_0x7d37,0x1db));var _0x77d3=function(_0x184759,_0x869683){_0x184759=_0x184759-0x0;var _0x455498=_0x7d37[_0x184759];return _0x455498;};'use strict';var _=require(_0x77d3('0x0'));var util=require(_0x77d3('0x1'));var moment=require(_0x77d3('0x2'));var BPromise=require('bluebird');var rs=require(_0x77d3('0x3'));var fs=require('fs');var Redis=require(_0x77d3('0x4'));var db=require(_0x77d3('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x77d3('0x6'))(_0x77d3('0x7'));var config=require('../../config/environment');var jayson=require(_0x77d3('0x8'));var client=jayson['client'][_0x77d3('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x519c6e,_0x40235d,_0x373da8){return new BPromise(function(_0x5c0108,_0x555390){return client[_0x77d3('0xa')](_0x519c6e,_0x373da8)[_0x77d3('0xb')](function(_0x506caa){logger[_0x77d3('0xc')]('CmHopper,\x20%s,\x20%s',_0x40235d,_0x77d3('0xd'));logger['debug'](_0x77d3('0xe'),_0x40235d,'request\x20sent',JSON[_0x77d3('0xf')](_0x506caa));if(_0x506caa[_0x77d3('0x10')]){if(_0x506caa[_0x77d3('0x10')][_0x77d3('0x11')]===0x1f4){logger[_0x77d3('0x10')](_0x77d3('0x12'),_0x40235d,_0x506caa[_0x77d3('0x10')][_0x77d3('0x13')]);return _0x555390(_0x506caa[_0x77d3('0x10')]['message']);}logger[_0x77d3('0x10')]('CmHopper,\x20%s,\x20%s',_0x40235d,_0x506caa['error']['message']);return _0x5c0108(_0x506caa[_0x77d3('0x10')][_0x77d3('0x13')]);}else{logger[_0x77d3('0xc')](_0x77d3('0x12'),_0x40235d,_0x77d3('0xd'));_0x5c0108(_0x506caa['result'][_0x77d3('0x13')]);}})[_0x77d3('0x14')](function(_0x5e92d8){logger['error'](_0x77d3('0x12'),_0x40235d,_0x5e92d8);_0x555390(_0x5e92d8);});});}exports[_0x77d3('0x15')]=function(_0x60173f){var _0x4500a2=this;return new Promise(function(_0x144656,_0x1378a5){return db[_0x77d3('0x16')][_0x77d3('0x17')]({'raw':_0x60173f[_0x77d3('0x18')]?_0x60173f[_0x77d3('0x18')][_0x77d3('0x19')]===undefined?!![]:![]:!![],'where':_0x60173f[_0x77d3('0x18')]?_0x60173f[_0x77d3('0x18')][_0x77d3('0x1a')]||null:null,'attributes':_0x60173f[_0x77d3('0x18')]?_0x60173f[_0x77d3('0x18')][_0x77d3('0x1b')]||null:null,'limit':_0x60173f[_0x77d3('0x18')]?_0x60173f['options'][_0x77d3('0x1c')]||null:null,'include':_0x60173f[_0x77d3('0x18')]?_0x60173f[_0x77d3('0x18')][_0x77d3('0x1d')]?_[_0x77d3('0x1e')](_0x60173f[_0x77d3('0x18')][_0x77d3('0x1d')],function(_0x17e9f9){return{'model':db[_0x17e9f9[_0x77d3('0x1f')]],'as':_0x17e9f9['as'],'attributes':_0x17e9f9['attributes'],'include':_0x17e9f9[_0x77d3('0x1d')]?_['map'](_0x17e9f9[_0x77d3('0x1d')],function(_0x443aa6){return{'model':db[_0x443aa6[_0x77d3('0x1f')]],'as':_0x443aa6['as'],'attributes':_0x443aa6[_0x77d3('0x1b')],'include':_0x443aa6[_0x77d3('0x1d')]?_[_0x77d3('0x1e')](_0x443aa6['include'],function(_0x17c6c6){return{'model':db[_0x17c6c6[_0x77d3('0x1f')]],'as':_0x17c6c6['as'],'attributes':_0x17c6c6[_0x77d3('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x77d3('0xb')](function(_0x451c1a){logger[_0x77d3('0xc')](_0x77d3('0x15'),_0x60173f);logger[_0x77d3('0x20')](_0x77d3('0x15'),_0x60173f,JSON[_0x77d3('0xf')](_0x451c1a));_0x144656(_0x451c1a);})['catch'](function(_0x3add49){logger[_0x77d3('0x10')]('GetCmHopper',_0x3add49[_0x77d3('0x13')],_0x60173f);_0x1378a5(_0x4500a2[_0x77d3('0x10')](0x1f4,_0x3add49['message']));});});};exports['ShowCmHopper']=function(_0x2f4542){var _0x582575=this;return new Promise(function(_0xb9ebbb,_0x14e933){return db[_0x77d3('0x16')]['find']({'raw':_0x2f4542['options']?_0x2f4542['options'][_0x77d3('0x19')]===undefined?!![]:![]:!![],'where':_0x2f4542[_0x77d3('0x18')]?_0x2f4542[_0x77d3('0x18')][_0x77d3('0x1a')]||null:null,'attributes':_0x2f4542[_0x77d3('0x18')]?_0x2f4542[_0x77d3('0x18')][_0x77d3('0x1b')]||null:null,'include':_0x2f4542[_0x77d3('0x18')]?_0x2f4542['options']['include']?_[_0x77d3('0x1e')](_0x2f4542[_0x77d3('0x18')]['include'],function(_0x5e7a57){return{'model':db[_0x5e7a57['model']],'as':_0x5e7a57['as'],'attributes':_0x5e7a57[_0x77d3('0x1b')],'include':_0x5e7a57[_0x77d3('0x1d')]?_[_0x77d3('0x1e')](_0x5e7a57[_0x77d3('0x1d')],function(_0x453956){return{'model':db[_0x453956['model']],'as':_0x453956['as'],'attributes':_0x453956['attributes'],'include':_0x453956[_0x77d3('0x1d')]?_[_0x77d3('0x1e')](_0x453956[_0x77d3('0x1d')],function(_0x248534){return{'model':db[_0x248534[_0x77d3('0x1f')]],'as':_0x248534['as'],'attributes':_0x248534[_0x77d3('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x77d3('0xb')](function(_0x1bd366){logger[_0x77d3('0xc')](_0x77d3('0x21'),_0x2f4542);logger['debug']('ShowCmHopper',_0x2f4542,JSON[_0x77d3('0xf')](_0x1bd366));_0xb9ebbb(_0x1bd366);})['catch'](function(_0xd34464){logger['error'](_0x77d3('0x21'),_0xd34464['message'],_0x2f4542);_0x14e933(_0x582575[_0x77d3('0x10')](0x1f4,_0xd34464[_0x77d3('0x13')]));});});};exports['CreateCmHopper']=function(_0x443b6b){var _0x4580ee=this;return new Promise(function(_0x519e80,_0x163fa5){return db[_0x77d3('0x16')][_0x77d3('0x22')](_0x443b6b[_0x77d3('0x23')],{'raw':_0x443b6b[_0x77d3('0x18')]?_0x443b6b[_0x77d3('0x18')][_0x77d3('0x19')]===undefined?!![]:![]:!![]})[_0x77d3('0xb')](function(_0x5a12e4){logger[_0x77d3('0xc')](_0x77d3('0x24'),_0x443b6b);logger[_0x77d3('0x20')](_0x77d3('0x24'),_0x443b6b,JSON[_0x77d3('0xf')](_0x5a12e4));_0x519e80(_0x5a12e4);})[_0x77d3('0x14')](function(_0x2986ca){logger[_0x77d3('0x10')](_0x77d3('0x24'),_0x2986ca[_0x77d3('0x13')],_0x443b6b);_0x163fa5(_0x4580ee[_0x77d3('0x10')](0x1f4,_0x2986ca[_0x77d3('0x13')]));});});};exports[_0x77d3('0x25')]=function(_0x23f72e){var _0x553215=this;return new Promise(function(_0x316441,_0x37ea08){return db[_0x77d3('0x16')]['update'](_0x23f72e['body'],{'raw':_0x23f72e['options']?_0x23f72e[_0x77d3('0x18')][_0x77d3('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x23f72e[_0x77d3('0x18')]?_0x23f72e[_0x77d3('0x18')][_0x77d3('0x1a')]||null:null,'attributes':_0x23f72e[_0x77d3('0x18')]?_0x23f72e['options']['attributes']||null:null,'limit':_0x23f72e[_0x77d3('0x18')]?_0x23f72e[_0x77d3('0x18')][_0x77d3('0x1c')]||null:null})['then'](function(_0x4ef56b){logger[_0x77d3('0xc')](_0x77d3('0x25'),_0x23f72e);logger['debug'](_0x77d3('0x25'),_0x23f72e,JSON['stringify'](_0x4ef56b));_0x316441(_0x4ef56b);})['catch'](function(_0x209dee){logger[_0x77d3('0x10')](_0x77d3('0x25'),_0x209dee[_0x77d3('0x13')],_0x23f72e);_0x37ea08(_0x553215[_0x77d3('0x10')](0x1f4,_0x209dee[_0x77d3('0x13')]));});});};exports[_0x77d3('0x26')]=function(_0xe38d91){var _0x5795c3=this;return new Promise(function(_0x3a08d7,_0x42148b){return db[_0x77d3('0x16')][_0x77d3('0x27')]({'where':_0xe38d91[_0x77d3('0x18')]?_0xe38d91[_0x77d3('0x18')][_0x77d3('0x1a')]||null:null})[_0x77d3('0xb')](function(_0x3ee816){logger[_0x77d3('0xc')]('DestroyCmHopper',_0xe38d91);logger[_0x77d3('0x20')](_0x77d3('0x26'),_0xe38d91,JSON['stringify'](_0x3ee816));_0x3a08d7(_0x3ee816);})['catch'](function(_0x5c2dd6){logger[_0x77d3('0x10')]('DestroyCmHopper',_0x5c2dd6[_0x77d3('0x13')],_0xe38d91);_0x42148b(_0x5795c3[_0x77d3('0x10')](0x1f4,_0x5c2dd6[_0x77d3('0x13')]));});});};exports[_0x77d3('0x28')]=function(_0x33ae34){var _0x53abac=this;return new Promise(function(_0x1b8917,_0x514688){return db[_0x77d3('0x29')]['describe']()['then'](function(_0x3d5def){return db['sequelize'][_0x77d3('0x2a')](function(_0x204d5b){return db['CmHopper'][_0x77d3('0x17')]({'where':_0x33ae34[_0x77d3('0x18')]?_0x33ae34[_0x77d3('0x18')][_0x77d3('0x1a')]||null:null,'attributes':_0x33ae34[_0x77d3('0x18')]?_0x33ae34[_0x77d3('0x18')][_0x77d3('0x1b')]||null:null,'limit':_0x33ae34[_0x77d3('0x18')]?_0x33ae34[_0x77d3('0x18')][_0x77d3('0x1c')]||null:null,'order':_0x33ae34['options']?_0x33ae34[_0x77d3('0x18')]['order']||null:null,'transaction':_0x204d5b,'lock':_0x204d5b[_0x77d3('0x2b')][_0x77d3('0x2c')],'include':[{'model':db['CmContact'],'as':_0x77d3('0x2d'),'attributes':_['keys'](_0x3d5def)},{'model':db[_0x77d3('0x2e')],'as':_0x77d3('0x2f'),'attributes':['id','name',_0x77d3('0x30')]}]})['then'](function(_0x47717d){var _0x1be357=[];var _0x54e798=[];for(var _0x2deccb=0x0;_0x2deccb<_0x47717d[_0x77d3('0x31')];_0x2deccb+=0x1){if(!_0x54e798[_0x77d3('0x32')](_0x47717d[_0x2deccb][_0x77d3('0x33')])){_0x54e798['push'](_0x47717d[_0x2deccb][_0x77d3('0x33')]);_0x1be357['push'](_0x47717d[_0x2deccb][_0x77d3('0x34')](_0x33ae34['body'],{'transaction':_0x204d5b}));}}return BPromise['all'](_0x1be357);});})[_0x77d3('0xb')](function(_0x5906b7){logger[_0x77d3('0xc')](_0x77d3('0x28'),_0x33ae34);logger[_0x77d3('0x20')](_0x77d3('0x28'),_0x33ae34,JSON[_0x77d3('0xf')](_0x5906b7));_0x1b8917(_0x5906b7);})[_0x77d3('0x14')](function(_0x4d194c){logger[_0x77d3('0x10')](_0x77d3('0x28'),_0x4d194c[_0x77d3('0x13')],_0x33ae34);_0x514688(_0x53abac['error'](0x1f4,_0x4d194c[_0x77d3('0x13')]));});});});};exports['MoveContactManagedDialer']=function(_0x36282f){var _0x28c099=this;return new Promise(function(_0xf358a9,_0x1357b7){return db[_0x77d3('0x35')][_0x77d3('0x2a')](function(_0x5ac0ec){return db[_0x77d3('0x36')][_0x77d3('0x22')](_0x36282f['body'],{'raw':_0x36282f[_0x77d3('0x18')]?_0x36282f[_0x77d3('0x18')][_0x77d3('0x19')]===undefined?!![]:![]:!![],'transaction':_0x5ac0ec})[_0x77d3('0xb')](function(){return db[_0x77d3('0x16')][_0x77d3('0x27')]({'where':_0x36282f[_0x77d3('0x18')]?_0x36282f[_0x77d3('0x18')][_0x77d3('0x1a')]||null:null,'transaction':_0x5ac0ec});});})[_0x77d3('0xb')](function(_0x49509d){logger[_0x77d3('0xc')]('MoveContactManagedDialer',_0x36282f);logger['debug']('MoveContactManagedDialer',_0x36282f,JSON[_0x77d3('0xf')](_0x49509d));_0xf358a9(_0x49509d);})[_0x77d3('0x14')](function(_0x51ec05){logger[_0x77d3('0x10')](_0x77d3('0x37'),_0x51ec05[_0x77d3('0x13')],_0x36282f);_0x1357b7(_0x28c099[_0x77d3('0x10')](0x1f4,_0x51ec05[_0x77d3('0x13')]));});});};exports[_0x77d3('0x38')]=function(_0x353147){var _0x334927=this;return new Promise(function(_0x2c2dc0,_0x4fa657){return db[_0x77d3('0x16')]['findAll']({'raw':_0x353147[_0x77d3('0x18')]?_0x353147[_0x77d3('0x18')][_0x77d3('0x19')]===undefined?!![]:![]:!![],'where':_0x353147[_0x77d3('0x18')]?_0x353147['options'][_0x77d3('0x1a')]||null:null,'attributes':[[db[_0x77d3('0x35')]['fn'](_0x77d3('0x39'),db['sequelize']['fn']('IF',db[_0x77d3('0x35')]['literal'](_0x77d3('0x3a')+util[_0x77d3('0x3b')](_0x77d3('0x3c'),moment()['format'](_0x77d3('0x3d')))+_0x77d3('0x3e')))),'contactsRescheduled']]})[_0x77d3('0xb')](function(_0x4a240d){logger[_0x77d3('0xc')](_0x77d3('0x38'),_0x353147);logger[_0x77d3('0x20')](_0x77d3('0x38'),_0x353147,JSON[_0x77d3('0xf')](_0x4a240d));_0x2c2dc0(_0x4a240d);})[_0x77d3('0x14')](function(_0x18d806){logger[_0x77d3('0x10')]('CountReScheduled',_0x18d806[_0x77d3('0x13')],_0x353147);_0x4fa657(_0x334927[_0x77d3('0x10')](0x1f4,_0x18d806[_0x77d3('0x13')]));});});};exports[_0x77d3('0x3f')]=function(_0x5205ce){var _0x233274=this;return new Promise(function(_0x4cc3ab,_0x3dfa5f){return db[_0x77d3('0x29')]['describe']()[_0x77d3('0xb')](function(_0x17098b){return db[_0x77d3('0x35')][_0x77d3('0x2a')](function(_0x5f5a05){return db['CmHopper'][_0x77d3('0x17')]({'where':_0x5205ce[_0x77d3('0x18')]?_0x5205ce[_0x77d3('0x18')]['where']||null:null,'attributes':_0x5205ce[_0x77d3('0x18')]?_0x5205ce['options'][_0x77d3('0x1b')]||null:null,'limit':0x1,'order':_0x5205ce[_0x77d3('0x18')]?_0x5205ce[_0x77d3('0x18')][_0x77d3('0x40')]||null:null,'group':db['CmHopper']['UserId'],'transaction':_0x5f5a05,'lock':_0x5f5a05[_0x77d3('0x2b')][_0x77d3('0x2c')],'include':_0x5205ce[_0x77d3('0x18')]?_0x5205ce[_0x77d3('0x18')][_0x77d3('0x1d')]?_['map'](_0x5205ce['options'][_0x77d3('0x1d')],function(_0x307726){return{'model':db[_0x307726[_0x77d3('0x1f')]],'as':_0x307726['as'],'attributes':_0x307726[_0x77d3('0x1b')],'include':_0x307726[_0x77d3('0x1d')]?_[_0x77d3('0x1e')](_0x307726[_0x77d3('0x1d')],function(_0x29a0fa){return{'model':db[_0x29a0fa[_0x77d3('0x1f')]],'as':_0x29a0fa['as'],'attributes':_0x29a0fa['attributes'],'include':_0x29a0fa['include']?_[_0x77d3('0x1e')](_0x29a0fa['include'],function(_0x475fd1){return{'model':db[_0x475fd1[_0x77d3('0x1f')]],'as':_0x475fd1['as'],'attributes':_0x475fd1[_0x77d3('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x77d3('0xb')](function(_0x8d6bec){var _0x42bdaa=[];for(var _0xa9fcc4=0x0;_0xa9fcc4<_0x8d6bec[_0x77d3('0x31')];_0xa9fcc4+=0x1){_0x42bdaa[_0x77d3('0x41')](_0x8d6bec[_0xa9fcc4][_0x77d3('0x34')](_0x5205ce['body'],{'transaction':_0x5f5a05}));}return BPromise[_0x77d3('0x42')](_0x42bdaa);});})[_0x77d3('0xb')](function(_0x1ad4d7){logger['info']('GetContactRecallMe',_0x5205ce);logger[_0x77d3('0x20')](_0x77d3('0x3f'),_0x5205ce,JSON[_0x77d3('0xf')](_0x1ad4d7));_0x4cc3ab(_0x1ad4d7);})['catch'](function(_0xe13fff){logger['error']('GetContactRecallMe',_0xe13fff[_0x77d3('0x13')],_0x5205ce);_0x3dfa5f(_0x233274[_0x77d3('0x10')](0x1f4,_0xe13fff[_0x77d3('0x13')]));});});});};exports[_0x77d3('0x43')]=function(_0x706e71){var _0x2e42a9=this;return new Promise(function(_0x333deb,_0x444e39){db[_0x77d3('0x29')][_0x77d3('0x44')]()[_0x77d3('0xb')](function(_0x2afce7){return db[_0x77d3('0x16')][_0x77d3('0x17')]({'raw':_0x706e71['options']?_0x706e71[_0x77d3('0x18')][_0x77d3('0x19')]===undefined?!![]:![]:!![],'where':_0x706e71[_0x77d3('0x18')]?_0x706e71['options'][_0x77d3('0x1a')]||null:null,'attributes':_0x706e71[_0x77d3('0x18')]?_0x706e71[_0x77d3('0x18')][_0x77d3('0x1b')]||null:null,'limit':_0x706e71[_0x77d3('0x18')]?_0x706e71[_0x77d3('0x18')][_0x77d3('0x1c')]||null:null,'include':_0x706e71['options']?_0x706e71[_0x77d3('0x18')][_0x77d3('0x1d')]?_['map'](_0x706e71[_0x77d3('0x18')]['include'],function(_0x17041b){return{'model':db[_0x17041b['model']],'as':_0x17041b['as'],'attributes':_0x17041b['as']===_0x77d3('0x2d')?_[_0x77d3('0x45')](_0x2afce7):_0x17041b[_0x77d3('0x1b')],'include':_0x17041b[_0x77d3('0x1d')]?_[_0x77d3('0x1e')](_0x17041b[_0x77d3('0x1d')],function(_0xca6905){return{'model':db[_0xca6905[_0x77d3('0x1f')]],'as':_0xca6905['as'],'attributes':_0xca6905[_0x77d3('0x1b')],'include':_0xca6905['include']?_['map'](_0xca6905[_0x77d3('0x1d')],function(_0x3a2cea){return{'model':db[_0x3a2cea[_0x77d3('0x1f')]],'as':_0x3a2cea['as'],'attributes':_0x3a2cea[_0x77d3('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x259893){logger[_0x77d3('0xc')](_0x77d3('0x15'),_0x706e71);logger[_0x77d3('0x20')](_0x77d3('0x15'),_0x706e71,JSON[_0x77d3('0xf')](_0x259893));_0x333deb(_0x259893);})[_0x77d3('0x14')](function(_0x7a963f){logger[_0x77d3('0x10')](_0x77d3('0x15'),_0x7a963f[_0x77d3('0x13')],_0x706e71);_0x444e39(_0x2e42a9[_0x77d3('0x10')](0x1f4,_0x7a963f['message']));});});});};exports[_0x77d3('0x46')]=function(_0x16030d){console[_0x77d3('0x47')](_0x77d3('0x48'),_0x16030d);console['log'](_0x77d3('0x49'),_0x16030d['options'][_0x77d3('0x1a')][_0x77d3('0x4a')]);_this=this;return new Promise(function(_0x19453c,_0x10b769){return db[_0x77d3('0x29')][_0x77d3('0x4b')]({'raw':!![],'where':{'phone':_0x16030d[_0x77d3('0x18')][_0x77d3('0x1a')][_0x77d3('0x4a')]},'attributes':['id','dialTimezone'],'order':[['id','DESC']]})[_0x77d3('0xb')](function(_0x1d0f90){console['log'](_0x77d3('0x4c'),_0x1d0f90);logger['info']('getContactByPhone',_0x16030d);logger[_0x77d3('0x20')]('getContactByPhone',_0x16030d,JSON[_0x77d3('0xf')](_0x1d0f90));_0x19453c(_0x1d0f90);})[_0x77d3('0x14')](function(_0x5ce533){logger['error'](_0x77d3('0x4d'),_0x5ce533[_0x77d3('0x13')],_0x16030d);_0x10b769(_this[_0x77d3('0x10')](0x1f4,_0x5ce533['message']));});});};
\ No newline at end of file
+var _0x7837=['format','\x22%s\x22','\x20,\x201,\x20null','contactsRescheduled','CountReScheduled','GetContactRecallMe','LOCK','GetCmHopperPreview','GetContactByPhone','log','req\x20value','phone\x20value','findOne','phone','getContactByPhone','lodash','util','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','request','then','CmHopper,\x20%s,\x20%s','request\x20sent','debug','CmHopper,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetCmHopper','CmHopper','findAll','options','raw','attributes','limit','include','model','map','info','ShowCmHopper','find','where','create','CreateCmHopper','UpdateCmHopper','destroy','DestroyCmHopper','GetContactDialer','CmContact','describe','sequelize','order','UPDATE','Contact','keys','User','Agent','name','voicePause','includes','UserId','push','body','all','MoveContactManagedDialer','transaction','CmHopperFinal','`scheduledat`\x20>=\x20'];(function(_0x581bdb,_0x2ed81b){var _0x250669=function(_0x36926e){while(--_0x36926e){_0x581bdb['push'](_0x581bdb['shift']());}};_0x250669(++_0x2ed81b);}(_0x7837,0xf3));var _0x7783=function(_0x44abd1,_0x5246b4){_0x44abd1=_0x44abd1-0x0;var _0x1f68e9=_0x7837[_0x44abd1];return _0x1f68e9;};'use strict';var _=require(_0x7783('0x0'));var util=require(_0x7783('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x7783('0x2'));var fs=require('fs');var Redis=require(_0x7783('0x3'));var db=require(_0x7783('0x4'))['db'];var utils=require(_0x7783('0x5'));var logger=require(_0x7783('0x6'))(_0x7783('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x7783('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x59b2e6,_0x277ae3,_0x2bec94){return new BPromise(function(_0x173374,_0x46c8e2){return client[_0x7783('0x9')](_0x59b2e6,_0x2bec94)[_0x7783('0xa')](function(_0x8f7900){logger['info'](_0x7783('0xb'),_0x277ae3,_0x7783('0xc'));logger[_0x7783('0xd')](_0x7783('0xe'),_0x277ae3,_0x7783('0xc'),JSON[_0x7783('0xf')](_0x8f7900));if(_0x8f7900[_0x7783('0x10')]){if(_0x8f7900[_0x7783('0x10')][_0x7783('0x11')]===0x1f4){logger['error']('CmHopper,\x20%s,\x20%s',_0x277ae3,_0x8f7900[_0x7783('0x10')]['message']);return _0x46c8e2(_0x8f7900[_0x7783('0x10')]['message']);}logger[_0x7783('0x10')](_0x7783('0xb'),_0x277ae3,_0x8f7900[_0x7783('0x10')][_0x7783('0x12')]);return _0x173374(_0x8f7900['error'][_0x7783('0x12')]);}else{logger['info'](_0x7783('0xb'),_0x277ae3,'request\x20sent');_0x173374(_0x8f7900[_0x7783('0x13')][_0x7783('0x12')]);}})[_0x7783('0x14')](function(_0xef698){logger[_0x7783('0x10')](_0x7783('0xb'),_0x277ae3,_0xef698);_0x46c8e2(_0xef698);});});}exports[_0x7783('0x15')]=function(_0x9e4acf){var _0x2a95b9=this;return new Promise(function(_0x24f950,_0x111e5e){return db[_0x7783('0x16')][_0x7783('0x17')]({'raw':_0x9e4acf[_0x7783('0x18')]?_0x9e4acf[_0x7783('0x18')][_0x7783('0x19')]===undefined?!![]:![]:!![],'where':_0x9e4acf[_0x7783('0x18')]?_0x9e4acf[_0x7783('0x18')]['where']||null:null,'attributes':_0x9e4acf[_0x7783('0x18')]?_0x9e4acf[_0x7783('0x18')][_0x7783('0x1a')]||null:null,'limit':_0x9e4acf[_0x7783('0x18')]?_0x9e4acf['options'][_0x7783('0x1b')]||null:null,'include':_0x9e4acf['options']?_0x9e4acf[_0x7783('0x18')][_0x7783('0x1c')]?_['map'](_0x9e4acf[_0x7783('0x18')][_0x7783('0x1c')],function(_0x5ae057){return{'model':db[_0x5ae057[_0x7783('0x1d')]],'as':_0x5ae057['as'],'attributes':_0x5ae057[_0x7783('0x1a')],'include':_0x5ae057['include']?_['map'](_0x5ae057[_0x7783('0x1c')],function(_0x4066e4){return{'model':db[_0x4066e4['model']],'as':_0x4066e4['as'],'attributes':_0x4066e4[_0x7783('0x1a')],'include':_0x4066e4[_0x7783('0x1c')]?_[_0x7783('0x1e')](_0x4066e4[_0x7783('0x1c')],function(_0x3a6294){return{'model':db[_0x3a6294[_0x7783('0x1d')]],'as':_0x3a6294['as'],'attributes':_0x3a6294[_0x7783('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x7783('0xa')](function(_0x5b3d0a){logger[_0x7783('0x1f')](_0x7783('0x15'),_0x9e4acf);logger[_0x7783('0xd')]('GetCmHopper',_0x9e4acf,JSON[_0x7783('0xf')](_0x5b3d0a));_0x24f950(_0x5b3d0a);})[_0x7783('0x14')](function(_0x401778){logger[_0x7783('0x10')](_0x7783('0x15'),_0x401778[_0x7783('0x12')],_0x9e4acf);_0x111e5e(_0x2a95b9[_0x7783('0x10')](0x1f4,_0x401778['message']));});});};exports[_0x7783('0x20')]=function(_0x3eaf8e){var _0x3cbe28=this;return new Promise(function(_0x35785a,_0x430b7b){return db[_0x7783('0x16')][_0x7783('0x21')]({'raw':_0x3eaf8e[_0x7783('0x18')]?_0x3eaf8e[_0x7783('0x18')][_0x7783('0x19')]===undefined?!![]:![]:!![],'where':_0x3eaf8e[_0x7783('0x18')]?_0x3eaf8e[_0x7783('0x18')][_0x7783('0x22')]||null:null,'attributes':_0x3eaf8e[_0x7783('0x18')]?_0x3eaf8e[_0x7783('0x18')][_0x7783('0x1a')]||null:null,'include':_0x3eaf8e[_0x7783('0x18')]?_0x3eaf8e['options'][_0x7783('0x1c')]?_['map'](_0x3eaf8e[_0x7783('0x18')][_0x7783('0x1c')],function(_0x270957){return{'model':db[_0x270957[_0x7783('0x1d')]],'as':_0x270957['as'],'attributes':_0x270957['attributes'],'include':_0x270957[_0x7783('0x1c')]?_[_0x7783('0x1e')](_0x270957[_0x7783('0x1c')],function(_0x355589){return{'model':db[_0x355589[_0x7783('0x1d')]],'as':_0x355589['as'],'attributes':_0x355589[_0x7783('0x1a')],'include':_0x355589[_0x7783('0x1c')]?_[_0x7783('0x1e')](_0x355589[_0x7783('0x1c')],function(_0x369f78){return{'model':db[_0x369f78['model']],'as':_0x369f78['as'],'attributes':_0x369f78[_0x7783('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3bb28f){logger['info']('ShowCmHopper',_0x3eaf8e);logger[_0x7783('0xd')](_0x7783('0x20'),_0x3eaf8e,JSON[_0x7783('0xf')](_0x3bb28f));_0x35785a(_0x3bb28f);})['catch'](function(_0x5637d1){logger[_0x7783('0x10')](_0x7783('0x20'),_0x5637d1[_0x7783('0x12')],_0x3eaf8e);_0x430b7b(_0x3cbe28[_0x7783('0x10')](0x1f4,_0x5637d1['message']));});});};exports['CreateCmHopper']=function(_0xd4c25b){var _0x847b56=this;return new Promise(function(_0x2d0eb9,_0x35bc91){return db['CmHopper'][_0x7783('0x23')](_0xd4c25b['body'],{'raw':_0xd4c25b[_0x7783('0x18')]?_0xd4c25b[_0x7783('0x18')][_0x7783('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x26bd30){logger[_0x7783('0x1f')](_0x7783('0x24'),_0xd4c25b);logger[_0x7783('0xd')](_0x7783('0x24'),_0xd4c25b,JSON[_0x7783('0xf')](_0x26bd30));_0x2d0eb9(_0x26bd30);})[_0x7783('0x14')](function(_0xf8c67){logger['error'](_0x7783('0x24'),_0xf8c67[_0x7783('0x12')],_0xd4c25b);_0x35bc91(_0x847b56['error'](0x1f4,_0xf8c67['message']));});});};exports[_0x7783('0x25')]=function(_0x4fe220){var _0x45994b=this;return new Promise(function(_0x4d87a4,_0x14b951){return db[_0x7783('0x16')]['update'](_0x4fe220['body'],{'raw':_0x4fe220['options']?_0x4fe220[_0x7783('0x18')][_0x7783('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4fe220[_0x7783('0x18')]?_0x4fe220[_0x7783('0x18')][_0x7783('0x22')]||null:null,'attributes':_0x4fe220[_0x7783('0x18')]?_0x4fe220[_0x7783('0x18')][_0x7783('0x1a')]||null:null,'limit':_0x4fe220[_0x7783('0x18')]?_0x4fe220[_0x7783('0x18')][_0x7783('0x1b')]||null:null})[_0x7783('0xa')](function(_0x26f8e7){logger['info']('UpdateCmHopper',_0x4fe220);logger[_0x7783('0xd')](_0x7783('0x25'),_0x4fe220,JSON[_0x7783('0xf')](_0x26f8e7));_0x4d87a4(_0x26f8e7);})[_0x7783('0x14')](function(_0x4daa43){logger['error'](_0x7783('0x25'),_0x4daa43['message'],_0x4fe220);_0x14b951(_0x45994b[_0x7783('0x10')](0x1f4,_0x4daa43[_0x7783('0x12')]));});});};exports['DestroyCmHopper']=function(_0x5e1d34){var _0x45df20=this;return new Promise(function(_0x86cf76,_0x3bbdad){return db[_0x7783('0x16')][_0x7783('0x26')]({'where':_0x5e1d34['options']?_0x5e1d34[_0x7783('0x18')]['where']||null:null})[_0x7783('0xa')](function(_0x17e079){logger[_0x7783('0x1f')](_0x7783('0x27'),_0x5e1d34);logger['debug'](_0x7783('0x27'),_0x5e1d34,JSON[_0x7783('0xf')](_0x17e079));_0x86cf76(_0x17e079);})[_0x7783('0x14')](function(_0x44a447){logger[_0x7783('0x10')](_0x7783('0x27'),_0x44a447[_0x7783('0x12')],_0x5e1d34);_0x3bbdad(_0x45df20[_0x7783('0x10')](0x1f4,_0x44a447[_0x7783('0x12')]));});});};exports[_0x7783('0x28')]=function(_0x1ac51f){var _0xe0a31e=this;return new Promise(function(_0x26ee52,_0x403b45){return db[_0x7783('0x29')][_0x7783('0x2a')]()[_0x7783('0xa')](function(_0x41badb){return db[_0x7783('0x2b')]['transaction'](function(_0x5b5a13){return db[_0x7783('0x16')]['findAll']({'where':_0x1ac51f[_0x7783('0x18')]?_0x1ac51f[_0x7783('0x18')][_0x7783('0x22')]||null:null,'attributes':_0x1ac51f[_0x7783('0x18')]?_0x1ac51f[_0x7783('0x18')][_0x7783('0x1a')]||null:null,'limit':_0x1ac51f[_0x7783('0x18')]?_0x1ac51f[_0x7783('0x18')][_0x7783('0x1b')]||null:null,'order':_0x1ac51f[_0x7783('0x18')]?_0x1ac51f['options'][_0x7783('0x2c')]||null:null,'transaction':_0x5b5a13,'lock':_0x5b5a13['LOCK'][_0x7783('0x2d')],'include':[{'model':db[_0x7783('0x29')],'as':_0x7783('0x2e'),'attributes':_[_0x7783('0x2f')](_0x41badb)},{'model':db[_0x7783('0x30')],'as':_0x7783('0x31'),'attributes':['id',_0x7783('0x32'),_0x7783('0x33')]}]})['then'](function(_0xcb8c04){var _0x4c6094=[];var _0x411086=[];for(var _0x25fd8f=0x0;_0x25fd8f<_0xcb8c04['length'];_0x25fd8f+=0x1){if(!_0x411086[_0x7783('0x34')](_0xcb8c04[_0x25fd8f][_0x7783('0x35')])){_0x411086[_0x7783('0x36')](_0xcb8c04[_0x25fd8f][_0x7783('0x35')]);_0x4c6094[_0x7783('0x36')](_0xcb8c04[_0x25fd8f]['update'](_0x1ac51f[_0x7783('0x37')],{'transaction':_0x5b5a13}));}}return BPromise[_0x7783('0x38')](_0x4c6094);});})[_0x7783('0xa')](function(_0x423499){logger[_0x7783('0x1f')](_0x7783('0x28'),_0x1ac51f);logger[_0x7783('0xd')](_0x7783('0x28'),_0x1ac51f,JSON[_0x7783('0xf')](_0x423499));_0x26ee52(_0x423499);})[_0x7783('0x14')](function(_0x25b63a){logger[_0x7783('0x10')](_0x7783('0x28'),_0x25b63a[_0x7783('0x12')],_0x1ac51f);_0x403b45(_0xe0a31e[_0x7783('0x10')](0x1f4,_0x25b63a[_0x7783('0x12')]));});});});};exports[_0x7783('0x39')]=function(_0x296648){var _0x79f722=this;return new Promise(function(_0x3c70be,_0x3bbd8b){return db[_0x7783('0x2b')][_0x7783('0x3a')](function(_0xcaca10){return db[_0x7783('0x3b')]['create'](_0x296648[_0x7783('0x37')],{'raw':_0x296648[_0x7783('0x18')]?_0x296648['options']['raw']===undefined?!![]:![]:!![],'transaction':_0xcaca10})[_0x7783('0xa')](function(){return db['CmHopper']['destroy']({'where':_0x296648[_0x7783('0x18')]?_0x296648[_0x7783('0x18')][_0x7783('0x22')]||null:null,'transaction':_0xcaca10});});})[_0x7783('0xa')](function(_0x3ebba9){logger[_0x7783('0x1f')](_0x7783('0x39'),_0x296648);logger[_0x7783('0xd')](_0x7783('0x39'),_0x296648,JSON[_0x7783('0xf')](_0x3ebba9));_0x3c70be(_0x3ebba9);})['catch'](function(_0x2a4962){logger[_0x7783('0x10')]('MoveContactManagedDialer',_0x2a4962['message'],_0x296648);_0x3bbd8b(_0x79f722[_0x7783('0x10')](0x1f4,_0x2a4962[_0x7783('0x12')]));});});};exports['CountReScheduled']=function(_0x5cda4e){var _0x31348e=this;return new Promise(function(_0x3b683d,_0x345fa3){return db[_0x7783('0x16')]['findAll']({'raw':_0x5cda4e['options']?_0x5cda4e['options'][_0x7783('0x19')]===undefined?!![]:![]:!![],'where':_0x5cda4e[_0x7783('0x18')]?_0x5cda4e[_0x7783('0x18')][_0x7783('0x22')]||null:null,'attributes':[[db[_0x7783('0x2b')]['fn']('COUNT',db[_0x7783('0x2b')]['fn']('IF',db[_0x7783('0x2b')]['literal'](_0x7783('0x3c')+util[_0x7783('0x3d')](_0x7783('0x3e'),moment()[_0x7783('0x3d')]('YYYY-MM-DD\x20HH:mm:ss'))+_0x7783('0x3f')))),_0x7783('0x40')]]})[_0x7783('0xa')](function(_0x2de591){logger['info'](_0x7783('0x41'),_0x5cda4e);logger['debug'](_0x7783('0x41'),_0x5cda4e,JSON['stringify'](_0x2de591));_0x3b683d(_0x2de591);})['catch'](function(_0x22d96d){logger['error']('CountReScheduled',_0x22d96d[_0x7783('0x12')],_0x5cda4e);_0x345fa3(_0x31348e[_0x7783('0x10')](0x1f4,_0x22d96d[_0x7783('0x12')]));});});};exports[_0x7783('0x42')]=function(_0x5a8279){var _0x5bec27=this;return new Promise(function(_0xd4e9eb,_0x4c7938){return db['CmContact'][_0x7783('0x2a')]()['then'](function(_0x4d1e39){return db[_0x7783('0x2b')][_0x7783('0x3a')](function(_0x44837b){return db[_0x7783('0x16')]['findAll']({'where':_0x5a8279['options']?_0x5a8279[_0x7783('0x18')][_0x7783('0x22')]||null:null,'attributes':_0x5a8279['options']?_0x5a8279['options'][_0x7783('0x1a')]||null:null,'limit':0x1,'order':_0x5a8279[_0x7783('0x18')]?_0x5a8279[_0x7783('0x18')][_0x7783('0x2c')]||null:null,'group':db[_0x7783('0x16')][_0x7783('0x35')],'transaction':_0x44837b,'lock':_0x44837b[_0x7783('0x43')][_0x7783('0x2d')],'include':_0x5a8279[_0x7783('0x18')]?_0x5a8279[_0x7783('0x18')][_0x7783('0x1c')]?_[_0x7783('0x1e')](_0x5a8279[_0x7783('0x18')]['include'],function(_0x476906){return{'model':db[_0x476906[_0x7783('0x1d')]],'as':_0x476906['as'],'attributes':_0x476906[_0x7783('0x1a')],'include':_0x476906['include']?_[_0x7783('0x1e')](_0x476906[_0x7783('0x1c')],function(_0x58ce24){return{'model':db[_0x58ce24[_0x7783('0x1d')]],'as':_0x58ce24['as'],'attributes':_0x58ce24[_0x7783('0x1a')],'include':_0x58ce24[_0x7783('0x1c')]?_[_0x7783('0x1e')](_0x58ce24[_0x7783('0x1c')],function(_0x275bf3){return{'model':db[_0x275bf3[_0x7783('0x1d')]],'as':_0x275bf3['as'],'attributes':_0x275bf3[_0x7783('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x7783('0xa')](function(_0x5743c5){var _0x587f90=[];for(var _0x4bcf17=0x0;_0x4bcf17<_0x5743c5['length'];_0x4bcf17+=0x1){_0x587f90[_0x7783('0x36')](_0x5743c5[_0x4bcf17]['update'](_0x5a8279[_0x7783('0x37')],{'transaction':_0x44837b}));}return BPromise[_0x7783('0x38')](_0x587f90);});})[_0x7783('0xa')](function(_0xed68bc){logger[_0x7783('0x1f')](_0x7783('0x42'),_0x5a8279);logger['debug'](_0x7783('0x42'),_0x5a8279,JSON[_0x7783('0xf')](_0xed68bc));_0xd4e9eb(_0xed68bc);})[_0x7783('0x14')](function(_0x28a193){logger['error'](_0x7783('0x42'),_0x28a193[_0x7783('0x12')],_0x5a8279);_0x4c7938(_0x5bec27[_0x7783('0x10')](0x1f4,_0x28a193[_0x7783('0x12')]));});});});};exports[_0x7783('0x44')]=function(_0x278ed2){var _0xcd565f=this;return new Promise(function(_0x1dc6ee,_0x4cc5fa){db['CmContact'][_0x7783('0x2a')]()['then'](function(_0x2cf47b){return db['CmHopper'][_0x7783('0x17')]({'raw':_0x278ed2['options']?_0x278ed2[_0x7783('0x18')][_0x7783('0x19')]===undefined?!![]:![]:!![],'where':_0x278ed2['options']?_0x278ed2['options']['where']||null:null,'attributes':_0x278ed2['options']?_0x278ed2[_0x7783('0x18')][_0x7783('0x1a')]||null:null,'limit':_0x278ed2[_0x7783('0x18')]?_0x278ed2[_0x7783('0x18')][_0x7783('0x1b')]||null:null,'include':_0x278ed2[_0x7783('0x18')]?_0x278ed2[_0x7783('0x18')][_0x7783('0x1c')]?_[_0x7783('0x1e')](_0x278ed2[_0x7783('0x18')]['include'],function(_0x1d26ec){return{'model':db[_0x1d26ec[_0x7783('0x1d')]],'as':_0x1d26ec['as'],'attributes':_0x1d26ec['as']===_0x7783('0x2e')?_[_0x7783('0x2f')](_0x2cf47b):_0x1d26ec[_0x7783('0x1a')],'include':_0x1d26ec[_0x7783('0x1c')]?_[_0x7783('0x1e')](_0x1d26ec[_0x7783('0x1c')],function(_0x2471b){return{'model':db[_0x2471b['model']],'as':_0x2471b['as'],'attributes':_0x2471b[_0x7783('0x1a')],'include':_0x2471b[_0x7783('0x1c')]?_[_0x7783('0x1e')](_0x2471b['include'],function(_0x3edf59){return{'model':db[_0x3edf59[_0x7783('0x1d')]],'as':_0x3edf59['as'],'attributes':_0x3edf59[_0x7783('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x7783('0xa')](function(_0x56a8b4){logger[_0x7783('0x1f')](_0x7783('0x15'),_0x278ed2);logger[_0x7783('0xd')](_0x7783('0x15'),_0x278ed2,JSON[_0x7783('0xf')](_0x56a8b4));_0x1dc6ee(_0x56a8b4);})[_0x7783('0x14')](function(_0x29da34){logger['error'](_0x7783('0x15'),_0x29da34[_0x7783('0x12')],_0x278ed2);_0x4cc5fa(_0xcd565f[_0x7783('0x10')](0x1f4,_0x29da34[_0x7783('0x12')]));});});});};exports[_0x7783('0x45')]=function(_0x4eae69){console[_0x7783('0x46')](_0x7783('0x47'),_0x4eae69);console[_0x7783('0x46')](_0x7783('0x48'),_0x4eae69['options'][_0x7783('0x22')]['phone']);_this=this;return new Promise(function(_0x1b581c,_0x3edfc9){return db[_0x7783('0x29')][_0x7783('0x49')]({'raw':!![],'where':{'phone':_0x4eae69[_0x7783('0x18')]['where'][_0x7783('0x4a')]},'attributes':['id','dialTimezone'],'order':[['id','DESC']]})[_0x7783('0xa')](function(_0x484ffb){console['log']('getcontactbyohone',_0x484ffb);logger[_0x7783('0x1f')](_0x7783('0x4b'),_0x4eae69);logger[_0x7783('0xd')](_0x7783('0x4b'),_0x4eae69,JSON[_0x7783('0xf')](_0x484ffb));_0x1b581c(_0x484ffb);})[_0x7783('0x14')](function(_0x4b9011){logger[_0x7783('0x10')](_0x7783('0x4b'),_0x4b9011['message'],_0x4eae69);_0x3edfc9(_this['error'](0x1f4,_0x4b9011[_0x7783('0x12')]));});});};
\ No newline at end of file