Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / services / routing / server / applications / autoreply.js
index fea086a..d5150c3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6829=['channel','mail','getMustacheRender','message','from','phone','subject','startsWith','Re:\x20','upperFirst','AccountId','account','InteractionId','interaction','Message','Smtp','service','host','port','secure','authentication','auth','user','pass','<div\x20id=\x22xm-mail-content\x22>','body','<div\x20id=\x22xm-mail-content\x22','<div','</div>','All','auto_reply','sendMailMessage','then','messageId','create','[%s][AUTOREPLY]\x20%s','stringify','catch','error','next','finally','stop','lodash','moment','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','../../mailRpc','consequence','isNil','created','info','Autoreply\x20already\x20sent','contact','format'];(function(_0xe589e6,_0x3acb61){var _0x2f4627=function(_0x2c8a6e){while(--_0x2c8a6e){_0xe589e6['push'](_0xe589e6['shift']());}};_0x2f4627(++_0x3acb61);}(_0x6829,0x14c));var _0x9682=function(_0x513aa5,_0x1fba79){_0x513aa5=_0x513aa5-0x0;var _0x1a1a7c=_0x6829[_0x513aa5];return _0x1a1a7c;};'use strict';var _=require(_0x9682('0x0'));var moment=require(_0x9682('0x1'));var utils=require('./utils');var logger=require('../../../../config/logger')('routing');var rpc={'chatMessage':require(_0x9682('0x2')),'openchannelMessage':require(_0x9682('0x3')),'mailMessage':require(_0x9682('0x4')),'smsMessage':require(_0x9682('0x5')),'faxMessage':require(_0x9682('0x6')),'whatsappMessage':require(_0x9682('0x7'))};var mailRpc=require(_0x9682('0x8'));exports[_0x9682('0x9')]=function(_0x19b909,_0x4cec91){return function(_0x37ab0a){try{if(_0x4cec91[0x0]==='1'&&(_[_0x9682('0xa')](this['interaction']['created'])||!this['interaction'][_0x9682('0xb')])){logger[_0x9682('0xc')]('[%s][AUTOREPLY]\x20%s',_0x19b909,_0x9682('0xd'));return _0x37ab0a['next']();}var _0x3da429=this['channel'];var _0x2da26c={'ContactId':this[_0x9682('0xe')]['id'],'sentAt':moment()[_0x9682('0xf')]('YYYY-MM-DD\x20HH:mm:ss'),'direction':'out'};if(this[_0x9682('0x10')]===_0x9682('0x11')){_0x2da26c['body']=utils[_0x9682('0x12')](_0x4cec91[0x2],this);}else{_0x2da26c['body']=utils[_0x9682('0x12')](_0x4cec91[0x1],this);}if(this[_0x9682('0x13')]){_0x2da26c['to']=this[_0x9682('0x13')][_0x9682('0x14')]||'';if(this[_0x9682('0x10')]===_0x9682('0x11')&&_0x4cec91[0x1]==='1'){_0x2da26c['cc']=this[_0x9682('0x13')]['cc']||'';}_0x2da26c[_0x9682('0x14')]=this[_0x9682('0x13')]['to']||'';_0x2da26c[_0x9682('0x15')]=this['message'][_0x9682('0x15')]||'';_0x2da26c['read']=!![];if(this[_0x9682('0x13')][_0x9682('0x16')]){_0x2da26c[_0x9682('0x16')]='';_0x2da26c['subject']+=_[_0x9682('0x17')](this['message'][_0x9682('0x16')],'Re:')?'':_0x9682('0x18');_0x2da26c[_0x9682('0x16')]+=this[_0x9682('0x13')][_0x9682('0x16')];}}if(this[_0x9682('0x10')]==='chat'){_0x2da26c['ChatWebsiteId']=this['account']['id'];}else{_0x2da26c[_[_0x9682('0x19')](this['channel'])+_0x9682('0x1a')]=this[_0x9682('0x1b')]['id'];}_0x2da26c[_['upperFirst'](this[_0x9682('0x10')])+_0x9682('0x1c')]=this[_0x9682('0x1d')]['id'];if(rpc[this[_0x9682('0x10')]+_0x9682('0x1e')]){if(this[_0x9682('0x10')]===_0x9682('0x11')){var _0x40e927={'tls':{'rejectUnauthorized':![]}};if(this[_0x9682('0x1b')][_0x9682('0x1f')]['service']){_0x40e927[_0x9682('0x20')]=this[_0x9682('0x1b')][_0x9682('0x1f')][_0x9682('0x20')];}else{_0x40e927[_0x9682('0x21')]=this['account'][_0x9682('0x1f')][_0x9682('0x21')];_0x40e927[_0x9682('0x22')]=this[_0x9682('0x1b')][_0x9682('0x1f')][_0x9682('0x22')];_0x40e927['secure']=this[_0x9682('0x1b')][_0x9682('0x1f')][_0x9682('0x23')];}if(this[_0x9682('0x1b')][_0x9682('0x1f')][_0x9682('0x24')]){_0x40e927[_0x9682('0x25')]={'user':this[_0x9682('0x1b')]['Smtp'][_0x9682('0x26')],'pass':this['account'][_0x9682('0x1f')][_0x9682('0x27')]};}_0x2da26c['inReplyTo']=this['message']['messageId'];_0x2da26c['html']=_0x9682('0x28')+_['replace'](_0x2da26c[_0x9682('0x29')],_0x9682('0x2a'),_0x9682('0x2b'))+_0x9682('0x2c');_0x2da26c['headers']={'Auto-Submitted':'auto-replied','X-Auto-Response-Suppress':_0x9682('0x2d'),'Precedence':_0x9682('0x2e')};return mailRpc[_0x9682('0x2f')](_0x40e927,_0x2da26c)[_0x9682('0x30')](function(_0x1e7279){logger['info']('[%s][AUTOREPLY]\x20SMTP\x20SENT',_0x19b909);_0x2da26c[_0x9682('0x31')]=_0x1e7279[_0x9682('0x13')][_0x9682('0x31')];return rpc[_0x3da429+_0x9682('0x1e')][_0x9682('0x32')](_0x2da26c);})[_0x9682('0x30')](function(_0x268a8b){logger['info'](_0x9682('0x33'),_0x19b909,JSON[_0x9682('0x34')](_0x268a8b));})[_0x9682('0x35')](function(_0x141bcb){logger[_0x9682('0x36')]('[RPC][%s][AUTOREPLY]\x20%s',_0x19b909,JSON[_0x9682('0x34')](_0x141bcb));})['finally'](function(){_0x37ab0a[_0x9682('0x37')]();});}else{return rpc[this[_0x9682('0x10')]+_0x9682('0x1e')][_0x9682('0x32')](_0x2da26c)[_0x9682('0x30')](function(_0x367b0b){logger[_0x9682('0xc')]('[%s][AUTOREPLY]\x20%s',_0x19b909,_0x2da26c[_0x9682('0x29')]);})['catch'](function(_0xe194aa){logger['error'](_0x9682('0x33'),_0x19b909,JSON[_0x9682('0x34')](_0xe194aa));})[_0x9682('0x38')](function(){_0x37ab0a[_0x9682('0x37')]();});}}}catch(_0x2d99c5){logger[_0x9682('0x36')](_0x9682('0x33'),_0x19b909,JSON[_0x9682('0x34')](_0x2d99c5));_0x37ab0a[_0x9682('0x39')]();}};};
\ No newline at end of file
+var _0xa212=['YYYY-MM-DD\x20HH:mm:ss','out','mail','body','getMustacheRender','message','from','phone','read','subject','startsWith','Re:','Re:\x20','chat','ChatWebsiteId','account','upperFirst','AccountId','Message','Smtp','service','host','port','secure','authentication','auth','user','pass','messageId','html','<div\x20id=\x22xm-mail-content\x22>','replace','<div\x20id=\x22xm-mail-content\x22','<div','</div>','headers','auto-replied','All','auto_reply','sendMailMessage','then','create','catch','finally','[%s][AUTOREPLY]\x20%s','error','stringify','lodash','moment','./utils','../../rpc/openchannelMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','../../mailRpc','consequence','isNil','interaction','created','info','Autoreply\x20already\x20sent','next','channel','format'];(function(_0xcf5436,_0x4632c3){var _0xc4f5c8=function(_0x567528){while(--_0x567528){_0xcf5436['push'](_0xcf5436['shift']());}};_0xc4f5c8(++_0x4632c3);}(_0xa212,0xec));var _0x2a21=function(_0x1d116e,_0x54956c){_0x1d116e=_0x1d116e-0x0;var _0x3f4710=_0xa212[_0x1d116e];return _0x3f4710;};'use strict';var _=require(_0x2a21('0x0'));var moment=require(_0x2a21('0x1'));var utils=require(_0x2a21('0x2'));var logger=require('../../../../config/logger')('routing');var rpc={'chatMessage':require('../../rpc/chatMessage'),'openchannelMessage':require(_0x2a21('0x3')),'mailMessage':require('../../rpc/mailMessage'),'smsMessage':require('../../rpc/smsMessage'),'faxMessage':require(_0x2a21('0x4')),'whatsappMessage':require(_0x2a21('0x5'))};var mailRpc=require(_0x2a21('0x6'));exports[_0x2a21('0x7')]=function(_0x39ad64,_0x4f76c0){return function(_0x3c0b85){try{if(_0x4f76c0[0x0]==='1'&&(_[_0x2a21('0x8')](this['interaction']['created'])||!this[_0x2a21('0x9')][_0x2a21('0xa')])){logger[_0x2a21('0xb')]('[%s][AUTOREPLY]\x20%s',_0x39ad64,_0x2a21('0xc'));return _0x3c0b85[_0x2a21('0xd')]();}var _0x3b6858=this[_0x2a21('0xe')];var _0x4185dd={'ContactId':this['contact']['id'],'sentAt':moment()[_0x2a21('0xf')](_0x2a21('0x10')),'direction':_0x2a21('0x11')};if(this[_0x2a21('0xe')]===_0x2a21('0x12')){_0x4185dd[_0x2a21('0x13')]=utils[_0x2a21('0x14')](_0x4f76c0[0x2],this);}else{_0x4185dd[_0x2a21('0x13')]=utils['getMustacheRender'](_0x4f76c0[0x1],this);}if(this[_0x2a21('0x15')]){_0x4185dd['to']=this[_0x2a21('0x15')][_0x2a21('0x16')]||'';if(this[_0x2a21('0xe')]===_0x2a21('0x12')&&_0x4f76c0[0x1]==='1'){_0x4185dd['cc']=this[_0x2a21('0x15')]['cc']||'';}_0x4185dd[_0x2a21('0x16')]=this[_0x2a21('0x15')]['to']||'';_0x4185dd[_0x2a21('0x17')]=this[_0x2a21('0x15')][_0x2a21('0x17')]||'';_0x4185dd[_0x2a21('0x18')]=!![];if(this['message'][_0x2a21('0x19')]){_0x4185dd[_0x2a21('0x19')]='';_0x4185dd[_0x2a21('0x19')]+=_[_0x2a21('0x1a')](this[_0x2a21('0x15')][_0x2a21('0x19')],_0x2a21('0x1b'))?'':_0x2a21('0x1c');_0x4185dd[_0x2a21('0x19')]+=this[_0x2a21('0x15')][_0x2a21('0x19')];}}if(this[_0x2a21('0xe')]===_0x2a21('0x1d')){_0x4185dd[_0x2a21('0x1e')]=this[_0x2a21('0x1f')]['id'];}else{_0x4185dd[_[_0x2a21('0x20')](this[_0x2a21('0xe')])+_0x2a21('0x21')]=this[_0x2a21('0x1f')]['id'];}_0x4185dd[_[_0x2a21('0x20')](this[_0x2a21('0xe')])+'InteractionId']=this['interaction']['id'];if(rpc[this['channel']+_0x2a21('0x22')]){if(this[_0x2a21('0xe')]===_0x2a21('0x12')){var _0x425e98={'tls':{'rejectUnauthorized':![]}};if(this[_0x2a21('0x1f')][_0x2a21('0x23')][_0x2a21('0x24')]){_0x425e98['service']=this[_0x2a21('0x1f')][_0x2a21('0x23')][_0x2a21('0x24')];}else{_0x425e98[_0x2a21('0x25')]=this['account'][_0x2a21('0x23')][_0x2a21('0x25')];_0x425e98[_0x2a21('0x26')]=this['account'][_0x2a21('0x23')][_0x2a21('0x26')];_0x425e98[_0x2a21('0x27')]=this[_0x2a21('0x1f')][_0x2a21('0x23')][_0x2a21('0x27')];}if(this['account'][_0x2a21('0x23')][_0x2a21('0x28')]){_0x425e98[_0x2a21('0x29')]={'user':this[_0x2a21('0x1f')][_0x2a21('0x23')][_0x2a21('0x2a')],'pass':this[_0x2a21('0x1f')][_0x2a21('0x23')][_0x2a21('0x2b')]};}_0x4185dd['inReplyTo']=this['message'][_0x2a21('0x2c')];_0x4185dd[_0x2a21('0x2d')]=_0x2a21('0x2e')+_[_0x2a21('0x2f')](_0x4185dd[_0x2a21('0x13')],_0x2a21('0x30'),_0x2a21('0x31'))+_0x2a21('0x32');_0x4185dd[_0x2a21('0x33')]={'Auto-Submitted':_0x2a21('0x34'),'X-Auto-Response-Suppress':_0x2a21('0x35'),'Precedence':_0x2a21('0x36')};return mailRpc[_0x2a21('0x37')](_0x425e98,_0x4185dd)[_0x2a21('0x38')](function(_0x16200e){logger['info']('[%s][AUTOREPLY]\x20SMTP\x20SENT',_0x39ad64);_0x4185dd['messageId']=_0x16200e[_0x2a21('0x15')]['messageId'];return rpc[_0x3b6858+_0x2a21('0x22')][_0x2a21('0x39')](_0x4185dd);})['then'](function(_0x55e31b){logger[_0x2a21('0xb')]('[%s][AUTOREPLY]\x20%s',_0x39ad64,JSON['stringify'](_0x55e31b));})[_0x2a21('0x3a')](function(_0x23d542){logger['error']('[RPC][%s][AUTOREPLY]\x20%s',_0x39ad64,JSON['stringify'](_0x23d542));})[_0x2a21('0x3b')](function(){_0x3c0b85[_0x2a21('0xd')]();});}else{return rpc[this[_0x2a21('0xe')]+'Message'][_0x2a21('0x39')](_0x4185dd)[_0x2a21('0x38')](function(_0x1d3a40){logger['info'](_0x2a21('0x3c'),_0x39ad64,_0x4185dd[_0x2a21('0x13')]);})[_0x2a21('0x3a')](function(_0x5393a3){logger[_0x2a21('0x3d')](_0x2a21('0x3c'),_0x39ad64,JSON[_0x2a21('0x3e')](_0x5393a3));})[_0x2a21('0x3b')](function(){_0x3c0b85[_0x2a21('0xd')]();});}}}catch(_0xd20cf0){logger['error'](_0x2a21('0x3c'),_0x39ad64,JSON[_0x2a21('0x3e')](_0xd20cf0));_0x3c0b85['stop']();}};};
\ No newline at end of file