Built motion from commit 445c00a.|0.0.50
[motion.git] / server / api / mail_business_automation / mail_business_automation.controller.js
1 var _0x9089=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x4D\x61\x69\x6C\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x42\x75\x73\x69\x6E\x65\x73\x73\x43\x6F\x6E\x64\x69\x74\x69\x6F\x6E","\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x63\x74\x69\x6F\x6E","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x6F\x72","\x62\x6F\x64\x79","\x4D\x61\x69\x6C\x42\x75\x73\x69\x6E\x65\x73\x73\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x49\x64","\x63\x6F\x6E\x63\x61\x74","\x61\x6E\x64","\x61\x63\x74\x69\x6F\x6E\x73","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x9089[0];var _=require(_0x9089[1]);var util=require(_0x9089[2]);var MailBusinessAutomation=require(_0x9089[4])[_0x9089[3]];var BusinessCondition=require(_0x9089[4])[_0x9089[5]];var BusinessAction=require(_0x9089[4])[_0x9089[6]];var sequelize=require(_0x9089[4])[_0x9089[7]];exports[_0x9089[8]]=function(_0x656fx7,_0x656fx8,_0x656fx9){var _0x656fxa=[_0x9089[9],_0x9089[10]];var _0x656fxb=_0x656fx7[_0x9089[12]][_0x9089[11]]?parseInt(_0x656fx7[_0x9089[12]][_0x9089[11]],10):100;var _0x656fxc=_0x656fx7[_0x9089[12]][_0x9089[13]]?parseInt(_0x656fx7[_0x9089[12]][_0x9089[13]],10):0;var _0x656fxd={where:{},limit:_0x656fxb,offset:_0x656fxc*_0x656fxb};_[_0x9089[27]](_0x656fx7[_0x9089[12]],function(_0x656fxe,_0x656fxf){switch(_0x656fxf){case _0x9089[11]:;case _0x9089[13]:break;case _0x9089[16]:_0x656fxd[_0x9089[14]]=util[_0x9089[19]](_0x9089[15],_0x656fx7[_0x9089[12]][_0x9089[16]],_0x656fx7[_0x9089[12]][_0x9089[17]]||_0x9089[18])||null;break;case _0x9089[17]:break;case _0x9089[25]:_0x656fxd[_0x9089[21]][_0x9089[20]]=[];_0x656fxa[_0x9089[24]](function(_0x656fx10){var _0x656fx11={};_0x656fx11[_0x656fx10]={$like:_0x9089[22]+_0x656fxe+_0x9089[22]};_0x656fxd[_0x9089[21]][_0x9089[20]][_0x9089[23]](_0x656fx11)});break;default:_0x656fxd[_0x9089[21]][_0x656fxf]={$like:{}};_0x656fxd[_0x9089[21]][_0x656fxf][_0x9089[26]]=_0x9089[22]+_0x656fxe+_0x9089[22]}});MailBusinessAutomation[_0x9089[42]](_0x656fxd)[_0x9089[41]](function(_0x656fx13){var _0x656fx14=Math[_0x9089[33]](_0x656fx13[_0x9089[32]]/_0x656fxb);var _0x656fx15=_0x656fx14>(_0x656fxd[_0x9089[34]]+1)?util[_0x9089[19]](_0x9089[35],_0x656fx7[_0x9089[36]],_0x656fx7[_0x9089[38]][_0x9089[37]],_0x656fx7[_0x9089[39]],_0x656fxc+1):null;var _0x656fx16=_0x656fxc>0?util[_0x9089[19]](_0x9089[35],_0x656fx7[_0x9089[36]],_0x656fx7[_0x9089[38]][_0x9089[37]],_0x656fx7[_0x9089[39]],_0x656fxc-1):null;_0x656fx8[_0x9089[30]](200)[_0x9089[29]]({count:_0x656fx13[_0x9089[32]],mailAutomations:_0x656fx13[_0x9089[40]],next_page:_0x656fx15,previous_page:_0x656fx16,total_pages:_0x656fx14})})[_0x9089[31]](function(_0x656fx12){_0x656fx8[_0x9089[30]](500)[_0x9089[29]]({error:_0x9089[28]})})};exports[_0x9089[43]]=function(_0x656fx7,_0x656fx8){MailBusinessAutomation[_0x9089[47]](_0x656fx7[_0x9089[46]][_0x9089[45]],{include:[{all:true}]})[_0x9089[41]](function(_0x656fx17){if(!_0x656fx17){return _0x656fx8[_0x9089[44]](404)};return _0x656fx8[_0x9089[29]](_0x656fx17)})[_0x9089[31]](function(_0x656fx12){return handleError(_0x656fx8,_0x656fx12)})};exports[_0x9089[48]]=function(_0x656fx7,_0x656fx8,_0x656fx9){return sequelize[_0x9089[56]](function(_0x656fx18){return MailBusinessAutomation[_0x9089[48]](_0x656fx7[_0x9089[50]],{transaction:_0x656fx18})[_0x9089[41]](function(_0x656fx17){var _0x656fx19=[];if(_0x656fx7[_0x9089[50]][_0x9089[49]]){_0x656fx7[_0x9089[50]][_0x9089[49]][_0x9089[24]](function(_0x656fx1a){_0x656fx1a[_0x9089[51]]=_0x656fx17[_0x9089[45]]});_0x656fx19=_0x656fx19[_0x9089[52]](_0x656fx7[_0x9089[50]][_0x9089[49]])};if(_0x656fx7[_0x9089[50]][_0x9089[53]]){_0x656fx7[_0x9089[50]][_0x9089[53]][_0x9089[24]](function(_0x656fx1a){_0x656fx1a[_0x9089[51]]=_0x656fx17[_0x9089[45]]});_0x656fx19=_0x656fx19[_0x9089[52]](_0x656fx7[_0x9089[50]][_0x9089[53]])};return BusinessCondition[_0x9089[55]](_0x656fx19,{transaction:_0x656fx18})[_0x9089[41]](function(_0x656fx1b){if(_0x656fx7[_0x9089[50]][_0x9089[54]]){_0x656fx7[_0x9089[50]][_0x9089[54]][_0x9089[24]](function(_0x656fx1a){_0x656fx1a[_0x9089[51]]=_0x656fx17[_0x9089[45]]})};return BusinessAction[_0x9089[55]](_0x656fx7[_0x9089[50]][_0x9089[54]],{transaction:_0x656fx18})})})})[_0x9089[41]](function(){return _0x656fx8[_0x9089[44]](201)})[_0x9089[31]](function(_0x656fx12){return _0x656fx9(_0x656fx12)})};exports[_0x9089[57]]=function(_0x656fx7,_0x656fx8){if(_0x656fx7[_0x9089[50]][_0x9089[45]]){delete _0x656fx7[_0x9089[50]][_0x9089[45]]};MailBusinessAutomation[_0x9089[60]]({where:{id:_0x656fx7[_0x9089[46]][_0x9089[45]]}})[_0x9089[41]](function(_0x656fx17){if(!_0x656fx17){return _0x656fx8[_0x9089[44]](404)};var _0x656fx1c=_[_0x9089[58]](_0x656fx17,_0x656fx7[_0x9089[50]]);_0x656fx1c[_0x9089[59]]()[_0x9089[41]](function(){return _0x656fx8[_0x9089[30]](200)[_0x9089[29]](_0x656fx17)})[_0x9089[31]](function(_0x656fx12){return handleError(_0x656fx8,_0x656fx12)})})[_0x9089[31]](function(_0x656fx12){return handleError(_0x656fx8,_0x656fx12)})};exports[_0x9089[61]]=function(_0x656fx7,_0x656fx8){MailBusinessAutomation[_0x9089[47]](_0x656fx7[_0x9089[46]][_0x9089[45]])[_0x9089[41]](function(_0x656fx17){if(!_0x656fx17){return _0x656fx8[_0x9089[44]](404)};_0x656fx17[_0x9089[61]]()[_0x9089[41]](function(){return _0x656fx8[_0x9089[44]](204)})[_0x9089[31]](function(_0x656fx12){return handleError(_0x656fx8,_0x656fx12)})})[_0x9089[31]](function(_0x656fx12){return handleError(_0x656fx8,_0x656fx12)})};exports[_0x9089[62]]=function(_0x656fx7,_0x656fx8){MailBusinessAutomation[_0x9089[61]]({where:{id:_0x656fx7[_0x9089[12]][_0x9089[45]]},individualHooks:true})[_0x9089[41]](function(){return _0x656fx8[_0x9089[44]](204)})[_0x9089[31]](function(_0x656fx12){return handleError(_0x656fx8,_0x656fx12)})};function handleError(_0x656fx8,_0x656fx12){return _0x656fx8[_0x9089[30]](500)[_0x9089[29]](_0x656fx12)}