Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / config / schedule / chat.js
index 8b11457..5216887 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x60fd=['schedule','redis','localhost','socket.io-emitter','chatTimeout','then','lastMsgAt','minutes','length','info','[CHAT]\x20Interactions\x20to\x20close:','system','format','YYYY-MM-DD\x20HH:mm:ss','join','chatInteraction:update','catch','error','[CHAT]\x20Error\x20closing\x20interactions','ioredis','util','../../config/environment','../../mysqldb'];(function(_0x4ae6ef,_0xc2af80){var _0x3cbb4e=function(_0x569ad5){while(--_0x569ad5){_0x4ae6ef['push'](_0x4ae6ef['shift']());}};_0x3cbb4e(++_0xc2af80);}(_0x60fd,0x1c8));var _0xd60f=function(_0x18c2ae,_0x286adc){_0x18c2ae=_0x18c2ae-0x0;var _0x1dd5d4=_0x60fd[_0x18c2ae];return _0x1dd5d4;};'use strict';var _=require('lodash');var moment=require('moment');var Redis=require(_0xd60f('0x0'));var util=require(_0xd60f('0x1'));var config=require(_0xd60f('0x2'));var db=require(_0xd60f('0x3'))['db'];var logger=require('../logger')(_0xd60f('0x4'));config[_0xd60f('0x5')]=_['defaults'](config['redis'],{'host':_0xd60f('0x6'),'port':0x18eb});var io=require(_0xd60f('0x7'))(new Redis(config[_0xd60f('0x5')]));function closeInteractions(){var _0x533690=0x0;var _0x46d37c=[];return db['Setting']['find']({'raw':!![],'attributes':['id',_0xd60f('0x8')],'where':{'id':0x1}})[_0xd60f('0x9')](function(_0xb6eed5){_0x533690=_0xb6eed5[_0xd60f('0x8')];if(_0x533690){return db['ChatInteraction']['findAll']({'raw':!![],'attributes':['id',_0xd60f('0xa')],'where':{'closed':![],'lastMsgAt':{'$lt':moment()['subtract'](_0xb6eed5[_0xd60f('0x8')],_0xd60f('0xb'))}}});}else{return[];}})[_0xd60f('0x9')](function(_0x12b84b){if(_0x12b84b&&_0x12b84b[_0xd60f('0xc')]){_0x46d37c=_['map'](_0x12b84b||[],'id');logger[_0xd60f('0xd')](_0xd60f('0xe'),_0x46d37c['join']());return db['ChatInteraction']['update']({'closeReason':_0xd60f('0xf'),'disposition':'timeout','closed':!![],'closedAt':moment()[_0xd60f('0x10')](_0xd60f('0x11'))},{'where':{'id':_0x46d37c}});}})[_0xd60f('0x9')](function(){if(_0x46d37c&&_0x46d37c[_0xd60f('0xc')]){logger[_0xd60f('0xd')]('[CHAT]\x20Sending\x20updates\x20for\x20interactions:',_0x46d37c[_0xd60f('0x12')]());for(var _0xbdc10=0x0;_0xbdc10<_0x46d37c[_0xd60f('0xc')];_0xbdc10++){io['emit'](_0xd60f('0x13'),{'id':_0x46d37c[_0xbdc10],'closed':!![]});}}})[_0xd60f('0x14')](function(_0x4893bb){logger[_0xd60f('0x15')](_0xd60f('0x16'),_0x4893bb?util['inspect'](_0x4893bb,{'showHidden':![],'depth':null}):'');});}exports['start']=function(){setInterval(function(){return closeInteractions();},0x3c*0x3e8);return closeInteractions();};
\ No newline at end of file
+var _0x652a=['YYYY-MM-DD\x20HH:mm:ss','[CHAT]\x20Sending\x20updates\x20for\x20interactions:','emit','chatInteraction:update','inspect','start','lodash','ioredis','util','../../config/environment','schedule','redis','defaults','localhost','Setting','chatTimeout','ChatInteraction','then','length','map','info','join','update','format'];(function(_0x30f806,_0x3bd0d8){var _0xddbfc7=function(_0x1ed34f){while(--_0x1ed34f){_0x30f806['push'](_0x30f806['shift']());}};_0xddbfc7(++_0x3bd0d8);}(_0x652a,0x1b6));var _0xa652=function(_0x25d7f4,_0x25f79f){_0x25d7f4=_0x25d7f4-0x0;var _0x4112d8=_0x652a[_0x25d7f4];return _0x4112d8;};'use strict';var _=require(_0xa652('0x0'));var moment=require('moment');var Redis=require(_0xa652('0x1'));var util=require(_0xa652('0x2'));var config=require(_0xa652('0x3'));var db=require('../../mysqldb')['db'];var logger=require('../logger')(_0xa652('0x4'));config[_0xa652('0x5')]=_[_0xa652('0x6')](config[_0xa652('0x5')],{'host':_0xa652('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xa652('0x5')]));function closeInteractions(){var _0x25e206=0x0;var _0xc0bfb8=[];return db[_0xa652('0x8')]['find']({'raw':!![],'attributes':['id',_0xa652('0x9')],'where':{'id':0x1}})['then'](function(_0x4f35dd){_0x25e206=_0x4f35dd[_0xa652('0x9')];if(_0x25e206){return db[_0xa652('0xa')]['findAll']({'raw':!![],'attributes':['id','lastMsgAt'],'where':{'closed':![],'lastMsgAt':{'$lt':moment()['subtract'](_0x4f35dd[_0xa652('0x9')],'minutes')}}});}else{return[];}})[_0xa652('0xb')](function(_0x3f0f88){if(_0x3f0f88&&_0x3f0f88[_0xa652('0xc')]){_0xc0bfb8=_[_0xa652('0xd')](_0x3f0f88||[],'id');logger[_0xa652('0xe')]('[CHAT]\x20Interactions\x20to\x20close:',_0xc0bfb8[_0xa652('0xf')]());return db[_0xa652('0xa')][_0xa652('0x10')]({'closeReason':'system','disposition':'timeout','closed':!![],'closedAt':moment()[_0xa652('0x11')](_0xa652('0x12'))},{'where':{'id':_0xc0bfb8}});}})[_0xa652('0xb')](function(){if(_0xc0bfb8&&_0xc0bfb8['length']){logger['info'](_0xa652('0x13'),_0xc0bfb8[_0xa652('0xf')]());for(var _0x578b23=0x0;_0x578b23<_0xc0bfb8[_0xa652('0xc')];_0x578b23++){io[_0xa652('0x14')](_0xa652('0x15'),{'id':_0xc0bfb8[_0x578b23],'closed':!![]});}}})['catch'](function(_0x1291ee){logger['error']('[CHAT]\x20Error\x20closing\x20interactions',_0x1291ee?util[_0xa652('0x16')](_0x1291ee,{'showHidden':![],'depth':null}):'');});}exports[_0xa652('0x17')]=function(){setInterval(function(){return closeInteractions();},0x3c*0x3e8);return closeInteractions();};
\ No newline at end of file