Built motion from commit 65070aa.|0.0.108
[motion.git] / server / config / smtp / smtp.js
1 var _0x5f56=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x75\x74\x69\x6C","\x62\x6C\x75\x65\x62\x69\x72\x64","\x6C\x6F\x64\x61\x73\x68","\x6D\x75\x73\x74\x61\x63\x68\x65","\x6E\x6F\x64\x65\x6D\x61\x69\x6C\x65\x72","\x6E\x6F\x64\x65\x6D\x61\x69\x6C\x65\x72\x2D\x73\x6D\x74\x70\x2D\x74\x72\x61\x6E\x73\x70\x6F\x72\x74","\x68\x74\x6D\x6C\x2D\x74\x6F\x2D\x74\x65\x78\x74","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x54\x65\x6D\x70\x6C\x61\x74\x65","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x65\x72\x72\x6F\x72","\x6F\x6E","\x63\x6C\x6F\x73\x65","\x53\x4D\x54\x50\x20\x53\x45\x52\x56\x45\x52\x20\x25\x73\x20\x45\x58\x49\x54\x45\x44\x20\x57\x49\x54\x48\x20\x43\x4F\x44\x45\x20\x25\x73","\x61\x72\x67\x76","\x66\x6F\x72\x6D\x61\x74","\x6C\x6F\x67","\x6D\x65\x73\x73\x61\x67\x65","\x74\x79\x70\x65","\x63\x61\x74\x63\x68","\x72\x65\x74\x72\x79\x53\x65\x6E\x64","\x74\x68\x65\x6E","\x69\x64","\x66\x69\x6E\x64\x42\x79\x49\x64","\x73\x74\x61\x74\x65","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x43\x4F\x4E\x4E\x45\x43\x54\x49\x4E\x47","\x53\x4D\x54\x50\x20\x53\x45\x52\x56\x45\x52\x20\x25\x73\x20\x53\x54\x41\x52\x54\x49\x4E\x47\x2C\x20\x50\x52\x4F\x43\x45\x53\x53\x20\x49\x44\x3A\x20\x25\x73\x20","\x70\x69\x64","\x45\x52\x52\x4F\x52","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x53\x4D\x54\x50\x20\x53\x45\x52\x56\x45\x52\x20\x25\x73\x20\x45\x52\x52\x4F\x52\x2C\x20\x50\x52\x4F\x43\x45\x53\x53\x20\x49\x44\x3A\x20\x25\x73\x20","\x73\x65\x6E\x64","\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x53\x4D\x54\x50\x20\x53\x45\x52\x56\x45\x52\x20\x25\x73\x20\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44\x2C\x20\x50\x52\x4F\x43\x45\x53\x53\x20\x49\x44\x3A\x20\x25\x73\x20","\x76\x65\x72\x69\x66\x79","\x68\x6F\x73\x74","\x70\x6F\x72\x74","\x73\x73\x6C","\x70\x61\x73\x73\x77\x6F\x72\x64","\x63\x72\x65\x61\x74\x65\x54\x72\x61\x6E\x73\x70\x6F\x72\x74","\x6D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x6D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74\x49\x64","\x53\x4D\x54\x50\x20\x53\x45\x52\x56\x45\x52\x20\x25\x73\x20\x53\x45\x4E\x44\x49\x4E\x47\x20\x4D\x53\x47\x2C\x20\x50\x52\x4F\x43\x45\x53\x53\x20\x49\x44\x3A\x20\x25\x73\x20","\x73\x74\x61\x74\x75\x73","\x53\x45\x4E\x44\x49\x4E\x47","\x69\x6E\x52\x65\x70\x6C\x79\x54\x6F","\x75\x70\x64\x61\x74\x65","\x46\x41\x49\x4C\x45\x44","\x6D\x65\x73\x73\x61\x67\x65\x49\x64","\x53\x45\x4E\x54","\x68\x74\x6D\x6C","\x73\x75\x62\x6A\x65\x63\x74","\x66\x72\x6F\x6D\x53\x74\x72\x69\x6E\x67","\x6E\x61\x6D\x65","\x66\x72\x6F\x6D","\x74\x6F","\x63\x63","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x72\x65\x6E\x64\x65\x72","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x70\x61\x74\x68","\x6D\x61\x70","\x73\x65\x6E\x64\x4D\x61\x69\x6C","\x61\x64\x64\x55\x73\x65\x72","\x6C\x65\x6E\x67\x74\x68","\x6D\x61\x69\x6C\x4F\x75\x74","\x61\x64\x64\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x67\x65\x74\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x66\x69\x6E\x64\x4F\x6E\x65","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D\x49\x64","\x3B","\x6A\x6F\x69\x6E","\x4F\x50\x45\x4E","\x55\x73\x65\x72\x49\x64","\x63\x72\x65\x61\x74\x65"];_0x5f56[0];var util=require(_0x5f56[1]);var promise=require(_0x5f56[2]);var _=require(_0x5f56[3]);var Mustache=require(_0x5f56[4]);var nodemailer=require(_0x5f56[5]);var smtpTransport=require(_0x5f56[6]);var htmlToText=require(_0x5f56[7]);var Agent=require(_0x5f56[9])[_0x5f56[8]];var Room=require(_0x5f56[9])[_0x5f56[10]];var Template=require(_0x5f56[9])[_0x5f56[11]];var Account=require(_0x5f56[9])[_0x5f56[12]];var Message=require(_0x5f56[9])[_0x5f56[13]];var Message=require(_0x5f56[9])[_0x5f56[13]];var Server=require(_0x5f56[9])[_0x5f56[14]];var Attachment=require(_0x5f56[9])[_0x5f56[15]];var smtp;var timeout;process[_0x5f56[17]](_0x5f56[23],function(_0xbf22x13){if(_0xbf22x13[_0x5f56[24]]===_0x5f56[23]){return Message[_0x5f56[29]](_0xbf22x13[_0x5f56[28]],{include:[{model:Attachment}]})[_0x5f56[27]](function(_0xbf22x14){onSend(_0xbf22x14,_0xbf22x13[_0x5f56[26]])})[_0x5f56[25]](function(_0xbf22x11){console[_0x5f56[16]](_0xbf22x11)})};if(_0xbf22x13[_0x5f56[24]]===_0x5f56[30]){switch(_0xbf22x13[_0x5f56[30]]){case _0x5f56[32]:onVerify(_0xbf22x13[_0x5f56[31]]);break;default:}}})[_0x5f56[17]](_0x5f56[18],function(_0xbf22x12){console[_0x5f56[22]](util[_0x5f56[21]](_0x5f56[19],process[_0x5f56[20]][3],_0xbf22x12))})[_0x5f56[17]](_0x5f56[16],function(_0xbf22x11){console[_0x5f56[16]](_0xbf22x11)});console[_0x5f56[22]](util[_0x5f56[21]](_0x5f56[33],process[_0x5f56[20]][3],process[_0x5f56[34]]));function onVerify(_0xbf22x16){smtp[_0x5f56[41]]()[_0x5f56[27]](function(){process[_0x5f56[38]]({type:_0x5f56[30],state:_0x5f56[39],source:null,log:util[_0x5f56[21]](_0x5f56[40],_0xbf22x16,process[_0x5f56[34]])})})[_0x5f56[25]](function(_0xbf22x11){process[_0x5f56[38]]({type:_0x5f56[30],state:_0x5f56[35],source:JSON[_0x5f56[36]](_0xbf22x11),log:util[_0x5f56[21]](_0x5f56[37],_0xbf22x16,process[_0x5f56[34]])})})}function onSave(_0xbf22x18){smtp=nodemailer[_0x5f56[46]](smtpTransport({host:_0xbf22x18[_0x5f56[42]],port:_0xbf22x18[_0x5f56[43]],secure:_0xbf22x18[_0x5f56[44]],pool:true,auth:{user:_0xbf22x18[_0x5f56[31]],pass:_0xbf22x18[_0x5f56[45]]}}));smtp[_0x5f56[47]]=_0xbf22x18[_0x5f56[48]];smtp[_0x5f56[49]]=_0xbf22x18[_0x5f56[28]];smtp[_0x5f56[31]]=_0xbf22x18[_0x5f56[31]];onVerify(_0xbf22x18[_0x5f56[31]])}function onSend(_0xbf22x14,_0xbf22x1a){console[_0x5f56[22]](util[_0x5f56[21]](_0x5f56[50],process[_0x5f56[20]][3],process[_0x5f56[34]]));if(_0xbf22x14[_0x5f56[51]]===_0x5f56[52]){var _0xbf22x1b;var _0xbf22x1c;var _0xbf22x1d;var _0xbf22x1e=_0xbf22x14;var _0xbf22x1f,_0xbf22x20,_0xbf22x21,_0xbf22x22;if(_0xbf22x1e[_0x5f56[53]]){return Message[_0x5f56[79]]({where:{messageId:_0xbf22x1e[_0x5f56[53]]}})[_0x5f56[27]](function(_0xbf22x29){return _0xbf22x29[_0x5f56[78]]({include:{model:Account,include:[{model:Template}]}})})[_0x5f56[27]](function(_0xbf22x28){_0xbf22x1b=_0xbf22x28;_0xbf22x1c=_0xbf22x28[_0x5f56[12]];return _0xbf22x1b[_0x5f56[77]](_0xbf22x1e)})[_0x5f56[27]](function(){return _0xbf22x1b[_0x5f56[54]]({lastEvent:_0x5f56[52],attachment:_0xbf22x1e[_0x5f56[69]]&&_0xbf22x1e[_0x5f56[69]][_0x5f56[75]],mailOut:++_0xbf22x1b[_0x5f56[76]]})})[_0x5f56[27]](function(){return Agent[_0x5f56[29]](_0xbf22x1e.UserId)})[_0x5f56[27]](function(_0xbf22x27){_0xbf22x1d=_0xbf22x27;return _0xbf22x1b[_0x5f56[74]](_0xbf22x1d)})[_0x5f56[27]](function(){var _0xbf22x24=_0xbf22x1c[_0x5f56[11]]?Mustache[_0x5f56[68]](_0xbf22x1c[_0x5f56[11]][_0x5f56[58]],{interactionId:_0xbf22x1b[_0x5f56[28]],subject:_0xbf22x1e[_0x5f56[59]],body:_0xbf22x1e[_0x5f56[58]]?htmlToText[_0x5f56[60]](_0xbf22x1e[_0x5f56[58]],{wordwrap:false}):null,accountName:_0xbf22x1c[_0x5f56[61]],from:_0xbf22x1e[_0x5f56[62]],to:_0xbf22x1e[_0x5f56[63]],cc:_0xbf22x1e[_0x5f56[64]],agentName:_0xbf22x1d[_0x5f56[65]],agentEmail:_0xbf22x1d[_0x5f56[66]],createdAt:_0xbf22x1e[_0x5f56[67]]}):_0xbf22x1e[_0x5f56[58]];var _0xbf22x25={status:_0xbf22x1e[_0x5f56[51]],from:_0xbf22x1e[_0x5f56[62]],to:_0xbf22x1e[_0x5f56[63]],cc:_0xbf22x1e[_0x5f56[64]],subject:_0xbf22x1e[_0x5f56[59]],html:_0xbf22x24,text:_0xbf22x1e[_0x5f56[58]]?htmlToText[_0x5f56[60]](_0xbf22x1e[_0x5f56[58]],{wordwrap:false}):null};if(_0xbf22x1e[_0x5f56[69]]){_0xbf22x25[_0x5f56[70]]=_[_0x5f56[72]](_0xbf22x1e.MailAttachments,function(_0xbf22x26){return {path:_0xbf22x26[_0x5f56[71]],filename:_0xbf22x26[_0x5f56[61]]}})};return smtp[_0x5f56[73]](_0xbf22x25)})[_0x5f56[27]](function(_0xbf22x23){process[_0x5f56[38]]({msgId:_0xbf22x1e[_0x5f56[28]],roomId:_0xbf22x1b[_0x5f56[28]],type:_0x5f56[54],messageId:_0xbf22x23[_0x5f56[56]],status:_0x5f56[57],retry:_0xbf22x1a})})[_0x5f56[25]](function(_0xbf22x11){process[_0x5f56[38]]({msgId:_0xbf22x1e[_0x5f56[28]],roomId:_0xbf22x1b[_0x5f56[28]],type:_0x5f56[54],status:_0x5f56[55],retry:_0xbf22x1a})})}else {return Account[_0x5f56[29]](smtp[_0x5f56[47]],{include:[{model:Template}]})[_0x5f56[27]](function(_0xbf22x2a){_0xbf22x1c=_0xbf22x2a;if(_0xbf22x14[_0x5f56[80]]){return Room[_0x5f56[29]](_0xbf22x14.MailRoomId)}else {return Room[_0x5f56[85]]({subject:_0xbf22x1e[_0x5f56[59]],from:_0xbf22x1e[_0x5f56[62]][_0x5f56[82]](_0x5f56[81]),account:_0xbf22x2a?_0xbf22x2a[_0x5f56[61]]:null,status:_0x5f56[83],lastEvent:_0x5f56[52],attachment:_0xbf22x1e[_0x5f56[69]]&&_0xbf22x1e[_0x5f56[69]][_0x5f56[75]],MailAccountId:_0xbf22x2a?_0xbf22x2a[_0x5f56[28]]:null,mailOut:1},{userId:_0xbf22x1e[_0x5f56[84]]})}})[_0x5f56[27]](function(_0xbf22x28){_0xbf22x1b=_0xbf22x28;return _0xbf22x1b[_0x5f56[77]](_0xbf22x1e[_0x5f56[28]])})[_0x5f56[27]](function(){return Agent[_0x5f56[29]](_0xbf22x1e.UserId)})[_0x5f56[27]](function(_0xbf22x27){_0xbf22x1d=_0xbf22x27;return _0xbf22x1b[_0x5f56[74]](_0xbf22x1d)})[_0x5f56[27]](function(){var _0xbf22x24=_0xbf22x1c[_0x5f56[11]]?Mustache[_0x5f56[68]](_0xbf22x1c[_0x5f56[11]][_0x5f56[58]],{interactionId:_0xbf22x1b[_0x5f56[28]],subject:_0xbf22x1e[_0x5f56[59]],body:_0xbf22x1e[_0x5f56[58]]?htmlToText[_0x5f56[60]](_0xbf22x1e[_0x5f56[58]],{wordwrap:false}):null,accountName:_0xbf22x1c[_0x5f56[61]],from:_0xbf22x1e[_0x5f56[62]],to:_0xbf22x1e[_0x5f56[63]],cc:_0xbf22x1e[_0x5f56[64]],agentName:_0xbf22x1d[_0x5f56[65]],agentEmail:_0xbf22x1d[_0x5f56[66]],createdAt:_0xbf22x1e[_0x5f56[67]]}):_0xbf22x1e[_0x5f56[58]];var _0xbf22x25={status:_0xbf22x1e[_0x5f56[51]],from:_0xbf22x1e[_0x5f56[62]],to:_0xbf22x1e[_0x5f56[63]],cc:_0xbf22x1e[_0x5f56[64]],subject:_0xbf22x1e[_0x5f56[59]],html:_0xbf22x24,text:_0xbf22x1e[_0x5f56[58]]?htmlToText[_0x5f56[60]](_0xbf22x1e[_0x5f56[58]],{wordwrap:false}):null};if(_0xbf22x1e[_0x5f56[69]]){_0xbf22x25[_0x5f56[70]]=_[_0x5f56[72]](_0xbf22x1e.MailAttachments,function(_0xbf22x26){return {path:_0xbf22x26[_0x5f56[71]],filename:_0xbf22x26[_0x5f56[61]]}})};return smtp[_0x5f56[73]](_0xbf22x25)})[_0x5f56[27]](function(_0xbf22x23){process[_0x5f56[38]]({msgId:_0xbf22x1e[_0x5f56[28]],roomId:_0xbf22x1b[_0x5f56[28]],type:_0x5f56[54],messageId:_0xbf22x23[_0x5f56[56]],status:_0x5f56[57],retry:_0xbf22x1a})})[_0x5f56[25]](function(_0xbf22x11){process[_0x5f56[38]]({msgId:_0xbf22x1e[_0x5f56[28]],roomId:_0xbf22x1b[_0x5f56[28]],type:_0x5f56[54],status:_0x5f56[55],retry:_0xbf22x1a})})}}}Server[_0x5f56[29]](process[_0x5f56[20]][2])[_0x5f56[27]](function(_0xbf22x18){onSave(_0xbf22x18)})[_0x5f56[25]](function(_0xbf22x11){console[_0x5f56[16]](_0xbf22x11)})