Built motion from commit 36b8e3b.|0.0.111
[motion.git] / server / api / mail_account / mail_account.controller.js
1 var _0x84ca=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x61\x73\x79\x6E\x63","\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","\x4D\x61\x69\x6C\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x4D\x61\x69\x6C\x51\x75\x65\x75\x65","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x49\x6E","\x4D\x61\x69\x6C\x53\x65\x72\x76\x65\x72\x4F\x75\x74","\x4D\x61\x69\x6C\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x4D\x61\x69\x6C\x44\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E","\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","\x73\x63\x6F\x70\x65","\x67\x65\x74\x4D\x61\x69\x6C\x52\x6F\x6F\x6D\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x73\x75\x62\x6A\x65\x63\x74","\x66\x72\x6F\x6D","\x61\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x64\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E","\x74\x61\x67\x73","\x6C\x61\x73\x74\x45\x76\x65\x6E\x74","\x75\x70\x64\x61\x74\x65\x64\x41\x74","\x69\x73\x41\x72\x72\x61\x79","\x6C\x65\x6E\x67\x74\x68","\x25","\x3B\x25","\x70\x75\x73\x68","\x24\x61\x6E\x64","\x77\x68\x65\x72\x65","\x6D\x65\x72\x67\x65","\x55\x4E\x4D\x41\x4E\x41\x47\x45\x44","\x75\x73\x65\x72","\x69\x6E\x63\x6C\x75\x64\x65","\x61\x67\x65\x6E\x74","\x72\x6F\x6C\x65","\x65\x72\x72\x6F\x72","\x66\x69\x6E\x64\x41\x6C\x6C","\x67\x65\x74\x44\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E\x73","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x67\x65\x74\x4D\x61\x69\x6C\x44\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x73\x68\x6F\x77","\x73\x68\x6F\x77\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x6E\x61\x6D\x65","\x6F\x6E\x6C\x69\x6E\x65","\x67\x65\x74\x4D\x61\x69\x6C\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x63\x72\x65\x61\x74\x65","\x68\x61\x6E\x64\x6C\x65\x55\x6E\x69\x71\x75\x65\x43\x6F\x6E\x73\x74\x72\x61\x69\x6E\x74\x45\x72\x72\x6F\x72","\x65\x72\x72\x6F\x72\x4D\x61\x6E\x61\x67\x65\x72","\x62\x6F\x64\x79","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x63\x72\x65\x61\x74\x65\x44\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x75\x70\x64\x61\x74\x65","\x73\x61\x76\x65","\x75\x70\x64\x61\x74\x65\x44\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E","\x64\x69\x73\x70\x49\x64","\x75\x70\x64\x61\x74\x65\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x70\x72\x69\x6F\x72\x69\x74\x79","\x66\x6F\x72\x45\x61\x63\x68","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x64\x65\x73\x74\x72\x6F\x79\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x61\x70\x70\x49\x64","\x64\x65\x73\x74\x72\x6F\x79\x44\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x69\x64\x73","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x6C\x6F\x67"];_0x84ca[0];var _=require(_0x84ca[1]);var util=require(_0x84ca[2]);var async=require(_0x84ca[3]);var Util=require(_0x84ca[4]);var sequelize=require(_0x84ca[6])[_0x84ca[5]];var User=require(_0x84ca[6])[_0x84ca[7]];var MailAttachment=require(_0x84ca[6])[_0x84ca[8]];var MailQueue=require(_0x84ca[6])[_0x84ca[9]];var MailRoom=require(_0x84ca[6])[_0x84ca[10]];var MailAccount=require(_0x84ca[6])[_0x84ca[11]];var MailServerIn=require(_0x84ca[6])[_0x84ca[12]];var MailServerOut=require(_0x84ca[6])[_0x84ca[13]];var MailApplication=require(_0x84ca[6])[_0x84ca[14]];var MailDisposition=require(_0x84ca[6])[_0x84ca[15]];exports[_0x84ca[16]]=function(_0x87f1xf,_0x87f1x10){return MailAccount[_0x84ca[25]](_0x84ca[24])[_0x84ca[23]](Util[_0x84ca[22]](_0x87f1xf[_0x84ca[21]]))[_0x84ca[20]](function(_0x87f1x12){_0x87f1x10[_0x84ca[19]](200)[_0x84ca[18]](_0x87f1x12)})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[26]]=function(_0x87f1xf,_0x87f1x10,_0x87f1x13){var _0x87f1x14={include:[],where:{MailAccountId:_0x87f1xf[_0x84ca[28]][_0x84ca[27]],$and:[]},attributes:[_0x84ca[27],_0x84ca[29],_0x84ca[30],_0x84ca[31],_0x84ca[32],_0x84ca[33],_0x84ca[34],_0x84ca[35]]};if(_0x87f1xf[_0x84ca[21]]){if(_0x87f1xf[_0x84ca[21]][_0x84ca[33]]){if(_[_0x84ca[36]](_0x87f1xf[_0x84ca[21]][_0x84ca[33]])){for(var _0x87f1x15=0;_0x87f1x15<_0x87f1xf[_0x84ca[21]][_0x84ca[33]][_0x84ca[37]];_0x87f1x15++){_0x87f1x14[_0x84ca[42]][_0x84ca[41]][_0x84ca[40]]({tags:{$like:_0x84ca[38]+_0x87f1xf[_0x84ca[21]][_0x84ca[33]][_0x87f1x15]+_0x84ca[39]}})}}else {_0x87f1x14[_0x84ca[42]][_0x84ca[41]][_0x84ca[40]]({tags:{$like:_0x84ca[38]+_0x87f1xf[_0x84ca[21]][_0x84ca[33]]+_0x84ca[39]}})};delete _0x87f1xf[_0x84ca[21]][_0x84ca[33]]};_[_0x84ca[43]](_0x87f1x14[_0x84ca[42]],_0x87f1xf[_0x84ca[21]])};switch(_0x87f1xf[_0x84ca[45]][_0x84ca[48]]){case _0x84ca[47]:if(_0x87f1xf[_0x84ca[21]][_0x84ca[19]]&&_0x87f1xf[_0x84ca[21]][_0x84ca[19]]!==_0x84ca[44]){_0x87f1x14[_0x84ca[46]][_0x84ca[40]]({model:User,attributes:[_0x84ca[27]],where:{id:_0x87f1xf[_0x84ca[45]][_0x84ca[27]]}})};break;default:};return MailRoom[_0x84ca[50]](_0x87f1x14)[_0x84ca[20]](function(_0x87f1x16){return _0x87f1x10[_0x84ca[19]](200)[_0x84ca[18]](_0x87f1x16)})[_0x84ca[17]](function(_0x87f1x11){console[_0x84ca[49]](_0x87f1x11);return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[51]]=function(_0x87f1xf,_0x87f1x10,_0x87f1x13){return MailAccount[_0x84ca[54]](_0x87f1xf[_0x84ca[28]][_0x84ca[27]])[_0x84ca[20]](function(_0x87f1x18){if(!_0x87f1x18){return _0x87f1x10[_0x84ca[52]](404)};return _0x87f1x18[_0x84ca[53]]()})[_0x84ca[20]](function(_0x87f1x17){return _0x87f1x10[_0x84ca[19]](200)[_0x84ca[18]]({rows:_0x87f1x17,count:_0x87f1x17[_0x84ca[37]]})})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[55]]=function(_0x87f1xf,_0x87f1x10,_0x87f1x13){return MailAccount[_0x84ca[25]](_0x84ca[24])[_0x84ca[54]](_0x87f1xf[_0x84ca[28]][_0x84ca[27]])[_0x84ca[20]](function(_0x87f1x18){if(!_0x87f1x18){return _0x87f1x10[_0x84ca[52]](404)};return _0x87f1x10[_0x84ca[18]](_0x87f1x18)})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[56]]=function(_0x87f1xf,_0x87f1x10,_0x87f1x13){return MailAccount[_0x84ca[25]](_0x84ca[24])[_0x84ca[54]](_0x87f1xf[_0x84ca[28]][_0x84ca[27]])[_0x84ca[20]](function(_0x87f1x18){if(!_0x87f1x18){return _0x87f1x10[_0x84ca[52]](404)};return _0x87f1x18[_0x84ca[59]](_[_0x84ca[43]](Util[_0x84ca[22]](_0x87f1xf[_0x84ca[21]]),{include:[{model:MailQueue,attributes:[_0x84ca[27],_0x84ca[57]]},{model:User,attributes:[_0x84ca[27],_0x84ca[57],_0x84ca[58]]}]}))})[_0x84ca[20]](function(_0x87f1x19){return _0x87f1x10[_0x84ca[18]]({count:_0x87f1x19[_0x84ca[37]],rows:_0x87f1x19})})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[60]]=function(_0x87f1xf,_0x87f1x10,_0x87f1x13){return sequelize[_0x84ca[64]](function(_0x87f1x1a){return MailAccount[_0x84ca[60]](_0x87f1xf[_0x84ca[63]],{include:[{model:MailServerIn},{model:MailServerOut}],transaction:_0x87f1x1a})})[_0x84ca[20]](function(_0x87f1x18){return _0x87f1x10[_0x84ca[19]](201)[_0x84ca[18]](_0x87f1x18)})[_0x84ca[17]](sequelize.UniqueConstraintError,function(_0x87f1x11){return Util[_0x84ca[62]][_0x84ca[61]](_0x87f1x10,_0x87f1x11)})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[65]]=function(_0x87f1xf,_0x87f1x10,_0x87f1x13){_0x87f1xf[_0x84ca[63]][_0x84ca[66]]=_0x87f1xf[_0x84ca[28]][_0x84ca[27]];return MailDisposition[_0x84ca[60]](_0x87f1xf[_0x84ca[63]])[_0x84ca[20]](function(_0x87f1x1b){return _0x87f1x10[_0x84ca[19]](201)[_0x84ca[18]](_0x87f1x1b)})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[67]]=function(_0x87f1xf,_0x87f1x10){if(_0x87f1xf[_0x84ca[63]][_0x84ca[27]]){delete _0x87f1xf[_0x84ca[63]][_0x84ca[27]]};return MailAccount[_0x84ca[54]](_0x87f1xf[_0x84ca[28]][_0x84ca[27]])[_0x84ca[20]](function(_0x87f1x18){if(!_0x87f1x18){return _0x87f1x10[_0x84ca[52]](404)};var _0x87f1x1c=_[_0x84ca[43]](_0x87f1x18,_0x87f1xf[_0x84ca[63]]);return _0x87f1x1c[_0x84ca[68]]()})[_0x84ca[20]](function(_0x87f1x18){return _0x87f1x10[_0x84ca[19]](200)[_0x84ca[18]](_0x87f1x18)})[_0x84ca[17]](sequelize.UniqueConstraintError,function(_0x87f1x11){return Util[_0x84ca[62]][_0x84ca[61]](_0x87f1x10,_0x87f1x11)})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[69]]=function(_0x87f1xf,_0x87f1x10){if(_0x87f1xf[_0x84ca[63]][_0x84ca[27]]){delete _0x87f1xf[_0x84ca[63]][_0x84ca[27]]};return MailDisposition[_0x84ca[54]](_0x87f1xf[_0x84ca[28]][_0x84ca[70]])[_0x84ca[20]](function(_0x87f1x1d){if(!_0x87f1x1d){return _0x87f1x10[_0x84ca[52]](404)};var _0x87f1x1c=_[_0x84ca[43]](_0x87f1x1d,_0x87f1xf[_0x84ca[63]]);return _0x87f1x1c[_0x84ca[68]]()})[_0x84ca[20]](function(_0x87f1x18){return _0x87f1x10[_0x84ca[19]](200)[_0x84ca[18]](_0x87f1x18)})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[71]]=function(_0x87f1xf,_0x87f1x10){var _0x87f1x1e=0;var _0x87f1x1f=_0x87f1xf[_0x84ca[63]];_0x87f1x1f[_0x84ca[74]](function(_0x87f1x20){delete _0x87f1x20[_0x84ca[27]];delete _0x87f1x20[_0x84ca[72]];delete _0x87f1x20[_0x84ca[35]];_0x87f1x20[_0x84ca[73]]= ++_0x87f1x1e});return sequelize[_0x84ca[64]](function(_0x87f1x1a){return MailApplication[_0x84ca[76]]({where:{MailAccountId:_0x87f1xf[_0x84ca[28]][_0x84ca[27]]},individualHooks:true,transaction:_0x87f1x1a})[_0x84ca[20]](function(_0x87f1x22){return MailApplication[_0x84ca[75]](_0x87f1x1f,{individualHooks:true,transaction:_0x87f1x1a})})})[_0x84ca[20]](function(_0x87f1x21){return _0x87f1x10[_0x84ca[19]](200)[_0x84ca[18]]({count:_0x87f1x21[_0x84ca[37]],rows:_0x87f1x21})})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[76]]=function(_0x87f1xf,_0x87f1x10,_0x87f1x13){return MailAccount[_0x84ca[54]](_0x87f1xf[_0x84ca[28]][_0x84ca[27]])[_0x84ca[20]](function(_0x87f1x18){if(!_0x87f1x18){return _0x87f1x10[_0x84ca[52]](404)};return _0x87f1x18[_0x84ca[76]]()})[_0x84ca[20]](function(){return _0x87f1x10[_0x84ca[52]](204)})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[77]]=function(_0x87f1xf,_0x87f1x10,_0x87f1x13){return MailApplication[_0x84ca[54]](_0x87f1xf[_0x84ca[28]][_0x84ca[78]])[_0x84ca[20]](function(_0x87f1x22){if(!_0x87f1x22){return _0x87f1x10[_0x84ca[52]](404)};return _0x87f1x22[_0x84ca[76]]()})[_0x84ca[20]](function(){return _0x87f1x10[_0x84ca[52]](204)})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[79]]=function(_0x87f1xf,_0x87f1x10,_0x87f1x13){return MailDisposition[_0x84ca[54]](_0x87f1xf[_0x84ca[28]][_0x84ca[70]])[_0x84ca[20]](function(_0x87f1x1b){if(!_0x87f1x1b){return _0x87f1x10[_0x84ca[52]](404)};return _0x87f1x1b[_0x84ca[76]]()})[_0x84ca[20]](function(){return _0x87f1x10[_0x84ca[52]](204)})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[80]]=function(_0x87f1xf,_0x87f1x10){return MailAccount[_0x84ca[76]]({where:{id:_0x87f1xf[_0x84ca[21]][_0x84ca[81]]},individualHooks:true})[_0x84ca[20]](function(){return _0x87f1x10[_0x84ca[52]](204)})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};exports[_0x84ca[82]]=function(_0x87f1xf,_0x87f1x10){return MailApplication[_0x84ca[76]]({where:{id:_0x87f1xf[_0x84ca[21]][_0x84ca[81]]},individualHooks:true})[_0x84ca[20]](function(){return _0x87f1x10[_0x84ca[52]](204)})[_0x84ca[17]](function(_0x87f1x11){return handleError(_0x87f1x10,_0x87f1x11)})};function handleError(_0x87f1x10,_0x87f1x11){console[_0x84ca[83]](_0x87f1x11);return _0x87f1x10[_0x84ca[19]](500)[_0x84ca[18]](_0x87f1x11)}