Built motion from commit fdd6c00de.|1.0.35
[motion.git] / server / api / mail_message / mail_message.controller.js
1 var _0xb8af=["\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","\x61\x70\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6C\x6F\x67\x67\x65\x72\x2E\x6A\x73","\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","\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","\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","\x73\x74\x61\x63\x6B","\x65\x72\x72\x6F\x72"];_0xb8af[0];var _=require(_0xb8af[1]);var async=require(_0xb8af[2]);var htmlToText=require(_0xb8af[3]);var formidable=require(_0xb8af[4]);var moment=require(_0xb8af[5]);var path=require(_0xb8af[6]);var logger=require(_0xb8af[8])(_0xb8af[7]);var config=require(_0xb8af[9]);var sequelize=require(_0xb8af[11])[_0xb8af[10]];var MailMessage=require(_0xb8af[11])[_0xb8af[12]];var MailAttachment=require(_0xb8af[11])[_0xb8af[13]];var MailRoom=require(_0xb8af[11])[_0xb8af[14]];var MailAccount=require(_0xb8af[11])[_0xb8af[15]];var ContactEmail=require(_0xb8af[11])[_0xb8af[16]];var Contact=require(_0xb8af[11])[_0xb8af[17]];var User=require(_0xb8af[11])[_0xb8af[18]];exports[_0xb8af[19]]= function(_0x3f54x11,_0x3f54x12,_0x3f54x13){var _0x3f54x14={order:_0xb8af[20],include:[{all:true,include:[{all:true}]}]};switch(_0x3f54x11[_0xb8af[26]][_0xb8af[25]]){case _0xb8af[23]:_0x3f54x14[_0xb8af[21]]= _0x3f54x11[_0xb8af[22]];break;case _0xb8af[24]:break;default:};return MailMessage[_0xb8af[31]](_0x3f54x14)[_0xb8af[30]](function(_0x3f54x16){return _0x3f54x12[_0xb8af[29]](200)[_0xb8af[28]](_0x3f54x16)})[_0xb8af[27]](function(_0x3f54x15){return handleError(_0x3f54x12,_0x3f54x15,_0x3f54x13)})};exports[_0xb8af[32]]= function(_0x3f54x11,_0x3f54x12){return MailMessage[_0xb8af[32]]()[_0xb8af[30]](function(_0x3f54x17){return _0x3f54x12[_0xb8af[29]](200)[_0xb8af[28]](_0x3f54x17)})[_0xb8af[27]](function(_0x3f54x15){return handleError(_0x3f54x12,_0x3f54x15)})};exports[_0xb8af[33]]= function(_0x3f54x11,_0x3f54x12,_0x3f54x13){return MailMessage[_0xb8af[40]](_0x3f54x11[_0xb8af[36]][_0xb8af[35]],{include:[{model:MailAttachment},{model:User,attributes:[_0xb8af[35],_0xb8af[37],_0xb8af[38],_0xb8af[39]]}]})[_0xb8af[30]](function(_0x3f54x18){if(!_0x3f54x18){return _0x3f54x12[_0xb8af[34]](404)};return _0x3f54x12[_0xb8af[28]](_0x3f54x18)})[_0xb8af[27]](function(_0x3f54x15){return handleError(_0x3f54x12,_0x3f54x15,_0x3f54x13)})};exports[_0xb8af[41]]= function(_0x3f54x11,_0x3f54x12,_0x3f54x13){_0x3f54x11[_0xb8af[43]][_0xb8af[42]]= _0x3f54x11[_0xb8af[26]][_0xb8af[35]];_0x3f54x11[_0xb8af[43]][_0xb8af[44]]= _0x3f54x11[_0xb8af[26]][_0xb8af[37]];_0x3f54x11[_0xb8af[43]][_0xb8af[45]]= _0x3f54x11[_0xb8af[26]][_0xb8af[38]];_0x3f54x11[_0xb8af[43]][_0xb8af[46]]= _0x3f54x11[_0xb8af[43]][_0xb8af[46]]|| htmlToText[_0xb8af[48]](_0x3f54x11[_0xb8af[43]][_0xb8af[47]],{wordwrap:false});return MailAccount[_0xb8af[57]]({where:{address:_0x3f54x11[_0xb8af[43]][_0xb8af[51]][0]}})[_0xb8af[30]](function(_0x3f54x1a){_0x3f54x11[_0xb8af[43]][_0xb8af[49]]= _0x3f54x1a[_0xb8af[35]];_0x3f54x11[_0xb8af[43]][_0xb8af[50]]= _0x3f54x1a[_0xb8af[37]];return MailRoom[_0xb8af[41]]({from:_0x3f54x11[_0xb8af[43]][_0xb8af[51]][0],subject:_0x3f54x11[_0xb8af[43]][_0xb8af[52]],account:_0x3f54x1a[_0xb8af[37]],mailIn:0,mailOut:1,status:_0xb8af[53],openReason:_0xb8af[24],lastEvent:_0xb8af[54],lastEventAt:moment()[_0xb8af[56]](_0xb8af[55]),MailAccountId:_0x3f54x1a[_0xb8af[35]],MailMessages:[_0x3f54x11[_0xb8af[43]]]},{include:[{model:MailMessage,include:[{model:MailAttachment}]}]})})[_0xb8af[30]](function(_0x3f54x19){return _0x3f54x12[_0xb8af[29]](201)[_0xb8af[28]](_0x3f54x19)})[_0xb8af[27]](function(_0x3f54x15){return handleError(_0x3f54x12,_0x3f54x15)})};exports[_0xb8af[58]]= function(_0x3f54x11,_0x3f54x12,_0x3f54x13){return MailMessage[_0xb8af[40]](_0x3f54x11[_0xb8af[36]][_0xb8af[35]],{include:[{all:true}]})[_0xb8af[30]](function(_0x3f54x18){if(!_0x3f54x18){return _0x3f54x12[_0xb8af[34]](404)};return _0x3f54x18[_0xb8af[58]](_0x3f54x11[_0xb8af[43]])})[_0xb8af[30]](function(_0x3f54x18){return _0x3f54x12[_0xb8af[29]](200)[_0xb8af[28]](_0x3f54x18)})[_0xb8af[27]](function(_0x3f54x15){return handleError(_0x3f54x12,_0x3f54x15,_0x3f54x13)})};exports[_0xb8af[59]]= function(_0x3f54x11,_0x3f54x12,_0x3f54x13){return MailMessage[_0xb8af[40]](_0x3f54x11[_0xb8af[36]][_0xb8af[35]])[_0xb8af[30]](function(_0x3f54x18){if(!_0x3f54x18){return _0x3f54x12[_0xb8af[34]](404)};return _0x3f54x18[_0xb8af[59]]()})[_0xb8af[30]](function(){return _0x3f54x12[_0xb8af[34]](204)})[_0xb8af[27]](function(_0x3f54x15){return handleError(_0x3f54x12,_0x3f54x15,_0x3f54x13)})};exports[_0xb8af[60]]= function(_0x3f54x11,_0x3f54x12,_0x3f54x13){return MailMessage[_0xb8af[62]]({where:{id:{$in:_0x3f54x11[_0xb8af[43]][_0xb8af[35]]}},attributes:{directory:_0xb8af[61]}})[_0xb8af[30]](function(_0x3f54x18){if(!_0x3f54x18){return _0x3f54x12[_0xb8af[34]](404)};return _0x3f54x18[_0xb8af[59]]()})[_0xb8af[30]](function(){return _0x3f54x12[_0xb8af[34]](204)})[_0xb8af[27]](function(_0x3f54x15){return handleError(_0x3f54x12,_0x3f54x15,_0x3f54x13)})};function handleError(_0x3f54x12,_0x3f54x15,_0x3f54x13){logger[_0xb8af[64]](_0x3f54x15[_0xb8af[63]]);return _0x3f54x12[_0xb8af[29]](500)[_0xb8af[28]](_0x3f54x15)}