Built motion from commit 538092ac.|2.6.10
[motion2.git] / server / services / routing / server / applications / autoreply.js
index 7f3e2a3..36758f5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1902=['Autoreply\x20already\x20sent','autoreplyExecuted','[%s][AUTOREPLY][autoreplyExecuted]\x20%s','One\x20Time\x20already\x20sent','contact','format','YYYY-MM-DD\x20HH:mm:ss','out','body','getMustacheRender','message','from','phone','read','subject','startsWith','Re:','Re:\x20','chat','ChatWebsiteId','account','upperFirst','AccountId','InteractionId','messageId','<div\x20id=\x22xm-mail-content\x22>','<div','</div>','headers','auto-replied','All','auto_reply','sendMailMessage','smtpOptions','then','[%s][AUTOREPLY]\x20SMTP\x20SENT','Message','stringify','catch','error','resolve','Interaction','[RPC][%s][AUTOREPLY][autoreplyExecuted]\x20%s','finally','update','stop','lodash','moment','./utils','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','../../rpc/chatInteraction','../../rpc/mailInteraction','../../rpc/smsInteraction','../../rpc/faxInteraction','../../rpc/whatsappInteraction','../../mailRpc','consequence','channel','mail','info','[%s][AUTOREPLY]\x20%s','Autoreply\x20not\x20executed\x20(message\x20is\x20autoreply)','next','isNil','interaction','created'];(function(_0x698239,_0x107a44){var _0x87e18f=function(_0x1e15a6){while(--_0x1e15a6){_0x698239['push'](_0x698239['shift']());}};_0x87e18f(++_0x107a44);}(_0x1902,0xbe));var _0x2190=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x1902[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x2190('0x0'));var moment=require(_0x2190('0x1'));var utils=require(_0x2190('0x2'));var logger=require(_0x2190('0x3'))(_0x2190('0x4'));var rpc={'chatMessage':require(_0x2190('0x5')),'openchannelMessage':require(_0x2190('0x6')),'mailMessage':require(_0x2190('0x7')),'smsMessage':require('../../rpc/smsMessage'),'faxMessage':require(_0x2190('0x8')),'whatsappMessage':require(_0x2190('0x9')),'chatInteraction':require(_0x2190('0xa')),'openchannelInteraction':require('../../rpc/openchannelInteraction'),'mailInteraction':require(_0x2190('0xb')),'smsInteraction':require(_0x2190('0xc')),'faxInteraction':require(_0x2190('0xd')),'whatsappInteraction':require(_0x2190('0xe'))};var mailRpc=require(_0x2190('0xf'));exports[_0x2190('0x10')]=function(_0x4c5d8e,_0x4dfcf1,_0xd482dd,_0x2914a5){return function(_0x3267fc){try{var _0x3e50a0=this[_0x2190('0x11')];if(_0x3e50a0===_0x2190('0x12')&&_0x2914a5['body']['isAutoreply']){logger[_0x2190('0x13')](_0x2190('0x14'),_0x4c5d8e,_0x2190('0x15'));return _0x3267fc[_0x2190('0x16')]();}if(_0x4dfcf1[0x0]==='1'&&(_[_0x2190('0x17')](this[_0x2190('0x18')][_0x2190('0x19')])||!this[_0x2190('0x18')][_0x2190('0x19')])){logger['info'](_0x2190('0x14'),_0x4c5d8e,_0x2190('0x1a'));return _0x3267fc[_0x2190('0x16')]();}if(_0x4dfcf1[0x0]==='2'&&this['interaction'][_0x2190('0x1b')]){logger[_0x2190('0x13')](_0x2190('0x1c'),_0x4c5d8e,_0x2190('0x1d'));return _0x3267fc[_0x2190('0x16')]();}var _0x511b28={'ContactId':this[_0x2190('0x1e')]['id'],'sentAt':moment()[_0x2190('0x1f')](_0x2190('0x20')),'direction':_0x2190('0x21')};if(this[_0x2190('0x11')]==='mail'){_0x511b28[_0x2190('0x22')]=utils[_0x2190('0x23')](_0x4dfcf1[0x2],this);}else{_0x511b28[_0x2190('0x22')]=utils[_0x2190('0x23')](_0x4dfcf1[0x1],this);}if(this[_0x2190('0x24')]){_0x511b28['to']=this[_0x2190('0x24')][_0x2190('0x25')]||'';if(this[_0x2190('0x11')]===_0x2190('0x12')&&_0x4dfcf1[0x1]==='1'){_0x511b28['cc']=this[_0x2190('0x24')]['cc']||'';}_0x511b28['from']=this[_0x2190('0x24')]['to']||'';_0x511b28[_0x2190('0x26')]=this[_0x2190('0x24')][_0x2190('0x26')]||'';_0x511b28[_0x2190('0x27')]=!![];if(this[_0x2190('0x24')]['subject']){_0x511b28['subject']='';_0x511b28[_0x2190('0x28')]+=_[_0x2190('0x29')](this['message'][_0x2190('0x28')],_0x2190('0x2a'))?'':_0x2190('0x2b');_0x511b28[_0x2190('0x28')]+=this[_0x2190('0x24')]['subject'];}}if(this[_0x2190('0x11')]===_0x2190('0x2c')){_0x511b28[_0x2190('0x2d')]=this[_0x2190('0x2e')]['id'];}else{_0x511b28[_[_0x2190('0x2f')](this[_0x2190('0x11')])+_0x2190('0x30')]=this[_0x2190('0x2e')]['id'];}_0x511b28[_[_0x2190('0x2f')](this[_0x2190('0x11')])+_0x2190('0x31')]=this[_0x2190('0x18')]['id'];var _0x52a426=this['interaction'];if(rpc[this['channel']+'Message']){if(this[_0x2190('0x11')]==='mail'){_0x511b28['inReplyTo']=this[_0x2190('0x24')][_0x2190('0x32')];_0x511b28['html']=_0x2190('0x33')+_['replace'](_0x511b28[_0x2190('0x22')],'<div\x20id=\x22xm-mail-content\x22',_0x2190('0x34'))+_0x2190('0x35');_0x511b28[_0x2190('0x36')]={'Auto-Submitted':_0x2190('0x37'),'X-Auto-Response-Suppress':_0x2190('0x38'),'Precedence':_0x2190('0x39')};return mailRpc[_0x2190('0x3a')](this[_0x2190('0x2e')][_0x2190('0x3b')],_0x511b28)[_0x2190('0x3c')](function(_0x5a0be9){logger['info'](_0x2190('0x3d'),_0x4c5d8e);_0x511b28[_0x2190('0x32')]=_0x5a0be9['message'][_0x2190('0x32')];return rpc[_0x3e50a0+_0x2190('0x3e')]['create'](_0x511b28);})[_0x2190('0x3c')](function(_0x526b16){logger[_0x2190('0x13')](_0x2190('0x14'),_0x4c5d8e,JSON[_0x2190('0x3f')](_0x526b16));})[_0x2190('0x40')](function(_0x5aa41e){logger[_0x2190('0x41')]('[RPC][%s][AUTOREPLY]\x20%s',_0x4c5d8e,JSON[_0x2190('0x3f')](_0x5aa41e));})['finally'](function(){Promise[_0x2190('0x42')]()['then'](function(){if(_0x4dfcf1[0x0]!=='2'||_0x52a426[_0x2190('0x1b')])return;return rpc[_0x3e50a0+_0x2190('0x43')]['update'](_0x52a426['id'],{'autoreplyExecuted':!![]})[_0x2190('0x3c')](function(_0x45c47e){logger[_0x2190('0x13')](_0x2190('0x1c'),_0x4c5d8e,JSON[_0x2190('0x3f')](_0x45c47e));})['catch'](function(_0x3766ee){logger[_0x2190('0x41')](_0x2190('0x44'),_0x4c5d8e,JSON[_0x2190('0x3f')](_0x3766ee));});})['then'](function(){_0x3267fc['next']();});});}else{return rpc[this[_0x2190('0x11')]+_0x2190('0x3e')]['create'](_0x511b28)[_0x2190('0x3c')](function(){logger['info'](_0x2190('0x14'),_0x4c5d8e,_0x511b28[_0x2190('0x22')]);})[_0x2190('0x40')](function(_0x440571){logger[_0x2190('0x41')]('[%s][AUTOREPLY]\x20%s',_0x4c5d8e,JSON[_0x2190('0x3f')](_0x440571));})[_0x2190('0x45')](function(){Promise[_0x2190('0x42')]()[_0x2190('0x3c')](function(){if(_0x4dfcf1[0x0]!=='2'||_0x52a426[_0x2190('0x1b')])return;return rpc[_0x3e50a0+'Interaction'][_0x2190('0x46')](_0x52a426['id'],{'autoreplyExecuted':!![]})[_0x2190('0x3c')](function(_0xded1f){logger[_0x2190('0x13')](_0x2190('0x1c'),_0x4c5d8e,JSON[_0x2190('0x3f')](_0xded1f));})['catch'](function(_0x39cca7){logger[_0x2190('0x41')]('[RPC][%s][AUTOREPLY][autoreplyExecuted]\x20%s',_0x4c5d8e,JSON[_0x2190('0x3f')](_0x39cca7));});})[_0x2190('0x3c')](function(){_0x3267fc['next']();});});}}}catch(_0xbe590c){logger[_0x2190('0x41')](_0x2190('0x14'),_0x4c5d8e,JSON[_0x2190('0x3f')](_0xbe590c));_0x3267fc[_0x2190('0x47')]();}};};
\ No newline at end of file
+var _0x8f94=['mail','message','phone','read','subject','startsWith','Re:','Re:\x20','chat','account','AccountId','upperFirst','InteractionId','inReplyTo','messageId','html','<div\x20id=\x22xm-mail-content\x22>','<div\x20id=\x22xm-mail-content\x22','<div','headers','sendMailMessage','smtpOptions','[%s][AUTOREPLY]\x20SMTP\x20SENT','Message','then','stringify','catch','[RPC][%s][AUTOREPLY]\x20%s','finally','autoreplyExecuted','Interaction','update','error','[RPC][%s][AUTOREPLY][autoreplyExecuted]\x20%s','create','stop','lodash','moment','./utils','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','../../rpc/chatInteraction','../../rpc/mailInteraction','../../rpc/smsInteraction','../../rpc/faxInteraction','../../rpc/whatsappInteraction','../../mailRpc','consequence','channel','body','info','Autoreply\x20not\x20executed\x20(message\x20is\x20autoreply)','interaction','created','[%s][AUTOREPLY]\x20%s','Autoreply\x20already\x20sent','next','[%s][AUTOREPLY][autoreplyExecuted]\x20%s','contact','format','YYYY-MM-DD\x20HH:mm:ss','getMustacheRender','from'];(function(_0x45c569,_0x255cd0){var _0x1cc195=function(_0x23248c){while(--_0x23248c){_0x45c569['push'](_0x45c569['shift']());}};_0x1cc195(++_0x255cd0);}(_0x8f94,0xf0));var _0x48f9=function(_0x6c993a,_0x5ea3ab){_0x6c993a=_0x6c993a-0x0;var _0x27f547=_0x8f94[_0x6c993a];return _0x27f547;};'use strict';var _=require(_0x48f9('0x0'));var moment=require(_0x48f9('0x1'));var utils=require(_0x48f9('0x2'));var logger=require(_0x48f9('0x3'))(_0x48f9('0x4'));var rpc={'chatMessage':require(_0x48f9('0x5')),'openchannelMessage':require(_0x48f9('0x6')),'mailMessage':require('../../rpc/mailMessage'),'smsMessage':require(_0x48f9('0x7')),'faxMessage':require(_0x48f9('0x8')),'whatsappMessage':require(_0x48f9('0x9')),'chatInteraction':require(_0x48f9('0xa')),'openchannelInteraction':require('../../rpc/openchannelInteraction'),'mailInteraction':require(_0x48f9('0xb')),'smsInteraction':require(_0x48f9('0xc')),'faxInteraction':require(_0x48f9('0xd')),'whatsappInteraction':require(_0x48f9('0xe'))};var mailRpc=require(_0x48f9('0xf'));exports[_0x48f9('0x10')]=function(_0x56a2b7,_0x435ccb,_0x1e40d9,_0x10bb41){return function(_0x47cf33){try{var _0x119071=this[_0x48f9('0x11')];if(_0x119071==='mail'&&_0x10bb41[_0x48f9('0x12')]['isAutoreply']){logger[_0x48f9('0x13')]('[%s][AUTOREPLY]\x20%s',_0x56a2b7,_0x48f9('0x14'));return _0x47cf33['next']();}if(_0x435ccb[0x0]==='1'&&(_['isNil'](this[_0x48f9('0x15')][_0x48f9('0x16')])||!this['interaction']['created'])){logger[_0x48f9('0x13')](_0x48f9('0x17'),_0x56a2b7,_0x48f9('0x18'));return _0x47cf33[_0x48f9('0x19')]();}if(_0x435ccb[0x0]==='2'&&this[_0x48f9('0x15')]['autoreplyExecuted']){logger['info'](_0x48f9('0x1a'),_0x56a2b7,'One\x20Time\x20already\x20sent');return _0x47cf33[_0x48f9('0x19')]();}var _0x52f355={'ContactId':this[_0x48f9('0x1b')]['id'],'sentAt':moment()[_0x48f9('0x1c')](_0x48f9('0x1d')),'direction':'out'};if(this[_0x48f9('0x11')]==='mail'){_0x52f355[_0x48f9('0x12')]=utils[_0x48f9('0x1e')](_0x435ccb[0x2],this);}else{_0x52f355[_0x48f9('0x12')]=utils[_0x48f9('0x1e')](_0x435ccb[0x1],this);}if(this['message']){_0x52f355['to']=this['message'][_0x48f9('0x1f')]||'';if(this['channel']===_0x48f9('0x20')&&_0x435ccb[0x1]==='1'){_0x52f355['cc']=this[_0x48f9('0x21')]['cc']||'';}_0x52f355[_0x48f9('0x1f')]=this['message']['to']||'';_0x52f355['phone']=this[_0x48f9('0x21')][_0x48f9('0x22')]||'';_0x52f355[_0x48f9('0x23')]=!![];if(this[_0x48f9('0x21')][_0x48f9('0x24')]){_0x52f355['subject']='';_0x52f355[_0x48f9('0x24')]+=_[_0x48f9('0x25')](this[_0x48f9('0x21')][_0x48f9('0x24')],_0x48f9('0x26'))?'':_0x48f9('0x27');_0x52f355['subject']+=this[_0x48f9('0x21')][_0x48f9('0x24')];}}if(this[_0x48f9('0x11')]===_0x48f9('0x28')){_0x52f355['ChatWebsiteId']=this[_0x48f9('0x29')]['id'];}else{_0x52f355[_['upperFirst'](this[_0x48f9('0x11')])+_0x48f9('0x2a')]=this[_0x48f9('0x29')]['id'];}_0x52f355[_[_0x48f9('0x2b')](this[_0x48f9('0x11')])+_0x48f9('0x2c')]=this[_0x48f9('0x15')]['id'];var _0x3be328=this['interaction'];if(rpc[this['channel']+'Message']){if(this[_0x48f9('0x11')]===_0x48f9('0x20')){_0x52f355[_0x48f9('0x2d')]=this['message'][_0x48f9('0x2e')];_0x52f355[_0x48f9('0x2f')]=_0x48f9('0x30')+_['replace'](_0x52f355[_0x48f9('0x12')],_0x48f9('0x31'),_0x48f9('0x32'))+'</div>';_0x52f355[_0x48f9('0x33')]={'Auto-Submitted':'auto-replied','X-Auto-Response-Suppress':'All','Precedence':'auto_reply'};return mailRpc[_0x48f9('0x34')](this[_0x48f9('0x29')][_0x48f9('0x35')],_0x52f355)['then'](function(_0x1487be){logger['info'](_0x48f9('0x36'),_0x56a2b7);_0x52f355[_0x48f9('0x2e')]=_0x1487be['message']['messageId'];return rpc[_0x119071+_0x48f9('0x37')]['create'](_0x52f355);})[_0x48f9('0x38')](function(_0x5204a1){logger[_0x48f9('0x13')](_0x48f9('0x17'),_0x56a2b7,JSON[_0x48f9('0x39')](_0x5204a1));})[_0x48f9('0x3a')](function(_0x5b0a43){logger['error'](_0x48f9('0x3b'),_0x56a2b7,JSON[_0x48f9('0x39')](_0x5b0a43));})[_0x48f9('0x3c')](function(){Promise['resolve']()[_0x48f9('0x38')](function(){if(_0x435ccb[0x0]!=='2'||_0x3be328[_0x48f9('0x3d')])return;return rpc[_0x119071+_0x48f9('0x3e')][_0x48f9('0x3f')](_0x3be328['id'],{'autoreplyExecuted':!![]})[_0x48f9('0x38')](function(_0x10aa62){logger[_0x48f9('0x13')](_0x48f9('0x1a'),_0x56a2b7,JSON[_0x48f9('0x39')](_0x10aa62));})['catch'](function(_0x378053){logger[_0x48f9('0x40')](_0x48f9('0x41'),_0x56a2b7,JSON[_0x48f9('0x39')](_0x378053));});})['then'](function(){_0x47cf33[_0x48f9('0x19')]();});});}else{return rpc[this[_0x48f9('0x11')]+_0x48f9('0x37')][_0x48f9('0x42')](_0x52f355)[_0x48f9('0x38')](function(){logger[_0x48f9('0x13')](_0x48f9('0x17'),_0x56a2b7,_0x52f355['body']);})[_0x48f9('0x3a')](function(_0x329b7b){logger['error'](_0x48f9('0x17'),_0x56a2b7,JSON[_0x48f9('0x39')](_0x329b7b));})[_0x48f9('0x3c')](function(){Promise['resolve']()['then'](function(){if(_0x435ccb[0x0]!=='2'||_0x3be328[_0x48f9('0x3d')])return;return rpc[_0x119071+_0x48f9('0x3e')]['update'](_0x3be328['id'],{'autoreplyExecuted':!![]})[_0x48f9('0x38')](function(_0x2ab909){logger['info']('[%s][AUTOREPLY][autoreplyExecuted]\x20%s',_0x56a2b7,JSON['stringify'](_0x2ab909));})[_0x48f9('0x3a')](function(_0x5f366a){logger[_0x48f9('0x40')](_0x48f9('0x41'),_0x56a2b7,JSON[_0x48f9('0x39')](_0x5f366a));});})[_0x48f9('0x38')](function(){_0x47cf33[_0x48f9('0x19')]();});});}}}catch(_0xa298){logger[_0x48f9('0x40')](_0x48f9('0x17'),_0x56a2b7,JSON[_0x48f9('0x39')](_0xa298));_0x47cf33[_0x48f9('0x43')]();}};};
\ No newline at end of file