Built motion from commit 52def3a.|0.0.67
[motion.git] / server / api / mail_room / mail_room.controller.js
1 var _0x2621=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x68\x74\x6D\x6C\x2D\x74\x6F\x2D\x74\x65\x78\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x55\x73\x65\x72","\x43\x6F\x6E\x74\x61\x63\x74","\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","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x67\x65\x74\x51\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x64\x65\x66\x61\x75\x6C\x74","\x61\x67\x65\x6E\x74","\x69\x64","\x75\x73\x65\x72","\x73\x63\x6F\x70\x65","\x72\x6F\x6C\x65","\x61\x67\x65\x6E\x74\x49\x6E\x64\x65\x78","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x65\x72\x72\x6F\x72","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x73\x68\x6F\x77\x41\x67\x65\x6E\x74\x73","\x6E\x61\x6D\x65","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x67\x65\x74\x55\x73\x65\x72\x73","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x63\x72\x65\x61\x74\x65\x4D\x65\x73\x73\x61\x67\x65","\x55\x73\x65\x72\x49\x64","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D\x49\x64","\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x73","\x6C\x65\x6E\x67\x74\x68","\x74\x65\x78\x74","\x68\x74\x6D\x6C","\x66\x72\x6F\x6D\x53\x74\x72\x69\x6E\x67","\x72\x6F\x6C\x6C\x62\x61\x63\x6B","\x63\x6F\x6D\x6D\x69\x74","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x6A\x6F\x62\x49\x64","\x4D\x61\x69\x6C\x20\x61\x6C\x72\x65\x61\x64\x79\x20\x61\x73\x73\x69\x67\x6E\x65\x64","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x75\x70\x64\x61\x74\x65\x41\x67\x65\x6E\x74\x73","\x61\x67\x65\x6E\x74\x73","\x73\x65\x74\x55\x73\x65\x72\x73","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x69\x64\x73"];_0x2621[0];var _=require(_0x2621[1]);var util=require(_0x2621[2]);var htmlToText=require(_0x2621[3]);var Util=require(_0x2621[4]);var sequelize=require(_0x2621[6])[_0x2621[5]];var User=require(_0x2621[6])[_0x2621[7]];var Agent=require(_0x2621[6])[_0x2621[7]];var Contact=require(_0x2621[6])[_0x2621[8]];var MailRoom=require(_0x2621[6])[_0x2621[9]];var MailMessage=require(_0x2621[6])[_0x2621[10]];var MailAccount=require(_0x2621[6])[_0x2621[11]];var MailAttachment=require(_0x2621[6])[_0x2621[12]];exports[_0x2621[13]]=function(_0xe9b0xd,_0xe9b0xe,_0xe9b0xf){switch(_0xe9b0xd[_0x2621[24]][_0x2621[26]]){case _0x2621[22]:return MailRoom[_0x2621[25]](_0x2621[21],{method:[_0x2621[22],_0xe9b0xd[_0x2621[24]][_0x2621[23]]]})[_0x2621[20]](Util[_0x2621[19]](_0xe9b0xd[_0x2621[18]]))[_0x2621[17]](function(_0xe9b0x11){return _0xe9b0xe[_0x2621[16]](200)[_0x2621[15]](_0xe9b0x11)})[_0x2621[14]](function(_0xe9b0x10){return handleError(_0xe9b0xe,_0xe9b0x10)});default:return MailRoom[_0x2621[25]](_0x2621[21])[_0x2621[20]](Util[_0x2621[19]](_0xe9b0xd[_0x2621[18]]))[_0x2621[17]](function(_0xe9b0x11){return _0xe9b0xe[_0x2621[16]](200)[_0x2621[15]](_0xe9b0x11)})[_0x2621[14]](function(_0xe9b0x10){return handleError(_0xe9b0xe,_0xe9b0x10)})}};exports[_0x2621[27]]=function(_0xe9b0xd,_0xe9b0xe,_0xe9b0xf){return MailRoom[_0x2621[29]]({where:{UserId:_0xe9b0xd[_0x2621[28]][_0x2621[23]]},include:[{all:true}]})[_0x2621[17]](function(_0xe9b0x12){return _0xe9b0xe[_0x2621[16]](200)[_0x2621[15]](_0xe9b0x12)})[_0x2621[14]](function(_0xe9b0x10){return handleError(_0xe9b0xe,_0xe9b0x10)})};exports[_0x2621[30]]=function(_0xe9b0xd,_0xe9b0xe,_0xe9b0xf){return MailRoom[_0x2621[25]](_0x2621[21])[_0x2621[33]](_0xe9b0xd[_0x2621[28]][_0x2621[23]])[_0x2621[17]](function(_0xe9b0x13){if(!_0xe9b0x13){return _0xe9b0xe[_0x2621[32]](404)};return _0xe9b0xe[_0x2621[15]](_0xe9b0x13)})[_0x2621[14]](function(_0xe9b0x10){console[_0x2621[31]](_0xe9b0x10);return handleError(_0xe9b0xe,_0xe9b0x10)})};exports[_0x2621[34]]=function(_0xe9b0xd,_0xe9b0xe,_0xe9b0xf){return MailRoom[_0x2621[33]](_0xe9b0xd[_0x2621[28]][_0x2621[23]])[_0x2621[17]](function(_0xe9b0x13){if(!_0xe9b0x13){return _0xe9b0xe[_0x2621[32]](404)};return _0xe9b0x13[_0x2621[39]]({attributes:[_0x2621[23],_0x2621[35],_0x2621[36],_0x2621[37],_0x2621[26],_0x2621[38]]})})[_0x2621[17]](function(_0xe9b0x14){return _0xe9b0xe[_0x2621[15]](_0xe9b0x14)})[_0x2621[14]](function(_0xe9b0x10){return handleError(_0xe9b0xe,_0xe9b0x10)})};exports[_0x2621[40]]=function(_0xe9b0xd,_0xe9b0xe,_0xe9b0xf){return MailRoom[_0x2621[40]](_0xe9b0xd[_0x2621[41]])[_0x2621[17]](function(_0xe9b0x13){return _0xe9b0xe[_0x2621[16]](201)[_0x2621[15]](_0xe9b0x13)})[_0x2621[14]](function(_0xe9b0x10){return handleError(_0xe9b0xe,_0xe9b0x10)})};exports[_0x2621[42]]=function(_0xe9b0xd,_0xe9b0xe,_0xe9b0xf){_0xe9b0xd[_0x2621[41]][_0x2621[43]]=_0xe9b0xd[_0x2621[24]][_0x2621[23]];_0xe9b0xd[_0x2621[41]][_0x2621[44]]=_0xe9b0xd[_0x2621[28]][_0x2621[23]];_0xe9b0xd[_0x2621[41]][_0x2621[45]]=(_0xe9b0xd[_0x2621[41]][_0x2621[46]]&&_0xe9b0xd[_0x2621[41]][_0x2621[46]][_0x2621[47]])?true:false;_0xe9b0xd[_0x2621[41]][_0x2621[48]]=_0xe9b0xd[_0x2621[41]][_0x2621[48]]||htmlToText[_0x2621[50]](_0xe9b0xd[_0x2621[41]][_0x2621[49]],{wordwrap:false});return sequelize[_0x2621[53]]()[_0x2621[17]](function(_0xe9b0x15){return MailMessage[_0x2621[40]](_0xe9b0xd[_0x2621[41]],{include:[{model:MailAttachment}],transaction:_0xe9b0x15,user:_0xe9b0xd[_0x2621[24]]})[_0x2621[17]](function(_0xe9b0x16){_0xe9b0x15[_0x2621[52]]();return _0xe9b0xe[_0x2621[16]](201)[_0x2621[15]](_0xe9b0x16)})[_0x2621[14]](function(_0xe9b0x10){console[_0x2621[31]](_0xe9b0x10);_0xe9b0x15[_0x2621[51]]();return handleError(_0xe9b0xe,_0xe9b0x10)})})};exports[_0x2621[54]]=function(_0xe9b0xd,_0xe9b0xe,_0xe9b0xf){return MailRoom[_0x2621[33]](_0xe9b0xd[_0x2621[28]][_0x2621[23]])[_0x2621[17]](function(_0xe9b0x13){if(!_0xe9b0x13){return _0xe9b0xe[_0x2621[32]](404)};if(_0xe9b0x13[_0x2621[55]]){throw  new Error(_0x2621[56])};var _0xe9b0x17=_[_0x2621[57]](_0xe9b0x13,_0xe9b0xd[_0x2621[41]]);return _0xe9b0x17[_0x2621[58]]()})[_0x2621[17]](function(_0xe9b0x13){return _0xe9b0xe[_0x2621[16]](200)[_0x2621[15]](_0xe9b0x13)})[_0x2621[14]](function(_0xe9b0x10){return handleError(_0xe9b0xe,_0xe9b0x10)})};exports[_0x2621[59]]=function(_0xe9b0xd,_0xe9b0xe,_0xe9b0xf){return MailRoom[_0x2621[33]](_0xe9b0xd[_0x2621[28]][_0x2621[23]])[_0x2621[17]](function(_0xe9b0x13){if(!_0xe9b0x13){return _0xe9b0xe[_0x2621[32]](404)};return _0xe9b0x13[_0x2621[61]](_0xe9b0xd[_0x2621[41]][_0x2621[60]],{individualHooks:true})})[_0x2621[17]](function(){return _0xe9b0xe[_0x2621[32]](200)})[_0x2621[14]](function(_0xe9b0x10){return handleError(_0xe9b0xe,_0xe9b0x10)})};exports[_0x2621[62]]=function(_0xe9b0xd,_0xe9b0xe,_0xe9b0xf){return MailRoom[_0x2621[33]](_0xe9b0xd[_0x2621[28]][_0x2621[23]])[_0x2621[17]](function(_0xe9b0x13){if(!_0xe9b0x13){return _0xe9b0xe[_0x2621[32]](404)};return _0xe9b0x13[_0x2621[62]]()})[_0x2621[17]](function(){return _0xe9b0xe[_0x2621[32]](204)})[_0x2621[14]](function(_0xe9b0x10){return handleError(_0xe9b0xe,_0xe9b0x10)})};exports[_0x2621[63]]=function(_0xe9b0xd,_0xe9b0xe){return MailRoom[_0x2621[62]]({where:{id:_0xe9b0xd[_0x2621[18]][_0x2621[64]]},individualHooks:true})[_0x2621[17]](function(){return _0xe9b0xe[_0x2621[32]](200)})[_0x2621[14]](function(_0xe9b0x10){return handleError(_0xe9b0xe,_0xe9b0x10)})};function handleError(_0xe9b0xe,_0xe9b0x10){return _0xe9b0xe[_0x2621[16]](500)[_0x2621[15]](_0xe9b0x10)}