Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / services / routing / server / applications / autoreply.js
index 52226e3..1d0c710 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7a12=['getMustacheRender','message','from','phone','read','subject','startsWith','Re:','ChatWebsiteId','account','upperFirst','AccountId','mail','Smtp','service','host','port','secure','authentication','auth','pass','inReplyTo','html','replace','<div','headers','auto-replied','All','then','[%s][AUTOREPLY]\x20SMTP\x20SENT','messageId','Message','create','catch','error','[RPC][%s][AUTOREPLY]\x20%s','info','stringify','finally','stop','lodash','moment','./utils','../../../../config/logger','routing','../../rpc/chatMessage','../../rpc/openchannelMessage','../../rpc/mailMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','../../mailRpc','consequence','isNil','interaction','created','[%s][AUTOREPLY]\x20%s','Autoreply\x20already\x20sent','next','channel','contact','format','YYYY-MM-DD\x20HH:mm:ss','out','body'];(function(_0x4d68b8,_0x4a7855){var _0x5d72ec=function(_0xe3a42b){while(--_0xe3a42b){_0x4d68b8['push'](_0x4d68b8['shift']());}};_0x5d72ec(++_0x4a7855);}(_0x7a12,0xe8));var _0x27a1=function(_0x21ed68,_0x449c6f){_0x21ed68=_0x21ed68-0x0;var _0x280281=_0x7a12[_0x21ed68];return _0x280281;};'use strict';var _=require(_0x27a1('0x0'));var moment=require(_0x27a1('0x1'));var utils=require(_0x27a1('0x2'));var logger=require(_0x27a1('0x3'))(_0x27a1('0x4'));var rpc={'chatMessage':require(_0x27a1('0x5')),'openchannelMessage':require(_0x27a1('0x6')),'mailMessage':require(_0x27a1('0x7')),'smsMessage':require('../../rpc/smsMessage'),'faxMessage':require(_0x27a1('0x8')),'whatsappMessage':require(_0x27a1('0x9'))};var mailRpc=require(_0x27a1('0xa'));exports[_0x27a1('0xb')]=function(_0x2ccadb,_0xed784f){return function(_0x4a4e2c){try{if(_0xed784f[0x0]==='1'&&(_[_0x27a1('0xc')](this[_0x27a1('0xd')]['created'])||!this[_0x27a1('0xd')][_0x27a1('0xe')])){logger['info'](_0x27a1('0xf'),_0x2ccadb,_0x27a1('0x10'));return _0x4a4e2c[_0x27a1('0x11')]();}var _0x56a122=this[_0x27a1('0x12')];var _0x455a8f={'ContactId':this[_0x27a1('0x13')]['id'],'sentAt':moment()[_0x27a1('0x14')](_0x27a1('0x15')),'direction':_0x27a1('0x16')};if(this[_0x27a1('0x12')]==='mail'){_0x455a8f[_0x27a1('0x17')]=utils[_0x27a1('0x18')](_0xed784f[0x2],this);}else{_0x455a8f[_0x27a1('0x17')]=utils[_0x27a1('0x18')](_0xed784f[0x1],this);}if(this['message']){_0x455a8f['to']=this[_0x27a1('0x19')][_0x27a1('0x1a')]||'';if(this['channel']==='mail'&&_0xed784f[0x1]==='1'){_0x455a8f['cc']=this[_0x27a1('0x19')]['cc']||'';}_0x455a8f[_0x27a1('0x1a')]=this['message']['to']||'';_0x455a8f[_0x27a1('0x1b')]=this[_0x27a1('0x19')]['phone']||'';_0x455a8f[_0x27a1('0x1c')]=!![];if(this[_0x27a1('0x19')][_0x27a1('0x1d')]){_0x455a8f[_0x27a1('0x1d')]='';_0x455a8f['subject']+=_[_0x27a1('0x1e')](this['message'][_0x27a1('0x1d')],_0x27a1('0x1f'))?'':'Re:\x20';_0x455a8f[_0x27a1('0x1d')]+=this[_0x27a1('0x19')][_0x27a1('0x1d')];}}if(this[_0x27a1('0x12')]==='chat'){_0x455a8f[_0x27a1('0x20')]=this[_0x27a1('0x21')]['id'];}else{_0x455a8f[_[_0x27a1('0x22')](this[_0x27a1('0x12')])+_0x27a1('0x23')]=this['account']['id'];}_0x455a8f[_[_0x27a1('0x22')](this[_0x27a1('0x12')])+'InteractionId']=this['interaction']['id'];if(rpc[this[_0x27a1('0x12')]+'Message']){if(this[_0x27a1('0x12')]===_0x27a1('0x24')){var _0x21c37e={'tls':{'rejectUnauthorized':![]}};if(this[_0x27a1('0x21')][_0x27a1('0x25')][_0x27a1('0x26')]){_0x21c37e['service']=this[_0x27a1('0x21')][_0x27a1('0x25')]['service'];}else{_0x21c37e[_0x27a1('0x27')]=this['account'][_0x27a1('0x25')]['host'];_0x21c37e[_0x27a1('0x28')]=this[_0x27a1('0x21')]['Smtp'][_0x27a1('0x28')];_0x21c37e[_0x27a1('0x29')]=this[_0x27a1('0x21')][_0x27a1('0x25')]['secure'];}if(this[_0x27a1('0x21')]['Smtp'][_0x27a1('0x2a')]){_0x21c37e[_0x27a1('0x2b')]={'user':this[_0x27a1('0x21')][_0x27a1('0x25')]['user'],'pass':this[_0x27a1('0x21')][_0x27a1('0x25')][_0x27a1('0x2c')]};}_0x455a8f[_0x27a1('0x2d')]=this[_0x27a1('0x19')]['messageId'];_0x455a8f[_0x27a1('0x2e')]='<div\x20id=\x22xm-mail-content\x22>'+_[_0x27a1('0x2f')](_0x455a8f[_0x27a1('0x17')],'<div\x20id=\x22xm-mail-content\x22',_0x27a1('0x30'))+'</div>';_0x455a8f[_0x27a1('0x31')]={'Auto-Submitted':_0x27a1('0x32'),'X-Auto-Response-Suppress':_0x27a1('0x33'),'Precedence':'auto_reply'};return mailRpc['sendMailMessage'](_0x21c37e,_0x455a8f)[_0x27a1('0x34')](function(_0x4c16cc){logger['info'](_0x27a1('0x35'),_0x2ccadb);_0x455a8f[_0x27a1('0x36')]=_0x4c16cc[_0x27a1('0x19')][_0x27a1('0x36')];return rpc[_0x56a122+_0x27a1('0x37')][_0x27a1('0x38')](_0x455a8f);})[_0x27a1('0x34')](function(_0x3b14d6){logger['info']('[%s][AUTOREPLY]\x20%s',_0x2ccadb,JSON['stringify'](_0x3b14d6));})[_0x27a1('0x39')](function(_0xcdbe1c){logger[_0x27a1('0x3a')](_0x27a1('0x3b'),_0x2ccadb,JSON['stringify'](_0xcdbe1c));})['finally'](function(){_0x4a4e2c[_0x27a1('0x11')]();});}else{return rpc[this[_0x27a1('0x12')]+_0x27a1('0x37')][_0x27a1('0x38')](_0x455a8f)[_0x27a1('0x34')](function(_0x6fe6c0){logger[_0x27a1('0x3c')]('[%s][AUTOREPLY]\x20%s',_0x2ccadb,_0x455a8f['body']);})[_0x27a1('0x39')](function(_0x1b26a){logger[_0x27a1('0x3a')]('[%s][AUTOREPLY]\x20%s',_0x2ccadb,JSON[_0x27a1('0x3d')](_0x1b26a));})[_0x27a1('0x3e')](function(){_0x4a4e2c[_0x27a1('0x11')]();});}}}catch(_0x1358c8){logger['error'](_0x27a1('0xf'),_0x2ccadb,JSON[_0x27a1('0x3d')](_0x1358c8));_0x4a4e2c[_0x27a1('0x3f')]();}};};
\ No newline at end of file
+var _0x8c8c=['secure','authentication','user','pass','inReplyTo','messageId','<div\x20id=\x22xm-mail-content\x22>','replace','<div\x20id=\x22xm-mail-content\x22','<div','auto-replied','All','auto_reply','sendMailMessage','then','[%s][AUTOREPLY]\x20SMTP\x20SENT','Message','create','stringify','error','finally','catch','stop','lodash','moment','./utils','../../../../config/logger','../../rpc/chatMessage','../../rpc/smsMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','../../mailRpc','consequence','isNil','interaction','created','info','[%s][AUTOREPLY]\x20%s','next','format','YYYY-MM-DD\x20HH:mm:ss','out','channel','mail','body','getMustacheRender','message','from','phone','read','subject','Re:','Re:\x20','account','upperFirst','AccountId','InteractionId','Smtp','service','host','port'];(function(_0x2e17a7,_0x5b5efa){var _0x443505=function(_0x1bc24d){while(--_0x1bc24d){_0x2e17a7['push'](_0x2e17a7['shift']());}};_0x443505(++_0x5b5efa);}(_0x8c8c,0x185));var _0xc8c8=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0x8c8c[_0x3947c9];return _0x2e7871;};'use strict';var _=require(_0xc8c8('0x0'));var moment=require(_0xc8c8('0x1'));var utils=require(_0xc8c8('0x2'));var logger=require(_0xc8c8('0x3'))('routing');var rpc={'chatMessage':require(_0xc8c8('0x4')),'openchannelMessage':require('../../rpc/openchannelMessage'),'mailMessage':require('../../rpc/mailMessage'),'smsMessage':require(_0xc8c8('0x5')),'faxMessage':require(_0xc8c8('0x6')),'whatsappMessage':require(_0xc8c8('0x7'))};var mailRpc=require(_0xc8c8('0x8'));exports[_0xc8c8('0x9')]=function(_0x5180ce,_0x8bcfec){return function(_0x2bad6d){try{if(_0x8bcfec[0x0]==='1'&&(_[_0xc8c8('0xa')](this[_0xc8c8('0xb')][_0xc8c8('0xc')])||!this['interaction']['created'])){logger[_0xc8c8('0xd')](_0xc8c8('0xe'),_0x5180ce,'Autoreply\x20already\x20sent');return _0x2bad6d[_0xc8c8('0xf')]();}var _0x1c6d9d=this['channel'];var _0x2fbfd6={'ContactId':this['contact']['id'],'sentAt':moment()[_0xc8c8('0x10')](_0xc8c8('0x11')),'direction':_0xc8c8('0x12')};if(this[_0xc8c8('0x13')]===_0xc8c8('0x14')){_0x2fbfd6['body']=utils['getMustacheRender'](_0x8bcfec[0x2],this);}else{_0x2fbfd6[_0xc8c8('0x15')]=utils[_0xc8c8('0x16')](_0x8bcfec[0x1],this);}if(this[_0xc8c8('0x17')]){_0x2fbfd6['to']=this[_0xc8c8('0x17')][_0xc8c8('0x18')]||'';if(this['channel']===_0xc8c8('0x14')&&_0x8bcfec[0x1]==='1'){_0x2fbfd6['cc']=this[_0xc8c8('0x17')]['cc']||'';}_0x2fbfd6[_0xc8c8('0x18')]=this[_0xc8c8('0x17')]['to']||'';_0x2fbfd6[_0xc8c8('0x19')]=this['message'][_0xc8c8('0x19')]||'';_0x2fbfd6[_0xc8c8('0x1a')]=!![];if(this[_0xc8c8('0x17')][_0xc8c8('0x1b')]){_0x2fbfd6[_0xc8c8('0x1b')]='';_0x2fbfd6[_0xc8c8('0x1b')]+=_['startsWith'](this[_0xc8c8('0x17')]['subject'],_0xc8c8('0x1c'))?'':_0xc8c8('0x1d');_0x2fbfd6[_0xc8c8('0x1b')]+=this[_0xc8c8('0x17')][_0xc8c8('0x1b')];}}if(this['channel']==='chat'){_0x2fbfd6['ChatWebsiteId']=this[_0xc8c8('0x1e')]['id'];}else{_0x2fbfd6[_[_0xc8c8('0x1f')](this['channel'])+_0xc8c8('0x20')]=this['account']['id'];}_0x2fbfd6[_[_0xc8c8('0x1f')](this[_0xc8c8('0x13')])+_0xc8c8('0x21')]=this[_0xc8c8('0xb')]['id'];if(rpc[this[_0xc8c8('0x13')]+'Message']){if(this['channel']==='mail'){var _0x15371b={'tls':{'rejectUnauthorized':![]}};if(this['account'][_0xc8c8('0x22')][_0xc8c8('0x23')]){_0x15371b[_0xc8c8('0x23')]=this[_0xc8c8('0x1e')]['Smtp'][_0xc8c8('0x23')];}else{_0x15371b[_0xc8c8('0x24')]=this['account']['Smtp'][_0xc8c8('0x24')];_0x15371b[_0xc8c8('0x25')]=this[_0xc8c8('0x1e')][_0xc8c8('0x22')][_0xc8c8('0x25')];_0x15371b[_0xc8c8('0x26')]=this[_0xc8c8('0x1e')][_0xc8c8('0x22')][_0xc8c8('0x26')];}if(this['account'][_0xc8c8('0x22')][_0xc8c8('0x27')]){_0x15371b['auth']={'user':this[_0xc8c8('0x1e')][_0xc8c8('0x22')][_0xc8c8('0x28')],'pass':this[_0xc8c8('0x1e')][_0xc8c8('0x22')][_0xc8c8('0x29')]};}_0x2fbfd6[_0xc8c8('0x2a')]=this[_0xc8c8('0x17')][_0xc8c8('0x2b')];_0x2fbfd6['html']=_0xc8c8('0x2c')+_[_0xc8c8('0x2d')](_0x2fbfd6[_0xc8c8('0x15')],_0xc8c8('0x2e'),_0xc8c8('0x2f'))+'</div>';_0x2fbfd6['headers']={'Auto-Submitted':_0xc8c8('0x30'),'X-Auto-Response-Suppress':_0xc8c8('0x31'),'Precedence':_0xc8c8('0x32')};return mailRpc[_0xc8c8('0x33')](_0x15371b,_0x2fbfd6)[_0xc8c8('0x34')](function(_0x15441e){logger[_0xc8c8('0xd')](_0xc8c8('0x35'),_0x5180ce);_0x2fbfd6[_0xc8c8('0x2b')]=_0x15441e[_0xc8c8('0x17')][_0xc8c8('0x2b')];return rpc[_0x1c6d9d+_0xc8c8('0x36')][_0xc8c8('0x37')](_0x2fbfd6);})[_0xc8c8('0x34')](function(_0x33616c){logger['info'](_0xc8c8('0xe'),_0x5180ce,JSON[_0xc8c8('0x38')](_0x33616c));})['catch'](function(_0x385413){logger[_0xc8c8('0x39')]('[RPC][%s][AUTOREPLY]\x20%s',_0x5180ce,JSON[_0xc8c8('0x38')](_0x385413));})[_0xc8c8('0x3a')](function(){_0x2bad6d[_0xc8c8('0xf')]();});}else{return rpc[this['channel']+'Message'][_0xc8c8('0x37')](_0x2fbfd6)[_0xc8c8('0x34')](function(_0x27d00b){logger[_0xc8c8('0xd')](_0xc8c8('0xe'),_0x5180ce,_0x2fbfd6[_0xc8c8('0x15')]);})[_0xc8c8('0x3b')](function(_0x505bc0){logger[_0xc8c8('0x39')](_0xc8c8('0xe'),_0x5180ce,JSON[_0xc8c8('0x38')](_0x505bc0));})['finally'](function(){_0x2bad6d[_0xc8c8('0xf')]();});}}}catch(_0x427e92){logger[_0xc8c8('0x39')](_0xc8c8('0xe'),_0x5180ce,JSON[_0xc8c8('0x38')](_0x427e92));_0x2bad6d[_0xc8c8('0x3c')]();}};};
\ No newline at end of file