Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / cmHopper / cmHopper.rpc.js
index c988381..6b3c3a8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb8f0=['describe','sequelize','transaction','order','LOCK','UPDATE','Contact','keys','User','Agent','name','length','UserId','update','all','MoveContactManagedDialer','CmHopperFinal','CountReScheduled','`scheduledat`\x20>=\x20','format','\x22%s\x22','YYYY-MM-DD\x20HH:mm:ss','\x20,\x201,\x20null','contactsRescheduled','push','GetContactRecallMe','findAll','GetContactByPhone','log','phone\x20value','findOne','phone','dialTimezone','getContactByPhone','moment','bluebird','randomstring','ioredis','rpc','../../config/environment','jayson/promise','http','request','then','info','request\x20sent','debug','CmHopper,\x20%s,\x20%s,\x20%s','error','code','CmHopper,\x20%s,\x20%s','message','result','GetCmHopper','CmHopper','options','raw','where','limit','include','model','attributes','map','stringify','catch','ShowCmHopper','find','CreateCmHopper','create','UpdateCmHopper','body','destroy','DestroyCmHopper','GetContactDialer','CmContact'];(function(_0x129b51,_0x5374e1){var _0x4914c5=function(_0xdd154c){while(--_0xdd154c){_0x129b51['push'](_0x129b51['shift']());}};_0x4914c5(++_0x5374e1);}(_0xb8f0,0x6d));var _0x0b8f=function(_0x3f40c1,_0x4397f6){_0x3f40c1=_0x3f40c1-0x0;var _0x1aa2a2=_0xb8f0[_0x3f40c1];return _0x1aa2a2;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x0b8f('0x0'));var BPromise=require(_0x0b8f('0x1'));var rs=require(_0x0b8f('0x2'));var fs=require('fs');var Redis=require(_0x0b8f('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x0b8f('0x4'));var config=require(_0x0b8f('0x5'));var jayson=require(_0x0b8f('0x6'));var client=jayson['client'][_0x0b8f('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x45d201,_0x2fbc42,_0x5e2ce4){return new BPromise(function(_0x1ea34b,_0x525701){return client[_0x0b8f('0x8')](_0x45d201,_0x5e2ce4)[_0x0b8f('0x9')](function(_0x1f5e95){logger[_0x0b8f('0xa')]('CmHopper,\x20%s,\x20%s',_0x2fbc42,_0x0b8f('0xb'));logger[_0x0b8f('0xc')](_0x0b8f('0xd'),_0x2fbc42,_0x0b8f('0xb'),JSON['stringify'](_0x1f5e95));if(_0x1f5e95[_0x0b8f('0xe')]){if(_0x1f5e95[_0x0b8f('0xe')][_0x0b8f('0xf')]===0x1f4){logger[_0x0b8f('0xe')](_0x0b8f('0x10'),_0x2fbc42,_0x1f5e95[_0x0b8f('0xe')][_0x0b8f('0x11')]);return _0x525701(_0x1f5e95[_0x0b8f('0xe')]['message']);}logger[_0x0b8f('0xe')](_0x0b8f('0x10'),_0x2fbc42,_0x1f5e95[_0x0b8f('0xe')][_0x0b8f('0x11')]);return _0x1ea34b(_0x1f5e95[_0x0b8f('0xe')][_0x0b8f('0x11')]);}else{logger[_0x0b8f('0xa')](_0x0b8f('0x10'),_0x2fbc42,_0x0b8f('0xb'));_0x1ea34b(_0x1f5e95[_0x0b8f('0x12')][_0x0b8f('0x11')]);}})['catch'](function(_0x304146){logger[_0x0b8f('0xe')](_0x0b8f('0x10'),_0x2fbc42,_0x304146);_0x525701(_0x304146);});});}exports[_0x0b8f('0x13')]=function(_0x250a42){var _0x10faa1=this;return new Promise(function(_0x4a42ec,_0x532137){return db[_0x0b8f('0x14')]['findAll']({'raw':_0x250a42[_0x0b8f('0x15')]?_0x250a42['options'][_0x0b8f('0x16')]===undefined?!![]:![]:!![],'where':_0x250a42[_0x0b8f('0x15')]?_0x250a42[_0x0b8f('0x15')][_0x0b8f('0x17')]||null:null,'attributes':_0x250a42['options']?_0x250a42[_0x0b8f('0x15')]['attributes']||null:null,'limit':_0x250a42[_0x0b8f('0x15')]?_0x250a42['options'][_0x0b8f('0x18')]||null:null,'include':_0x250a42[_0x0b8f('0x15')]?_0x250a42[_0x0b8f('0x15')]['include']?_['map'](_0x250a42[_0x0b8f('0x15')][_0x0b8f('0x19')],function(_0x31af88){return{'model':db[_0x31af88[_0x0b8f('0x1a')]],'as':_0x31af88['as'],'attributes':_0x31af88[_0x0b8f('0x1b')],'include':_0x31af88[_0x0b8f('0x19')]?_[_0x0b8f('0x1c')](_0x31af88[_0x0b8f('0x19')],function(_0x5b47d1){return{'model':db[_0x5b47d1[_0x0b8f('0x1a')]],'as':_0x5b47d1['as'],'attributes':_0x5b47d1[_0x0b8f('0x1b')],'include':_0x5b47d1[_0x0b8f('0x19')]?_[_0x0b8f('0x1c')](_0x5b47d1[_0x0b8f('0x19')],function(_0x1c2800){return{'model':db[_0x1c2800[_0x0b8f('0x1a')]],'as':_0x1c2800['as'],'attributes':_0x1c2800['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x1035bf){logger['info'](_0x0b8f('0x13'),_0x250a42);logger[_0x0b8f('0xc')](_0x0b8f('0x13'),_0x250a42,JSON[_0x0b8f('0x1d')](_0x1035bf));_0x4a42ec(_0x1035bf);})[_0x0b8f('0x1e')](function(_0x54649b){logger[_0x0b8f('0xe')](_0x0b8f('0x13'),_0x54649b[_0x0b8f('0x11')],_0x250a42);_0x532137(_0x10faa1['error'](0x1f4,_0x54649b[_0x0b8f('0x11')]));});});};exports[_0x0b8f('0x1f')]=function(_0x31094e){var _0x58ed78=this;return new Promise(function(_0x323fca,_0x1a675c){return db['CmHopper'][_0x0b8f('0x20')]({'raw':_0x31094e[_0x0b8f('0x15')]?_0x31094e[_0x0b8f('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x31094e['options']?_0x31094e[_0x0b8f('0x15')][_0x0b8f('0x17')]||null:null,'attributes':_0x31094e[_0x0b8f('0x15')]?_0x31094e[_0x0b8f('0x15')][_0x0b8f('0x1b')]||null:null,'include':_0x31094e[_0x0b8f('0x15')]?_0x31094e[_0x0b8f('0x15')]['include']?_['map'](_0x31094e['options'][_0x0b8f('0x19')],function(_0x548c7b){return{'model':db[_0x548c7b[_0x0b8f('0x1a')]],'as':_0x548c7b['as'],'attributes':_0x548c7b[_0x0b8f('0x1b')],'include':_0x548c7b['include']?_[_0x0b8f('0x1c')](_0x548c7b[_0x0b8f('0x19')],function(_0x37dd97){return{'model':db[_0x37dd97['model']],'as':_0x37dd97['as'],'attributes':_0x37dd97[_0x0b8f('0x1b')],'include':_0x37dd97[_0x0b8f('0x19')]?_[_0x0b8f('0x1c')](_0x37dd97[_0x0b8f('0x19')],function(_0x5da22c){return{'model':db[_0x5da22c[_0x0b8f('0x1a')]],'as':_0x5da22c['as'],'attributes':_0x5da22c[_0x0b8f('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x0b8f('0x9')](function(_0xa9d39a){logger[_0x0b8f('0xa')](_0x0b8f('0x1f'),_0x31094e);logger[_0x0b8f('0xc')]('ShowCmHopper',_0x31094e,JSON[_0x0b8f('0x1d')](_0xa9d39a));_0x323fca(_0xa9d39a);})[_0x0b8f('0x1e')](function(_0x538c75){logger[_0x0b8f('0xe')](_0x0b8f('0x1f'),_0x538c75[_0x0b8f('0x11')],_0x31094e);_0x1a675c(_0x58ed78['error'](0x1f4,_0x538c75[_0x0b8f('0x11')]));});});};exports[_0x0b8f('0x21')]=function(_0x708dbe){var _0x26d664=this;return new Promise(function(_0x67af49,_0x44d363){return db[_0x0b8f('0x14')][_0x0b8f('0x22')](_0x708dbe['body'],{'raw':_0x708dbe[_0x0b8f('0x15')]?_0x708dbe[_0x0b8f('0x15')][_0x0b8f('0x16')]===undefined?!![]:![]:!![]})['then'](function(_0x4c8e4d){logger[_0x0b8f('0xa')](_0x0b8f('0x21'),_0x708dbe);logger[_0x0b8f('0xc')](_0x0b8f('0x21'),_0x708dbe,JSON[_0x0b8f('0x1d')](_0x4c8e4d));_0x67af49(_0x4c8e4d);})[_0x0b8f('0x1e')](function(_0x40ca71){logger[_0x0b8f('0xe')](_0x0b8f('0x21'),_0x40ca71[_0x0b8f('0x11')],_0x708dbe);_0x44d363(_0x26d664['error'](0x1f4,_0x40ca71['message']));});});};exports[_0x0b8f('0x23')]=function(_0x3b31c3){var _0x27b598=this;return new Promise(function(_0x4a2f8b,_0xfb3f8e){return db[_0x0b8f('0x14')]['update'](_0x3b31c3[_0x0b8f('0x24')],{'raw':_0x3b31c3[_0x0b8f('0x15')]?_0x3b31c3[_0x0b8f('0x15')][_0x0b8f('0x16')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3b31c3[_0x0b8f('0x15')]?_0x3b31c3['options'][_0x0b8f('0x17')]||null:null,'attributes':_0x3b31c3[_0x0b8f('0x15')]?_0x3b31c3[_0x0b8f('0x15')][_0x0b8f('0x1b')]||null:null,'limit':_0x3b31c3[_0x0b8f('0x15')]?_0x3b31c3['options'][_0x0b8f('0x18')]||null:null})[_0x0b8f('0x9')](function(_0x562056){logger[_0x0b8f('0xa')](_0x0b8f('0x23'),_0x3b31c3);logger[_0x0b8f('0xc')](_0x0b8f('0x23'),_0x3b31c3,JSON['stringify'](_0x562056));_0x4a2f8b(_0x562056);})['catch'](function(_0x283bd3){logger[_0x0b8f('0xe')](_0x0b8f('0x23'),_0x283bd3[_0x0b8f('0x11')],_0x3b31c3);_0xfb3f8e(_0x27b598[_0x0b8f('0xe')](0x1f4,_0x283bd3[_0x0b8f('0x11')]));});});};exports['DestroyCmHopper']=function(_0x11370b){var _0x3f8a8b=this;return new Promise(function(_0x50ffc2,_0x5ec2a0){return db[_0x0b8f('0x14')][_0x0b8f('0x25')]({'where':_0x11370b[_0x0b8f('0x15')]?_0x11370b[_0x0b8f('0x15')][_0x0b8f('0x17')]||null:null})[_0x0b8f('0x9')](function(_0x422f5d){logger['info'](_0x0b8f('0x26'),_0x11370b);logger[_0x0b8f('0xc')](_0x0b8f('0x26'),_0x11370b,JSON['stringify'](_0x422f5d));_0x50ffc2(_0x422f5d);})[_0x0b8f('0x1e')](function(_0x3ef42c){logger[_0x0b8f('0xe')](_0x0b8f('0x26'),_0x3ef42c[_0x0b8f('0x11')],_0x11370b);_0x5ec2a0(_0x3f8a8b[_0x0b8f('0xe')](0x1f4,_0x3ef42c['message']));});});};exports[_0x0b8f('0x27')]=function(_0x427294){var _0x229dee=this;return new Promise(function(_0x3525ce,_0x520459){return db[_0x0b8f('0x28')][_0x0b8f('0x29')]()['then'](function(_0x54aa95){return db[_0x0b8f('0x2a')][_0x0b8f('0x2b')](function(_0x164ec7){return db[_0x0b8f('0x14')]['findAll']({'where':_0x427294[_0x0b8f('0x15')]?_0x427294['options']['where']||null:null,'attributes':_0x427294[_0x0b8f('0x15')]?_0x427294[_0x0b8f('0x15')][_0x0b8f('0x1b')]||null:null,'limit':_0x427294[_0x0b8f('0x15')]?_0x427294['options']['limit']||null:null,'order':_0x427294['options']?_0x427294[_0x0b8f('0x15')][_0x0b8f('0x2c')]||null:null,'transaction':_0x164ec7,'lock':_0x164ec7[_0x0b8f('0x2d')][_0x0b8f('0x2e')],'include':[{'model':db[_0x0b8f('0x28')],'as':_0x0b8f('0x2f'),'attributes':_[_0x0b8f('0x30')](_0x54aa95)},{'model':db[_0x0b8f('0x31')],'as':_0x0b8f('0x32'),'attributes':['id',_0x0b8f('0x33'),'voicePause']}]})[_0x0b8f('0x9')](function(_0x2c0627){var _0x44640e=[];var _0x5eb44c=[];for(var _0x23b3f5=0x0;_0x23b3f5<_0x2c0627[_0x0b8f('0x34')];_0x23b3f5+=0x1){if(!_0x5eb44c['includes'](_0x2c0627[_0x23b3f5][_0x0b8f('0x35')])){_0x5eb44c['push'](_0x2c0627[_0x23b3f5]['UserId']);_0x44640e['push'](_0x2c0627[_0x23b3f5][_0x0b8f('0x36')](_0x427294['body'],{'transaction':_0x164ec7}));}}return BPromise[_0x0b8f('0x37')](_0x44640e);});})['then'](function(_0x2c3a71){logger[_0x0b8f('0xa')]('GetContactDialer',_0x427294);logger[_0x0b8f('0xc')](_0x0b8f('0x27'),_0x427294,JSON['stringify'](_0x2c3a71));_0x3525ce(_0x2c3a71);})[_0x0b8f('0x1e')](function(_0x51115e){logger[_0x0b8f('0xe')](_0x0b8f('0x27'),_0x51115e['message'],_0x427294);_0x520459(_0x229dee[_0x0b8f('0xe')](0x1f4,_0x51115e['message']));});});});};exports[_0x0b8f('0x38')]=function(_0x4a1918){var _0x15dd53=this;return new Promise(function(_0x3a0ca0,_0x4728c6){return db[_0x0b8f('0x2a')][_0x0b8f('0x2b')](function(_0x29b6aa){return db[_0x0b8f('0x39')][_0x0b8f('0x22')](_0x4a1918['body'],{'raw':_0x4a1918['options']?_0x4a1918['options'][_0x0b8f('0x16')]===undefined?!![]:![]:!![],'transaction':_0x29b6aa})[_0x0b8f('0x9')](function(){return db[_0x0b8f('0x14')]['destroy']({'where':_0x4a1918['options']?_0x4a1918[_0x0b8f('0x15')][_0x0b8f('0x17')]||null:null,'transaction':_0x29b6aa});});})['then'](function(_0x118621){logger['info'](_0x0b8f('0x38'),_0x4a1918);logger[_0x0b8f('0xc')](_0x0b8f('0x38'),_0x4a1918,JSON[_0x0b8f('0x1d')](_0x118621));_0x3a0ca0(_0x118621);})[_0x0b8f('0x1e')](function(_0x2c78b8){logger[_0x0b8f('0xe')](_0x0b8f('0x38'),_0x2c78b8[_0x0b8f('0x11')],_0x4a1918);_0x4728c6(_0x15dd53[_0x0b8f('0xe')](0x1f4,_0x2c78b8[_0x0b8f('0x11')]));});});};exports[_0x0b8f('0x3a')]=function(_0x4f98fa){var _0x26f894=this;return new Promise(function(_0x1b8dd6,_0x1dff98){return db[_0x0b8f('0x14')]['findAll']({'raw':_0x4f98fa[_0x0b8f('0x15')]?_0x4f98fa[_0x0b8f('0x15')][_0x0b8f('0x16')]===undefined?!![]:![]:!![],'where':_0x4f98fa['options']?_0x4f98fa[_0x0b8f('0x15')]['where']||null:null,'attributes':[[db['sequelize']['fn']('COUNT',db[_0x0b8f('0x2a')]['fn']('IF',db[_0x0b8f('0x2a')]['literal'](_0x0b8f('0x3b')+util[_0x0b8f('0x3c')](_0x0b8f('0x3d'),moment()[_0x0b8f('0x3c')](_0x0b8f('0x3e')))+_0x0b8f('0x3f')))),_0x0b8f('0x40')]]})[_0x0b8f('0x9')](function(_0x13a707){logger['info']('CountReScheduled',_0x4f98fa);logger[_0x0b8f('0xc')](_0x0b8f('0x3a'),_0x4f98fa,JSON['stringify'](_0x13a707));_0x1b8dd6(_0x13a707);})[_0x0b8f('0x1e')](function(_0x319b67){logger[_0x0b8f('0xe')](_0x0b8f('0x3a'),_0x319b67[_0x0b8f('0x11')],_0x4f98fa);_0x1dff98(_0x26f894[_0x0b8f('0xe')](0x1f4,_0x319b67[_0x0b8f('0x11')]));});});};exports['GetContactRecallMe']=function(_0x1acb89){var _0x43b8f0=this;return new Promise(function(_0x146b2c,_0x2d25f2){return db[_0x0b8f('0x28')]['describe']()[_0x0b8f('0x9')](function(_0xbde666){return db[_0x0b8f('0x2a')]['transaction'](function(_0x448328){return db[_0x0b8f('0x14')]['findAll']({'where':_0x1acb89[_0x0b8f('0x15')]?_0x1acb89[_0x0b8f('0x15')][_0x0b8f('0x17')]||null:null,'attributes':_0x1acb89[_0x0b8f('0x15')]?_0x1acb89[_0x0b8f('0x15')][_0x0b8f('0x1b')]||null:null,'limit':0x1,'order':_0x1acb89['options']?_0x1acb89['options'][_0x0b8f('0x2c')]||null:null,'group':db[_0x0b8f('0x14')][_0x0b8f('0x35')],'transaction':_0x448328,'lock':_0x448328['LOCK'][_0x0b8f('0x2e')],'include':_0x1acb89['options']?_0x1acb89[_0x0b8f('0x15')][_0x0b8f('0x19')]?_[_0x0b8f('0x1c')](_0x1acb89[_0x0b8f('0x15')][_0x0b8f('0x19')],function(_0x445343){return{'model':db[_0x445343[_0x0b8f('0x1a')]],'as':_0x445343['as'],'attributes':_0x445343[_0x0b8f('0x1b')],'include':_0x445343[_0x0b8f('0x19')]?_['map'](_0x445343[_0x0b8f('0x19')],function(_0x4a0de7){return{'model':db[_0x4a0de7['model']],'as':_0x4a0de7['as'],'attributes':_0x4a0de7[_0x0b8f('0x1b')],'include':_0x4a0de7['include']?_[_0x0b8f('0x1c')](_0x4a0de7[_0x0b8f('0x19')],function(_0x31226b){return{'model':db[_0x31226b[_0x0b8f('0x1a')]],'as':_0x31226b['as'],'attributes':_0x31226b[_0x0b8f('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x0b8f('0x9')](function(_0x485e7a){var _0x171648=[];for(var _0x33069e=0x0;_0x33069e<_0x485e7a[_0x0b8f('0x34')];_0x33069e+=0x1){_0x171648[_0x0b8f('0x41')](_0x485e7a[_0x33069e][_0x0b8f('0x36')](_0x1acb89[_0x0b8f('0x24')],{'transaction':_0x448328}));}return BPromise[_0x0b8f('0x37')](_0x171648);});})[_0x0b8f('0x9')](function(_0x10135a){logger['info'](_0x0b8f('0x42'),_0x1acb89);logger['debug'](_0x0b8f('0x42'),_0x1acb89,JSON[_0x0b8f('0x1d')](_0x10135a));_0x146b2c(_0x10135a);})[_0x0b8f('0x1e')](function(_0x32bc7c){logger[_0x0b8f('0xe')](_0x0b8f('0x42'),_0x32bc7c[_0x0b8f('0x11')],_0x1acb89);_0x2d25f2(_0x43b8f0['error'](0x1f4,_0x32bc7c[_0x0b8f('0x11')]));});});});};exports['GetCmHopperPreview']=function(_0xff520e){var _0xa4ba42=this;return new Promise(function(_0x53fddb,_0x4a10){db[_0x0b8f('0x28')][_0x0b8f('0x29')]()['then'](function(_0x245715){return db['CmHopper'][_0x0b8f('0x43')]({'raw':_0xff520e[_0x0b8f('0x15')]?_0xff520e[_0x0b8f('0x15')][_0x0b8f('0x16')]===undefined?!![]:![]:!![],'where':_0xff520e['options']?_0xff520e['options'][_0x0b8f('0x17')]||null:null,'attributes':_0xff520e[_0x0b8f('0x15')]?_0xff520e[_0x0b8f('0x15')]['attributes']||null:null,'limit':_0xff520e[_0x0b8f('0x15')]?_0xff520e[_0x0b8f('0x15')][_0x0b8f('0x18')]||null:null,'include':_0xff520e[_0x0b8f('0x15')]?_0xff520e[_0x0b8f('0x15')][_0x0b8f('0x19')]?_['map'](_0xff520e[_0x0b8f('0x15')]['include'],function(_0x1346d9){return{'model':db[_0x1346d9[_0x0b8f('0x1a')]],'as':_0x1346d9['as'],'attributes':_0x1346d9['as']==='Contact'?_[_0x0b8f('0x30')](_0x245715):_0x1346d9[_0x0b8f('0x1b')],'include':_0x1346d9['include']?_['map'](_0x1346d9['include'],function(_0xe00aa){return{'model':db[_0xe00aa[_0x0b8f('0x1a')]],'as':_0xe00aa['as'],'attributes':_0xe00aa['attributes'],'include':_0xe00aa[_0x0b8f('0x19')]?_[_0x0b8f('0x1c')](_0xe00aa[_0x0b8f('0x19')],function(_0x2c6d62){return{'model':db[_0x2c6d62[_0x0b8f('0x1a')]],'as':_0x2c6d62['as'],'attributes':_0x2c6d62[_0x0b8f('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x0b8f('0x9')](function(_0xe5f7cf){logger[_0x0b8f('0xa')]('GetCmHopper',_0xff520e);logger[_0x0b8f('0xc')](_0x0b8f('0x13'),_0xff520e,JSON[_0x0b8f('0x1d')](_0xe5f7cf));_0x53fddb(_0xe5f7cf);})['catch'](function(_0x528756){logger[_0x0b8f('0xe')](_0x0b8f('0x13'),_0x528756[_0x0b8f('0x11')],_0xff520e);_0x4a10(_0xa4ba42[_0x0b8f('0xe')](0x1f4,_0x528756[_0x0b8f('0x11')]));});});});};exports[_0x0b8f('0x44')]=function(_0x4ae663){console[_0x0b8f('0x45')]('req\x20value',_0x4ae663);console['log'](_0x0b8f('0x46'),_0x4ae663[_0x0b8f('0x15')][_0x0b8f('0x17')]['phone']);_this=this;return new Promise(function(_0x58e074,_0x10cd97){return db['CmContact'][_0x0b8f('0x47')]({'raw':!![],'where':{'phone':_0x4ae663[_0x0b8f('0x15')][_0x0b8f('0x17')][_0x0b8f('0x48')]},'attributes':['id',_0x0b8f('0x49')],'order':[['id','DESC']]})[_0x0b8f('0x9')](function(_0x24e267){console['log']('getcontactbyohone',_0x24e267);logger[_0x0b8f('0xa')](_0x0b8f('0x4a'),_0x4ae663);logger[_0x0b8f('0xc')]('getContactByPhone',_0x4ae663,JSON[_0x0b8f('0x1d')](_0x24e267));_0x58e074(_0x24e267);})['catch'](function(_0x5030fe){logger[_0x0b8f('0xe')](_0x0b8f('0x4a'),_0x5030fe[_0x0b8f('0x11')],_0x4ae663);_0x10cd97(_this[_0x0b8f('0xe')](0x1f4,_0x5030fe[_0x0b8f('0x11')]));});});};
\ No newline at end of file
+var _0x074a=['raw','then','stringify','create','body','CreateCmHopper','UpdateCmHopper','update','DestroyCmHopper','destroy','CmContact','describe','sequelize','order','LOCK','Contact','keys','User','name','voicePause','length','includes','UserId','push','all','GetContactDialer','transaction','MoveContactManagedDialer','CountReScheduled','COUNT','literal','`scheduledat`\x20>=\x20','format','YYYY-MM-DD\x20HH:mm:ss','\x20,\x201,\x20null','contactsRescheduled','GetContactRecallMe','UPDATE','GetCmHopperPreview','GetContactByPhone','log','req\x20value','phone\x20value','phone','findOne','dialTimezone','DESC','getcontactbyohone','getContactByPhone','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','request','info','CmHopper,\x20%s,\x20%s','request\x20sent','debug','CmHopper,\x20%s,\x20%s,\x20%s','error','message','catch','GetCmHopper','CmHopper','findAll','options','where','attributes','limit','include','map','model','ShowCmHopper','find'];(function(_0x2b7764,_0x2606f1){var _0x848dcb=function(_0x1ae85b){while(--_0x1ae85b){_0x2b7764['push'](_0x2b7764['shift']());}};_0x848dcb(++_0x2606f1);}(_0x074a,0x175));var _0xa074=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x074a[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0xa074('0x0'));var util=require(_0xa074('0x1'));var moment=require(_0xa074('0x2'));var BPromise=require(_0xa074('0x3'));var rs=require(_0xa074('0x4'));var fs=require('fs');var Redis=require(_0xa074('0x5'));var db=require(_0xa074('0x6'))['db'];var utils=require(_0xa074('0x7'));var logger=require(_0xa074('0x8'))('rpc');var config=require(_0xa074('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xa074('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5d8385,_0x34d052,_0x331338){return new BPromise(function(_0x1993be,_0x410cba){return client[_0xa074('0xb')](_0x5d8385,_0x331338)['then'](function(_0x1b9225){logger[_0xa074('0xc')](_0xa074('0xd'),_0x34d052,_0xa074('0xe'));logger[_0xa074('0xf')](_0xa074('0x10'),_0x34d052,'request\x20sent',JSON['stringify'](_0x1b9225));if(_0x1b9225[_0xa074('0x11')]){if(_0x1b9225['error']['code']===0x1f4){logger[_0xa074('0x11')](_0xa074('0xd'),_0x34d052,_0x1b9225[_0xa074('0x11')][_0xa074('0x12')]);return _0x410cba(_0x1b9225['error'][_0xa074('0x12')]);}logger[_0xa074('0x11')](_0xa074('0xd'),_0x34d052,_0x1b9225['error'][_0xa074('0x12')]);return _0x1993be(_0x1b9225[_0xa074('0x11')][_0xa074('0x12')]);}else{logger['info'](_0xa074('0xd'),_0x34d052,_0xa074('0xe'));_0x1993be(_0x1b9225['result'][_0xa074('0x12')]);}})[_0xa074('0x13')](function(_0x13475e){logger['error'](_0xa074('0xd'),_0x34d052,_0x13475e);_0x410cba(_0x13475e);});});}exports[_0xa074('0x14')]=function(_0x540f77){var _0x13641a=this;return new Promise(function(_0x237e2b,_0x12abd9){return db[_0xa074('0x15')][_0xa074('0x16')]({'raw':_0x540f77[_0xa074('0x17')]?_0x540f77[_0xa074('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x540f77[_0xa074('0x17')]?_0x540f77['options'][_0xa074('0x18')]||null:null,'attributes':_0x540f77[_0xa074('0x17')]?_0x540f77[_0xa074('0x17')][_0xa074('0x19')]||null:null,'limit':_0x540f77[_0xa074('0x17')]?_0x540f77[_0xa074('0x17')][_0xa074('0x1a')]||null:null,'include':_0x540f77[_0xa074('0x17')]?_0x540f77[_0xa074('0x17')]['include']?_['map'](_0x540f77[_0xa074('0x17')][_0xa074('0x1b')],function(_0x248f56){return{'model':db[_0x248f56['model']],'as':_0x248f56['as'],'attributes':_0x248f56['attributes'],'include':_0x248f56[_0xa074('0x1b')]?_[_0xa074('0x1c')](_0x248f56[_0xa074('0x1b')],function(_0x1f1089){return{'model':db[_0x1f1089[_0xa074('0x1d')]],'as':_0x1f1089['as'],'attributes':_0x1f1089[_0xa074('0x19')],'include':_0x1f1089[_0xa074('0x1b')]?_['map'](_0x1f1089['include'],function(_0x48105a){return{'model':db[_0x48105a['model']],'as':_0x48105a['as'],'attributes':_0x48105a['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0xc3bed5){logger[_0xa074('0xc')](_0xa074('0x14'),_0x540f77);logger[_0xa074('0xf')]('GetCmHopper',_0x540f77,JSON['stringify'](_0xc3bed5));_0x237e2b(_0xc3bed5);})[_0xa074('0x13')](function(_0x3f856c){logger['error'](_0xa074('0x14'),_0x3f856c['message'],_0x540f77);_0x12abd9(_0x13641a[_0xa074('0x11')](0x1f4,_0x3f856c[_0xa074('0x12')]));});});};exports[_0xa074('0x1e')]=function(_0xae3d93){var _0x2a4a16=this;return new Promise(function(_0x2d111a,_0x2a77f4){return db['CmHopper'][_0xa074('0x1f')]({'raw':_0xae3d93['options']?_0xae3d93[_0xa074('0x17')][_0xa074('0x20')]===undefined?!![]:![]:!![],'where':_0xae3d93[_0xa074('0x17')]?_0xae3d93['options'][_0xa074('0x18')]||null:null,'attributes':_0xae3d93[_0xa074('0x17')]?_0xae3d93[_0xa074('0x17')][_0xa074('0x19')]||null:null,'include':_0xae3d93[_0xa074('0x17')]?_0xae3d93[_0xa074('0x17')][_0xa074('0x1b')]?_[_0xa074('0x1c')](_0xae3d93['options'][_0xa074('0x1b')],function(_0x4c327e){return{'model':db[_0x4c327e[_0xa074('0x1d')]],'as':_0x4c327e['as'],'attributes':_0x4c327e[_0xa074('0x19')],'include':_0x4c327e[_0xa074('0x1b')]?_[_0xa074('0x1c')](_0x4c327e[_0xa074('0x1b')],function(_0x37bf5d){return{'model':db[_0x37bf5d[_0xa074('0x1d')]],'as':_0x37bf5d['as'],'attributes':_0x37bf5d[_0xa074('0x19')],'include':_0x37bf5d['include']?_['map'](_0x37bf5d['include'],function(_0x1663cf){return{'model':db[_0x1663cf[_0xa074('0x1d')]],'as':_0x1663cf['as'],'attributes':_0x1663cf[_0xa074('0x19')]};}):[]};}):[]};}):[]:[]})[_0xa074('0x21')](function(_0x4e39dc){logger['info'](_0xa074('0x1e'),_0xae3d93);logger['debug'](_0xa074('0x1e'),_0xae3d93,JSON[_0xa074('0x22')](_0x4e39dc));_0x2d111a(_0x4e39dc);})['catch'](function(_0x3fecd0){logger['error']('ShowCmHopper',_0x3fecd0['message'],_0xae3d93);_0x2a77f4(_0x2a4a16[_0xa074('0x11')](0x1f4,_0x3fecd0[_0xa074('0x12')]));});});};exports['CreateCmHopper']=function(_0x3b0288){var _0x36bd33=this;return new Promise(function(_0x4ba475,_0xe84c11){return db[_0xa074('0x15')][_0xa074('0x23')](_0x3b0288[_0xa074('0x24')],{'raw':_0x3b0288[_0xa074('0x17')]?_0x3b0288[_0xa074('0x17')][_0xa074('0x20')]===undefined?!![]:![]:!![]})[_0xa074('0x21')](function(_0x2c6545){logger[_0xa074('0xc')](_0xa074('0x25'),_0x3b0288);logger['debug']('CreateCmHopper',_0x3b0288,JSON['stringify'](_0x2c6545));_0x4ba475(_0x2c6545);})['catch'](function(_0x5f4b64){logger[_0xa074('0x11')](_0xa074('0x25'),_0x5f4b64[_0xa074('0x12')],_0x3b0288);_0xe84c11(_0x36bd33[_0xa074('0x11')](0x1f4,_0x5f4b64['message']));});});};exports[_0xa074('0x26')]=function(_0x372882){var _0x261b37=this;return new Promise(function(_0x49d879,_0xe47f75){return db['CmHopper'][_0xa074('0x27')](_0x372882[_0xa074('0x24')],{'raw':_0x372882[_0xa074('0x17')]?_0x372882['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x372882[_0xa074('0x17')]?_0x372882['options'][_0xa074('0x18')]||null:null,'attributes':_0x372882[_0xa074('0x17')]?_0x372882[_0xa074('0x17')][_0xa074('0x19')]||null:null,'limit':_0x372882[_0xa074('0x17')]?_0x372882[_0xa074('0x17')][_0xa074('0x1a')]||null:null})[_0xa074('0x21')](function(_0x4582b3){logger[_0xa074('0xc')](_0xa074('0x26'),_0x372882);logger[_0xa074('0xf')](_0xa074('0x26'),_0x372882,JSON[_0xa074('0x22')](_0x4582b3));_0x49d879(_0x4582b3);})[_0xa074('0x13')](function(_0x2a4020){logger['error'](_0xa074('0x26'),_0x2a4020[_0xa074('0x12')],_0x372882);_0xe47f75(_0x261b37[_0xa074('0x11')](0x1f4,_0x2a4020[_0xa074('0x12')]));});});};exports[_0xa074('0x28')]=function(_0x223714){var _0x20ac57=this;return new Promise(function(_0x461f07,_0x1945e0){return db[_0xa074('0x15')][_0xa074('0x29')]({'where':_0x223714['options']?_0x223714[_0xa074('0x17')][_0xa074('0x18')]||null:null})[_0xa074('0x21')](function(_0x475105){logger[_0xa074('0xc')](_0xa074('0x28'),_0x223714);logger['debug'](_0xa074('0x28'),_0x223714,JSON[_0xa074('0x22')](_0x475105));_0x461f07(_0x475105);})['catch'](function(_0x164244){logger[_0xa074('0x11')](_0xa074('0x28'),_0x164244[_0xa074('0x12')],_0x223714);_0x1945e0(_0x20ac57[_0xa074('0x11')](0x1f4,_0x164244[_0xa074('0x12')]));});});};exports['GetContactDialer']=function(_0x14a81f){var _0x5d09ef=this;return new Promise(function(_0x5dd7a9,_0x58cfcb){return db[_0xa074('0x2a')][_0xa074('0x2b')]()[_0xa074('0x21')](function(_0x3d92da){return db[_0xa074('0x2c')]['transaction'](function(_0x303042){return db[_0xa074('0x15')]['findAll']({'where':_0x14a81f['options']?_0x14a81f[_0xa074('0x17')][_0xa074('0x18')]||null:null,'attributes':_0x14a81f[_0xa074('0x17')]?_0x14a81f[_0xa074('0x17')]['attributes']||null:null,'limit':_0x14a81f[_0xa074('0x17')]?_0x14a81f[_0xa074('0x17')]['limit']||null:null,'order':_0x14a81f[_0xa074('0x17')]?_0x14a81f[_0xa074('0x17')][_0xa074('0x2d')]||null:null,'transaction':_0x303042,'lock':_0x303042[_0xa074('0x2e')]['UPDATE'],'include':[{'model':db[_0xa074('0x2a')],'as':_0xa074('0x2f'),'attributes':_[_0xa074('0x30')](_0x3d92da)},{'model':db[_0xa074('0x31')],'as':'Agent','attributes':['id',_0xa074('0x32'),_0xa074('0x33')]}]})[_0xa074('0x21')](function(_0x23a2a0){var _0x4c1cbd=[];var _0x383c60=[];for(var _0x1b97ba=0x0;_0x1b97ba<_0x23a2a0[_0xa074('0x34')];_0x1b97ba+=0x1){if(!_0x383c60[_0xa074('0x35')](_0x23a2a0[_0x1b97ba][_0xa074('0x36')])){_0x383c60['push'](_0x23a2a0[_0x1b97ba]['UserId']);_0x4c1cbd[_0xa074('0x37')](_0x23a2a0[_0x1b97ba][_0xa074('0x27')](_0x14a81f[_0xa074('0x24')],{'transaction':_0x303042}));}}return BPromise[_0xa074('0x38')](_0x4c1cbd);});})[_0xa074('0x21')](function(_0x2a8c04){logger[_0xa074('0xc')]('GetContactDialer',_0x14a81f);logger[_0xa074('0xf')](_0xa074('0x39'),_0x14a81f,JSON['stringify'](_0x2a8c04));_0x5dd7a9(_0x2a8c04);})[_0xa074('0x13')](function(_0x2755d7){logger[_0xa074('0x11')]('GetContactDialer',_0x2755d7['message'],_0x14a81f);_0x58cfcb(_0x5d09ef[_0xa074('0x11')](0x1f4,_0x2755d7['message']));});});});};exports['MoveContactManagedDialer']=function(_0x116d2e){var _0x1b8b34=this;return new Promise(function(_0x5a2d7d,_0x5d71fe){return db[_0xa074('0x2c')][_0xa074('0x3a')](function(_0x325b0a){return db['CmHopperFinal']['create'](_0x116d2e[_0xa074('0x24')],{'raw':_0x116d2e['options']?_0x116d2e[_0xa074('0x17')][_0xa074('0x20')]===undefined?!![]:![]:!![],'transaction':_0x325b0a})[_0xa074('0x21')](function(){return db[_0xa074('0x15')][_0xa074('0x29')]({'where':_0x116d2e['options']?_0x116d2e[_0xa074('0x17')]['where']||null:null,'transaction':_0x325b0a});});})['then'](function(_0x15c2a2){logger[_0xa074('0xc')](_0xa074('0x3b'),_0x116d2e);logger[_0xa074('0xf')]('MoveContactManagedDialer',_0x116d2e,JSON[_0xa074('0x22')](_0x15c2a2));_0x5a2d7d(_0x15c2a2);})[_0xa074('0x13')](function(_0x7e343c){logger[_0xa074('0x11')](_0xa074('0x3b'),_0x7e343c['message'],_0x116d2e);_0x5d71fe(_0x1b8b34['error'](0x1f4,_0x7e343c[_0xa074('0x12')]));});});};exports[_0xa074('0x3c')]=function(_0x2867e2){var _0x965010=this;return new Promise(function(_0x29bed0,_0x36a068){return db[_0xa074('0x15')][_0xa074('0x16')]({'raw':_0x2867e2[_0xa074('0x17')]?_0x2867e2[_0xa074('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x2867e2[_0xa074('0x17')]?_0x2867e2[_0xa074('0x17')][_0xa074('0x18')]||null:null,'attributes':[[db[_0xa074('0x2c')]['fn'](_0xa074('0x3d'),db['sequelize']['fn']('IF',db[_0xa074('0x2c')][_0xa074('0x3e')](_0xa074('0x3f')+util[_0xa074('0x40')]('\x22%s\x22',moment()[_0xa074('0x40')](_0xa074('0x41')))+_0xa074('0x42')))),_0xa074('0x43')]]})[_0xa074('0x21')](function(_0x154195){logger[_0xa074('0xc')]('CountReScheduled',_0x2867e2);logger[_0xa074('0xf')](_0xa074('0x3c'),_0x2867e2,JSON[_0xa074('0x22')](_0x154195));_0x29bed0(_0x154195);})[_0xa074('0x13')](function(_0x5e5b73){logger[_0xa074('0x11')](_0xa074('0x3c'),_0x5e5b73[_0xa074('0x12')],_0x2867e2);_0x36a068(_0x965010[_0xa074('0x11')](0x1f4,_0x5e5b73['message']));});});};exports[_0xa074('0x44')]=function(_0x47c0c2){var _0x24dffb=this;return new Promise(function(_0x29b437,_0x2ebdd7){return db[_0xa074('0x2a')][_0xa074('0x2b')]()['then'](function(_0x2aa47d){return db[_0xa074('0x2c')][_0xa074('0x3a')](function(_0x3e0003){return db[_0xa074('0x15')][_0xa074('0x16')]({'where':_0x47c0c2[_0xa074('0x17')]?_0x47c0c2[_0xa074('0x17')][_0xa074('0x18')]||null:null,'attributes':_0x47c0c2[_0xa074('0x17')]?_0x47c0c2[_0xa074('0x17')]['attributes']||null:null,'limit':0x1,'order':_0x47c0c2[_0xa074('0x17')]?_0x47c0c2['options'][_0xa074('0x2d')]||null:null,'group':db[_0xa074('0x15')][_0xa074('0x36')],'transaction':_0x3e0003,'lock':_0x3e0003['LOCK'][_0xa074('0x45')],'include':_0x47c0c2['options']?_0x47c0c2['options']['include']?_['map'](_0x47c0c2[_0xa074('0x17')][_0xa074('0x1b')],function(_0x864a09){return{'model':db[_0x864a09[_0xa074('0x1d')]],'as':_0x864a09['as'],'attributes':_0x864a09[_0xa074('0x19')],'include':_0x864a09['include']?_[_0xa074('0x1c')](_0x864a09[_0xa074('0x1b')],function(_0x4968fa){return{'model':db[_0x4968fa['model']],'as':_0x4968fa['as'],'attributes':_0x4968fa[_0xa074('0x19')],'include':_0x4968fa[_0xa074('0x1b')]?_[_0xa074('0x1c')](_0x4968fa[_0xa074('0x1b')],function(_0x834ac9){return{'model':db[_0x834ac9['model']],'as':_0x834ac9['as'],'attributes':_0x834ac9['attributes']};}):[]};}):[]};}):[]:[]})[_0xa074('0x21')](function(_0x33a49e){var _0x1b28f3=[];for(var _0x260543=0x0;_0x260543<_0x33a49e[_0xa074('0x34')];_0x260543+=0x1){_0x1b28f3['push'](_0x33a49e[_0x260543][_0xa074('0x27')](_0x47c0c2['body'],{'transaction':_0x3e0003}));}return BPromise[_0xa074('0x38')](_0x1b28f3);});})[_0xa074('0x21')](function(_0x5e9693){logger[_0xa074('0xc')](_0xa074('0x44'),_0x47c0c2);logger[_0xa074('0xf')](_0xa074('0x44'),_0x47c0c2,JSON[_0xa074('0x22')](_0x5e9693));_0x29b437(_0x5e9693);})[_0xa074('0x13')](function(_0x448eb4){logger[_0xa074('0x11')](_0xa074('0x44'),_0x448eb4['message'],_0x47c0c2);_0x2ebdd7(_0x24dffb['error'](0x1f4,_0x448eb4['message']));});});});};exports[_0xa074('0x46')]=function(_0x31cb4f){var _0x517f05=this;return new Promise(function(_0x21ff5c,_0x50ae9a){db[_0xa074('0x2a')][_0xa074('0x2b')]()[_0xa074('0x21')](function(_0x2005e5){return db[_0xa074('0x15')][_0xa074('0x16')]({'raw':_0x31cb4f['options']?_0x31cb4f['options'][_0xa074('0x20')]===undefined?!![]:![]:!![],'where':_0x31cb4f[_0xa074('0x17')]?_0x31cb4f[_0xa074('0x17')][_0xa074('0x18')]||null:null,'attributes':_0x31cb4f['options']?_0x31cb4f[_0xa074('0x17')]['attributes']||null:null,'limit':_0x31cb4f[_0xa074('0x17')]?_0x31cb4f[_0xa074('0x17')][_0xa074('0x1a')]||null:null,'include':_0x31cb4f['options']?_0x31cb4f['options'][_0xa074('0x1b')]?_[_0xa074('0x1c')](_0x31cb4f[_0xa074('0x17')]['include'],function(_0x19a1fb){return{'model':db[_0x19a1fb[_0xa074('0x1d')]],'as':_0x19a1fb['as'],'attributes':_0x19a1fb['as']===_0xa074('0x2f')?_['keys'](_0x2005e5):_0x19a1fb[_0xa074('0x19')],'include':_0x19a1fb[_0xa074('0x1b')]?_[_0xa074('0x1c')](_0x19a1fb[_0xa074('0x1b')],function(_0x24b2ae){return{'model':db[_0x24b2ae[_0xa074('0x1d')]],'as':_0x24b2ae['as'],'attributes':_0x24b2ae[_0xa074('0x19')],'include':_0x24b2ae[_0xa074('0x1b')]?_[_0xa074('0x1c')](_0x24b2ae[_0xa074('0x1b')],function(_0x52b042){return{'model':db[_0x52b042[_0xa074('0x1d')]],'as':_0x52b042['as'],'attributes':_0x52b042[_0xa074('0x19')]};}):[]};}):[]};}):[]:[]})[_0xa074('0x21')](function(_0x2c929b){logger[_0xa074('0xc')](_0xa074('0x14'),_0x31cb4f);logger['debug'](_0xa074('0x14'),_0x31cb4f,JSON[_0xa074('0x22')](_0x2c929b));_0x21ff5c(_0x2c929b);})[_0xa074('0x13')](function(_0x371cc8){logger[_0xa074('0x11')](_0xa074('0x14'),_0x371cc8[_0xa074('0x12')],_0x31cb4f);_0x50ae9a(_0x517f05[_0xa074('0x11')](0x1f4,_0x371cc8[_0xa074('0x12')]));});});});};exports[_0xa074('0x47')]=function(_0x195086){console[_0xa074('0x48')](_0xa074('0x49'),_0x195086);console['log'](_0xa074('0x4a'),_0x195086[_0xa074('0x17')]['where'][_0xa074('0x4b')]);_this=this;return new Promise(function(_0x3ad60d,_0x287e72){return db[_0xa074('0x2a')][_0xa074('0x4c')]({'raw':!![],'where':{'phone':_0x195086[_0xa074('0x17')]['where'][_0xa074('0x4b')]},'attributes':['id',_0xa074('0x4d')],'order':[['id',_0xa074('0x4e')]]})['then'](function(_0xec34fe){console[_0xa074('0x48')](_0xa074('0x4f'),_0xec34fe);logger['info'](_0xa074('0x50'),_0x195086);logger['debug'](_0xa074('0x50'),_0x195086,JSON['stringify'](_0xec34fe));_0x3ad60d(_0xec34fe);})[_0xa074('0x13')](function(_0x5b2372){logger[_0xa074('0x11')]('getContactByPhone',_0x5b2372['message'],_0x195086);_0x287e72(_this[_0xa074('0x11')](0x1f4,_0x5b2372['message']));});});};
\ No newline at end of file