Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / config / schedule / chat.js
index 2938c4f..fe479dd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x951c=['chatTimeout','then','lastMsgAt','subtract','minutes','ChatInteraction','update','system','YYYY-MM-DD\x20HH:mm:ss','map','length','chatInteraction:update','error','lodash','ioredis','../../mysqldb','../../config/environment','redis','localhost','socket.io-emitter','Setting','find'];(function(_0x58e469,_0x95ee3e){var _0x4c01c5=function(_0x1ef7ae){while(--_0x1ef7ae){_0x58e469['push'](_0x58e469['shift']());}};_0x4c01c5(++_0x95ee3e);}(_0x951c,0x115));var _0xc951=function(_0x3b96d8,_0x17e32e){_0x3b96d8=_0x3b96d8-0x0;var _0x37c4fa=_0x951c[_0x3b96d8];return _0x37c4fa;};'use strict';var _=require(_0xc951('0x0'));var moment=require('moment');var Redis=require(_0xc951('0x1'));var db=require(_0xc951('0x2'))['db'];var config=require(_0xc951('0x3'));config[_0xc951('0x4')]=_['defaults'](config[_0xc951('0x4')],{'host':_0xc951('0x5'),'port':0x18eb});var io=require(_0xc951('0x6'))(new Redis(config[_0xc951('0x4')]));function closeInteractions(){var _0x11b817=0x0;var _0x162de7=[];return db[_0xc951('0x7')][_0xc951('0x8')]({'raw':!![],'attributes':['id',_0xc951('0x9')],'where':{'id':0x1}})[_0xc951('0xa')](function(_0x34d669){_0x11b817=_0x34d669['chatTimeout'];if(_0x11b817){return db['ChatInteraction']['findAll']({'raw':!![],'attributes':['id',_0xc951('0xb')],'where':{'closed':![],'lastMsgAt':{'$lt':moment()[_0xc951('0xc')](_0x34d669[_0xc951('0x9')],_0xc951('0xd'))}}});}else{return[];}})[_0xc951('0xa')](function(_0xa35ca1){_0x162de7=_0xa35ca1;if(_0x11b817){return db[_0xc951('0xe')][_0xc951('0xf')]({'closeReason':_0xc951('0x10'),'disposition':'timeout','closed':!![],'closedAt':moment()['format'](_0xc951('0x11'))},{'where':{'id':_[_0xc951('0x12')](_0x162de7||[],'id')}});}})[_0xc951('0xa')](function(_0x5d288f){for(var _0x2e02dd=0x0;_0x2e02dd<_0x162de7[_0xc951('0x13')];_0x2e02dd++){io['emit'](_0xc951('0x14'),{'id':_0x162de7[_0x2e02dd]['id'],'closed':!![]});}})['catch'](function(_0x388f0a){console[_0xc951('0x15')](_0x388f0a);});}exports['start']=function(){setInterval(function(){return closeInteractions();},0x3c*0x3e8);return closeInteractions();};
\ No newline at end of file
+var _0x8d2b=['redis','localhost','Setting','find','chatTimeout','ChatInteraction','findAll','lastMsgAt','subtract','then','map','join','system','timeout','format','YYYY-MM-DD\x20HH:mm:ss','length','info','[CHAT]\x20Sending\x20updates\x20for\x20interactions:','emit','error','[CHAT]\x20Error\x20closing\x20interactions','inspect','start','lodash','moment','ioredis','util','../../config/environment','../../mysqldb','../logger'];(function(_0x12510b,_0x68b81d){var _0x56362f=function(_0x3ae55d){while(--_0x3ae55d){_0x12510b['push'](_0x12510b['shift']());}};_0x56362f(++_0x68b81d);}(_0x8d2b,0x94));var _0xb8d2=function(_0x34eb31,_0x8f0f70){_0x34eb31=_0x34eb31-0x0;var _0x254994=_0x8d2b[_0x34eb31];return _0x254994;};'use strict';var _=require(_0xb8d2('0x0'));var moment=require(_0xb8d2('0x1'));var Redis=require(_0xb8d2('0x2'));var util=require(_0xb8d2('0x3'));var config=require(_0xb8d2('0x4'));var db=require(_0xb8d2('0x5'))['db'];var logger=require(_0xb8d2('0x6'))('schedule');config[_0xb8d2('0x7')]=_['defaults'](config['redis'],{'host':_0xb8d2('0x8'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function closeInteractions(){var _0x420839=0x0;var _0x44903e=[];return db[_0xb8d2('0x9')][_0xb8d2('0xa')]({'raw':!![],'attributes':['id',_0xb8d2('0xb')],'where':{'id':0x1}})['then'](function(_0xa81533){_0x420839=_0xa81533[_0xb8d2('0xb')];if(_0x420839){return db[_0xb8d2('0xc')][_0xb8d2('0xd')]({'raw':!![],'attributes':['id',_0xb8d2('0xe')],'where':{'closed':![],'lastMsgAt':{'$lt':moment()[_0xb8d2('0xf')](_0xa81533[_0xb8d2('0xb')],'minutes')}}});}else{return[];}})[_0xb8d2('0x10')](function(_0x2e604f){if(_0x2e604f&&_0x2e604f['length']){_0x44903e=_[_0xb8d2('0x11')](_0x2e604f||[],'id');logger['info']('[CHAT]\x20Interactions\x20to\x20close:',_0x44903e[_0xb8d2('0x12')]());return db[_0xb8d2('0xc')]['update']({'closeReason':_0xb8d2('0x13'),'disposition':_0xb8d2('0x14'),'closed':!![],'closedAt':moment()[_0xb8d2('0x15')](_0xb8d2('0x16'))},{'where':{'id':_0x44903e}});}})[_0xb8d2('0x10')](function(){if(_0x44903e&&_0x44903e[_0xb8d2('0x17')]){logger[_0xb8d2('0x18')](_0xb8d2('0x19'),_0x44903e[_0xb8d2('0x12')]());for(var _0x8b4c13=0x0;_0x8b4c13<_0x44903e[_0xb8d2('0x17')];_0x8b4c13++){io[_0xb8d2('0x1a')]('chatInteraction:update',{'id':_0x44903e[_0x8b4c13],'closed':!![]});}}})['catch'](function(_0x21190a){logger[_0xb8d2('0x1b')](_0xb8d2('0x1c'),_0x21190a?util[_0xb8d2('0x1d')](_0x21190a,{'showHidden':![],'depth':null}):'');});}exports[_0xb8d2('0x1e')]=function(){setInterval(function(){return closeInteractions();},0x3c*0x3e8);return closeInteractions();};
\ No newline at end of file