706358d76ee449ceedb242701733b82d61acf275
[motion.git] / server / api / voice_queue / voice_queue.controller.js
1 var _0xf2ce=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\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","\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x55\x73\x65\x72\x48\x61\x73\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\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\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65\x73\x49\x64\x42\x79\x55\x73\x65\x72","\x69\x64","\x75\x73\x65\x72","\x66\x69\x6E\x64\x42\x79\x49\x64","\x6C\x6F\x67","\x67\x65\x74\x51\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x72\x6F\x6C\x65","\x67\x65\x74\x52\x65\x61\x6C\x74\x69\x6D\x65\x51\x75\x65\x75\x65\x73","\x72\x65\x61\x6C\x74\x69\x6D\x65\x51\x75\x65\x75\x65\x4D\x65\x6D\x62\x65\x72\x73","\x61\x6D\x69","\x6C\x6F\x63\x61\x6C\x73","\x61\x70\x70","\x72\x6F\x77\x73","\x6E\x61\x6D\x65","\x6D\x61\x70","\x75\x6E\x69\x6F\x6E","\x66\x6F\x72\x45\x61\x63\x68","\x6D\x65\x72\x67\x65","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x70\x61\x72\x61\x6D\x73","\x73\x68\x6F\x77\x41\x67\x65\x6E\x74\x73","\x6C\x65\x6E\x67\x74\x68","\x61\x67\x65\x6E\x74","\x67\x65\x74\x55\x73\x65\x72\x73","\x63\x72\x65\x61\x74\x65","\x70\x75\x73\x68","\x50\x52\x49\x4D\x41\x52\x59","\x70\x61\x74\x68","\x65\x72\x72\x6F\x72\x73","\x20\x6D\x75\x73\x74\x20\x62\x65\x20\x75\x6E\x69\x71\x75\x65","\x6D\x65\x73\x73\x61\x67\x65","\x6A\x6F\x69\x6E","\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\x51\x55\x45\x55\x45","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x73\x61\x76\x65","\x53\x49\x50\x2F\x25\x73","\x66\x6F\x72\x6D\x61\x74","\x70\x65\x6E\x61\x6C\x74\x79","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x61\x67\x65\x6E\x74\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x61\x64\x64\x41\x67\x65\x6E\x74\x73","\x61\x6C\x6C","\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"];_0xf2ce[0];var _=require(_0xf2ce[1]);var util=require(_0xf2ce[2]);var Util=require(_0xf2ce[3]);var sequelize=require(_0xf2ce[5])[_0xf2ce[4]];var User=require(_0xf2ce[5])[_0xf2ce[6]];var VoiceQueue=require(_0xf2ce[5])[_0xf2ce[7]];var UserHasVoiceQueue=require(_0xf2ce[5])[_0xf2ce[8]];var VoiceExtension=require(_0xf2ce[5])[_0xf2ce[9]];exports[_0xf2ce[10]]= function(_0x7881x9,_0x7881xa){switch(_0x7881x9[_0xf2ce[18]][_0xf2ce[23]]){case _0xf2ce[18]:return User[_0xf2ce[19]](_0x7881x9[_0xf2ce[18]][_0xf2ce[17]],{attributes:[_0xf2ce[17]]})[_0xf2ce[14]](Util[_0xf2ce[16]](_0x7881x9[_0xf2ce[15]]))[_0xf2ce[14]](function(_0x7881xc){_0x7881xa[_0xf2ce[13]](200)[_0xf2ce[12]](_0x7881xc)})[_0xf2ce[11]](function(_0x7881xb){return handleError(_0x7881xa,_0x7881xb)});default:return VoiceQueue[_0xf2ce[22]](Util[_0xf2ce[21]](_0x7881x9[_0xf2ce[15]]))[_0xf2ce[14]](function(_0x7881xc){_0x7881xa[_0xf2ce[13]](200)[_0xf2ce[12]](_0x7881xc)})[_0xf2ce[11]](function(_0x7881xb){console[_0xf2ce[20]](_0x7881xb);return handleError(_0x7881xa,_0x7881xb)})}};exports[_0xf2ce[24]]= function(_0x7881x9,_0x7881xa,_0x7881xd){var _0x7881xe;switch(_0x7881x9[_0xf2ce[18]][_0xf2ce[23]]){case _0xf2ce[18]:var _0x7881xf=[];return User[_0xf2ce[19]](_0x7881x9[_0xf2ce[18]][_0xf2ce[17]],{attributes:[_0xf2ce[17]]})[_0xf2ce[14]](Util[_0xf2ce[16]]({},{attributes:[_0xf2ce[30]],include:[{raw:true,model:User,attributes:[_0xf2ce[17]]}]}))[_0xf2ce[14]](function(_0x7881x10){_0x7881xe= _[_0xf2ce[31]](_0x7881x10[_0xf2ce[29]],_0xf2ce[30]);_0x7881x10[_0xf2ce[29]][_0xf2ce[33]](function(_0x7881x11){_0x7881xf= _[_0xf2ce[32]](_0x7881xf,_[_0xf2ce[31]](_0x7881x11.Users,_0xf2ce[17]))});return VoiceQueue[_0xf2ce[22]](_[_0xf2ce[34]](Util[_0xf2ce[21]](_0x7881x9[_0xf2ce[15]],{name:_0x7881xe}),{include:[{model:User,where:{id:_0x7881xf},required:false}]}))})[_0xf2ce[14]](function(_0x7881xc){_0x7881x9[_0xf2ce[28]][_0xf2ce[27]][_0xf2ce[26]][_0xf2ce[12]]({message:_0xf2ce[25],queues:_0x7881xe});return _0x7881xa[_0xf2ce[13]](200)[_0xf2ce[12]](_0x7881xc)})[_0xf2ce[11]](function(_0x7881xb){console[_0xf2ce[20]](_0x7881xb);return handleError(_0x7881xa,_0x7881xb)});default:return VoiceQueue[_0xf2ce[22]](_[_0xf2ce[34]](Util[_0xf2ce[21]](_0x7881x9[_0xf2ce[15]]),{include:[{model:User,required:false}]}))[_0xf2ce[14]](function(_0x7881xc){_0x7881xe= _[_0xf2ce[31]](_0x7881xc[_0xf2ce[29]],_0xf2ce[30]);_0x7881x9[_0xf2ce[28]][_0xf2ce[27]][_0xf2ce[26]][_0xf2ce[12]]({message:_0xf2ce[25],queues:_0x7881xe});return _0x7881xa[_0xf2ce[13]](200)[_0xf2ce[12]](_0x7881xc)})[_0xf2ce[11]](function(_0x7881xb){console[_0xf2ce[20]](_0x7881xb);return handleError(_0x7881xa,_0x7881xb)})}};exports[_0xf2ce[35]]= function(_0x7881x9,_0x7881xa){return VoiceQueue[_0xf2ce[19]](_0x7881x9[_0xf2ce[37]][_0xf2ce[30]])[_0xf2ce[14]](function(_0x7881x12){if(!_0x7881x12){return _0x7881xa[_0xf2ce[36]](404)};return _0x7881xa[_0xf2ce[12]](_0x7881x12)})[_0xf2ce[11]](function(_0x7881xb){return handleError(_0x7881xa,_0x7881xb)})};exports[_0xf2ce[38]]= function(_0x7881x9,_0x7881xa){return VoiceQueue[_0xf2ce[19]](_0x7881x9[_0xf2ce[37]][_0xf2ce[30]])[_0xf2ce[14]](function(_0x7881x11){if(!_0x7881x11){return _0x7881xa[_0xf2ce[36]](404)};return _0x7881x11[_0xf2ce[41]]({where:{role:_0xf2ce[40]}})})[_0xf2ce[14]](function(_0x7881xf){return _0x7881xa[_0xf2ce[13]](200)[_0xf2ce[12]]({rows:_0x7881xf,count:_0x7881xf[_0xf2ce[39]]})})[_0xf2ce[11]](function(_0x7881xb){return handleError(_0x7881xa,_0x7881xb)})};exports[_0xf2ce[42]]= function(_0x7881x9,_0x7881xa){var _0x7881x13;return VoiceQueue[_0xf2ce[42]](_0x7881x9[_0xf2ce[52]])[_0xf2ce[14]](function(_0x7881x12){_0x7881x13= _0x7881x12})[_0xf2ce[14]](addAgents(_0x7881x9,_0x7881x9[_0xf2ce[52]][_0xf2ce[30]]))[_0xf2ce[14]](function(){return _0x7881xa[_0xf2ce[13]](201)[_0xf2ce[12]](_0x7881x13)})[_0xf2ce[11]](sequelize.UniqueConstraintError,function(_0x7881xb){var _0x7881x14=[];_0x7881xb[_0xf2ce[46]][_0xf2ce[33]](function(_0x7881x15){switch(_0x7881x15[_0xf2ce[45]]){case _0xf2ce[44]:_0x7881x14[_0xf2ce[43]](_0xf2ce[30]);break;default:_0x7881x14[_0xf2ce[43]](_0x7881x15[_0xf2ce[45]])}});_0x7881x14[_0xf2ce[43]](_0xf2ce[47]);_0x7881xb[_0xf2ce[48]]= _0x7881x14[_0xf2ce[49]]();_0x7881xb[_0xf2ce[50]]= _0xf2ce[51];return _0x7881xa[_0xf2ce[13]](500)[_0xf2ce[12]](_0x7881xb)})[_0xf2ce[11]](function(_0x7881xb){return handleError(_0x7881xa,_0x7881xb)})};exports[_0xf2ce[53]]= function(_0x7881x9,_0x7881xa){if(_0x7881x9[_0xf2ce[52]][_0xf2ce[30]]){delete _0x7881x9[_0xf2ce[52]][_0xf2ce[30]]};return VoiceQueue[_0xf2ce[19]](_0x7881x9[_0xf2ce[37]][_0xf2ce[30]])[_0xf2ce[14]](function(_0x7881x12){if(!_0x7881x12){return _0x7881xa[_0xf2ce[36]](404)};var _0x7881x16=_[_0xf2ce[34]](_0x7881x12,_0x7881x9[_0xf2ce[52]]);return _0x7881x16[_0xf2ce[54]]()})[_0xf2ce[14]](function(_0x7881x12){return _0x7881xa[_0xf2ce[13]](200)[_0xf2ce[12]](_0x7881x12)})[_0xf2ce[11]](function(_0x7881xb){console[_0xf2ce[20]](_0x7881xb);return handleError(_0x7881xa,_0x7881xb)})};function addAgents(_0x7881x9,_0x7881x11){return function(){return User[_0xf2ce[60]]({where:{id:_0x7881x9[_0xf2ce[52]][_0xf2ce[59]]},raw:true})[_0xf2ce[14]](function(_0x7881x18){var _0x7881x19=_[_0xf2ce[31]](_0x7881x18,function(_0x7881x1a){return {queue:_0x7881x11,interface:util[_0xf2ce[56]](_0xf2ce[55],_0x7881x1a[_0xf2ce[30]]),stateinterface:util[_0xf2ce[56]](_0xf2ce[55],_0x7881x1a[_0xf2ce[30]]),membername:_0x7881x1a[_0xf2ce[30]],UserId:_0x7881x1a[_0xf2ce[17]],penalty:_0x7881x9[_0xf2ce[52]][_0xf2ce[57]]}});return UserHasVoiceQueue[_0xf2ce[58]](_0x7881x19,{individualHooks:true})})}}exports[_0xf2ce[61]]= function(_0x7881x9,_0x7881xa,_0x7881xd){return Promise[_0xf2ce[62]]([])[_0xf2ce[14]](addAgents(_0x7881x9,_0x7881x9[_0xf2ce[37]][_0xf2ce[30]]))[_0xf2ce[14]](function(){return _0x7881xa[_0xf2ce[36]](200)})[_0xf2ce[11]](function(_0x7881xb){console[_0xf2ce[20]](_0x7881xb);return _0x7881xd(_0x7881xb)})};exports[_0xf2ce[63]]= function(_0x7881x9,_0x7881xa,_0x7881xd){return UserHasVoiceQueue[_0xf2ce[64]]({where:{UserId:_0x7881x9[_0xf2ce[15]][_0xf2ce[59]],queue:_0x7881x9[_0xf2ce[37]][_0xf2ce[30]]},individualHooks:true})[_0xf2ce[14]](function(){return _0x7881xa[_0xf2ce[36]](202)})[_0xf2ce[11]](function(_0x7881xb){return _0x7881xd(_0x7881xb)})};exports[_0xf2ce[64]]= function(_0x7881x9,_0x7881xa){return VoiceQueue[_0xf2ce[64]]({where:{name:_0x7881x9[_0xf2ce[37]][_0xf2ce[30]]},individualHooks:true})[_0xf2ce[14]](function(){return _0x7881xa[_0xf2ce[36]](204)})[_0xf2ce[11]](function(_0x7881xb){return handleError(_0x7881xa,_0x7881xb)})};exports[_0xf2ce[65]]= function(_0x7881x9,_0x7881xa){return VoiceQueue[_0xf2ce[64]]({where:{name:_0x7881x9[_0xf2ce[15]][_0xf2ce[66]]},individualHooks:true})[_0xf2ce[14]](function(){return _0x7881xa[_0xf2ce[36]](204)})[_0xf2ce[11]](function(_0x7881xb){return handleError(_0x7881xa,_0x7881xb)})};function handleError(_0x7881xa,_0x7881xb){return _0x7881xa[_0xf2ce[13]](500)[_0xf2ce[12]](_0x7881xb)}