Built motion from commit (unavailable).|2.5.0
[motion2.git] / server / config / schedule / chat.js
index cbeacea..d3e775f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9e00=['chatTimeout','ChatInteraction','lastMsgAt','subtract','minutes','update','system','timeout','YYYY-MM-DD\x20HH:mm:ss','map','length','emit','chatInteraction:update','error','start','moment','../../config/environment','defaults','redis','Setting','then'];(function(_0x3b3200,_0xc9454c){var _0x3650c1=function(_0x2dc786){while(--_0x2dc786){_0x3b3200['push'](_0x3b3200['shift']());}};_0x3650c1(++_0xc9454c);}(_0x9e00,0x1c8));var _0x09e0=function(_0x1facfa,_0x1acf7d){_0x1facfa=_0x1facfa-0x0;var _0x9ec701=_0x9e00[_0x1facfa];return _0x9ec701;};'use strict';var _=require('lodash');var moment=require(_0x09e0('0x0'));var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var config=require(_0x09e0('0x1'));config['redis']=_[_0x09e0('0x2')](config[_0x09e0('0x3')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x09e0('0x3')]));function closeInteractions(){var _0xc1aeb6=0x0;var _0x1660f4=[];return db[_0x09e0('0x4')]['find']({'raw':!![],'attributes':['id','chatTimeout'],'where':{'id':0x1}})[_0x09e0('0x5')](function(_0x59f912){_0xc1aeb6=_0x59f912[_0x09e0('0x6')];if(_0xc1aeb6){return db[_0x09e0('0x7')]['findAll']({'raw':!![],'attributes':['id',_0x09e0('0x8')],'where':{'closed':![],'lastMsgAt':{'$lt':moment()[_0x09e0('0x9')](_0x59f912[_0x09e0('0x6')],_0x09e0('0xa'))}}});}else{return[];}})['then'](function(_0x8d579e){_0x1660f4=_0x8d579e;if(_0xc1aeb6){return db[_0x09e0('0x7')][_0x09e0('0xb')]({'closeReason':_0x09e0('0xc'),'disposition':_0x09e0('0xd'),'closed':!![],'closedAt':moment()['format'](_0x09e0('0xe'))},{'where':{'id':_[_0x09e0('0xf')](_0x1660f4||[],'id')}});}})['then'](function(_0x1b5a5a){for(var _0x55ac5c=0x0;_0x55ac5c<_0x1660f4[_0x09e0('0x10')];_0x55ac5c++){io[_0x09e0('0x11')](_0x09e0('0x12'),{'id':_0x1660f4[_0x55ac5c]['id'],'closed':!![]});}})['catch'](function(_0x5b0855){console[_0x09e0('0x13')](_0x5b0855);});}exports[_0x09e0('0x14')]=function(){setInterval(function(){return closeInteractions();},0x3c*0x3e8);return closeInteractions();};
\ No newline at end of file
+var _0x259c=['Setting','find','chatTimeout','findAll','lastMsgAt','subtract','minutes','then','ChatInteraction','update','system','timeout','format','YYYY-MM-DD\x20HH:mm:ss','emit','chatInteraction:update','error','start','moment','../../mysqldb','../../config/environment','redis','defaults','localhost'];(function(_0x291276,_0x5a4690){var _0x303ab3=function(_0xb0fe70){while(--_0xb0fe70){_0x291276['push'](_0x291276['shift']());}};_0x303ab3(++_0x5a4690);}(_0x259c,0x17a));var _0xc259=function(_0x5af5e6,_0x39f247){_0x5af5e6=_0x5af5e6-0x0;var _0x278e5d=_0x259c[_0x5af5e6];return _0x278e5d;};'use strict';var _=require('lodash');var moment=require(_0xc259('0x0'));var Redis=require('ioredis');var db=require(_0xc259('0x1'))['db'];var config=require(_0xc259('0x2'));config[_0xc259('0x3')]=_[_0xc259('0x4')](config[_0xc259('0x3')],{'host':_0xc259('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xc259('0x3')]));function closeInteractions(){var _0x370243=0x0;var _0x5a6f8f=[];return db[_0xc259('0x6')][_0xc259('0x7')]({'raw':!![],'attributes':['id',_0xc259('0x8')],'where':{'id':0x1}})['then'](function(_0x28625d){_0x370243=_0x28625d['chatTimeout'];if(_0x370243){return db['ChatInteraction'][_0xc259('0x9')]({'raw':!![],'attributes':['id',_0xc259('0xa')],'where':{'closed':![],'lastMsgAt':{'$lt':moment()[_0xc259('0xb')](_0x28625d['chatTimeout'],_0xc259('0xc'))}}});}else{return[];}})[_0xc259('0xd')](function(_0x29afa0){_0x5a6f8f=_0x29afa0;if(_0x370243){return db[_0xc259('0xe')][_0xc259('0xf')]({'closeReason':_0xc259('0x10'),'disposition':_0xc259('0x11'),'closed':!![],'closedAt':moment()[_0xc259('0x12')](_0xc259('0x13'))},{'where':{'id':_['map'](_0x5a6f8f||[],'id')}});}})[_0xc259('0xd')](function(_0x423521){for(var _0x170b77=0x0;_0x170b77<_0x5a6f8f['length'];_0x170b77++){io[_0xc259('0x14')](_0xc259('0x15'),{'id':_0x5a6f8f[_0x170b77]['id'],'closed':!![]});}})['catch'](function(_0x297a3c){console[_0xc259('0x16')](_0x297a3c);});}exports[_0xc259('0x17')]=function(){setInterval(function(){return closeInteractions();},0x3c*0x3e8);return closeInteractions();};
\ No newline at end of file