Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / config / schedule / chat.js
index 3193709..9d31676 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3149=['chatInteraction:update','catch','error','start','lodash','moment','ioredis','../../mysqldb','../../config/environment','redis','defaults','localhost','socket.io-emitter','Setting','find','then','chatTimeout','ChatInteraction','findAll','lastMsgAt','subtract','minutes','update','system','timeout','format','YYYY-MM-DD\x20HH:mm:ss','length','emit'];(function(_0x2c1eab,_0x10ff7f){var _0x58360e=function(_0x308197){while(--_0x308197){_0x2c1eab['push'](_0x2c1eab['shift']());}};_0x58360e(++_0x10ff7f);}(_0x3149,0x1b7));var _0x9314=function(_0x29e090,_0x4a5a14){_0x29e090=_0x29e090-0x0;var _0xb0a91f=_0x3149[_0x29e090];return _0xb0a91f;};'use strict';var _=require(_0x9314('0x0'));var moment=require(_0x9314('0x1'));var Redis=require(_0x9314('0x2'));var db=require(_0x9314('0x3'))['db'];var config=require(_0x9314('0x4'));config[_0x9314('0x5')]=_[_0x9314('0x6')](config['redis'],{'host':_0x9314('0x7'),'port':0x18eb});var io=require(_0x9314('0x8'))(new Redis(config[_0x9314('0x5')]));function closeInteractions(){var _0x3bcb91=0x0;var _0x4c1c50=[];return db[_0x9314('0x9')][_0x9314('0xa')]({'raw':!![],'attributes':['id','chatTimeout'],'where':{'id':0x1}})[_0x9314('0xb')](function(_0x665265){_0x3bcb91=_0x665265[_0x9314('0xc')];if(_0x3bcb91){return db[_0x9314('0xd')][_0x9314('0xe')]({'raw':!![],'attributes':['id',_0x9314('0xf')],'where':{'closed':![],'lastMsgAt':{'$lt':moment()[_0x9314('0x10')](_0x665265['chatTimeout'],_0x9314('0x11'))}}});}else{return[];}})['then'](function(_0x817bc4){_0x4c1c50=_0x817bc4;if(_0x3bcb91){return db['ChatInteraction'][_0x9314('0x12')]({'closeReason':_0x9314('0x13'),'disposition':_0x9314('0x14'),'closed':!![],'closedAt':moment()[_0x9314('0x15')](_0x9314('0x16'))},{'where':{'id':_['map'](_0x4c1c50||[],'id')}});}})[_0x9314('0xb')](function(_0x51c1c9){for(var _0xd1de7b=0x0;_0xd1de7b<_0x4c1c50[_0x9314('0x17')];_0xd1de7b++){io[_0x9314('0x18')](_0x9314('0x19'),{'id':_0x4c1c50[_0xd1de7b]['id'],'closed':!![]});}})[_0x9314('0x1a')](function(_0x198e57){console[_0x9314('0x1b')](_0x198e57);});}exports[_0x9314('0x1c')]=function(){setInterval(function(){return closeInteractions();},0x3c*0x3e8);return closeInteractions();};
\ No newline at end of file
+var _0x72a9=['chatInteraction:update','catch','error','start','lodash','moment','ioredis','../../config/environment','redis','defaults','localhost','find','then','ChatInteraction','chatTimeout','minutes','update','timeout','format','YYYY-MM-DD\x20HH:mm:ss','emit'];(function(_0x2ef714,_0x49e1c4){var _0x252ab0=function(_0x868e73){while(--_0x868e73){_0x2ef714['push'](_0x2ef714['shift']());}};_0x252ab0(++_0x49e1c4);}(_0x72a9,0x12a));var _0x972a=function(_0x36e5fe,_0x425955){_0x36e5fe=_0x36e5fe-0x0;var _0x3cded9=_0x72a9[_0x36e5fe];return _0x3cded9;};'use strict';var _=require(_0x972a('0x0'));var moment=require(_0x972a('0x1'));var Redis=require(_0x972a('0x2'));var db=require('../../mysqldb')['db'];var config=require(_0x972a('0x3'));config[_0x972a('0x4')]=_[_0x972a('0x5')](config[_0x972a('0x4')],{'host':_0x972a('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x972a('0x4')]));function closeInteractions(){var _0x15e7b7=0x0;var _0x4cc7c9=[];return db['Setting'][_0x972a('0x7')]({'raw':!![],'attributes':['id','chatTimeout'],'where':{'id':0x1}})[_0x972a('0x8')](function(_0x538459){_0x15e7b7=_0x538459['chatTimeout'];if(_0x15e7b7){return db[_0x972a('0x9')]['findAll']({'raw':!![],'attributes':['id','lastMsgAt'],'where':{'closed':![],'lastMsgAt':{'$lt':moment()['subtract'](_0x538459[_0x972a('0xa')],_0x972a('0xb'))}}});}else{return[];}})[_0x972a('0x8')](function(_0x483a75){_0x4cc7c9=_0x483a75;if(_0x15e7b7){return db['ChatInteraction'][_0x972a('0xc')]({'closeReason':'system','disposition':_0x972a('0xd'),'closed':!![],'closedAt':moment()[_0x972a('0xe')](_0x972a('0xf'))},{'where':{'id':_['map'](_0x4cc7c9||[],'id')}});}})[_0x972a('0x8')](function(_0x199693){for(var _0x27b906=0x0;_0x27b906<_0x4cc7c9['length'];_0x27b906++){io[_0x972a('0x10')](_0x972a('0x11'),{'id':_0x4cc7c9[_0x27b906]['id'],'closed':!![]});}})[_0x972a('0x12')](function(_0xe07f6e){console[_0x972a('0x13')](_0xe07f6e);});}exports[_0x972a('0x14')]=function(){setInterval(function(){return closeInteractions();},0x3c*0x3e8);return closeInteractions();};
\ No newline at end of file