Built motion from commit f74363e9.|2.6.34
[motion2.git] / server / services / routing / server / applications / autoreply.js
index d32b43d..9990287 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5db8=['../../rpc/mailInteraction','../../mailRpc','consequence','channel','body','info','[%s][AUTOREPLY]\x20%s','Autoreply\x20not\x20executed\x20(message\x20is\x20autoreply)','next','isNil','interaction','created','Autoreply\x20already\x20sent','autoreplyExecuted','One\x20Time\x20already\x20sent','contact','YYYY-MM-DD\x20HH:mm:ss','out','mail','getMustacheRender','message','from','phone','read','subject','startsWith','Re:','Re:\x20','chat','upperFirst','account','InteractionId','Message','messageId','html','<div\x20id=\x22xm-mail-content\x22>','<div\x20id=\x22xm-mail-content\x22','<div','</div>','auto-replied','All','auto_reply','sendMailMessage','smtpOptions','then','create','stringify','error','resolve','[%s][AUTOREPLY][autoreplyExecuted]\x20%s','[RPC][%s][AUTOREPLY][autoreplyExecuted]\x20%s','catch','finally','update','stop','lodash','moment','./utils','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/faxMessage','../../rpc/chatInteraction','../../rpc/openchannelInteraction'];(function(_0x2b5ffa,_0x8420cf){var _0x2bef51=function(_0x34c3dc){while(--_0x34c3dc){_0x2b5ffa['push'](_0x2b5ffa['shift']());}};_0x2bef51(++_0x8420cf);}(_0x5db8,0x13b));var _0x85db=function(_0x2dfd0e,_0x13739e){_0x2dfd0e=_0x2dfd0e-0x0;var _0x343af6=_0x5db8[_0x2dfd0e];return _0x343af6;};'use strict';var _=require(_0x85db('0x0'));var moment=require(_0x85db('0x1'));var utils=require(_0x85db('0x2'));var logger=require(_0x85db('0x3'))(_0x85db('0x4'));var rpc={'chatMessage':require(_0x85db('0x5')),'openchannelMessage':require(_0x85db('0x6')),'mailMessage':require('../../rpc/mailMessage'),'smsMessage':require('../../rpc/smsMessage'),'faxMessage':require(_0x85db('0x7')),'whatsappMessage':require('../../rpc/whatsappMessage'),'chatInteraction':require(_0x85db('0x8')),'openchannelInteraction':require(_0x85db('0x9')),'mailInteraction':require(_0x85db('0xa')),'smsInteraction':require('../../rpc/smsInteraction'),'faxInteraction':require('../../rpc/faxInteraction'),'whatsappInteraction':require('../../rpc/whatsappInteraction')};var mailRpc=require(_0x85db('0xb'));exports[_0x85db('0xc')]=function(_0x1efbc9,_0x52d983,_0x557142,_0x58af58){return function(_0x256a65){try{var _0x4603b1=this[_0x85db('0xd')];if(_0x4603b1==='mail'&&_0x58af58[_0x85db('0xe')]['isAutoreply']){logger[_0x85db('0xf')](_0x85db('0x10'),_0x1efbc9,_0x85db('0x11'));return _0x256a65[_0x85db('0x12')]();}if(_0x52d983[0x0]==='1'&&(_[_0x85db('0x13')](this[_0x85db('0x14')][_0x85db('0x15')])||!this[_0x85db('0x14')][_0x85db('0x15')])){logger[_0x85db('0xf')](_0x85db('0x10'),_0x1efbc9,_0x85db('0x16'));return _0x256a65['next']();}if(_0x52d983[0x0]==='2'&&this['interaction'][_0x85db('0x17')]){logger[_0x85db('0xf')]('[%s][AUTOREPLY][autoreplyExecuted]\x20%s',_0x1efbc9,_0x85db('0x18'));return _0x256a65[_0x85db('0x12')]();}var _0x20f5a0={'ContactId':this[_0x85db('0x19')]['id'],'sentAt':moment()['format'](_0x85db('0x1a')),'direction':_0x85db('0x1b')};if(this['channel']===_0x85db('0x1c')){_0x20f5a0[_0x85db('0xe')]=utils[_0x85db('0x1d')](_0x52d983[0x2],this);}else{_0x20f5a0[_0x85db('0xe')]=utils[_0x85db('0x1d')](_0x52d983[0x1],this);}if(this[_0x85db('0x1e')]){_0x20f5a0['to']=this['message']['from']||'';if(this['channel']===_0x85db('0x1c')&&_0x52d983[0x1]==='1'){_0x20f5a0['cc']=this[_0x85db('0x1e')]['cc']||'';}_0x20f5a0[_0x85db('0x1f')]=this[_0x85db('0x1e')]['to']||'';_0x20f5a0[_0x85db('0x20')]=this[_0x85db('0x1e')][_0x85db('0x20')]||'';_0x20f5a0[_0x85db('0x21')]=!![];if(this[_0x85db('0x1e')][_0x85db('0x22')]){_0x20f5a0['subject']='';_0x20f5a0[_0x85db('0x22')]+=_[_0x85db('0x23')](this['message'][_0x85db('0x22')],_0x85db('0x24'))?'':_0x85db('0x25');_0x20f5a0[_0x85db('0x22')]+=this[_0x85db('0x1e')][_0x85db('0x22')];}}if(this['channel']===_0x85db('0x26')){_0x20f5a0['ChatWebsiteId']=this['account']['id'];}else{_0x20f5a0[_[_0x85db('0x27')](this[_0x85db('0xd')])+'AccountId']=this[_0x85db('0x28')]['id'];}_0x20f5a0[_['upperFirst'](this[_0x85db('0xd')])+_0x85db('0x29')]=this[_0x85db('0x14')]['id'];var _0x176549=this[_0x85db('0x14')];if(rpc[this[_0x85db('0xd')]+_0x85db('0x2a')]){if(this[_0x85db('0xd')]===_0x85db('0x1c')){_0x20f5a0['inReplyTo']=this['message'][_0x85db('0x2b')];_0x20f5a0[_0x85db('0x2c')]=_0x85db('0x2d')+_['replace'](_0x20f5a0[_0x85db('0xe')],_0x85db('0x2e'),_0x85db('0x2f'))+_0x85db('0x30');_0x20f5a0['headers']={'Auto-Submitted':_0x85db('0x31'),'X-Auto-Response-Suppress':_0x85db('0x32'),'Precedence':_0x85db('0x33')};return mailRpc[_0x85db('0x34')](this['account'][_0x85db('0x35')],_0x20f5a0)[_0x85db('0x36')](function(_0x2101c5){logger[_0x85db('0xf')]('[%s][AUTOREPLY]\x20SMTP\x20SENT',_0x1efbc9);_0x20f5a0[_0x85db('0x2b')]=_0x2101c5[_0x85db('0x1e')][_0x85db('0x2b')];return rpc[_0x4603b1+_0x85db('0x2a')][_0x85db('0x37')](_0x20f5a0);})[_0x85db('0x36')](function(_0x2a0883){logger['info']('[%s][AUTOREPLY]\x20%s',_0x1efbc9,JSON[_0x85db('0x38')](_0x2a0883));})['catch'](function(_0x2f15a0){logger[_0x85db('0x39')]('[RPC][%s][AUTOREPLY]\x20%s',_0x1efbc9,JSON[_0x85db('0x38')](_0x2f15a0));})['finally'](function(){Promise[_0x85db('0x3a')]()[_0x85db('0x36')](function(){if(_0x52d983[0x0]!=='2'||_0x176549[_0x85db('0x17')])return;return rpc[_0x4603b1+'Interaction']['update'](_0x176549['id'],{'autoreplyExecuted':!![]})['then'](function(_0x11eb91){logger[_0x85db('0xf')](_0x85db('0x3b'),_0x1efbc9,JSON[_0x85db('0x38')](_0x11eb91));})['catch'](function(_0x4cdb1f){logger[_0x85db('0x39')](_0x85db('0x3c'),_0x1efbc9,JSON['stringify'](_0x4cdb1f));});})['then'](function(){_0x256a65['next']();});});}else{return rpc[this[_0x85db('0xd')]+'Message'][_0x85db('0x37')](_0x20f5a0)[_0x85db('0x36')](function(){logger[_0x85db('0xf')](_0x85db('0x10'),_0x1efbc9,_0x20f5a0['body']);})[_0x85db('0x3d')](function(_0x46ab8b){logger[_0x85db('0x39')](_0x85db('0x10'),_0x1efbc9,JSON['stringify'](_0x46ab8b));})[_0x85db('0x3e')](function(){Promise[_0x85db('0x3a')]()[_0x85db('0x36')](function(){if(_0x52d983[0x0]!=='2'||_0x176549[_0x85db('0x17')])return;return rpc[_0x4603b1+'Interaction'][_0x85db('0x3f')](_0x176549['id'],{'autoreplyExecuted':!![]})[_0x85db('0x36')](function(_0x2801cc){logger[_0x85db('0xf')]('[%s][AUTOREPLY][autoreplyExecuted]\x20%s',_0x1efbc9,JSON[_0x85db('0x38')](_0x2801cc));})[_0x85db('0x3d')](function(_0x4c39ce){logger['error'](_0x85db('0x3c'),_0x1efbc9,JSON['stringify'](_0x4c39ce));});})[_0x85db('0x36')](function(){_0x256a65['next']();});});}}}catch(_0x212603){logger[_0x85db('0x39')](_0x85db('0x10'),_0x1efbc9,JSON[_0x85db('0x38')](_0x212603));_0x256a65[_0x85db('0x40')]();}};};
\ No newline at end of file
+var _0xbdc6=['Interaction','update','stringify','error','[RPC][%s][AUTOREPLY][autoreplyExecuted]\x20%s','stop','lodash','moment','./utils','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','../../rpc/chatInteraction','../../rpc/openchannelInteraction','../../rpc/mailInteraction','../../rpc/smsInteraction','../../rpc/faxInteraction','../../rpc/whatsappInteraction','../../mailRpc','consequence','channel','mail','[%s][AUTOREPLY]\x20%s','Autoreply\x20not\x20executed\x20(message\x20is\x20autoreply)','next','isNil','interaction','created','info','Autoreply\x20already\x20sent','autoreplyExecuted','[%s][AUTOREPLY][autoreplyExecuted]\x20%s','One\x20Time\x20already\x20sent','format','YYYY-MM-DD\x20HH:mm:ss','out','body','getMustacheRender','message','from','phone','read','subject','startsWith','Re:','Re:\x20','chat','ChatWebsiteId','upperFirst','AccountId','account','Message','inReplyTo','messageId','html','<div\x20id=\x22xm-mail-content\x22>','replace','<div\x20id=\x22xm-mail-content\x22','</div>','headers','auto-replied','All','sendMailMessage','smtpOptions','then','create','catch','[RPC][%s][AUTOREPLY]\x20%s','finally','resolve'];(function(_0x2daf2c,_0x4815b8){var _0x1763b0=function(_0x3ae553){while(--_0x3ae553){_0x2daf2c['push'](_0x2daf2c['shift']());}};_0x1763b0(++_0x4815b8);}(_0xbdc6,0x178));var _0x6bdc=function(_0x450c40,_0x3cd4d2){_0x450c40=_0x450c40-0x0;var _0xf20c92=_0xbdc6[_0x450c40];return _0xf20c92;};'use strict';var _=require(_0x6bdc('0x0'));var moment=require(_0x6bdc('0x1'));var utils=require(_0x6bdc('0x2'));var logger=require(_0x6bdc('0x3'))(_0x6bdc('0x4'));var rpc={'chatMessage':require(_0x6bdc('0x5')),'openchannelMessage':require('../../rpc/openchannelMessage'),'mailMessage':require(_0x6bdc('0x6')),'smsMessage':require(_0x6bdc('0x7')),'faxMessage':require(_0x6bdc('0x8')),'whatsappMessage':require(_0x6bdc('0x9')),'chatInteraction':require(_0x6bdc('0xa')),'openchannelInteraction':require(_0x6bdc('0xb')),'mailInteraction':require(_0x6bdc('0xc')),'smsInteraction':require(_0x6bdc('0xd')),'faxInteraction':require(_0x6bdc('0xe')),'whatsappInteraction':require(_0x6bdc('0xf'))};var mailRpc=require(_0x6bdc('0x10'));exports[_0x6bdc('0x11')]=function(_0x4fd7c0,_0x2f2fe7,_0x28018f,_0x17bded){return function(_0x1eb78b){try{var _0x9571fd=this[_0x6bdc('0x12')];if(_0x9571fd===_0x6bdc('0x13')&&_0x17bded['body']['isAutoreply']){logger['info'](_0x6bdc('0x14'),_0x4fd7c0,_0x6bdc('0x15'));return _0x1eb78b[_0x6bdc('0x16')]();}if(_0x2f2fe7[0x0]==='1'&&(_[_0x6bdc('0x17')](this[_0x6bdc('0x18')]['created'])||!this[_0x6bdc('0x18')][_0x6bdc('0x19')])){logger[_0x6bdc('0x1a')](_0x6bdc('0x14'),_0x4fd7c0,_0x6bdc('0x1b'));return _0x1eb78b[_0x6bdc('0x16')]();}if(_0x2f2fe7[0x0]==='2'&&this['interaction'][_0x6bdc('0x1c')]){logger['info'](_0x6bdc('0x1d'),_0x4fd7c0,_0x6bdc('0x1e'));return _0x1eb78b[_0x6bdc('0x16')]();}var _0x24cc1a={'ContactId':this['contact']['id'],'sentAt':moment()[_0x6bdc('0x1f')](_0x6bdc('0x20')),'direction':_0x6bdc('0x21')};if(this[_0x6bdc('0x12')]===_0x6bdc('0x13')){_0x24cc1a[_0x6bdc('0x22')]=utils[_0x6bdc('0x23')](_0x2f2fe7[0x2],this);}else{_0x24cc1a[_0x6bdc('0x22')]=utils[_0x6bdc('0x23')](_0x2f2fe7[0x1],this);}if(this[_0x6bdc('0x24')]){_0x24cc1a['to']=this[_0x6bdc('0x24')][_0x6bdc('0x25')]||'';if(this[_0x6bdc('0x12')]===_0x6bdc('0x13')&&_0x2f2fe7[0x1]==='1'){_0x24cc1a['cc']=this[_0x6bdc('0x24')]['cc']||'';}_0x24cc1a[_0x6bdc('0x25')]=this[_0x6bdc('0x24')]['to']||'';_0x24cc1a[_0x6bdc('0x26')]=this[_0x6bdc('0x24')]['phone']||'';_0x24cc1a[_0x6bdc('0x27')]=!![];if(this[_0x6bdc('0x24')][_0x6bdc('0x28')]){_0x24cc1a[_0x6bdc('0x28')]='';_0x24cc1a[_0x6bdc('0x28')]+=_[_0x6bdc('0x29')](this[_0x6bdc('0x24')]['subject'],_0x6bdc('0x2a'))?'':_0x6bdc('0x2b');_0x24cc1a[_0x6bdc('0x28')]+=this[_0x6bdc('0x24')][_0x6bdc('0x28')];}}if(this['channel']===_0x6bdc('0x2c')){_0x24cc1a[_0x6bdc('0x2d')]=this['account']['id'];}else{_0x24cc1a[_[_0x6bdc('0x2e')](this[_0x6bdc('0x12')])+_0x6bdc('0x2f')]=this[_0x6bdc('0x30')]['id'];}_0x24cc1a[_['upperFirst'](this[_0x6bdc('0x12')])+'InteractionId']=this[_0x6bdc('0x18')]['id'];var _0x2cb868=this[_0x6bdc('0x18')];if(rpc[this[_0x6bdc('0x12')]+_0x6bdc('0x31')]){if(this[_0x6bdc('0x12')]===_0x6bdc('0x13')){_0x24cc1a[_0x6bdc('0x32')]=this[_0x6bdc('0x24')][_0x6bdc('0x33')];_0x24cc1a[_0x6bdc('0x34')]=_0x6bdc('0x35')+_[_0x6bdc('0x36')](_0x24cc1a[_0x6bdc('0x22')],_0x6bdc('0x37'),'<div')+_0x6bdc('0x38');_0x24cc1a[_0x6bdc('0x39')]={'Auto-Submitted':_0x6bdc('0x3a'),'X-Auto-Response-Suppress':_0x6bdc('0x3b'),'Precedence':'auto_reply'};return mailRpc[_0x6bdc('0x3c')](this[_0x6bdc('0x30')][_0x6bdc('0x3d')],_0x24cc1a)[_0x6bdc('0x3e')](function(_0x8fa086){logger[_0x6bdc('0x1a')]('[%s][AUTOREPLY]\x20SMTP\x20SENT',_0x4fd7c0);_0x24cc1a['messageId']=_0x8fa086[_0x6bdc('0x24')]['messageId'];return rpc[_0x9571fd+_0x6bdc('0x31')][_0x6bdc('0x3f')](_0x24cc1a);})[_0x6bdc('0x3e')](function(_0x3cfbbe){logger[_0x6bdc('0x1a')](_0x6bdc('0x14'),_0x4fd7c0,JSON['stringify'](_0x3cfbbe));})[_0x6bdc('0x40')](function(_0x3fda84){logger['error'](_0x6bdc('0x41'),_0x4fd7c0,JSON['stringify'](_0x3fda84));})[_0x6bdc('0x42')](function(){Promise[_0x6bdc('0x43')]()['then'](function(){if(_0x2f2fe7[0x0]!=='2'||_0x2cb868[_0x6bdc('0x1c')])return;return rpc[_0x9571fd+_0x6bdc('0x44')][_0x6bdc('0x45')](_0x2cb868['id'],{'autoreplyExecuted':!![]})[_0x6bdc('0x3e')](function(_0x57d6b7){logger[_0x6bdc('0x1a')](_0x6bdc('0x1d'),_0x4fd7c0,JSON[_0x6bdc('0x46')](_0x57d6b7));})['catch'](function(_0x591120){logger[_0x6bdc('0x47')]('[RPC][%s][AUTOREPLY][autoreplyExecuted]\x20%s',_0x4fd7c0,JSON[_0x6bdc('0x46')](_0x591120));});})[_0x6bdc('0x3e')](function(){_0x1eb78b[_0x6bdc('0x16')]();});});}else{return rpc[this['channel']+'Message']['create'](_0x24cc1a)[_0x6bdc('0x3e')](function(){logger[_0x6bdc('0x1a')]('[%s][AUTOREPLY]\x20%s',_0x4fd7c0,_0x24cc1a[_0x6bdc('0x22')]);})['catch'](function(_0x379ed9){logger[_0x6bdc('0x47')](_0x6bdc('0x14'),_0x4fd7c0,JSON[_0x6bdc('0x46')](_0x379ed9));})[_0x6bdc('0x42')](function(){Promise['resolve']()[_0x6bdc('0x3e')](function(){if(_0x2f2fe7[0x0]!=='2'||_0x2cb868[_0x6bdc('0x1c')])return;return rpc[_0x9571fd+'Interaction']['update'](_0x2cb868['id'],{'autoreplyExecuted':!![]})['then'](function(_0x574fc4){logger[_0x6bdc('0x1a')](_0x6bdc('0x1d'),_0x4fd7c0,JSON[_0x6bdc('0x46')](_0x574fc4));})[_0x6bdc('0x40')](function(_0x56c5cd){logger[_0x6bdc('0x47')](_0x6bdc('0x48'),_0x4fd7c0,JSON[_0x6bdc('0x46')](_0x56c5cd));});})[_0x6bdc('0x3e')](function(){_0x1eb78b['next']();});});}}}catch(_0x3928d5){logger['error'](_0x6bdc('0x14'),_0x4fd7c0,JSON[_0x6bdc('0x46')](_0x3928d5));_0x1eb78b[_0x6bdc('0x49')]();}};};
\ No newline at end of file