5c0a4f81877b936fe62266a2390c65641692cf07
[motion.git] / server / api / list / list.controller.js
1 var _0x70f9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x62\x6C\x75\x65\x62\x69\x72\x64","\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","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x4C\x69\x73\x74","\x54\x64\x55\x70\x64\x61\x74\x65","\x55\x73\x65\x72\x48\x61\x73\x4C\x69\x73\x74","\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x43\x6F\x6E\x74\x61\x63\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","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x69\x64","\x6D\x61\x70","\x71\x75\x65\x72\x79","\x67\x65\x74\x51\x75\x65\x72\x79","\x6D\x65\x72\x67\x65","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x63\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x73","\x73\x63\x6F\x70\x65","\x67\x65\x74\x4C\x69\x73\x74\x73","\x75\x73\x65\x72","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x67\x65\x6E\x74","\x72\x6F\x6C\x65","\x67\x65\x74\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x73","\x70\x61\x72\x61\x6D\x73","\x67\x65\x74\x41\x6C\x6C\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x73","\x67\x65\x74\x43\x6F\x6E\x74\x61\x63\x74","\x62\x6F\x64\x79","\x73\x70\x72\x65\x61\x64","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x67\x65\x74\x43\x6F\x6E\x74\x61\x63\x74\x73","\x70\x68\x6F\x6E\x65","\x6D\x6F\x62\x69\x6C\x65","\x66\x61\x78","\x65\x6D\x61\x69\x6C","\x77\x68\x65\x72\x65","\x25","\x66\x6F\x72\x49\x6E","\x6C\x65\x6E\x67\x74\x68","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x75\x70\x64\x61\x74\x65\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x73\x61\x76\x65","\x63\x72\x65\x61\x74\x65\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x4C\x69\x73\x74\x49\x64","\x41\x4C\x54\x45\x52\x20\x54\x41\x42\x4C\x45\x20\x63\x6D\x5F\x63\x6F\x6E\x74\x61\x63\x74\x73\x20\x41\x44\x44\x20\x43\x4F\x4C\x55\x4D\x4E\x20\x25\x73\x20\x56\x41\x52\x43\x48\x41\x52\x28\x32\x35\x35\x29","\x6E\x61\x6D\x65","\x66\x6F\x72\x6D\x61\x74","\x63\x66\x5F","\x63\x72\x65\x61\x74\x65","\x73\x68\x6F\x77","\x74\x72\x61\x6E\x73\x6C\x61\x74\x65\x64\x4D\x65\x73\x73\x61\x67\x65","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x4C\x49\x53\x54","\x6D\x65\x73\x73\x61\x67\x65","\x54\x68\x65\x20\x6C\x69\x73\x74\x20\x6E\x61\x6D\x65\x20\x61\x6C\x72\x65\x61\x64\x79\x20\x65\x78\x69\x73\x74\x73","\x6C\x69\x73\x74\x2F\x69\x6E\x73\x65\x72\x74","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x6C\x69\x73\x74\x2F\x75\x70\x64\x61\x74\x65","\x73\x68\x6F\x77\x41\x67\x65\x6E\x74\x73","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x67\x65\x74\x55\x73\x65\x72\x73","\x61\x64\x64\x41\x67\x65\x6E\x74\x73","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x61\x67\x65\x6E\x74\x73","\x72\x65\x6D\x6F\x76\x65\x41\x67\x65\x6E\x74\x73","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x69\x64\x73","\x61\x6C\x6C","\x69\x6E\x63\x6C\x75\x64\x65\x73","\x41\x4C\x54\x45\x52\x20\x54\x41\x42\x4C\x45\x20\x63\x6D\x5F\x63\x6F\x6E\x74\x61\x63\x74\x73\x20\x44\x52\x4F\x50\x20\x43\x4F\x4C\x55\x4D\x4E\x20\x25\x73","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x6B\x65\x79\x73","\x64\x65\x73\x63\x72\x69\x62\x65","\x72\x65\x6D\x6F\x76\x65\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x72\x65\x6D\x6F\x76\x65\x41\x6C\x6C\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x73","\x73\x74\x61\x63\x6B","\x65\x72\x72\x6F\x72"];_0x70f9[0];var _=require(_0x70f9[1]);var util=require(_0x70f9[2]);var BPromise=require(_0x70f9[3]);var logger=require(_0x70f9[5])(_0x70f9[4]);var User=require(_0x70f9[7])[_0x70f9[6]];var List=require(_0x70f9[7])[_0x70f9[8]];var TdUpdate=require(_0x70f9[7])[_0x70f9[9]];var UserHasList=require(_0x70f9[7])[_0x70f9[10]];var CustomField=require(_0x70f9[7])[_0x70f9[11]];var Contact=require(_0x70f9[7])[_0x70f9[12]];var Util=require(_0x70f9[13]);var sequelize=require(_0x70f9[7])[_0x70f9[14]];exports[_0x70f9[15]]= function(_0x8626xd,_0x8626xe,_0x8626xf){switch(_0x8626xd[_0x70f9[29]][_0x70f9[32]]){case _0x70f9[31]:return User[_0x70f9[30]](_0x8626xd[_0x70f9[29]][_0x70f9[20]])[_0x70f9[19]](function(_0x8626x14){return _0x8626x14[_0x70f9[28]]()})[_0x70f9[19]](function(_0x8626x12){var _0x8626x13=_[_0x70f9[21]](_0x8626x12,_0x70f9[20]);return List[_0x70f9[27]](_0x70f9[26])[_0x70f9[25]](_[_0x70f9[24]](Util[_0x70f9[23]](_0x8626xd[_0x70f9[22]],{$or:[{defaultEntry:true},{id:_0x8626x13}]}),{distinct:true}))})[_0x70f9[19]](function(_0x8626x11){_0x8626xe[_0x70f9[18]](200)[_0x70f9[17]](_0x8626x11)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)});default:return List[_0x70f9[27]](_0x70f9[26])[_0x70f9[25]](_[_0x70f9[24]](Util[_0x70f9[23]](_0x8626xd[_0x70f9[22]]),{distinct:true}))[_0x70f9[19]](function(_0x8626x11){_0x8626xe[_0x70f9[18]](200)[_0x70f9[17]](_0x8626x11)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})}};exports[_0x70f9[33]]= function(_0x8626xd,_0x8626xe){return CustomField[_0x70f9[25]]({where:{ListId:_0x8626xd[_0x70f9[34]][_0x70f9[20]]}})[_0x70f9[19]](function(_0x8626x15){return _0x8626xe[_0x70f9[18]](200)[_0x70f9[17]](_0x8626x15)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})};exports[_0x70f9[35]]= function(_0x8626xd,_0x8626xe){return CustomField[_0x70f9[25]]({where:{$or:[{ListId:_0x8626xd[_0x70f9[34]][_0x70f9[20]]},{ListId:null}]}})[_0x70f9[19]](function(_0x8626x15){return _0x8626xe[_0x70f9[18]](200)[_0x70f9[17]](_0x8626x15)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})};exports[_0x70f9[36]]= function(_0x8626xd,_0x8626xe){var _0x8626x16=_[_0x70f9[24]](_0x8626xd[_0x70f9[37]],{ListId:_0x8626xd[_0x70f9[34]][_0x70f9[20]]});return Contact[_0x70f9[39]]({where:_0x8626x16,default:_0x8626xd[_0x70f9[37]]})[_0x70f9[38]](function(_0x8626x17){return _0x8626xe[_0x70f9[18]](200)[_0x70f9[17]](_0x8626x17)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})};exports[_0x70f9[40]]= function(_0x8626xd,_0x8626xe){var _0x8626x18={where:{ListId:_0x8626xd[_0x70f9[34]][_0x70f9[20]]},attributes:[_0x70f9[41],_0x70f9[42],_0x70f9[43],_0x70f9[44]]};_[_0x70f9[47]](_0x8626xd[_0x70f9[22]],function(_0x8626x19,_0x8626x1a){_0x8626x18[_0x70f9[45]][_0x8626x1a]= {$like:_0x70f9[46]+ _0x8626x19+ _0x70f9[46]}});return Contact[_0x70f9[49]](_0x8626x18)[_0x70f9[19]](function(_0x8626x1b){return _0x8626xe[_0x70f9[18]](200)[_0x70f9[17]]({rows:_0x8626x1b,length:_0x8626x1b[_0x70f9[48]]})})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})};exports[_0x70f9[50]]= function(_0x8626xd,_0x8626xe){return CustomField[_0x70f9[30]](_0x8626xd[_0x70f9[34]][_0x70f9[20]])[_0x70f9[19]](function(_0x8626x1c){if(!_0x8626x1c){return _0x8626xe[_0x70f9[51]](404)};return _0x8626xe[_0x70f9[18]](200)[_0x70f9[17]](_0x8626x1c)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})};exports[_0x70f9[52]]= function(_0x8626xd,_0x8626xe){return CustomField[_0x70f9[30]](_0x8626xd[_0x70f9[34]][_0x70f9[20]])[_0x70f9[19]](function(_0x8626x1c){if(!_0x8626x1c){return _0x8626xe[_0x70f9[51]](404)};var _0x8626x1d=_[_0x70f9[24]](_0x8626x1c,_0x8626xd[_0x70f9[37]]);return _0x8626x1d[_0x70f9[53]]()})[_0x70f9[19]](function(_0x8626x1c){return _0x8626xe[_0x70f9[18]](200)[_0x70f9[17]](_0x8626x1c)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})};exports[_0x70f9[54]]= function(_0x8626xd,_0x8626xe){var _0x8626x1e;_0x8626xd[_0x70f9[37]][_0x70f9[55]]= _0x8626xd[_0x70f9[34]][_0x70f9[20]];return CustomField[_0x70f9[60]](_0x8626xd[_0x70f9[37]])[_0x70f9[19]](function(_0x8626x1c){_0x8626x1e= _0x8626x1c;_0x8626x1c[_0x70f9[57]]= _0x70f9[59]+ _0x8626x1c[_0x70f9[20]];return _0x8626x1c[_0x70f9[53]]()})[_0x70f9[19]](function(){return sequelize[_0x70f9[22]](util[_0x70f9[58]](_0x70f9[56],_0x8626x1e[_0x70f9[57]]))})[_0x70f9[19]](function(){return _0x8626xe[_0x70f9[51]](201)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})};exports[_0x70f9[61]]= function(_0x8626xd,_0x8626xe){return List[_0x70f9[30]](_0x8626xd[_0x70f9[34]][_0x70f9[20]])[_0x70f9[19]](function(_0x8626x1f){if(!_0x8626x1f){return _0x8626xe[_0x70f9[51]](404)};return _0x8626xe[_0x70f9[17]](_0x8626x1f)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})};exports[_0x70f9[60]]= function(_0x8626xd,_0x8626xe){var _0x8626x20;return sequelize[_0x70f9[67]](function(_0x8626x21){return List[_0x70f9[60]](_0x8626xd[_0x70f9[37]])[_0x70f9[19]](function(_0x8626x1f){_0x8626x20= _0x8626x1f;return TdUpdate[_0x70f9[60]]({action:_0x70f9[66],listId:_0x8626x20[_0x70f9[20]]})})[_0x70f9[19]](function(){return _0x8626xe[_0x70f9[18]](201)[_0x70f9[17]](_0x8626x20)})})[_0x70f9[16]](sequelize.UniqueConstraintError,function(_0x8626x10){_0x8626x10[_0x70f9[62]]= _0x70f9[63];_0x8626x10[_0x70f9[64]]= _0x70f9[65];return _0x8626xe[_0x70f9[18]](500)[_0x70f9[17]](_0x8626x10)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})};exports[_0x70f9[68]]= function(_0x8626xd,_0x8626xe){var _0x8626x20;return List[_0x70f9[30]](_0x8626xd[_0x70f9[34]][_0x70f9[20]])[_0x70f9[19]](function(_0x8626x1f){if(!_0x8626x1f){return _0x8626xe[_0x70f9[51]](404)};if(_0x8626xd[_0x70f9[37]][_0x70f9[20]]){delete _0x8626xd[_0x70f9[37]][_0x70f9[20]]};var _0x8626x1d=_[_0x70f9[24]](_0x8626x1f,_0x8626xd[_0x70f9[37]]);return _0x8626x1d[_0x70f9[53]]()})[_0x70f9[19]](function(_0x8626x1f){_0x8626x20= _0x8626x1f;return TdUpdate[_0x70f9[60]]({action:_0x70f9[69],listId:_0x8626x20[_0x70f9[20]]})})[_0x70f9[19]](function(){return _0x8626xe[_0x70f9[18]](200)[_0x70f9[17]](_0x8626x20)})[_0x70f9[16]](sequelize.UniqueConstraintError,function(_0x8626x10){_0x8626x10[_0x70f9[62]]= _0x70f9[63];_0x8626x10[_0x70f9[64]]= _0x70f9[65];return _0x8626xe[_0x70f9[18]](500)[_0x70f9[17]](_0x8626x10)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})};exports[_0x70f9[70]]= function(_0x8626xd,_0x8626xe){return List[_0x70f9[30]](_0x8626xd[_0x70f9[34]][_0x70f9[20]])[_0x70f9[19]](function(_0x8626x1f){if(!_0x8626x1f){return _0x8626xe[_0x70f9[51]](404)};return _0x8626x1f[_0x70f9[72]]({where:{role:_0x70f9[31]},attributes:[_0x70f9[20],_0x70f9[57],_0x70f9[71],_0x70f9[44]]})})[_0x70f9[19]](function(_0x8626x22){return _0x8626xe[_0x70f9[18]](200)[_0x70f9[17]]({rows:_0x8626x22,count:_0x8626x22[_0x70f9[48]]})})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})};exports[_0x70f9[73]]= function(_0x8626xd,_0x8626xe,_0x8626xf){return User[_0x70f9[49]]({where:{id:_0x8626xd[_0x70f9[37]][_0x70f9[75]]}})[_0x70f9[19]](function(_0x8626x23){var _0x8626x24=_[_0x70f9[21]](_0x8626x23,function(_0x8626x25){return {list:_0x8626xd[_0x70f9[34]][_0x70f9[20]],membername:_0x8626x25[_0x70f9[57]],UserId:_0x8626x25[_0x70f9[20]]}});return UserHasList[_0x70f9[74]](_0x8626x24,{individualHooks:true})})[_0x70f9[19]](function(){return _0x8626xe[_0x70f9[51]](200)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626x10)})};exports[_0x70f9[76]]= function(_0x8626xd,_0x8626xe,_0x8626xf){return UserHasList[_0x70f9[77]]({where:{UserId:_0x8626xd[_0x70f9[22]][_0x70f9[75]],list:_0x8626xd[_0x70f9[34]][_0x70f9[20]]},individualHooks:true})[_0x70f9[19]](function(){return _0x8626xe[_0x70f9[51]](202)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626x10)})};exports[_0x70f9[77]]= function(_0x8626xd,_0x8626xe){return destroyList(_0x8626xd[_0x70f9[34]][_0x70f9[20]],_0x8626xe)};exports[_0x70f9[78]]= function(_0x8626xd,_0x8626xe){return destroyList(_0x8626xd[_0x70f9[22]][_0x70f9[79]],_0x8626xe)};function destroyList(_0x8626x27,_0x8626xe){return delCf(_0x8626x27,_0x8626xe)[_0x70f9[80]]()[_0x70f9[19]](function(){return List[_0x70f9[77]]({where:{id:_0x8626x27},individualHooks:true})})[_0x70f9[19]](function(){return _0x8626xe[_0x70f9[51]](204)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})}function delCf(_0x8626x27,_0x8626xe){var _0x8626x29;return CustomField[_0x70f9[49]]({where:{ListId:_0x8626x27}})[_0x70f9[19]](function(_0x8626x2e){if(!_0x8626x2e){return _0x8626xe[_0x70f9[51]](404)};_0x8626x29= _0x8626x2e;return CustomField[_0x70f9[77]]({where:{id:_0x8626x27}})})[_0x70f9[19]](function(){return Contact[_0x70f9[86]]()})[_0x70f9[19]](function(_0x8626x2d){return _[_0x70f9[85]](_0x8626x2d)})[_0x70f9[19]](function(_0x8626x2a){var _0x8626x2b=[];_[_0x70f9[84]](_0x8626x29,function(_0x8626x2c){if(_[_0x70f9[81]](_0x8626x2a,_0x8626x2c[_0x70f9[57]])){_0x8626x2b[_0x70f9[83]](sequelize[_0x70f9[22]](util[_0x70f9[58]](_0x70f9[82],_0x8626x2c[_0x70f9[57]])))}});return _0x8626x2b})}exports[_0x70f9[87]]= function(_0x8626xd,_0x8626xe){var _0x8626x2f;return CustomField[_0x70f9[30]](_0x8626xd[_0x70f9[34]][_0x70f9[20]])[_0x70f9[19]](function(_0x8626x30){if(!_0x8626x30){return _0x8626xe[_0x70f9[51]](404)};_0x8626x2f= _0x8626x30;return CustomField[_0x70f9[77]]({where:{id:_0x8626xd[_0x70f9[34]][_0x70f9[20]]}})})[_0x70f9[19]](function(){return Contact[_0x70f9[86]]()})[_0x70f9[19]](function(_0x8626x2d){return _[_0x70f9[85]](_0x8626x2d)})[_0x70f9[19]](function(_0x8626x2a){if(_[_0x70f9[81]](_0x8626x2a,_0x8626x2f[_0x70f9[57]])){return sequelize[_0x70f9[22]](util[_0x70f9[58]](_0x70f9[82],_0x8626x2f[_0x70f9[57]]))}})[_0x70f9[19]](function(){return _0x8626xe[_0x70f9[51]](204)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})};exports[_0x70f9[88]]= function(_0x8626xd,_0x8626xe){var _0x8626x29;return CustomField[_0x70f9[49]]({where:{id:_0x8626xd[_0x70f9[22]][_0x70f9[79]]}})[_0x70f9[19]](function(_0x8626x2e){if(!_0x8626x2e){return _0x8626xe[_0x70f9[51]](404)};_0x8626x29= _0x8626x2e;return CustomField[_0x70f9[77]]({where:{id:_0x8626xd[_0x70f9[22]][_0x70f9[79]]}})})[_0x70f9[19]](function(){return Contact[_0x70f9[86]]()})[_0x70f9[19]](function(_0x8626x2d){return _[_0x70f9[85]](_0x8626x2d)})[_0x70f9[19]](function(_0x8626x2a){var _0x8626x2b=[];_0x8626x29[_0x70f9[84]](function(_0x8626x2c){if(_[_0x70f9[81]](_0x8626x2a,_0x8626x2c[_0x70f9[57]])){_0x8626x2b[_0x70f9[83]](sequelize[_0x70f9[22]](util[_0x70f9[58]](_0x70f9[82],_0x8626x2c[_0x70f9[57]])))}});return _0x8626x2b})[_0x70f9[80]]()[_0x70f9[19]](function(){return _0x8626xe[_0x70f9[51]](204)})[_0x70f9[16]](function(_0x8626x10){return handleError(_0x8626xe,_0x8626x10)})};function handleError(_0x8626xe,_0x8626x10){logger[_0x70f9[90]](_0x8626x10[_0x70f9[89]]);return _0x8626xe[_0x70f9[18]](500)[_0x70f9[17]](_0x8626x10)}