Built motion from commit a11024eac.|1.0.35
[motion.git] / server / config / smtp / smtp.js
1 var _0x94d5=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x75\x74\x69\x6C","\x6C\x6F\x64\x61\x73\x68","\x6D\x6F\x6D\x65\x6E\x74","\x6D\x75\x73\x74\x61\x63\x68\x65","\x6D\x61\x69\x6C","\x2E\x2E\x2F\x6C\x6F\x67\x67\x65\x72\x2E\x6A\x73","\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","\x2E\x2E\x2F\x72\x70\x63\x2F\x63\x6C\x69\x65\x6E\x74","\x65\x72\x72\x6F\x72","\x53\x4D\x54\x50\x20\x50\x52\x4F\x43\x45\x53\x53\x20\x25\x73\x20\x45\x52\x52\x4F\x52","\x61\x72\x67\x76","\x66\x6F\x72\x6D\x61\x74","\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","\x69\x6E\x66\x6F","\x6D\x65\x73\x73\x61\x67\x65","\x74\x79\x70\x65","\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","\x67\x63","\x47\x61\x72\x62\x61\x67\x65\x20\x63\x6F\x6C\x6C\x65\x63\x74\x69\x6F\x6E\x20\x75\x6E\x61\x76\x61\x69\x6C\x61\x62\x6C\x65\x2E\x20\x20\x50\x61\x73\x73\x20\x2D\x2D\x65\x78\x70\x6F\x73\x65\x2D\x67\x63\x20","\x77\x68\x65\x6E\x20\x6C\x61\x75\x6E\x63\x68\x69\x6E\x67\x20\x6E\x6F\x64\x65\x20\x74\x6F\x20\x65\x6E\x61\x62\x6C\x65\x20\x66\x6F\x72\x63\x65\x64\x20\x67\x61\x72\x62\x61\x67\x65\x20\x63\x6F\x6C\x6C\x65\x63\x74\x69\x6F\x6E\x2E","\x77\x61\x72\x6E","\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\x74\x61\x63\x6B","\x45\x52\x52\x4F\x52","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x73\x65\x6E\x64","\x63\x61\x74\x63\x68","\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","\x43\x4F\x4E\x4E\x45\x43\x54\x45\x44","\x74\x68\x65\x6E","\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","\x69\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","\x5B\x53\x4D\x54\x50\x5D\x20\x45\x72\x72\x6F\x72\x20\x73\x65\x6E\x64\x69\x6E\x67\x20\x6D\x65\x73\x73\x61\x67\x65\x20\x25\x73","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D\x49\x64","\x75\x70\x64\x61\x74\x65","\x46\x41\x49\x4C\x45\x44","\x72\x65\x74\x72\x79\x53\x65\x6E\x64","\x6D\x65\x73\x73\x61\x67\x65\x49\x64","\x53\x45\x4E\x54","\x68\x74\x6D\x6C","\x75\x74\x66\x38","\x74\x65\x78\x74","\x74\x6F","\x69\x73\x41\x72\x72\x61\x79","\x61\x64\x64\x72\x65\x73\x73","\x77\x69\x74\x68\x6F\x75\x74","\x3B","\x73\x70\x6C\x69\x74","\x63\x63","\x62\x63\x63","\x73\x75\x62\x6A\x65\x63\x74","\x6E\x61\x6D\x65","\x66\x72\x6F\x6D","\x6A\x6F\x69\x6E","\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","\x54\x65\x6D\x70\x6C\x61\x74\x65","\x61\x75\x74\x6F","","\x66\x72\x6F\x6D\x53\x74\x72\x69\x6E\x67","\x77\x68\x69\x74\x65\x4C\x61\x62\x65\x6C","\x3C\x62\x72\x3E","\x3C\x62\x72\x3E\x20\x53\x65\x6E\x74\x20\x77\x69\x74\x68\x20\x58\x43\x41\x4C\x4C\x59\xAE","\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","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x55\x73\x65\x72\x48\x61\x73\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x72\x65\x71\x75\x65\x73\x74","\x73\x68\x6F\x77","\x55\x73\x65\x72","\x55\x73\x65\x72\x49\x64","\x6C\x65\x6E\x67\x74\x68","\x6D\x61\x69\x6C\x4F\x75\x74","\x50\x45\x4E\x44\x49\x4E\x47","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x5C\x6E","\x5C\x6E\x20\x53\x65\x6E\x74\x20\x77\x69\x74\x68\x20\x58\x43\x41\x4C\x4C\x59\xAE","\x63\x72\x65\x61\x74\x65","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D\x53\x74\x61\x74\x75\x73","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74"];_0x94d5[0];var util=require(_0x94d5[1]);var _=require(_0x94d5[2]);var moment=require(_0x94d5[3]);var Mustache=require(_0x94d5[4]);var logger=require(_0x94d5[6])(_0x94d5[5]);var nodemailer=require(_0x94d5[7]);var smtpTransport=require(_0x94d5[8]);var htmlToText=require(_0x94d5[9]);var rpcClient=require(_0x94d5[10]);var smtp;process[_0x94d5[15]](_0x94d5[19],function(_0x4bb5xd){if(_0x4bb5xd[_0x94d5[20]]=== _0x94d5[19]){onSend(_0x4bb5xd)};if(_0x4bb5xd[_0x94d5[20]]=== _0x94d5[21]){switch(_0x4bb5xd[_0x94d5[21]]){case _0x94d5[23]:onVerify(_0x4bb5xd[_0x94d5[22]]);break;default:}}})[_0x94d5[15]](_0x94d5[16],function(_0x4bb5xc){logger[_0x94d5[18]](util[_0x94d5[14]](_0x94d5[17],process[_0x94d5[13]][3],_0x4bb5xc))})[_0x94d5[15]](_0x94d5[11],function(_0x4bb5xb){logger[_0x94d5[11]](util[_0x94d5[14]](_0x94d5[12],process[_0x94d5[13]][3]),_0x4bb5xb)});logger[_0x94d5[18]](util[_0x94d5[14]](_0x94d5[24],process[_0x94d5[13]][3],process[_0x94d5[25]]));setInterval(function(){if(global[_0x94d5[26]]){global[_0x94d5[26]]()}else {logger[_0x94d5[29]](_0x94d5[27]+ _0x94d5[28])}},20000);function onVerify(_0x4bb5xf){smtp[_0x94d5[39]]()[_0x94d5[38]](function(){logger[_0x94d5[18]](util[_0x94d5[14]](_0x94d5[36],_0x4bb5xf,process[_0x94d5[25]]));process[_0x94d5[34]]({type:_0x94d5[21],state:_0x94d5[37],source:null})})[_0x94d5[35]](function(_0x4bb5xb){logger[_0x94d5[11]](util[_0x94d5[14]](_0x94d5[30],_0x4bb5xf,process[_0x94d5[25]]),_0x4bb5xb[_0x94d5[31]]);process[_0x94d5[34]]({type:_0x94d5[21],state:_0x94d5[32],source:JSON[_0x94d5[33]](_0x4bb5xb)})})}function onSave(_0x4bb5x11){smtp= nodemailer[_0x94d5[44]](smtpTransport({host:_0x4bb5x11[_0x94d5[40]],port:_0x4bb5x11[_0x94d5[41]],secure:_0x4bb5x11[_0x94d5[42]],pool:true,auth:{user:_0x4bb5x11[_0x94d5[22]],pass:_0x4bb5x11[_0x94d5[43]]}}));smtp[_0x94d5[45]]= _0x4bb5x11[_0x94d5[46]];smtp[_0x94d5[47]]= _0x4bb5x11[_0x94d5[48]];smtp[_0x94d5[22]]= _0x4bb5x11[_0x94d5[22]];onVerify(_0x4bb5x11[_0x94d5[22]])}function onSend(_0x4bb5x13){logger[_0x94d5[18]](util[_0x94d5[14]](_0x94d5[49],process[_0x94d5[13]][3],process[_0x94d5[25]]));if(_0x4bb5x13[_0x94d5[50]]=== _0x94d5[51]){var _0x4bb5x14;var _0x4bb5x15;var _0x4bb5x16;var _0x4bb5x17=_0x4bb5x13;var _0x4bb5x18,_0x4bb5x19,_0x4bb5x1a,_0x4bb5x1b;var _0x4bb5x1c,_0x4bb5x1d;if(_0x4bb5x17[_0x94d5[52]]){return rpcClient[_0x94d5[93]](_0x94d5[94],[_0x94d5[100],{where:{id:_0x4bb5x17[_0x94d5[54]]}}])[_0x94d5[38]](function(_0x4bb5x27){_0x4bb5x14= _0x4bb5x27;return rpcClient[_0x94d5[93]](_0x94d5[94],[_0x94d5[102],{where:{id:_0x4bb5x27[_0x94d5[46]]},include:[{model:_0x94d5[79]}]}])})[_0x94d5[38]](function(_0x4bb5x26){_0x4bb5x15= _0x4bb5x26;return rpcClient[_0x94d5[93]](_0x94d5[55],[_0x94d5[101],{MailRoomId:_0x4bb5x14[_0x94d5[48]]},{where:{id:_0x4bb5x17[_0x94d5[48]]}}])})[_0x94d5[38]](function(){var _0x4bb5xd={lastEvent:_0x94d5[51],attachment:_0x4bb5x17[_0x94d5[86]]&& _0x4bb5x17[_0x94d5[86]][_0x94d5[97]],mailOut:++_0x4bb5x14[_0x94d5[98]]};if(!_0x4bb5x13[_0x94d5[80]]){_0x4bb5xd[_0x94d5[50]]= _0x94d5[99]};return rpcClient[_0x94d5[93]](_0x94d5[55],[_0x94d5[100],_0x4bb5xd,{where:{id:_0x4bb5x14[_0x94d5[48]]}}])})[_0x94d5[38]](function(){return rpcClient[_0x94d5[93]](_0x94d5[94],[_0x94d5[95],{where:{id:_0x4bb5x17[_0x94d5[96]]}}])})[_0x94d5[38]](function(_0x4bb5x25){_0x4bb5x16= _0x4bb5x25;return rpcClient[_0x94d5[93]](_0x94d5[91],[_0x94d5[92],{where:{UserId:_0x4bb5x16[_0x94d5[48]],MailRoomId:_0x4bb5x14[_0x94d5[48]]},defaults:{UserId:_0x4bb5x16[_0x94d5[48]],MailRoomId:_0x4bb5x14[_0x94d5[48]]}}])})[_0x94d5[38]](function(_0x4bb5x1f){_0x4bb5x17[_0x94d5[60]]= _0x4bb5x17[_0x94d5[60]]?_0x4bb5x17[_0x94d5[60]].toString(_0x94d5[61]):null;_0x4bb5x17[_0x94d5[62]]= _0x4bb5x17[_0x94d5[62]]?_0x4bb5x17[_0x94d5[62]].toString(_0x94d5[61]):null;var _0x4bb5x20=_0x4bb5x17[_0x94d5[63]]?_[_0x94d5[64]](_0x4bb5x17[_0x94d5[63]])?_[_0x94d5[66]](_0x4bb5x17[_0x94d5[63]],_0x4bb5x15[_0x94d5[65]]):_[_0x94d5[66]](_0x4bb5x17[_0x94d5[63]][_0x94d5[68]](_0x94d5[67]),_0x4bb5x15[_0x94d5[65]]):[];var _0x4bb5x21=_0x4bb5x17[_0x94d5[69]]?(_[_0x94d5[64]](_0x4bb5x17[_0x94d5[69]])?_[_0x94d5[66]](_0x4bb5x17[_0x94d5[69]],_0x4bb5x15[_0x94d5[65]]):_[_0x94d5[66]](_0x4bb5x17[_0x94d5[69]][_0x94d5[68]](_0x94d5[67]),_0x4bb5x15[_0x94d5[65]])):[];var _0x4bb5x22=_0x4bb5x17[_0x94d5[70]]?_[_0x94d5[64]](_0x4bb5x17[_0x94d5[70]])?_[_0x94d5[66]](_0x4bb5x17[_0x94d5[70]],_0x4bb5x15[_0x94d5[65]]):_[_0x94d5[66]](_0x4bb5x17[_0x94d5[70]][_0x94d5[68]](_0x94d5[67]),_0x4bb5x15[_0x94d5[65]]):[];if(_0x4bb5x17[_0x94d5[71]]){_0x4bb5x17[_0x94d5[71]]= Mustache[_0x94d5[78]](_0x4bb5x17[_0x94d5[71]],{interactionId:_0x4bb5x14[_0x94d5[48]],accountName:_0x4bb5x15[_0x94d5[72]],from:_0x4bb5x17[_0x94d5[73]],to:_0x4bb5x20[_0x94d5[74]](_0x94d5[67]),cc:_0x4bb5x21[_0x94d5[74]](_0x94d5[67]),bcc:_0x4bb5x22[_0x94d5[74]](_0x94d5[67]),agentName:_0x4bb5x16[_0x94d5[75]],agentEmail:_0x4bb5x16[_0x94d5[76]],createdAt:_0x4bb5x17[_0x94d5[77]]})};if(_0x4bb5x15[_0x94d5[79]]&& _0x4bb5x15[_0x94d5[79]][_0x94d5[71]]&&  !_0x4bb5x13[_0x94d5[80]]){_0x4bb5x15[_0x94d5[79]][_0x94d5[71]]= Mustache[_0x94d5[78]](_0x4bb5x15[_0x94d5[79]][_0x94d5[71]],{interactionId:_0x4bb5x14[_0x94d5[48]],accountName:_0x4bb5x15[_0x94d5[72]],subject:_0x4bb5x17[_0x94d5[71]]|| _0x94d5[81],from:_0x4bb5x17[_0x94d5[73]],to:_0x4bb5x20[_0x94d5[74]](_0x94d5[67]),cc:_0x4bb5x21[_0x94d5[74]](_0x94d5[67]),bcc:_0x4bb5x22[_0x94d5[74]](_0x94d5[67]),agentName:_0x4bb5x16[_0x94d5[75]],agentEmail:_0x4bb5x16[_0x94d5[76]],createdAt:_0x4bb5x17[_0x94d5[77]]})};if(_0x4bb5x17[_0x94d5[60]]){_0x4bb5x17[_0x94d5[60]]= Mustache[_0x94d5[78]](_0x4bb5x17[_0x94d5[60]],{interactionId:_0x4bb5x14[_0x94d5[48]],subject:_0x4bb5x17[_0x94d5[71]],accountName:_0x4bb5x15[_0x94d5[72]],from:_0x4bb5x17[_0x94d5[73]],to:_0x4bb5x20[_0x94d5[74]](_0x94d5[67]),cc:_0x4bb5x21[_0x94d5[74]](_0x94d5[67]),bcc:_0x4bb5x22[_0x94d5[74]](_0x94d5[67]),agentName:_0x4bb5x16[_0x94d5[75]],agentEmail:_0x4bb5x16[_0x94d5[76]],createdAt:_0x4bb5x17[_0x94d5[77]]})};if(_0x4bb5x17[_0x94d5[62]]){_0x4bb5x17[_0x94d5[62]]= Mustache[_0x94d5[78]](_0x4bb5x17[_0x94d5[62]],{interactionId:_0x4bb5x14[_0x94d5[48]],subject:_0x4bb5x17[_0x94d5[71]],accountName:_0x4bb5x15[_0x94d5[72]],from:_0x4bb5x17[_0x94d5[73]],to:_0x4bb5x20[_0x94d5[74]](_0x94d5[67]),cc:_0x4bb5x21[_0x94d5[74]](_0x94d5[67]),bcc:_0x4bb5x22[_0x94d5[74]](_0x94d5[67]),agentName:_0x4bb5x16[_0x94d5[75]],agentEmail:_0x4bb5x16[_0x94d5[76]],createdAt:_0x4bb5x17[_0x94d5[77]]})};_0x4bb5x1d= (_0x4bb5x15[_0x94d5[79]]&&  !_0x4bb5x13[_0x94d5[80]])?Mustache[_0x94d5[78]](_0x4bb5x15[_0x94d5[79]][_0x94d5[60]],{interactionId:_0x4bb5x14[_0x94d5[48]],subject:_0x4bb5x15[_0x94d5[79]][_0x94d5[71]]|| _0x4bb5x17[_0x94d5[71]],body:_0x4bb5x17[_0x94d5[60]]|| _0x4bb5x17[_0x94d5[62]]|| _0x94d5[81],accountName:_0x4bb5x15[_0x94d5[72]],from:_0x4bb5x17[_0x94d5[73]],to:_0x4bb5x20[_0x94d5[74]](_0x94d5[67]),cc:_0x4bb5x21[_0x94d5[74]](_0x94d5[67]),bcc:_0x4bb5x22[_0x94d5[74]](_0x94d5[67]),agentName:_0x4bb5x16[_0x94d5[75]],agentEmail:_0x4bb5x16[_0x94d5[76]],createdAt:_0x4bb5x17[_0x94d5[77]]}):_0x4bb5x17[_0x94d5[60]];_0x4bb5x1c= _0x4bb5x17[_0x94d5[62]]|| (_0x4bb5x1d?htmlToText[_0x94d5[82]](_0x4bb5x1d,{wordwrap:false}):_0x94d5[81]);if(_0x4bb5x15[_0x94d5[83]]){_0x4bb5x1d+= _0x94d5[84]+ _0x4bb5x15[_0x94d5[83]];_0x4bb5x1c+= _0x94d5[84]+ _0x4bb5x15[_0x94d5[83]]}else {_0x4bb5x1d+= _0x94d5[85];_0x4bb5x1c+= _0x94d5[85]};var _0x4bb5x23={status:_0x4bb5x17[_0x94d5[50]],from:{name:_0x4bb5x15[_0x94d5[72]],address:_0x4bb5x15[_0x94d5[65]]},to:_0x4bb5x20[_0x94d5[74]](_0x94d5[67]),cc:_0x4bb5x21[_0x94d5[74]](_0x94d5[67]),bcc:_0x4bb5x22[_0x94d5[74]](_0x94d5[67]),subject:(_0x4bb5x15[_0x94d5[79]]&&  !_0x4bb5x13[_0x94d5[80]]&& _0x4bb5x15[_0x94d5[79]][_0x94d5[71]])?_0x4bb5x15[_0x94d5[79]][_0x94d5[71]]:_0x4bb5x17[_0x94d5[71]],html:_0x4bb5x1d,text:_0x4bb5x1c};if(_0x4bb5x17[_0x94d5[86]]){_0x4bb5x23[_0x94d5[87]]= _[_0x94d5[89]](_0x4bb5x17.MailAttachments,function(_0x4bb5x24){return {path:_0x4bb5x24[_0x94d5[88]],filename:_0x4bb5x24[_0x94d5[72]]}})};return smtp[_0x94d5[90]](_0x4bb5x23)})[_0x94d5[38]](function(_0x4bb5x1e){process[_0x94d5[34]]({msgId:_0x4bb5x17[_0x94d5[48]],roomId:_0x4bb5x14[_0x94d5[48]],type:_0x94d5[55],messageId:_0x4bb5x1e[_0x94d5[58]],status:_0x94d5[59],retry:_0x4bb5x17[_0x94d5[57]],text:_0x4bb5x1c,html:_0x4bb5x1d})})[_0x94d5[35]](function(_0x4bb5xb){logger[_0x94d5[11]](util[_0x94d5[14]](_0x94d5[53],_0x4bb5x17[_0x94d5[48]]),_0x4bb5xb[_0x94d5[31]]);process[_0x94d5[34]]({msgId:_0x4bb5x17[_0x94d5[48]],roomId:_0x4bb5x17[_0x94d5[54]],type:_0x94d5[55],status:_0x94d5[56],retry:_0x4bb5x17[_0x94d5[57]],text:_0x4bb5x1c,html:_0x4bb5x1d})})}else {return rpcClient[_0x94d5[93]](_0x94d5[94],[_0x94d5[102],{where:{id:smtp[_0x94d5[45]]},include:[{model:_0x94d5[79]}]}])[_0x94d5[38]](function(_0x4bb5x26){_0x4bb5x15= _0x4bb5x26;if(_0x4bb5x17[_0x94d5[54]]){return rpcClient[_0x94d5[93]](_0x94d5[94],[_0x94d5[100],{where:{id:_0x4bb5x17[_0x94d5[54]]}}])}})[_0x94d5[38]](function(_0x4bb5x27){if(!_0x4bb5x27){return rpcClient[_0x94d5[93]](_0x94d5[94],[_0x94d5[95],{where:{id:_0x4bb5x13[_0x94d5[96]]}}])[_0x94d5[38]](function(_0x4bb5x28){return rpcClient[_0x94d5[93]](_0x94d5[105],[_0x94d5[100],{subject:_0x4bb5x17[_0x94d5[71]],from:_[_0x94d5[64]](_0x4bb5x17[_0x94d5[73]])?_0x4bb5x17[_0x94d5[73]][_0x94d5[74]](_0x94d5[67]):_0x4bb5x17[_0x94d5[73]],account:_0x4bb5x15?_0x4bb5x15[_0x94d5[72]]:null,status:_0x94d5[99],lastEvent:_0x94d5[51],attachment:_0x4bb5x17[_0x94d5[86]]&& _0x4bb5x17[_0x94d5[86]][_0x94d5[97]],MailAccountId:_0x4bb5x15?_0x4bb5x15[_0x94d5[48]]:null,mailOut:1,arrivedAt:moment()[_0x94d5[14]](_0x94d5[106]),MailRoomStatuses:[{status:_0x94d5[99],data1:_0x4bb5x28?_0x4bb5x28[_0x94d5[72]]:null,data2:_0x4bb5x28?_0x4bb5x28[_0x94d5[75]]:null,UserId:_0x4bb5x28?_0x4bb5x28[_0x94d5[48]]:null}]},{include:[{model:_0x94d5[101]},{model:_0x94d5[107]}]}])})}else {return _0x4bb5x27}})[_0x94d5[38]](function(_0x4bb5x27){_0x4bb5x14= _0x4bb5x27;return rpcClient[_0x94d5[93]](_0x94d5[55],[_0x94d5[101],{MailRoomId:_0x4bb5x27[_0x94d5[48]],accountId:_0x4bb5x15[_0x94d5[48]],accountName:_0x4bb5x15[_0x94d5[72]]},{where:{id:_0x4bb5x13[_0x94d5[48]]},individualHooks:true}])})[_0x94d5[38]](function(){return rpcClient[_0x94d5[93]](_0x94d5[94],[_0x94d5[95],{id:_0x4bb5x17[_0x94d5[96]]}])})[_0x94d5[38]](function(_0x4bb5x25){_0x4bb5x16= _0x4bb5x25;if(_0x4bb5x17[_0x94d5[96]]&& _0x4bb5x14[_0x94d5[48]]){return rpcClient[_0x94d5[93]](_0x94d5[91],[_0x94d5[92],{where:{UserId:_0x4bb5x17[_0x94d5[96]],MailRoomId:_0x4bb5x14[_0x94d5[48]]},defaults:{UserId:_0x4bb5x17[_0x94d5[96]],MailRoomId:_0x4bb5x14[_0x94d5[48]]}}])}})[_0x94d5[38]](function(){var _0x4bb5x20=_0x4bb5x17[_0x94d5[63]]?_[_0x94d5[64]](_0x4bb5x17[_0x94d5[63]])?_[_0x94d5[66]](_0x4bb5x17[_0x94d5[63]],_0x4bb5x15[_0x94d5[65]]):_[_0x94d5[66]](_0x4bb5x17[_0x94d5[63]][_0x94d5[68]](_0x94d5[67]),_0x4bb5x15[_0x94d5[65]]):[];var _0x4bb5x21=_0x4bb5x17[_0x94d5[69]]?(_[_0x94d5[64]](_0x4bb5x17[_0x94d5[69]])?_[_0x94d5[66]](_0x4bb5x17[_0x94d5[69]],_0x4bb5x15[_0x94d5[65]]):_[_0x94d5[66]](_0x4bb5x17[_0x94d5[69]][_0x94d5[68]](_0x94d5[67]),_0x4bb5x15[_0x94d5[65]])):[];var _0x4bb5x22=_0x4bb5x17[_0x94d5[70]]?_[_0x94d5[64]](_0x4bb5x17[_0x94d5[70]])?_[_0x94d5[66]](_0x4bb5x17[_0x94d5[70]],_0x4bb5x15[_0x94d5[65]]):_[_0x94d5[66]](_0x4bb5x17[_0x94d5[70]][_0x94d5[68]](_0x94d5[67]),_0x4bb5x15[_0x94d5[65]]):[];if(_0x4bb5x17[_0x94d5[71]]){_0x4bb5x17[_0x94d5[71]]= Mustache[_0x94d5[78]](_0x4bb5x17[_0x94d5[71]],{interactionId:_0x4bb5x14[_0x94d5[48]],accountName:_0x4bb5x15[_0x94d5[72]],from:_0x4bb5x17[_0x94d5[73]],to:_0x4bb5x20[_0x94d5[74]](_0x94d5[67]),cc:_0x4bb5x21[_0x94d5[74]](_0x94d5[67]),bcc:_0x4bb5x22[_0x94d5[74]](_0x94d5[67]),agentName:_0x4bb5x16[_0x94d5[75]],agentEmail:_0x4bb5x16[_0x94d5[76]],createdAt:_0x4bb5x17[_0x94d5[77]]})};if(_0x4bb5x15[_0x94d5[79]]&& _0x4bb5x15[_0x94d5[79]][_0x94d5[71]]&&  !_0x4bb5x13[_0x94d5[80]]){_0x4bb5x15[_0x94d5[79]][_0x94d5[71]]= Mustache[_0x94d5[78]](_0x4bb5x15[_0x94d5[79]][_0x94d5[71]],{interactionId:_0x4bb5x14[_0x94d5[48]],accountName:_0x4bb5x15[_0x94d5[72]],subject:_0x4bb5x17[_0x94d5[71]]|| _0x94d5[81],from:_0x4bb5x17[_0x94d5[73]],to:_0x4bb5x20[_0x94d5[74]](_0x94d5[67]),cc:_0x4bb5x21[_0x94d5[74]](_0x94d5[67]),bcc:_0x4bb5x22[_0x94d5[74]](_0x94d5[67]),agentName:_0x4bb5x16[_0x94d5[75]],agentEmail:_0x4bb5x16[_0x94d5[76]],createdAt:_0x4bb5x17[_0x94d5[77]]})};if(_0x4bb5x17[_0x94d5[60]]){_0x4bb5x17[_0x94d5[60]]= Mustache[_0x94d5[78]](_0x4bb5x17[_0x94d5[60]],{interactionId:_0x4bb5x14[_0x94d5[48]],subject:_0x4bb5x17[_0x94d5[71]],accountName:_0x4bb5x15[_0x94d5[72]],from:_0x4bb5x17[_0x94d5[73]],to:_0x4bb5x20[_0x94d5[74]](_0x94d5[67]),cc:_0x4bb5x21[_0x94d5[74]](_0x94d5[67]),bcc:_0x4bb5x22[_0x94d5[74]](_0x94d5[67]),agentName:_0x4bb5x16[_0x94d5[75]],agentEmail:_0x4bb5x16[_0x94d5[76]],createdAt:_0x4bb5x17[_0x94d5[77]]})};if(_0x4bb5x17[_0x94d5[62]]){_0x4bb5x17[_0x94d5[62]]= Mustache[_0x94d5[78]](_0x4bb5x17[_0x94d5[62]],{interactionId:_0x4bb5x14[_0x94d5[48]],subject:_0x4bb5x17[_0x94d5[71]],accountName:_0x4bb5x15[_0x94d5[72]],from:_0x4bb5x17[_0x94d5[73]],to:_0x4bb5x20[_0x94d5[74]](_0x94d5[67]),cc:_0x4bb5x21[_0x94d5[74]](_0x94d5[67]),bcc:_0x4bb5x22[_0x94d5[74]](_0x94d5[67]),agentName:_0x4bb5x16[_0x94d5[75]],agentEmail:_0x4bb5x16[_0x94d5[76]],createdAt:_0x4bb5x17[_0x94d5[77]]})};_0x4bb5x1d= (_0x4bb5x15[_0x94d5[79]]&&  !_0x4bb5x13[_0x94d5[80]])?Mustache[_0x94d5[78]](_0x4bb5x15[_0x94d5[79]][_0x94d5[60]],{interactionId:_0x4bb5x14[_0x94d5[48]],subject:_0x4bb5x15[_0x94d5[79]][_0x94d5[71]]|| _0x4bb5x17[_0x94d5[71]],body:_0x4bb5x17[_0x94d5[60]]|| _0x4bb5x17[_0x94d5[62]]|| null,accountName:_0x4bb5x15[_0x94d5[72]],from:_0x4bb5x17[_0x94d5[73]],to:_0x4bb5x20[_0x94d5[74]](_0x94d5[67]),cc:_0x4bb5x21[_0x94d5[74]](_0x94d5[67]),bcc:_0x4bb5x22[_0x94d5[74]](_0x94d5[67]),agentName:_0x4bb5x16?_0x4bb5x16[_0x94d5[75]]:_0x94d5[81],agentEmail:_0x4bb5x16?_0x4bb5x16[_0x94d5[76]]:_0x94d5[81],createdAt:_0x4bb5x17[_0x94d5[77]]}):_0x4bb5x17[_0x94d5[60]];_0x4bb5x1c= _0x4bb5x17[_0x94d5[62]]|| (_0x4bb5x1d?htmlToText[_0x94d5[82]](_0x4bb5x1d,{wordwrap:false}):_0x94d5[81]);if(_0x4bb5x15[_0x94d5[83]]){_0x4bb5x1d+= _0x94d5[84]+ _0x4bb5x15[_0x94d5[83]];_0x4bb5x1c+= _0x94d5[103]+ _0x4bb5x15[_0x94d5[83]]}else {_0x4bb5x1d+= _0x94d5[85];_0x4bb5x1c+= _0x94d5[104]};var _0x4bb5x23={status:_0x4bb5x17[_0x94d5[50]],from:{name:_0x4bb5x15[_0x94d5[72]],address:_0x4bb5x15[_0x94d5[65]]},to:_0x4bb5x20[_0x94d5[74]](_0x94d5[67]),cc:_0x4bb5x21[_0x94d5[74]](_0x94d5[67]),bcc:_0x4bb5x22[_0x94d5[74]](_0x94d5[67]),subject:(_0x4bb5x15[_0x94d5[79]]&&  !_0x4bb5x13[_0x94d5[80]]&& _0x4bb5x15[_0x94d5[79]][_0x94d5[71]])?_0x4bb5x15[_0x94d5[79]][_0x94d5[71]]:_0x4bb5x17[_0x94d5[71]],html:_0x4bb5x1d,text:_0x4bb5x1c};if(_0x4bb5x17[_0x94d5[86]]){_0x4bb5x23[_0x94d5[87]]= _[_0x94d5[89]](_0x4bb5x17.MailAttachments,function(_0x4bb5x24){return {path:_0x4bb5x24[_0x94d5[88]],filename:_0x4bb5x24[_0x94d5[72]]}})};return smtp[_0x94d5[90]](_0x4bb5x23)})[_0x94d5[38]](function(_0x4bb5x1e){process[_0x94d5[34]]({msgId:_0x4bb5x17[_0x94d5[48]],roomId:_0x4bb5x14[_0x94d5[48]],type:_0x94d5[55],messageId:_0x4bb5x1e[_0x94d5[58]],status:_0x94d5[59],retry:_0x4bb5x17[_0x94d5[57]],text:_0x4bb5x1c,html:_0x4bb5x1d})})[_0x94d5[35]](function(_0x4bb5xb){logger[_0x94d5[11]](util[_0x94d5[14]](_0x94d5[53],_0x4bb5x17[_0x94d5[48]]),_0x4bb5xb[_0x94d5[31]]);process[_0x94d5[34]]({msgId:_0x4bb5x17[_0x94d5[48]],roomId:_0x4bb5x17[_0x94d5[54]],type:_0x94d5[55],status:_0x94d5[56],retry:_0x4bb5x17[_0x94d5[57]],text:_0x4bb5x1c,html:_0x4bb5x1d})})}}}return rpcClient[_0x94d5[93]](_0x94d5[94],[_0x94d5[108],{where:{id:process[_0x94d5[13]][2]}}])[_0x94d5[38]](function(_0x4bb5x11){onSave(_0x4bb5x11)})[_0x94d5[35]](function(_0x4bb5xb){logger[_0x94d5[11]](_0x4bb5xb[_0x94d5[31]])})