1baa107b432b587d3dd7f57de090fc57f219b43e
[motion.git] / server / api / mail_message / mail_message.controller.js
1 var _0x65a1=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x61\x73\x79\x6E\x63","\x68\x74\x6D\x6C\x2D\x74\x6F\x2D\x74\x65\x78\x74","\x66\x6F\x72\x6D\x69\x64\x61\x62\x6C\x65","\x6D\x6F\x6D\x65\x6E\x74","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x43\x6F\x6E\x74\x61\x63\x74\x45\x6D\x61\x69\x6C","\x43\x6F\x6E\x74\x61\x63\x74","\x55\x73\x65\x72","\x69\x6E\x64\x65\x78","\x63\x72\x65\x61\x74\x65\x64\x41\x74\x20\x44\x45\x53\x43","\x77\x68\x65\x72\x65","\x71\x75\x65\x72\x79","\x61\x64\x6D\x69\x6E","\x61\x67\x65\x6E\x74","\x72\x6F\x6C\x65","\x75\x73\x65\x72","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x64\x65\x73\x63\x72\x69\x62\x65","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x6E\x61\x6D\x65","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x55\x73\x65\x72\x49\x64","\x62\x6F\x64\x79","\x75\x73\x65\x72\x4E\x61\x6D\x65","\x75\x73\x65\x72\x46\x75\x6C\x6C\x6E\x61\x6D\x65","\x74\x65\x78\x74","\x68\x74\x6D\x6C","\x66\x72\x6F\x6D\x53\x74\x72\x69\x6E\x67","\x65\x72\x72\x6F\x72","\x61\x63\x63\x6F\x75\x6E\x74\x49\x64","\x61\x63\x63\x6F\x75\x6E\x74\x4E\x61\x6D\x65","\x66\x72\x6F\x6D","\x73\x75\x62\x6A\x65\x63\x74","\x50\x45\x4E\x44\x49\x4E\x47","\x53\x45\x4E\x44\x49\x4E\x47","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x66\x69\x6E\x64\x4F\x6E\x65","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x6C\x65\x74\x65","\x54\x52\x41\x53\x48","\x62\x75\x6C\x6B\x55\x70\x64\x61\x74\x65"];_0x65a1[0];var _=require(_0x65a1[1]);var async=require(_0x65a1[2]);var htmlToText=require(_0x65a1[3]);var formidable=require(_0x65a1[4]);var moment=require(_0x65a1[5]);var path=require(_0x65a1[6]);var config=require(_0x65a1[7]);var sequelize=require(_0x65a1[9])[_0x65a1[8]];var MailMessage=require(_0x65a1[9])[_0x65a1[10]];var MailAttachment=require(_0x65a1[9])[_0x65a1[11]];var MailRoom=require(_0x65a1[9])[_0x65a1[12]];var MailAccount=require(_0x65a1[9])[_0x65a1[13]];var ContactEmail=require(_0x65a1[9])[_0x65a1[14]];var Contact=require(_0x65a1[9])[_0x65a1[15]];var User=require(_0x65a1[9])[_0x65a1[16]];exports[_0x65a1[17]]= function(_0xb29dx10,_0xb29dx11,_0xb29dx12){var _0xb29dx13={order:_0x65a1[18],include:[{all:true,include:[{all:true}]}]};switch(_0xb29dx10[_0x65a1[24]][_0x65a1[23]]){case _0x65a1[21]:_0xb29dx13[_0x65a1[19]]= _0xb29dx10[_0x65a1[20]];break;case _0x65a1[22]:break;default:};return MailMessage[_0x65a1[29]](_0xb29dx13)[_0x65a1[28]](function(_0xb29dx15){return _0xb29dx11[_0x65a1[27]](200)[_0x65a1[26]](_0xb29dx15)})[_0x65a1[25]](function(_0xb29dx14){return handleError(_0xb29dx11,_0xb29dx14,_0xb29dx12)})};exports[_0x65a1[30]]= function(_0xb29dx10,_0xb29dx11){return MailMessage[_0x65a1[30]]()[_0x65a1[28]](function(_0xb29dx16){return _0xb29dx11[_0x65a1[27]](200)[_0x65a1[26]](_0xb29dx16)})[_0x65a1[25]](function(_0xb29dx14){return handleError(_0xb29dx11,_0xb29dx14)})};exports[_0x65a1[31]]= function(_0xb29dx10,_0xb29dx11,_0xb29dx12){return MailMessage[_0x65a1[38]](_0xb29dx10[_0x65a1[34]][_0x65a1[33]],{include:[{model:MailAttachment},{model:User,attributes:[_0x65a1[33],_0x65a1[35],_0x65a1[36],_0x65a1[37]]}]})[_0x65a1[28]](function(_0xb29dx17){if(!_0xb29dx17){return _0xb29dx11[_0x65a1[32]](404)};return _0xb29dx11[_0x65a1[26]](_0xb29dx17)})[_0x65a1[25]](function(_0xb29dx14){return handleError(_0xb29dx11,_0xb29dx14,_0xb29dx12)})};exports[_0x65a1[39]]= function(_0xb29dx10,_0xb29dx11,_0xb29dx12){_0xb29dx10[_0x65a1[41]][_0x65a1[40]]= _0xb29dx10[_0x65a1[24]][_0x65a1[33]];_0xb29dx10[_0x65a1[41]][_0x65a1[42]]= _0xb29dx10[_0x65a1[24]][_0x65a1[35]];_0xb29dx10[_0x65a1[41]][_0x65a1[43]]= _0xb29dx10[_0x65a1[24]][_0x65a1[36]];_0xb29dx10[_0x65a1[41]][_0x65a1[44]]= _0xb29dx10[_0x65a1[41]][_0x65a1[44]]|| htmlToText[_0x65a1[46]](_0xb29dx10[_0x65a1[41]][_0x65a1[45]],{wordwrap:false});return MailAccount[_0x65a1[56]]({where:{address:_0xb29dx10[_0x65a1[41]][_0x65a1[50]][0]}})[_0x65a1[28]](function(_0xb29dx19){_0xb29dx10[_0x65a1[41]][_0x65a1[48]]= _0xb29dx19[_0x65a1[33]];_0xb29dx10[_0x65a1[41]][_0x65a1[49]]= _0xb29dx19[_0x65a1[35]];return MailRoom[_0x65a1[39]]({from:_0xb29dx10[_0x65a1[41]][_0x65a1[50]][0],subject:_0xb29dx10[_0x65a1[41]][_0x65a1[51]],account:_0xb29dx19[_0x65a1[35]],mailIn:0,mailOut:1,status:_0x65a1[52],openReason:_0x65a1[22],lastEvent:_0x65a1[53],lastEventAt:moment()[_0x65a1[55]](_0x65a1[54]),MailAccountId:_0xb29dx19[_0x65a1[33]],MailMessages:[_0xb29dx10[_0x65a1[41]]]},{include:[{model:MailMessage,include:[{model:MailAttachment}]}]})})[_0x65a1[28]](function(_0xb29dx18){return _0xb29dx11[_0x65a1[27]](201)[_0x65a1[26]](_0xb29dx18)})[_0x65a1[25]](function(_0xb29dx14){console[_0x65a1[47]](_0xb29dx14);return handleError(_0xb29dx11,_0xb29dx14)})};exports[_0x65a1[57]]= function(_0xb29dx10,_0xb29dx11,_0xb29dx12){return MailMessage[_0x65a1[38]](_0xb29dx10[_0x65a1[34]][_0x65a1[33]],{include:[{all:true}]})[_0x65a1[28]](function(_0xb29dx17){if(!_0xb29dx17){return _0xb29dx11[_0x65a1[32]](404)};var _0xb29dx1a=_[_0x65a1[58]](_0xb29dx17,_0xb29dx10[_0x65a1[41]]);return _0xb29dx1a[_0x65a1[59]]()})[_0x65a1[28]](function(_0xb29dx1a){return _0xb29dx11[_0x65a1[27]](200)[_0x65a1[26]](_0xb29dx1a)})[_0x65a1[25]](function(_0xb29dx14){return handleError(_0xb29dx11,_0xb29dx14,_0xb29dx12)})};exports[_0x65a1[60]]= function(_0xb29dx10,_0xb29dx11,_0xb29dx12){return MailMessage[_0x65a1[38]](_0xb29dx10[_0x65a1[34]][_0x65a1[33]])[_0x65a1[28]](function(_0xb29dx17){if(!_0xb29dx17){return _0xb29dx11[_0x65a1[32]](404)};return _0xb29dx17[_0x65a1[60]]()})[_0x65a1[28]](function(){return _0xb29dx11[_0x65a1[32]](204)})[_0x65a1[25]](function(_0xb29dx14){return handleError(_0xb29dx11,_0xb29dx14,_0xb29dx12)})};exports[_0x65a1[61]]= function(_0xb29dx10,_0xb29dx11,_0xb29dx12){return MailMessage[_0x65a1[63]]({where:{id:{$in:_0xb29dx10[_0x65a1[41]][_0x65a1[33]]}},attributes:{directory:_0x65a1[62]}})[_0x65a1[28]](function(_0xb29dx17){if(!_0xb29dx17){return _0xb29dx11[_0x65a1[32]](404)};return _0xb29dx17[_0x65a1[60]]()})[_0x65a1[28]](function(){return _0xb29dx11[_0x65a1[32]](204)})[_0x65a1[25]](function(_0xb29dx14){return handleError(_0xb29dx11,_0xb29dx14,_0xb29dx12)})};function handleError(_0xb29dx11,_0xb29dx14,_0xb29dx12){return _0xb29dx11[_0x65a1[27]](500)[_0x65a1[26]](_0xb29dx14)}