X-Git-Url: http://repos.xcallymotion.com/?a=blobdiff_plain;f=server%2Fservices%2Frouting%2Fserver%2Fapplications%2Fautoreply.js;h=751cd31b1404dc39941af84f93736ea9e213562a;hb=d56da45b6e1f0bbf558177cd907ef61f0b9840c2;hp=9f14cba86f51dbba8662ad4441aed5c181a75b2a;hpb=d49944cc2e95578bfbd15d79d46896f71a145821;p=motion2.git diff --git a/server/services/routing/server/applications/autoreply.js b/server/services/routing/server/applications/autoreply.js index 9f14cba..751cd31 100644 --- a/server/services/routing/server/applications/autoreply.js +++ b/server/services/routing/server/applications/autoreply.js @@ -15,4 +15,4 @@ // * treaties. The SOFTWARE PRODUCT is licensed, not sold. * // * * // ************************************************************************* -var _0x975d=['','headers','auto-replied','All','auto_reply','sendMailMessage','smtpOptions','then','[%s][AUTOREPLY]\x20SMTP\x20SENT','create','catch','stringify','finally','resolve','Interaction','[%s][AUTOREPLY][autoreplyExecuted]\x20%s','[RPC][%s][AUTOREPLY][autoreplyExecuted]\x20%s','error','stop','lodash','moment','./utils','../../../../config/logger','../../rpc/openchannelMessage','../../rpc/faxMessage','../../rpc/whatsappMessage','../../rpc/chatInteraction','../../rpc/openchannelInteraction','../../rpc/mailInteraction','../../rpc/smsInteraction','../../rpc/faxInteraction','../../rpc/whatsappInteraction','../../mailRpc','consequence','mail','isAutoreply','[%s][AUTOREPLY]\x20%s','Autoreply\x20not\x20executed\x20(message\x20is\x20autoreply)','next','isNil','interaction','created','info','Autoreply\x20already\x20sent','autoreplyExecuted','One\x20Time\x20already\x20sent','contact','format','YYYY-MM-DD\x20HH:mm:ss','channel','getMustacheRender','body','message','from','phone','read','subject','Re:\x20','chat','ChatWebsiteId','account','AccountId','upperFirst','Message','inReplyTo','messageId','html','','replace'];(function(_0x5f2ed4,_0x38a732){var _0x1fe7e0=function(_0x2ef190){while(--_0x2ef190){_0x5f2ed4['push'](_0x5f2ed4['shift']());}};_0x1fe7e0(++_0x38a732);}(_0x975d,0xe6));var _0xd975=function(_0x3f827f,_0x5c8266){_0x3f827f=_0x3f827f-0x0;var _0x28599e=_0x975d[_0x3f827f];return _0x28599e;};'use strict';var _=require(_0xd975('0x0'));var moment=require(_0xd975('0x1'));var utils=require(_0xd975('0x2'));var logger=require(_0xd975('0x3'))('routing');var rpc={'chatMessage':require('../../rpc/chatMessage'),'openchannelMessage':require(_0xd975('0x4')),'mailMessage':require('../../rpc/mailMessage'),'smsMessage':require('../../rpc/smsMessage'),'faxMessage':require(_0xd975('0x5')),'whatsappMessage':require(_0xd975('0x6')),'chatInteraction':require(_0xd975('0x7')),'openchannelInteraction':require(_0xd975('0x8')),'mailInteraction':require(_0xd975('0x9')),'smsInteraction':require(_0xd975('0xa')),'faxInteraction':require(_0xd975('0xb')),'whatsappInteraction':require(_0xd975('0xc'))};var mailRpc=require(_0xd975('0xd'));exports[_0xd975('0xe')]=function(_0x268d2c,_0x115d77,_0x4bc1cd,_0x550d4c){return function(_0x46c537){try{var _0x577003=this['channel'];if(_0x577003===_0xd975('0xf')&&_0x550d4c['body'][_0xd975('0x10')]){logger['info'](_0xd975('0x11'),_0x268d2c,_0xd975('0x12'));return _0x46c537[_0xd975('0x13')]();}if(_0x115d77[0x0]==='1'&&(_[_0xd975('0x14')](this[_0xd975('0x15')][_0xd975('0x16')])||!this[_0xd975('0x15')][_0xd975('0x16')])){logger[_0xd975('0x17')](_0xd975('0x11'),_0x268d2c,_0xd975('0x18'));return _0x46c537[_0xd975('0x13')]();}if(_0x115d77[0x0]==='2'&&this[_0xd975('0x15')][_0xd975('0x19')]){logger['info']('[%s][AUTOREPLY][autoreplyExecuted]\x20%s',_0x268d2c,_0xd975('0x1a'));return _0x46c537['next']();}var _0xba614a={'ContactId':this[_0xd975('0x1b')]['id'],'sentAt':moment()[_0xd975('0x1c')](_0xd975('0x1d')),'direction':'out'};if(this[_0xd975('0x1e')]===_0xd975('0xf')){_0xba614a['body']=utils[_0xd975('0x1f')](_0x115d77[0x2],this);}else{_0xba614a[_0xd975('0x20')]=utils[_0xd975('0x1f')](_0x115d77[0x1],this);}if(this[_0xd975('0x21')]){_0xba614a['to']=this['message'][_0xd975('0x22')]||'';if(this[_0xd975('0x1e')]==='mail'&&_0x115d77[0x1]==='1'){_0xba614a['cc']=this[_0xd975('0x21')]['cc']||'';}_0xba614a['from']=this['message']['to']||'';_0xba614a[_0xd975('0x23')]=this[_0xd975('0x21')][_0xd975('0x23')]||'';_0xba614a[_0xd975('0x24')]=!![];if(this['message'][_0xd975('0x25')]){_0xba614a[_0xd975('0x25')]='';_0xba614a[_0xd975('0x25')]+=_['startsWith'](this[_0xd975('0x21')]['subject'],'Re:')?'':_0xd975('0x26');_0xba614a[_0xd975('0x25')]+=this[_0xd975('0x21')][_0xd975('0x25')];}}if(this[_0xd975('0x1e')]===_0xd975('0x27')){_0xba614a[_0xd975('0x28')]=this[_0xd975('0x29')]['id'];}else{_0xba614a[_['upperFirst'](this[_0xd975('0x1e')])+_0xd975('0x2a')]=this[_0xd975('0x29')]['id'];}_0xba614a[_[_0xd975('0x2b')](this[_0xd975('0x1e')])+'InteractionId']=this[_0xd975('0x15')]['id'];var _0x4e667d=this[_0xd975('0x15')];if(rpc[this['channel']+_0xd975('0x2c')]){if(this[_0xd975('0x1e')]===_0xd975('0xf')){_0xba614a[_0xd975('0x2d')]=this[_0xd975('0x21')][_0xd975('0x2e')];_0xba614a[_0xd975('0x2f')]=_0xd975('0x30')+_[_0xd975('0x31')](_0xba614a[_0xd975('0x20')],'','replace','';_0x3faae7[_0xb0f0('0x34')]={'Auto-Submitted':_0xb0f0('0x35'),'X-Auto-Response-Suppress':_0xb0f0('0x36'),'Precedence':'auto_reply'};return mailRpc[_0xb0f0('0x37')](this[_0xb0f0('0x2c')][_0xb0f0('0x38')],_0x3faae7)[_0xb0f0('0x39')](function(_0x234157){logger['info'](_0xb0f0('0x3a'),_0x5b378d);_0x3faae7['messageId']=_0x234157[_0xb0f0('0x22')][_0xb0f0('0x30')];return rpc[_0x5c290f+_0xb0f0('0x3b')][_0xb0f0('0x3c')](_0x3faae7);})['then'](function(_0x5ab52a){logger['info'](_0xb0f0('0x12'),_0x5b378d,JSON[_0xb0f0('0x3d')](_0x5ab52a));})[_0xb0f0('0x3e')](function(_0x41e9da){logger[_0xb0f0('0x3f')](_0xb0f0('0x40'),_0x5b378d,JSON[_0xb0f0('0x3d')](_0x41e9da));})[_0xb0f0('0x41')](function(){Promise[_0xb0f0('0x42')]()[_0xb0f0('0x39')](function(){if(_0x1cd0ca[0x0]!=='2'||_0x2add78[_0xb0f0('0x19')])return;return rpc[_0x5c290f+_0xb0f0('0x43')]['update'](_0x2add78['id'],{'autoreplyExecuted':!![]})['then'](function(_0xbac62f){logger[_0xb0f0('0x11')](_0xb0f0('0x1a'),_0x5b378d,JSON[_0xb0f0('0x3d')](_0xbac62f));})[_0xb0f0('0x3e')](function(_0xb7df03){logger['error'](_0xb0f0('0x44'),_0x5b378d,JSON[_0xb0f0('0x3d')](_0xb7df03));});})[_0xb0f0('0x39')](function(){_0x5941ca[_0xb0f0('0x14')]();});});}else{return rpc[this[_0xb0f0('0x24')]+'Message']['create'](_0x3faae7)[_0xb0f0('0x39')](function(){logger[_0xb0f0('0x11')]('[%s][AUTOREPLY]\x20%s',_0x5b378d,_0x3faae7[_0xb0f0('0x20')]);})[_0xb0f0('0x3e')](function(_0x4f3430){logger[_0xb0f0('0x3f')](_0xb0f0('0x12'),_0x5b378d,JSON[_0xb0f0('0x3d')](_0x4f3430));})['finally'](function(){Promise[_0xb0f0('0x42')]()['then'](function(){if(_0x1cd0ca[0x0]!=='2'||_0x2add78[_0xb0f0('0x19')])return;return rpc[_0x5c290f+_0xb0f0('0x43')]['update'](_0x2add78['id'],{'autoreplyExecuted':!![]})['then'](function(_0xe58a4f){logger[_0xb0f0('0x11')](_0xb0f0('0x1a'),_0x5b378d,JSON[_0xb0f0('0x3d')](_0xe58a4f));})[_0xb0f0('0x3e')](function(_0x422a53){logger[_0xb0f0('0x3f')](_0xb0f0('0x44'),_0x5b378d,JSON[_0xb0f0('0x3d')](_0x422a53));});})['then'](function(){_0x5941ca[_0xb0f0('0x14')]();});});}}}catch(_0x4a31ae){logger[_0xb0f0('0x3f')](_0xb0f0('0x12'),_0x5b378d,JSON[_0xb0f0('0x3d')](_0x4a31ae));_0x5941ca[_0xb0f0('0x45')]();}};}; \ No newline at end of file