Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / cmHopper / cmHopper.rpc.js
index 7604e47..bc6eb6c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xabf4=['CreateCmHopper','create','body','UpdateCmHopper','update','limit','destroy','DestroyCmHopper','CmContact','describe','sequelize','LOCK','UPDATE','Contact','keys','User','Agent','voicePause','length','UserId','push','all','GetContactDialer','MoveContactManagedDialer','transaction','COUNT','literal','`scheduledat`\x20>=\x20','format','YYYY-MM-DD\x20HH:mm:ss','\x20,\x201,\x20null','contactsRescheduled','CountReScheduled','order','GetContactRecallMe','GetCmHopperPreview','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info','request\x20sent','debug','CmHopper,\x20%s,\x20%s,\x20%s','stringify','error','CmHopper,\x20%s,\x20%s','message','result','catch','GetCmHopper','findAll','options','raw','where','attributes','include','map','model','then','ShowCmHopper','CmHopper'];(function(_0xdfd048,_0x4f109e){var _0x1098d0=function(_0xd25220){while(--_0xd25220){_0xdfd048['push'](_0xdfd048['shift']());}};_0x1098d0(++_0x4f109e);}(_0xabf4,0x148));var _0x4abf=function(_0x9e80b,_0x88eb67){_0x9e80b=_0x9e80b-0x0;var _0x30303f=_0xabf4[_0x9e80b];return _0x30303f;};'use strict';var _=require(_0x4abf('0x0'));var util=require(_0x4abf('0x1'));var moment=require(_0x4abf('0x2'));var BPromise=require(_0x4abf('0x3'));var rs=require(_0x4abf('0x4'));var fs=require('fs');var Redis=require(_0x4abf('0x5'));var db=require(_0x4abf('0x6'))['db'];var utils=require(_0x4abf('0x7'));var logger=require(_0x4abf('0x8'))(_0x4abf('0x9'));var config=require(_0x4abf('0xa'));var jayson=require(_0x4abf('0xb'));var client=jayson[_0x4abf('0xc')][_0x4abf('0xd')]({'port':0x232a});function respondWithRpcPromise(_0xedda57,_0x493c6b,_0x140ef7){return new BPromise(function(_0x55dc5b,_0x252637){return client[_0x4abf('0xe')](_0xedda57,_0x140ef7)['then'](function(_0x5932e1){logger[_0x4abf('0xf')]('CmHopper,\x20%s,\x20%s',_0x493c6b,_0x4abf('0x10'));logger[_0x4abf('0x11')](_0x4abf('0x12'),_0x493c6b,'request\x20sent',JSON[_0x4abf('0x13')](_0x5932e1));if(_0x5932e1[_0x4abf('0x14')]){if(_0x5932e1[_0x4abf('0x14')]['code']===0x1f4){logger[_0x4abf('0x14')](_0x4abf('0x15'),_0x493c6b,_0x5932e1[_0x4abf('0x14')][_0x4abf('0x16')]);return _0x252637(_0x5932e1['error'][_0x4abf('0x16')]);}logger[_0x4abf('0x14')](_0x4abf('0x15'),_0x493c6b,_0x5932e1[_0x4abf('0x14')][_0x4abf('0x16')]);return _0x55dc5b(_0x5932e1['error']['message']);}else{logger[_0x4abf('0xf')](_0x4abf('0x15'),_0x493c6b,_0x4abf('0x10'));_0x55dc5b(_0x5932e1[_0x4abf('0x17')][_0x4abf('0x16')]);}})[_0x4abf('0x18')](function(_0x471eae){logger[_0x4abf('0x14')](_0x4abf('0x15'),_0x493c6b,_0x471eae);_0x252637(_0x471eae);});});}exports[_0x4abf('0x19')]=function(_0x4edf7a){var _0x593857=this;return new Promise(function(_0x49dae4,_0x4ee72d){return db['CmHopper'][_0x4abf('0x1a')]({'raw':_0x4edf7a[_0x4abf('0x1b')]?_0x4edf7a['options'][_0x4abf('0x1c')]===undefined?!![]:![]:!![],'where':_0x4edf7a[_0x4abf('0x1b')]?_0x4edf7a[_0x4abf('0x1b')][_0x4abf('0x1d')]||null:null,'attributes':_0x4edf7a[_0x4abf('0x1b')]?_0x4edf7a[_0x4abf('0x1b')][_0x4abf('0x1e')]||null:null,'limit':_0x4edf7a[_0x4abf('0x1b')]?_0x4edf7a[_0x4abf('0x1b')]['limit']||null:null,'include':_0x4edf7a[_0x4abf('0x1b')]?_0x4edf7a[_0x4abf('0x1b')][_0x4abf('0x1f')]?_[_0x4abf('0x20')](_0x4edf7a[_0x4abf('0x1b')][_0x4abf('0x1f')],function(_0x5b383b){return{'model':db[_0x5b383b[_0x4abf('0x21')]],'as':_0x5b383b['as'],'attributes':_0x5b383b[_0x4abf('0x1e')],'include':_0x5b383b[_0x4abf('0x1f')]?_[_0x4abf('0x20')](_0x5b383b['include'],function(_0x566ca7){return{'model':db[_0x566ca7[_0x4abf('0x21')]],'as':_0x566ca7['as'],'attributes':_0x566ca7[_0x4abf('0x1e')],'include':_0x566ca7['include']?_['map'](_0x566ca7[_0x4abf('0x1f')],function(_0x2d76c5){return{'model':db[_0x2d76c5['model']],'as':_0x2d76c5['as'],'attributes':_0x2d76c5[_0x4abf('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x4abf('0x22')](function(_0x3d9e35){logger[_0x4abf('0xf')](_0x4abf('0x19'),_0x4edf7a);logger['debug'](_0x4abf('0x19'),_0x4edf7a,JSON[_0x4abf('0x13')](_0x3d9e35));_0x49dae4(_0x3d9e35);})[_0x4abf('0x18')](function(_0x36cb3e){logger[_0x4abf('0x14')]('GetCmHopper',_0x36cb3e['message'],_0x4edf7a);_0x4ee72d(_0x593857[_0x4abf('0x14')](0x1f4,_0x36cb3e[_0x4abf('0x16')]));});});};exports[_0x4abf('0x23')]=function(_0x45c0d4){var _0x54ab47=this;return new Promise(function(_0x26e255,_0x3cd7db){return db[_0x4abf('0x24')]['find']({'raw':_0x45c0d4[_0x4abf('0x1b')]?_0x45c0d4['options']['raw']===undefined?!![]:![]:!![],'where':_0x45c0d4[_0x4abf('0x1b')]?_0x45c0d4[_0x4abf('0x1b')][_0x4abf('0x1d')]||null:null,'attributes':_0x45c0d4[_0x4abf('0x1b')]?_0x45c0d4[_0x4abf('0x1b')][_0x4abf('0x1e')]||null:null,'include':_0x45c0d4[_0x4abf('0x1b')]?_0x45c0d4['options']['include']?_[_0x4abf('0x20')](_0x45c0d4[_0x4abf('0x1b')][_0x4abf('0x1f')],function(_0xa35efd){return{'model':db[_0xa35efd[_0x4abf('0x21')]],'as':_0xa35efd['as'],'attributes':_0xa35efd[_0x4abf('0x1e')],'include':_0xa35efd[_0x4abf('0x1f')]?_['map'](_0xa35efd[_0x4abf('0x1f')],function(_0x34cef1){return{'model':db[_0x34cef1[_0x4abf('0x21')]],'as':_0x34cef1['as'],'attributes':_0x34cef1[_0x4abf('0x1e')],'include':_0x34cef1[_0x4abf('0x1f')]?_[_0x4abf('0x20')](_0x34cef1['include'],function(_0x5a55ce){return{'model':db[_0x5a55ce[_0x4abf('0x21')]],'as':_0x5a55ce['as'],'attributes':_0x5a55ce[_0x4abf('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x4abf('0x22')](function(_0x22deef){logger[_0x4abf('0xf')]('ShowCmHopper',_0x45c0d4);logger[_0x4abf('0x11')](_0x4abf('0x23'),_0x45c0d4,JSON[_0x4abf('0x13')](_0x22deef));_0x26e255(_0x22deef);})[_0x4abf('0x18')](function(_0x36efb1){logger['error'](_0x4abf('0x23'),_0x36efb1[_0x4abf('0x16')],_0x45c0d4);_0x3cd7db(_0x54ab47['error'](0x1f4,_0x36efb1['message']));});});};exports[_0x4abf('0x25')]=function(_0x7a1c8b){var _0x84eecd=this;return new Promise(function(_0x148321,_0x36bd8c){return db[_0x4abf('0x24')][_0x4abf('0x26')](_0x7a1c8b[_0x4abf('0x27')],{'raw':_0x7a1c8b[_0x4abf('0x1b')]?_0x7a1c8b[_0x4abf('0x1b')][_0x4abf('0x1c')]===undefined?!![]:![]:!![]})[_0x4abf('0x22')](function(_0x2b1833){logger[_0x4abf('0xf')]('CreateCmHopper',_0x7a1c8b);logger[_0x4abf('0x11')]('CreateCmHopper',_0x7a1c8b,JSON[_0x4abf('0x13')](_0x2b1833));_0x148321(_0x2b1833);})[_0x4abf('0x18')](function(_0x5e2662){logger[_0x4abf('0x14')]('CreateCmHopper',_0x5e2662[_0x4abf('0x16')],_0x7a1c8b);_0x36bd8c(_0x84eecd[_0x4abf('0x14')](0x1f4,_0x5e2662[_0x4abf('0x16')]));});});};exports[_0x4abf('0x28')]=function(_0x441b52){var _0x34a42=this;return new Promise(function(_0x4951d3,_0x4928ac){return db['CmHopper'][_0x4abf('0x29')](_0x441b52[_0x4abf('0x27')],{'raw':_0x441b52[_0x4abf('0x1b')]?_0x441b52[_0x4abf('0x1b')][_0x4abf('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x441b52[_0x4abf('0x1b')]?_0x441b52[_0x4abf('0x1b')]['where']||null:null,'attributes':_0x441b52['options']?_0x441b52[_0x4abf('0x1b')][_0x4abf('0x1e')]||null:null,'limit':_0x441b52[_0x4abf('0x1b')]?_0x441b52[_0x4abf('0x1b')][_0x4abf('0x2a')]||null:null})[_0x4abf('0x22')](function(_0x1f40ec){logger[_0x4abf('0xf')](_0x4abf('0x28'),_0x441b52);logger[_0x4abf('0x11')](_0x4abf('0x28'),_0x441b52,JSON[_0x4abf('0x13')](_0x1f40ec));_0x4951d3(_0x1f40ec);})[_0x4abf('0x18')](function(_0x27afe0){logger['error'](_0x4abf('0x28'),_0x27afe0[_0x4abf('0x16')],_0x441b52);_0x4928ac(_0x34a42[_0x4abf('0x14')](0x1f4,_0x27afe0[_0x4abf('0x16')]));});});};exports['DestroyCmHopper']=function(_0x2cb989){var _0x153a1c=this;return new Promise(function(_0x23f69f,_0x28d0bc){return db['CmHopper'][_0x4abf('0x2b')]({'where':_0x2cb989['options']?_0x2cb989['options'][_0x4abf('0x1d')]||null:null})[_0x4abf('0x22')](function(_0x348624){logger[_0x4abf('0xf')](_0x4abf('0x2c'),_0x2cb989);logger[_0x4abf('0x11')](_0x4abf('0x2c'),_0x2cb989,JSON[_0x4abf('0x13')](_0x348624));_0x23f69f(_0x348624);})['catch'](function(_0x2811dd){logger[_0x4abf('0x14')](_0x4abf('0x2c'),_0x2811dd[_0x4abf('0x16')],_0x2cb989);_0x28d0bc(_0x153a1c[_0x4abf('0x14')](0x1f4,_0x2811dd[_0x4abf('0x16')]));});});};exports['GetContactDialer']=function(_0x25dc57){var _0x91222d=this;return new Promise(function(_0x3c30bd,_0x1229ce){return db[_0x4abf('0x2d')][_0x4abf('0x2e')]()[_0x4abf('0x22')](function(_0x1cc56e){return db[_0x4abf('0x2f')]['transaction'](function(_0x2a1e77){return db[_0x4abf('0x24')]['findAll']({'where':_0x25dc57[_0x4abf('0x1b')]?_0x25dc57[_0x4abf('0x1b')][_0x4abf('0x1d')]||null:null,'attributes':_0x25dc57[_0x4abf('0x1b')]?_0x25dc57['options'][_0x4abf('0x1e')]||null:null,'limit':_0x25dc57[_0x4abf('0x1b')]?_0x25dc57['options'][_0x4abf('0x2a')]||null:null,'order':_0x25dc57[_0x4abf('0x1b')]?_0x25dc57[_0x4abf('0x1b')]['order']||null:null,'transaction':_0x2a1e77,'lock':_0x2a1e77[_0x4abf('0x30')][_0x4abf('0x31')],'include':[{'model':db[_0x4abf('0x2d')],'as':_0x4abf('0x32'),'attributes':_[_0x4abf('0x33')](_0x1cc56e)},{'model':db[_0x4abf('0x34')],'as':_0x4abf('0x35'),'attributes':['id','name',_0x4abf('0x36')]}]})[_0x4abf('0x22')](function(_0x392602){var _0x2bcd8e=[];var _0x3520ce=[];for(var _0x393626=0x0;_0x393626<_0x392602[_0x4abf('0x37')];_0x393626+=0x1){if(!_0x3520ce['includes'](_0x392602[_0x393626]['UserId'])){_0x3520ce['push'](_0x392602[_0x393626][_0x4abf('0x38')]);_0x2bcd8e[_0x4abf('0x39')](_0x392602[_0x393626][_0x4abf('0x29')](_0x25dc57['body'],{'transaction':_0x2a1e77}));}}return BPromise[_0x4abf('0x3a')](_0x2bcd8e);});})[_0x4abf('0x22')](function(_0x3268b5){logger[_0x4abf('0xf')](_0x4abf('0x3b'),_0x25dc57);logger['debug'](_0x4abf('0x3b'),_0x25dc57,JSON[_0x4abf('0x13')](_0x3268b5));_0x3c30bd(_0x3268b5);})[_0x4abf('0x18')](function(_0x32eb88){logger['error'](_0x4abf('0x3b'),_0x32eb88[_0x4abf('0x16')],_0x25dc57);_0x1229ce(_0x91222d[_0x4abf('0x14')](0x1f4,_0x32eb88[_0x4abf('0x16')]));});});});};exports[_0x4abf('0x3c')]=function(_0xf68fc0){var _0x4970cf=this;return new Promise(function(_0x6901fb,_0x2949b8){return db[_0x4abf('0x2f')][_0x4abf('0x3d')](function(_0x4318a3){return db['CmHopperFinal']['create'](_0xf68fc0[_0x4abf('0x27')],{'raw':_0xf68fc0[_0x4abf('0x1b')]?_0xf68fc0['options'][_0x4abf('0x1c')]===undefined?!![]:![]:!![],'transaction':_0x4318a3})[_0x4abf('0x22')](function(){return db['CmHopper'][_0x4abf('0x2b')]({'where':_0xf68fc0[_0x4abf('0x1b')]?_0xf68fc0[_0x4abf('0x1b')]['where']||null:null,'transaction':_0x4318a3});});})[_0x4abf('0x22')](function(_0x5cc175){logger[_0x4abf('0xf')]('MoveContactManagedDialer',_0xf68fc0);logger['debug'](_0x4abf('0x3c'),_0xf68fc0,JSON[_0x4abf('0x13')](_0x5cc175));_0x6901fb(_0x5cc175);})[_0x4abf('0x18')](function(_0x67bd68){logger[_0x4abf('0x14')](_0x4abf('0x3c'),_0x67bd68[_0x4abf('0x16')],_0xf68fc0);_0x2949b8(_0x4970cf['error'](0x1f4,_0x67bd68['message']));});});};exports['CountReScheduled']=function(_0x397c1a){var _0x2dc03b=this;return new Promise(function(_0x21f7f8,_0xab2eab){return db[_0x4abf('0x24')]['findAll']({'raw':_0x397c1a['options']?_0x397c1a[_0x4abf('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x397c1a[_0x4abf('0x1b')]?_0x397c1a[_0x4abf('0x1b')][_0x4abf('0x1d')]||null:null,'attributes':[[db[_0x4abf('0x2f')]['fn'](_0x4abf('0x3e'),db[_0x4abf('0x2f')]['fn']('IF',db['sequelize'][_0x4abf('0x3f')](_0x4abf('0x40')+util['format']('\x22%s\x22',moment()[_0x4abf('0x41')](_0x4abf('0x42')))+_0x4abf('0x43')))),_0x4abf('0x44')]]})['then'](function(_0x388f73){logger['info'](_0x4abf('0x45'),_0x397c1a);logger[_0x4abf('0x11')]('CountReScheduled',_0x397c1a,JSON['stringify'](_0x388f73));_0x21f7f8(_0x388f73);})[_0x4abf('0x18')](function(_0x236870){logger[_0x4abf('0x14')](_0x4abf('0x45'),_0x236870[_0x4abf('0x16')],_0x397c1a);_0xab2eab(_0x2dc03b[_0x4abf('0x14')](0x1f4,_0x236870['message']));});});};exports['GetContactRecallMe']=function(_0x5d7cc1){var _0x19d800=this;return new Promise(function(_0x29e361,_0x360e4d){return db[_0x4abf('0x2d')][_0x4abf('0x2e')]()[_0x4abf('0x22')](function(_0x3d3ab4){return db[_0x4abf('0x2f')][_0x4abf('0x3d')](function(_0xbfeb1a){return db[_0x4abf('0x24')][_0x4abf('0x1a')]({'where':_0x5d7cc1['options']?_0x5d7cc1[_0x4abf('0x1b')][_0x4abf('0x1d')]||null:null,'attributes':_0x5d7cc1[_0x4abf('0x1b')]?_0x5d7cc1[_0x4abf('0x1b')][_0x4abf('0x1e')]||null:null,'limit':0x1,'order':_0x5d7cc1['options']?_0x5d7cc1[_0x4abf('0x1b')][_0x4abf('0x46')]||null:null,'group':db['CmHopper'][_0x4abf('0x38')],'transaction':_0xbfeb1a,'lock':_0xbfeb1a[_0x4abf('0x30')][_0x4abf('0x31')],'include':_0x5d7cc1[_0x4abf('0x1b')]?_0x5d7cc1[_0x4abf('0x1b')][_0x4abf('0x1f')]?_['map'](_0x5d7cc1[_0x4abf('0x1b')][_0x4abf('0x1f')],function(_0x34f5be){return{'model':db[_0x34f5be[_0x4abf('0x21')]],'as':_0x34f5be['as'],'attributes':_0x34f5be['attributes'],'include':_0x34f5be['include']?_[_0x4abf('0x20')](_0x34f5be['include'],function(_0x4a6051){return{'model':db[_0x4a6051[_0x4abf('0x21')]],'as':_0x4a6051['as'],'attributes':_0x4a6051[_0x4abf('0x1e')],'include':_0x4a6051['include']?_[_0x4abf('0x20')](_0x4a6051['include'],function(_0x47cd93){return{'model':db[_0x47cd93[_0x4abf('0x21')]],'as':_0x47cd93['as'],'attributes':_0x47cd93[_0x4abf('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x4abf('0x22')](function(_0x557588){var _0x5ec95f=[];for(var _0x39e11a=0x0;_0x39e11a<_0x557588[_0x4abf('0x37')];_0x39e11a+=0x1){_0x5ec95f['push'](_0x557588[_0x39e11a][_0x4abf('0x29')](_0x5d7cc1[_0x4abf('0x27')],{'transaction':_0xbfeb1a}));}return BPromise['all'](_0x5ec95f);});})[_0x4abf('0x22')](function(_0x2db4f4){logger[_0x4abf('0xf')](_0x4abf('0x47'),_0x5d7cc1);logger[_0x4abf('0x11')](_0x4abf('0x47'),_0x5d7cc1,JSON[_0x4abf('0x13')](_0x2db4f4));_0x29e361(_0x2db4f4);})[_0x4abf('0x18')](function(_0x36501d){logger[_0x4abf('0x14')](_0x4abf('0x47'),_0x36501d['message'],_0x5d7cc1);_0x360e4d(_0x19d800[_0x4abf('0x14')](0x1f4,_0x36501d[_0x4abf('0x16')]));});});});};exports[_0x4abf('0x48')]=function(_0x3cbe7f){var _0x2052c2=this;return new Promise(function(_0x422fdf,_0x9b246a){db[_0x4abf('0x2d')][_0x4abf('0x2e')]()[_0x4abf('0x22')](function(_0x5a64aa){return db[_0x4abf('0x24')][_0x4abf('0x1a')]({'raw':_0x3cbe7f[_0x4abf('0x1b')]?_0x3cbe7f['options']['raw']===undefined?!![]:![]:!![],'where':_0x3cbe7f[_0x4abf('0x1b')]?_0x3cbe7f[_0x4abf('0x1b')][_0x4abf('0x1d')]||null:null,'attributes':_0x3cbe7f[_0x4abf('0x1b')]?_0x3cbe7f['options']['attributes']||null:null,'limit':_0x3cbe7f['options']?_0x3cbe7f[_0x4abf('0x1b')][_0x4abf('0x2a')]||null:null,'include':_0x3cbe7f[_0x4abf('0x1b')]?_0x3cbe7f['options'][_0x4abf('0x1f')]?_[_0x4abf('0x20')](_0x3cbe7f[_0x4abf('0x1b')]['include'],function(_0x2a0ee9){return{'model':db[_0x2a0ee9['model']],'as':_0x2a0ee9['as'],'attributes':_0x2a0ee9['as']==='Contact'?_[_0x4abf('0x33')](_0x5a64aa):_0x2a0ee9[_0x4abf('0x1e')],'include':_0x2a0ee9['include']?_['map'](_0x2a0ee9[_0x4abf('0x1f')],function(_0x2df24a){return{'model':db[_0x2df24a[_0x4abf('0x21')]],'as':_0x2df24a['as'],'attributes':_0x2df24a[_0x4abf('0x1e')],'include':_0x2df24a['include']?_['map'](_0x2df24a[_0x4abf('0x1f')],function(_0x406ef4){return{'model':db[_0x406ef4[_0x4abf('0x21')]],'as':_0x406ef4['as'],'attributes':_0x406ef4['attributes']};}):[]};}):[]};}):[]:[]})[_0x4abf('0x22')](function(_0x6492b){logger[_0x4abf('0xf')](_0x4abf('0x19'),_0x3cbe7f);logger[_0x4abf('0x11')](_0x4abf('0x19'),_0x3cbe7f,JSON[_0x4abf('0x13')](_0x6492b));_0x422fdf(_0x6492b);})[_0x4abf('0x18')](function(_0x3c1a53){logger['error'](_0x4abf('0x19'),_0x3c1a53[_0x4abf('0x16')],_0x3cbe7f);_0x9b246a(_0x2052c2['error'](0x1f4,_0x3c1a53[_0x4abf('0x16')]));});});});};
\ No newline at end of file
+var _0xad48=['DestroyCmHopper','GetContactDialer','CmContact','describe','sequelize','transaction','order','LOCK','Contact','keys','User','Agent','name','voicePause','includes','UserId','push','update','CmHopperFinal','MoveContactManagedDialer','CountReScheduled','COUNT','literal','`scheduledat`\x20>=\x20','format','\x22%s\x22','YYYY-MM-DD\x20HH:mm:ss','\x20,\x201,\x20null','GetContactRecallMe','UPDATE','length','GetCmHopperPreview','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request\x20sent','CmHopper,\x20%s,\x20%s,\x20%s','code','error','CmHopper,\x20%s,\x20%s','message','info','result','GetCmHopper','CmHopper','findAll','options','raw','where','attributes','limit','include','map','model','then','stringify','ShowCmHopper','find','debug','catch','create','body','CreateCmHopper','UpdateCmHopper'];(function(_0x2bbe1c,_0x3b4be8){var _0x487020=function(_0x396ae1){while(--_0x396ae1){_0x2bbe1c['push'](_0x2bbe1c['shift']());}};_0x487020(++_0x3b4be8);}(_0xad48,0x69));var _0x8ad4=function(_0x5b45f2,_0x1ffe79){_0x5b45f2=_0x5b45f2-0x0;var _0x2795e7=_0xad48[_0x5b45f2];return _0x2795e7;};'use strict';var _=require(_0x8ad4('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x8ad4('0x1'));var rs=require(_0x8ad4('0x2'));var fs=require('fs');var Redis=require(_0x8ad4('0x3'));var db=require(_0x8ad4('0x4'))['db'];var utils=require(_0x8ad4('0x5'));var logger=require(_0x8ad4('0x6'))(_0x8ad4('0x7'));var config=require(_0x8ad4('0x8'));var jayson=require(_0x8ad4('0x9'));var client=jayson[_0x8ad4('0xa')][_0x8ad4('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x2f4ee3,_0x5a681a,_0x3860ba){return new BPromise(function(_0x5a3d69,_0x3bf3cd){return client['request'](_0x2f4ee3,_0x3860ba)['then'](function(_0x4cf030){logger['info']('CmHopper,\x20%s,\x20%s',_0x5a681a,_0x8ad4('0xc'));logger['debug'](_0x8ad4('0xd'),_0x5a681a,'request\x20sent',JSON['stringify'](_0x4cf030));if(_0x4cf030['error']){if(_0x4cf030['error'][_0x8ad4('0xe')]===0x1f4){logger[_0x8ad4('0xf')](_0x8ad4('0x10'),_0x5a681a,_0x4cf030['error'][_0x8ad4('0x11')]);return _0x3bf3cd(_0x4cf030[_0x8ad4('0xf')][_0x8ad4('0x11')]);}logger[_0x8ad4('0xf')](_0x8ad4('0x10'),_0x5a681a,_0x4cf030[_0x8ad4('0xf')][_0x8ad4('0x11')]);return _0x5a3d69(_0x4cf030[_0x8ad4('0xf')]['message']);}else{logger[_0x8ad4('0x12')](_0x8ad4('0x10'),_0x5a681a,_0x8ad4('0xc'));_0x5a3d69(_0x4cf030[_0x8ad4('0x13')][_0x8ad4('0x11')]);}})['catch'](function(_0x54c781){logger[_0x8ad4('0xf')]('CmHopper,\x20%s,\x20%s',_0x5a681a,_0x54c781);_0x3bf3cd(_0x54c781);});});}exports[_0x8ad4('0x14')]=function(_0x89a02c){var _0x29c735=this;return new Promise(function(_0x2588a3,_0x711a1c){return db[_0x8ad4('0x15')][_0x8ad4('0x16')]({'raw':_0x89a02c[_0x8ad4('0x17')]?_0x89a02c['options'][_0x8ad4('0x18')]===undefined?!![]:![]:!![],'where':_0x89a02c[_0x8ad4('0x17')]?_0x89a02c[_0x8ad4('0x17')][_0x8ad4('0x19')]||null:null,'attributes':_0x89a02c[_0x8ad4('0x17')]?_0x89a02c[_0x8ad4('0x17')][_0x8ad4('0x1a')]||null:null,'limit':_0x89a02c[_0x8ad4('0x17')]?_0x89a02c[_0x8ad4('0x17')][_0x8ad4('0x1b')]||null:null,'include':_0x89a02c[_0x8ad4('0x17')]?_0x89a02c[_0x8ad4('0x17')][_0x8ad4('0x1c')]?_[_0x8ad4('0x1d')](_0x89a02c['options']['include'],function(_0xb8fca7){return{'model':db[_0xb8fca7[_0x8ad4('0x1e')]],'as':_0xb8fca7['as'],'attributes':_0xb8fca7[_0x8ad4('0x1a')],'include':_0xb8fca7[_0x8ad4('0x1c')]?_[_0x8ad4('0x1d')](_0xb8fca7[_0x8ad4('0x1c')],function(_0x42edf0){return{'model':db[_0x42edf0[_0x8ad4('0x1e')]],'as':_0x42edf0['as'],'attributes':_0x42edf0[_0x8ad4('0x1a')],'include':_0x42edf0['include']?_[_0x8ad4('0x1d')](_0x42edf0[_0x8ad4('0x1c')],function(_0x517d93){return{'model':db[_0x517d93[_0x8ad4('0x1e')]],'as':_0x517d93['as'],'attributes':_0x517d93['attributes']};}):[]};}):[]};}):[]:[]})[_0x8ad4('0x1f')](function(_0x324785){logger[_0x8ad4('0x12')](_0x8ad4('0x14'),_0x89a02c);logger['debug'](_0x8ad4('0x14'),_0x89a02c,JSON[_0x8ad4('0x20')](_0x324785));_0x2588a3(_0x324785);})['catch'](function(_0x15d32d){logger[_0x8ad4('0xf')](_0x8ad4('0x14'),_0x15d32d[_0x8ad4('0x11')],_0x89a02c);_0x711a1c(_0x29c735[_0x8ad4('0xf')](0x1f4,_0x15d32d[_0x8ad4('0x11')]));});});};exports[_0x8ad4('0x21')]=function(_0x1d7390){var _0x2be115=this;return new Promise(function(_0xddfda7,_0x5bf029){return db[_0x8ad4('0x15')][_0x8ad4('0x22')]({'raw':_0x1d7390['options']?_0x1d7390[_0x8ad4('0x17')][_0x8ad4('0x18')]===undefined?!![]:![]:!![],'where':_0x1d7390[_0x8ad4('0x17')]?_0x1d7390[_0x8ad4('0x17')][_0x8ad4('0x19')]||null:null,'attributes':_0x1d7390[_0x8ad4('0x17')]?_0x1d7390[_0x8ad4('0x17')][_0x8ad4('0x1a')]||null:null,'include':_0x1d7390['options']?_0x1d7390[_0x8ad4('0x17')][_0x8ad4('0x1c')]?_[_0x8ad4('0x1d')](_0x1d7390[_0x8ad4('0x17')][_0x8ad4('0x1c')],function(_0x4a9ece){return{'model':db[_0x4a9ece[_0x8ad4('0x1e')]],'as':_0x4a9ece['as'],'attributes':_0x4a9ece[_0x8ad4('0x1a')],'include':_0x4a9ece[_0x8ad4('0x1c')]?_[_0x8ad4('0x1d')](_0x4a9ece['include'],function(_0xaa7999){return{'model':db[_0xaa7999[_0x8ad4('0x1e')]],'as':_0xaa7999['as'],'attributes':_0xaa7999['attributes'],'include':_0xaa7999[_0x8ad4('0x1c')]?_[_0x8ad4('0x1d')](_0xaa7999[_0x8ad4('0x1c')],function(_0x23cf5a){return{'model':db[_0x23cf5a[_0x8ad4('0x1e')]],'as':_0x23cf5a['as'],'attributes':_0x23cf5a[_0x8ad4('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x8ad4('0x1f')](function(_0x4e5232){logger[_0x8ad4('0x12')](_0x8ad4('0x21'),_0x1d7390);logger[_0x8ad4('0x23')]('ShowCmHopper',_0x1d7390,JSON[_0x8ad4('0x20')](_0x4e5232));_0xddfda7(_0x4e5232);})[_0x8ad4('0x24')](function(_0x4b20ba){logger[_0x8ad4('0xf')](_0x8ad4('0x21'),_0x4b20ba[_0x8ad4('0x11')],_0x1d7390);_0x5bf029(_0x2be115[_0x8ad4('0xf')](0x1f4,_0x4b20ba[_0x8ad4('0x11')]));});});};exports['CreateCmHopper']=function(_0x1ca939){var _0xa52c53=this;return new Promise(function(_0x5651b3,_0x24a490){return db['CmHopper'][_0x8ad4('0x25')](_0x1ca939[_0x8ad4('0x26')],{'raw':_0x1ca939['options']?_0x1ca939['options'][_0x8ad4('0x18')]===undefined?!![]:![]:!![]})['then'](function(_0x4ebf5b){logger[_0x8ad4('0x12')]('CreateCmHopper',_0x1ca939);logger[_0x8ad4('0x23')](_0x8ad4('0x27'),_0x1ca939,JSON[_0x8ad4('0x20')](_0x4ebf5b));_0x5651b3(_0x4ebf5b);})[_0x8ad4('0x24')](function(_0x4ecde8){logger['error'](_0x8ad4('0x27'),_0x4ecde8[_0x8ad4('0x11')],_0x1ca939);_0x24a490(_0xa52c53[_0x8ad4('0xf')](0x1f4,_0x4ecde8[_0x8ad4('0x11')]));});});};exports['UpdateCmHopper']=function(_0x5c9102){var _0x5de28e=this;return new Promise(function(_0x23317c,_0x1cd035){return db[_0x8ad4('0x15')]['update'](_0x5c9102[_0x8ad4('0x26')],{'raw':_0x5c9102[_0x8ad4('0x17')]?_0x5c9102[_0x8ad4('0x17')][_0x8ad4('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5c9102[_0x8ad4('0x17')]?_0x5c9102[_0x8ad4('0x17')][_0x8ad4('0x19')]||null:null,'attributes':_0x5c9102[_0x8ad4('0x17')]?_0x5c9102[_0x8ad4('0x17')][_0x8ad4('0x1a')]||null:null,'limit':_0x5c9102['options']?_0x5c9102[_0x8ad4('0x17')][_0x8ad4('0x1b')]||null:null})[_0x8ad4('0x1f')](function(_0x2cf451){logger['info'](_0x8ad4('0x28'),_0x5c9102);logger[_0x8ad4('0x23')]('UpdateCmHopper',_0x5c9102,JSON[_0x8ad4('0x20')](_0x2cf451));_0x23317c(_0x2cf451);})['catch'](function(_0x1e0768){logger['error'](_0x8ad4('0x28'),_0x1e0768[_0x8ad4('0x11')],_0x5c9102);_0x1cd035(_0x5de28e['error'](0x1f4,_0x1e0768[_0x8ad4('0x11')]));});});};exports[_0x8ad4('0x29')]=function(_0x235bee){var _0x5086ba=this;return new Promise(function(_0xff1095,_0x394720){return db[_0x8ad4('0x15')]['destroy']({'where':_0x235bee[_0x8ad4('0x17')]?_0x235bee[_0x8ad4('0x17')][_0x8ad4('0x19')]||null:null})['then'](function(_0x531f17){logger['info'](_0x8ad4('0x29'),_0x235bee);logger['debug'](_0x8ad4('0x29'),_0x235bee,JSON[_0x8ad4('0x20')](_0x531f17));_0xff1095(_0x531f17);})[_0x8ad4('0x24')](function(_0x427481){logger[_0x8ad4('0xf')](_0x8ad4('0x29'),_0x427481[_0x8ad4('0x11')],_0x235bee);_0x394720(_0x5086ba[_0x8ad4('0xf')](0x1f4,_0x427481['message']));});});};exports[_0x8ad4('0x2a')]=function(_0x55a415){var _0x37f4f9=this;return new Promise(function(_0x433873,_0x8e3eef){return db[_0x8ad4('0x2b')][_0x8ad4('0x2c')]()[_0x8ad4('0x1f')](function(_0x29d4c7){return db[_0x8ad4('0x2d')][_0x8ad4('0x2e')](function(_0x5611ca){return db[_0x8ad4('0x15')][_0x8ad4('0x16')]({'where':_0x55a415[_0x8ad4('0x17')]?_0x55a415[_0x8ad4('0x17')][_0x8ad4('0x19')]||null:null,'attributes':_0x55a415[_0x8ad4('0x17')]?_0x55a415[_0x8ad4('0x17')][_0x8ad4('0x1a')]||null:null,'limit':_0x55a415[_0x8ad4('0x17')]?_0x55a415['options']['limit']||null:null,'order':_0x55a415[_0x8ad4('0x17')]?_0x55a415[_0x8ad4('0x17')][_0x8ad4('0x2f')]||null:null,'transaction':_0x5611ca,'lock':_0x5611ca[_0x8ad4('0x30')]['UPDATE'],'include':[{'model':db[_0x8ad4('0x2b')],'as':_0x8ad4('0x31'),'attributes':_[_0x8ad4('0x32')](_0x29d4c7)},{'model':db[_0x8ad4('0x33')],'as':_0x8ad4('0x34'),'attributes':['id',_0x8ad4('0x35'),_0x8ad4('0x36')]}]})[_0x8ad4('0x1f')](function(_0x4cdca0){var _0x1adea7=[];var _0x49ed64=[];for(var _0x1c4f6c=0x0;_0x1c4f6c<_0x4cdca0['length'];_0x1c4f6c+=0x1){if(!_0x49ed64[_0x8ad4('0x37')](_0x4cdca0[_0x1c4f6c][_0x8ad4('0x38')])){_0x49ed64[_0x8ad4('0x39')](_0x4cdca0[_0x1c4f6c][_0x8ad4('0x38')]);_0x1adea7['push'](_0x4cdca0[_0x1c4f6c][_0x8ad4('0x3a')](_0x55a415['body'],{'transaction':_0x5611ca}));}}return BPromise['all'](_0x1adea7);});})[_0x8ad4('0x1f')](function(_0x298336){logger[_0x8ad4('0x12')]('GetContactDialer',_0x55a415);logger[_0x8ad4('0x23')](_0x8ad4('0x2a'),_0x55a415,JSON[_0x8ad4('0x20')](_0x298336));_0x433873(_0x298336);})[_0x8ad4('0x24')](function(_0xd6fa03){logger['error']('GetContactDialer',_0xd6fa03[_0x8ad4('0x11')],_0x55a415);_0x8e3eef(_0x37f4f9[_0x8ad4('0xf')](0x1f4,_0xd6fa03[_0x8ad4('0x11')]));});});});};exports['MoveContactManagedDialer']=function(_0x5254ed){var _0x3bea00=this;return new Promise(function(_0x204a55,_0x34f657){return db[_0x8ad4('0x2d')]['transaction'](function(_0x3fc33f){return db[_0x8ad4('0x3b')][_0x8ad4('0x25')](_0x5254ed[_0x8ad4('0x26')],{'raw':_0x5254ed[_0x8ad4('0x17')]?_0x5254ed[_0x8ad4('0x17')][_0x8ad4('0x18')]===undefined?!![]:![]:!![],'transaction':_0x3fc33f})[_0x8ad4('0x1f')](function(){return db[_0x8ad4('0x15')]['destroy']({'where':_0x5254ed[_0x8ad4('0x17')]?_0x5254ed[_0x8ad4('0x17')][_0x8ad4('0x19')]||null:null,'transaction':_0x3fc33f});});})[_0x8ad4('0x1f')](function(_0x56e7dd){logger[_0x8ad4('0x12')](_0x8ad4('0x3c'),_0x5254ed);logger[_0x8ad4('0x23')](_0x8ad4('0x3c'),_0x5254ed,JSON[_0x8ad4('0x20')](_0x56e7dd));_0x204a55(_0x56e7dd);})['catch'](function(_0x5959ff){logger[_0x8ad4('0xf')](_0x8ad4('0x3c'),_0x5959ff[_0x8ad4('0x11')],_0x5254ed);_0x34f657(_0x3bea00['error'](0x1f4,_0x5959ff[_0x8ad4('0x11')]));});});};exports[_0x8ad4('0x3d')]=function(_0x474d09){var _0x319067=this;return new Promise(function(_0x2c423c,_0x411d7f){return db[_0x8ad4('0x15')][_0x8ad4('0x16')]({'raw':_0x474d09[_0x8ad4('0x17')]?_0x474d09['options'][_0x8ad4('0x18')]===undefined?!![]:![]:!![],'where':_0x474d09[_0x8ad4('0x17')]?_0x474d09[_0x8ad4('0x17')]['where']||null:null,'attributes':[[db[_0x8ad4('0x2d')]['fn'](_0x8ad4('0x3e'),db[_0x8ad4('0x2d')]['fn']('IF',db[_0x8ad4('0x2d')][_0x8ad4('0x3f')](_0x8ad4('0x40')+util[_0x8ad4('0x41')](_0x8ad4('0x42'),moment()[_0x8ad4('0x41')](_0x8ad4('0x43')))+_0x8ad4('0x44')))),'contactsRescheduled']]})['then'](function(_0xbd22f9){logger['info'](_0x8ad4('0x3d'),_0x474d09);logger[_0x8ad4('0x23')](_0x8ad4('0x3d'),_0x474d09,JSON['stringify'](_0xbd22f9));_0x2c423c(_0xbd22f9);})['catch'](function(_0x5b15fc){logger[_0x8ad4('0xf')](_0x8ad4('0x3d'),_0x5b15fc[_0x8ad4('0x11')],_0x474d09);_0x411d7f(_0x319067[_0x8ad4('0xf')](0x1f4,_0x5b15fc[_0x8ad4('0x11')]));});});};exports[_0x8ad4('0x45')]=function(_0x26d66e){var _0x67d097=this;return new Promise(function(_0x5a6721,_0x24fa81){return db['CmContact'][_0x8ad4('0x2c')]()['then'](function(_0x2c9015){return db[_0x8ad4('0x2d')][_0x8ad4('0x2e')](function(_0x2e0e26){return db[_0x8ad4('0x15')]['findAll']({'where':_0x26d66e['options']?_0x26d66e['options'][_0x8ad4('0x19')]||null:null,'attributes':_0x26d66e[_0x8ad4('0x17')]?_0x26d66e['options']['attributes']||null:null,'limit':0x1,'order':_0x26d66e['options']?_0x26d66e['options'][_0x8ad4('0x2f')]||null:null,'group':db[_0x8ad4('0x15')][_0x8ad4('0x38')],'transaction':_0x2e0e26,'lock':_0x2e0e26[_0x8ad4('0x30')][_0x8ad4('0x46')],'include':_0x26d66e[_0x8ad4('0x17')]?_0x26d66e[_0x8ad4('0x17')][_0x8ad4('0x1c')]?_[_0x8ad4('0x1d')](_0x26d66e[_0x8ad4('0x17')][_0x8ad4('0x1c')],function(_0x127dbd){return{'model':db[_0x127dbd[_0x8ad4('0x1e')]],'as':_0x127dbd['as'],'attributes':_0x127dbd['attributes'],'include':_0x127dbd[_0x8ad4('0x1c')]?_['map'](_0x127dbd[_0x8ad4('0x1c')],function(_0x2e2c4b){return{'model':db[_0x2e2c4b[_0x8ad4('0x1e')]],'as':_0x2e2c4b['as'],'attributes':_0x2e2c4b[_0x8ad4('0x1a')],'include':_0x2e2c4b[_0x8ad4('0x1c')]?_[_0x8ad4('0x1d')](_0x2e2c4b[_0x8ad4('0x1c')],function(_0x4ee436){return{'model':db[_0x4ee436[_0x8ad4('0x1e')]],'as':_0x4ee436['as'],'attributes':_0x4ee436[_0x8ad4('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5e94cf){var _0x16b5c5=[];for(var _0x27f9a2=0x0;_0x27f9a2<_0x5e94cf[_0x8ad4('0x47')];_0x27f9a2+=0x1){_0x16b5c5['push'](_0x5e94cf[_0x27f9a2][_0x8ad4('0x3a')](_0x26d66e[_0x8ad4('0x26')],{'transaction':_0x2e0e26}));}return BPromise['all'](_0x16b5c5);});})[_0x8ad4('0x1f')](function(_0x483223){logger[_0x8ad4('0x12')](_0x8ad4('0x45'),_0x26d66e);logger[_0x8ad4('0x23')](_0x8ad4('0x45'),_0x26d66e,JSON[_0x8ad4('0x20')](_0x483223));_0x5a6721(_0x483223);})['catch'](function(_0x5aff48){logger[_0x8ad4('0xf')](_0x8ad4('0x45'),_0x5aff48[_0x8ad4('0x11')],_0x26d66e);_0x24fa81(_0x67d097[_0x8ad4('0xf')](0x1f4,_0x5aff48[_0x8ad4('0x11')]));});});});};exports[_0x8ad4('0x48')]=function(_0x11d18c){var _0x5cf34f=this;return new Promise(function(_0x46af3c,_0x1ef832){db['CmContact'][_0x8ad4('0x2c')]()[_0x8ad4('0x1f')](function(_0x198510){return db[_0x8ad4('0x15')][_0x8ad4('0x16')]({'raw':_0x11d18c[_0x8ad4('0x17')]?_0x11d18c['options'][_0x8ad4('0x18')]===undefined?!![]:![]:!![],'where':_0x11d18c[_0x8ad4('0x17')]?_0x11d18c[_0x8ad4('0x17')][_0x8ad4('0x19')]||null:null,'attributes':_0x11d18c[_0x8ad4('0x17')]?_0x11d18c['options'][_0x8ad4('0x1a')]||null:null,'limit':_0x11d18c['options']?_0x11d18c[_0x8ad4('0x17')][_0x8ad4('0x1b')]||null:null,'include':_0x11d18c[_0x8ad4('0x17')]?_0x11d18c[_0x8ad4('0x17')][_0x8ad4('0x1c')]?_['map'](_0x11d18c[_0x8ad4('0x17')]['include'],function(_0x34df1d){return{'model':db[_0x34df1d[_0x8ad4('0x1e')]],'as':_0x34df1d['as'],'attributes':_0x34df1d['as']===_0x8ad4('0x31')?_[_0x8ad4('0x32')](_0x198510):_0x34df1d[_0x8ad4('0x1a')],'include':_0x34df1d[_0x8ad4('0x1c')]?_[_0x8ad4('0x1d')](_0x34df1d[_0x8ad4('0x1c')],function(_0x193925){return{'model':db[_0x193925[_0x8ad4('0x1e')]],'as':_0x193925['as'],'attributes':_0x193925[_0x8ad4('0x1a')],'include':_0x193925[_0x8ad4('0x1c')]?_[_0x8ad4('0x1d')](_0x193925[_0x8ad4('0x1c')],function(_0x1d2ed2){return{'model':db[_0x1d2ed2[_0x8ad4('0x1e')]],'as':_0x1d2ed2['as'],'attributes':_0x1d2ed2['attributes']};}):[]};}):[]};}):[]:[]})[_0x8ad4('0x1f')](function(_0x27e90c){logger[_0x8ad4('0x12')]('GetCmHopper',_0x11d18c);logger[_0x8ad4('0x23')](_0x8ad4('0x14'),_0x11d18c,JSON[_0x8ad4('0x20')](_0x27e90c));_0x46af3c(_0x27e90c);})[_0x8ad4('0x24')](function(_0x538838){logger[_0x8ad4('0xf')](_0x8ad4('0x14'),_0x538838[_0x8ad4('0x11')],_0x11d18c);_0x1ef832(_0x5cf34f[_0x8ad4('0xf')](0x1f4,_0x538838[_0x8ad4('0x11')]));});});});};
\ No newline at end of file