Built motion from commit a8c4dd89.|2.6.33
[motion2.git] / server / config / schedule / whatsapp.js
index 5eb249c..d447ac9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3f13=['length','map','info','[WHATSAPP]\x20Interactions\x20to\x20close:','join','update','system','format','YYYY-MM-DD\x20HH:mm:ss','[WHATSAPP]\x20Sending\x20updates\x20for\x20interactions:','emit','catch','[WHATSAPP]\x20Error\x20closing\x20interactions','inspect','start','lodash','util','../logger','schedule','redis','defaults','localhost','socket.io-emitter','WhatsappInteraction','lastMsgAt','subtract','hours','then'];(function(_0xabd853,_0x2f4184){var _0x2e20e6=function(_0x5857d1){while(--_0x5857d1){_0xabd853['push'](_0xabd853['shift']());}};_0x2e20e6(++_0x2f4184);}(_0x3f13,0x10b));var _0x33f1=function(_0x524a82,_0x5c3862){_0x524a82=_0x524a82-0x0;var _0x24d574=_0x3f13[_0x524a82];return _0x24d574;};'use strict';var _=require(_0x33f1('0x0'));var moment=require('moment');var Redis=require('ioredis');var util=require(_0x33f1('0x1'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];var logger=require(_0x33f1('0x2'))(_0x33f1('0x3'));config[_0x33f1('0x4')]=_[_0x33f1('0x5')](config[_0x33f1('0x4')],{'host':_0x33f1('0x6'),'port':0x18eb});var io=require(_0x33f1('0x7'))(new Redis(config['redis']));function closeInteractions(){var _0x21d367=[];return db[_0x33f1('0x8')]['findAll']({'raw':!![],'attributes':['id',_0x33f1('0x9')],'where':{'closed':![],'lastMsgDirection':'in','lastMsgAt':{'$lt':moment()[_0x33f1('0xa')](0x18,_0x33f1('0xb'))}}})[_0x33f1('0xc')](function(_0x43a539){if(_0x43a539&&_0x43a539[_0x33f1('0xd')]){_0x21d367=_[_0x33f1('0xe')](_0x43a539||[],'id');logger[_0x33f1('0xf')](_0x33f1('0x10'),_0x21d367[_0x33f1('0x11')]());return db[_0x33f1('0x8')][_0x33f1('0x12')]({'closeReason':_0x33f1('0x13'),'disposition':'timeout','closed':!![],'closedAt':moment()[_0x33f1('0x14')](_0x33f1('0x15'))},{'where':{'id':_0x21d367}});}})[_0x33f1('0xc')](function(){if(_0x21d367&&_0x21d367[_0x33f1('0xd')]){logger[_0x33f1('0xf')](_0x33f1('0x16'),_0x21d367['join']());for(var _0x23377c=0x0;_0x23377c<_0x21d367[_0x33f1('0xd')];_0x23377c++){io[_0x33f1('0x17')]('whatsappInteraction:update',{'id':_0x21d367[_0x23377c],'closed':!![]});}}})[_0x33f1('0x18')](function(_0x23dc3a){logger['error'](_0x33f1('0x19'),_0x23dc3a?util[_0x33f1('0x1a')](_0x23dc3a,{'showHidden':![],'depth':null}):'');});}exports[_0x33f1('0x1b')]=function(){setInterval(function(){return closeInteractions();},0x3c*0x3e8);return closeInteractions();};
\ No newline at end of file
+var _0x43ea=['[WHATSAPP]\x20Error\x20closing\x20interactions','inspect','moment','ioredis','util','../../config/environment','../../mysqldb','../logger','schedule','redis','defaults','localhost','socket.io-emitter','WhatsappInteraction','findAll','lastMsgAt','hours','length','map','[WHATSAPP]\x20Interactions\x20to\x20close:','join','update','system','timeout','format','YYYY-MM-DD\x20HH:mm:ss','then','[WHATSAPP]\x20Sending\x20updates\x20for\x20interactions:','emit','catch','error'];(function(_0x267e70,_0x4f4842){var _0x2e29ea=function(_0x8c02fd){while(--_0x8c02fd){_0x267e70['push'](_0x267e70['shift']());}};_0x2e29ea(++_0x4f4842);}(_0x43ea,0x157));var _0xa43e=function(_0x11abef,_0x30fd75){_0x11abef=_0x11abef-0x0;var _0xb0bf55=_0x43ea[_0x11abef];return _0xb0bf55;};'use strict';var _=require('lodash');var moment=require(_0xa43e('0x0'));var Redis=require(_0xa43e('0x1'));var util=require(_0xa43e('0x2'));var config=require(_0xa43e('0x3'));var db=require(_0xa43e('0x4'))['db'];var logger=require(_0xa43e('0x5'))(_0xa43e('0x6'));config[_0xa43e('0x7')]=_[_0xa43e('0x8')](config[_0xa43e('0x7')],{'host':_0xa43e('0x9'),'port':0x18eb});var io=require(_0xa43e('0xa'))(new Redis(config['redis']));function closeInteractions(){var _0x58efb2=[];return db[_0xa43e('0xb')][_0xa43e('0xc')]({'raw':!![],'attributes':['id',_0xa43e('0xd')],'where':{'closed':![],'lastMsgDirection':'in','lastMsgAt':{'$lt':moment()['subtract'](0x18,_0xa43e('0xe'))}}})['then'](function(_0x315992){if(_0x315992&&_0x315992[_0xa43e('0xf')]){_0x58efb2=_[_0xa43e('0x10')](_0x315992||[],'id');logger['info'](_0xa43e('0x11'),_0x58efb2[_0xa43e('0x12')]());return db['WhatsappInteraction'][_0xa43e('0x13')]({'closeReason':_0xa43e('0x14'),'disposition':_0xa43e('0x15'),'closed':!![],'closedAt':moment()[_0xa43e('0x16')](_0xa43e('0x17'))},{'where':{'id':_0x58efb2}});}})[_0xa43e('0x18')](function(){if(_0x58efb2&&_0x58efb2['length']){logger['info'](_0xa43e('0x19'),_0x58efb2[_0xa43e('0x12')]());for(var _0x193576=0x0;_0x193576<_0x58efb2[_0xa43e('0xf')];_0x193576++){io[_0xa43e('0x1a')]('whatsappInteraction:update',{'id':_0x58efb2[_0x193576],'closed':!![]});}}})[_0xa43e('0x1b')](function(_0x10b646){logger[_0xa43e('0x1c')](_0xa43e('0x1d'),_0x10b646?util[_0xa43e('0x1e')](_0x10b646,{'showHidden':![],'depth':null}):'');});}exports['start']=function(){setInterval(function(){return closeInteractions();},0x3c*0x3e8);return closeInteractions();};
\ No newline at end of file