64301396446da561e28339edfe6bf6e577bbaeb3
[motion.git] / server / api / openchannel_account / openchannel_account.controller.js
1 var _0x800f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C","\x4F\x70\x65\x6E\x63\x68\x61\x6E\x6E\x65\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x55\x73\x65\x72","\x4F\x70\x65\x6E\x63\x68\x61\x6E\x6E\x65\x6C\x51\x75\x65\x75\x65","\x4F\x70\x65\x6E\x63\x68\x61\x6E\x6E\x65\x6C\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x4F\x70\x65\x6E\x63\x68\x61\x6E\x6E\x65\x6C\x4D\x65\x73\x73\x61\x67\x65","\x4F\x70\x65\x6E\x63\x68\x61\x6E\x6E\x65\x6C\x52\x6F\x6F\x6D","\x4F\x70\x65\x6E\x63\x68\x61\x6E\x6E\x65\x6C\x44\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E","\x43\x6F\x6E\x74\x61\x63\x74","\x62\x6C\x75\x65\x62\x69\x72\x64","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\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","\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","\x67\x65\x74\x44\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E\x73","\x6C\x65\x6E\x67\x74\x68","\x67\x65\x74\x4F\x70\x65\x6E\x63\x68\x61\x6E\x6E\x65\x6C\x44\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E\x73","\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","\x6D\x65\x72\x67\x65","\x67\x65\x74\x4F\x70\x65\x6E\x63\x68\x61\x6E\x6E\x65\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","\x63\x72\x65\x61\x74\x65\x44\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E","\x4F\x70\x65\x6E\x63\x68\x61\x6E\x6E\x65\x6C\x41\x63\x63\x6F\x75\x6E\x74\x49\x64","\x73\x65\x6E\x64\x4D\x65\x73\x73\x61\x67\x65","\x55\x73\x65\x72\x49\x64","\x75\x73\x65\x72","\x72\x65\x63\x65\x69\x76\x65\x4D\x65\x73\x73\x61\x67\x65","\x4F\x70\x65\x6E\x63\x68\x61\x6E\x6E\x65\x6C\x52\x6F\x6F\x6D\x49\x64","\x52\x45\x43\x45\x49\x56\x45\x44","\x43\x4C\x4F\x53\x45\x44","\x66\x72\x6F\x6D","\x4F\x50\x45\x4E","\x41\x63\x63\x6F\x75\x6E\x74\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x44\x45\x53\x43","\x66\x69\x6E\x64\x41\x6C\x6C","\x75\x70\x64\x61\x74\x65","\x20\x20\x20\x65\x72\x72","\x6C\x6F\x67","\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","\x75\x70\x64\x61\x74\x65\x64\x41\x74","\x70\x72\x69\x6F\x72\x69\x74\x79","\x66\x6F\x72\x45\x61\x63\x68","\x72\x65\x71\x20\x61\x70\x70","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x64\x65\x73\x74\x72\x6F\x79","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\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\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x69\x64\x73","\x67\x65\x74\x4F\x70\x65\x6E\x63\x68\x61\x6E\x6E\x65\x6C\x52\x6F\x6F\x6D\x73","\x74\x61\x67\x73","\x64\x69\x73\x70\x6F\x73\x69\x74\x69\x6F\x6E","\x69\x73\x41\x72\x72\x61\x79","\x25","\x70\x75\x73\x68","\x24\x61\x6E\x64","\x77\x68\x65\x72\x65","\x69\x6E\x63\x6C\x75\x64\x65","\x61\x67\x65\x6E\x74","\x72\x6F\x6C\x65"];_0x800f[0];var _=require(_0x800f[1]);var Util=require(_0x800f[2]);var OpenchannelAccount=require(_0x800f[4])[_0x800f[3]];var sequelize=require(_0x800f[4])[_0x800f[5]];var User=require(_0x800f[4])[_0x800f[6]];var OpenchannelQueue=require(_0x800f[4])[_0x800f[7]];var OpenchannelApplication=require(_0x800f[4])[_0x800f[8]];var OpenchannelMessage=require(_0x800f[4])[_0x800f[9]];var OpenchannelRoom=require(_0x800f[4])[_0x800f[10]];var OpenchannelDisposition=require(_0x800f[4])[_0x800f[11]];var Contact=require(_0x800f[4])[_0x800f[12]];var Promise=require(_0x800f[13]);function handleError(_0xe732xe,_0xe732xf){return _0xe732xe[_0x800f[15]](500)[_0x800f[14]](_0xe732xf)}exports[_0x800f[16]]= function(_0xe732x10,_0xe732xe){return OpenchannelAccount[_0x800f[21]](Util[_0x800f[20]](_0xe732x10[_0x800f[19]]))[_0x800f[18]](function(_0xe732x11){_0xe732xe[_0x800f[15]](200)[_0x800f[14]](_0xe732x11)})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[22]]= function(_0xe732x10,_0xe732xe){return OpenchannelAccount[_0x800f[26]](_0xe732x10[_0x800f[25]][_0x800f[24]])[_0x800f[18]](function(_0xe732x12){if(!_0xe732x12){return _0xe732xe[_0x800f[23]](404)};return _0xe732xe[_0x800f[14]](_0xe732x12)})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[27]]= function(_0xe732x10,_0xe732xe,_0xe732x13){return OpenchannelAccount[_0x800f[26]](_0xe732x10[_0x800f[25]][_0x800f[24]])[_0x800f[18]](function(_0xe732x12){if(!_0xe732x12){return _0xe732xe[_0x800f[23]](404)};return _0xe732x12[_0x800f[29]]()})[_0x800f[18]](function(_0xe732x14){return _0xe732xe[_0x800f[15]](200)[_0x800f[14]]({rows:_0xe732x14,count:_0xe732x14[_0x800f[28]]})})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[30]]= function(_0xe732x10,_0xe732xe,_0xe732x13){return OpenchannelAccount[_0x800f[26]](_0xe732x10[_0x800f[25]][_0x800f[24]])[_0x800f[18]](function(_0xe732x12){if(!_0xe732x12){return _0xe732xe[_0x800f[23]](404)};return _0xe732x12[_0x800f[34]](_[_0x800f[33]](Util[_0x800f[20]](_0xe732x10[_0x800f[19]]),{include:[{model:OpenchannelQueue,attributes:[_0x800f[24],_0x800f[31]]},{model:User,attributes:[_0x800f[24],_0x800f[31],_0x800f[32]]}]}))})[_0x800f[18]](function(_0xe732x15){return _0xe732xe[_0x800f[14]]({count:_0xe732x15[_0x800f[28]],rows:_0xe732x15})})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[35]]= function(_0xe732x10,_0xe732xe){return OpenchannelAccount[_0x800f[35]](_0xe732x10[_0x800f[38]])[_0x800f[18]](function(_0xe732x12){return _0xe732xe[_0x800f[15]](201)[_0x800f[14]](_0xe732x12)})[_0x800f[17]](sequelize.UniqueConstraintError,function(_0xe732xf){return Util[_0x800f[37]][_0x800f[36]](_0xe732xe,_0xe732xf)})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[39]]= function(_0xe732x10,_0xe732xe,_0xe732x13){_0xe732x10[_0x800f[38]][_0x800f[40]]= _0xe732x10[_0x800f[25]][_0x800f[24]];return OpenchannelDisposition[_0x800f[35]](_0xe732x10[_0x800f[38]])[_0x800f[18]](function(_0xe732x16){return _0xe732xe[_0x800f[15]](201)[_0x800f[14]](_0xe732x16)})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[41]]= function(_0xe732x10,_0xe732xe,_0xe732x13){_0xe732x10[_0x800f[38]][_0x800f[40]]= _0xe732x10[_0x800f[25]][_0x800f[24]];_0xe732x10[_0x800f[38]][_0x800f[42]]= _0xe732x10[_0x800f[43]][_0x800f[24]];return OpenchannelMessage[_0x800f[35]](_0xe732x10[_0x800f[38]])[_0x800f[18]](function(_0xe732x17){return _0xe732xe[_0x800f[15]](201)[_0x800f[14]](_0xe732x17)})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[44]]= function(_0xe732x10,_0xe732xe,_0xe732x13){if(_0xe732x10[_0x800f[38]][_0x800f[24]]){delete _0xe732x10[_0x800f[38]][_0x800f[24]]};var _0xe732x18=_0xe732x10[_0x800f[38]];var _0xe732x19;return OpenchannelAccount[_0x800f[26]](_0xe732x10[_0x800f[25]][_0x800f[24]])[_0x800f[18]](function(_0xe732x12){if(!_0xe732x12){throw  new Error(_0x800f[50])};_0xe732x19= _0xe732x12;return OpenchannelRoom[_0x800f[53]]({limit:1,where:{from:_0xe732x18[_0x800f[48]],OpenchannelAccountId:_0xe732x19[_0x800f[24]]},order:[[_0x800f[51],_0x800f[52]]]})})[_0x800f[18]](function(_0xe732x1c){var _0xe732x1b=_0xe732x1c[0];if(!_0xe732x1b|| _0xe732x1b[_0x800f[15]]== _0x800f[47]){var _0xe732x1d=_0xe732x1b?_0xe732x1b[_0x800f[24]]:null;return OpenchannelRoom[_0x800f[35]]({from:_0xe732x18[_0x800f[48]],OpenchannelAccountId:_0xe732x19[_0x800f[24]],status:_0x800f[49],ParentId:_0xe732x1d})};return _0xe732x1b})[_0x800f[18]](function(_0xe732x1b){_0xe732x18[_0x800f[40]]= _0xe732x19[_0x800f[24]];_0xe732x18[_0x800f[45]]= _0xe732x1b[_0x800f[24]];_0xe732x18[_0x800f[15]]= _0x800f[46];return OpenchannelMessage[_0x800f[35]](_0xe732x18)})[_0x800f[18]](function(_0xe732x1a){return _0xe732xe[_0x800f[15]](201)[_0x800f[14]](_0xe732x1a)})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[54]]= function(_0xe732x10,_0xe732xe){if(_0xe732x10[_0x800f[38]][_0x800f[24]]){delete _0xe732x10[_0x800f[38]][_0x800f[24]]};return OpenchannelAccount[_0x800f[26]](_0xe732x10[_0x800f[25]][_0x800f[24]])[_0x800f[18]](function(_0xe732x12){if(!_0xe732x12){return _0xe732xe[_0x800f[23]](404)};var _0xe732x1e=_[_0x800f[33]](_0xe732x12,_0xe732x10[_0x800f[38]]);return _0xe732x1e[_0x800f[57]]()})[_0x800f[18]](function(_0xe732x12){return _0xe732xe[_0x800f[15]](200)[_0x800f[14]](_0xe732x12)})[_0x800f[17]](sequelize.UniqueConstraintError,function(_0xe732xf){return Util[_0x800f[37]][_0x800f[36]](_0xe732xe,_0xe732xf)})[_0x800f[17]](function(_0xe732xf){console[_0x800f[56]](_0x800f[55],_0xe732xf);return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[58]]= function(_0xe732x10,_0xe732xe){if(_0xe732x10[_0x800f[38]][_0x800f[24]]){delete _0xe732x10[_0x800f[38]][_0x800f[24]]};return OpenchannelDisposition[_0x800f[26]](_0xe732x10[_0x800f[25]][_0x800f[59]])[_0x800f[18]](function(_0xe732x1f){if(!_0xe732x1f){return _0xe732xe[_0x800f[23]](404)};var _0xe732x1e=_[_0x800f[33]](_0xe732x1f,_0xe732x10[_0x800f[38]]);return _0xe732x1e[_0x800f[57]]()})[_0x800f[18]](function(_0xe732x1f){return _0xe732xe[_0x800f[15]](200)[_0x800f[14]](_0xe732x1f)})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[60]]= function(_0xe732x10,_0xe732xe){var _0xe732x20=0;var _0xe732x21=_0xe732x10[_0x800f[38]];_0xe732x21[_0x800f[63]](function(_0xe732x22){delete _0xe732x22[_0x800f[24]];delete _0xe732x22[_0x800f[51]];delete _0xe732x22[_0x800f[61]];_0xe732x22[_0x800f[62]]=  ++_0xe732x20});console[_0x800f[56]](_0x800f[64],_0xe732x10[_0x800f[38]]);return sequelize[_0x800f[67]](function(_0xe732x24){return OpenchannelApplication[_0x800f[66]]({where:{OpenchannelAccountId:_0xe732x10[_0x800f[25]][_0x800f[24]]},individualHooks:true,transaction:_0xe732x24})[_0x800f[18]](function(_0xe732x25){return OpenchannelApplication[_0x800f[65]](_0xe732x21,{individualHooks:true,transaction:_0xe732x24})})})[_0x800f[18]](function(_0xe732x23){return _0xe732xe[_0x800f[15]](200)[_0x800f[14]]({count:_0xe732x23[_0x800f[28]],rows:_0xe732x23})})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[66]]= function(_0xe732x10,_0xe732xe){return OpenchannelAccount[_0x800f[26]](_0xe732x10[_0x800f[25]][_0x800f[24]])[_0x800f[18]](function(_0xe732x12){if(!_0xe732x12){return _0xe732xe[_0x800f[23]](404)};return _0xe732x12[_0x800f[66]]()})[_0x800f[18]](function(){return _0xe732xe[_0x800f[23]](204)})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[68]]= function(_0xe732x10,_0xe732xe,_0xe732x13){return OpenchannelApplication[_0x800f[26]](_0xe732x10[_0x800f[25]][_0x800f[69]])[_0x800f[18]](function(_0xe732x25){if(!_0xe732x25){return _0xe732xe[_0x800f[23]](404)};return _0xe732x25[_0x800f[66]]()})[_0x800f[18]](function(){return _0xe732xe[_0x800f[23]](204)})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[70]]= function(_0xe732x10,_0xe732xe,_0xe732x13){return OpenchannelDisposition[_0x800f[26]](_0xe732x10[_0x800f[25]][_0x800f[59]])[_0x800f[18]](function(_0xe732x16){if(!_0xe732x16){return _0xe732xe[_0x800f[23]](404)};return _0xe732x16[_0x800f[66]]()})[_0x800f[18]](function(){return _0xe732xe[_0x800f[23]](204)})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[71]]= function(_0xe732x10,_0xe732xe){return OpenchannelApplication[_0x800f[66]]({where:{id:_0xe732x10[_0x800f[19]][_0x800f[72]]},individualHooks:true})[_0x800f[18]](function(){return _0xe732xe[_0x800f[23]](204)})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})};exports[_0x800f[73]]= function(_0xe732x10,_0xe732xe,_0xe732x13){var _0xe732x26={where:{OpenchannelAccountId:_0xe732x10[_0x800f[25]][_0x800f[24]],$and:[]},attributes:[_0x800f[24],_0x800f[48],_0x800f[61],_0x800f[74],_0x800f[75]]};if(_0xe732x10[_0x800f[19]]){if(_0xe732x10[_0x800f[19]][_0x800f[74]]){if(_[_0x800f[76]](_0xe732x10[_0x800f[19]][_0x800f[74]])){for(var _0xe732x27=0;_0xe732x27< _0xe732x10[_0x800f[19]][_0x800f[74]][_0x800f[28]];_0xe732x27++){_0xe732x26[_0x800f[80]][_0x800f[79]][_0x800f[78]]({tags:{$like:_0x800f[77]+ _0xe732x10[_0x800f[19]][_0x800f[74]][_0xe732x27]+ _0x800f[77]}})}}else {_0xe732x26[_0x800f[80]][_0x800f[79]][_0x800f[78]]({tags:{$like:_0x800f[77]+ _0xe732x10[_0x800f[19]][_0x800f[74]]+ _0x800f[77]}})};delete _0xe732x10[_0x800f[19]][_0x800f[74]]};_[_0x800f[33]](_0xe732x26[_0x800f[80]],_0xe732x10[_0x800f[19]])};switch(_0xe732x10[_0x800f[43]][_0x800f[83]]){case _0x800f[82]:_0xe732x26[_0x800f[81]]= [{model:User,where:{id:_0xe732x10[_0x800f[43]][_0x800f[24]]}}];break;default:};return OpenchannelRoom[_0x800f[53]](_0xe732x26)[_0x800f[18]](function(_0xe732x28){return _0xe732xe[_0x800f[15]](200)[_0x800f[14]](_0xe732x28)})[_0x800f[17]](function(_0xe732xf){return handleError(_0xe732xe,_0xe732xf)})}