fc62ea662134a46bfd153bb9bb839d469615f4b2
[motion.git] / server / api / voice_queue / voice_queue.controller.js
1 var _0xfde0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\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","\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","\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","\x73\x74\x61\x63\x6B","\x65\x72\x72\x6F\x72"];_0xfde0[0];var _=require(_0xfde0[1]);var logger=require(_0xfde0[3])(_0xfde0[2]);var util=require(_0xfde0[4]);var Util=require(_0xfde0[5]);var sequelize=require(_0xfde0[7])[_0xfde0[6]];var User=require(_0xfde0[7])[_0xfde0[8]];var VoiceQueue=require(_0xfde0[7])[_0xfde0[9]];var UserHasVoiceQueue=require(_0xfde0[7])[_0xfde0[10]];var VoiceExtension=require(_0xfde0[7])[_0xfde0[11]];exports[_0xfde0[12]]= function(_0xb0aexa,_0xb0aexb){switch(_0xb0aexa[_0xfde0[20]][_0xfde0[24]]){case _0xfde0[20]:return User[_0xfde0[21]](_0xb0aexa[_0xfde0[20]][_0xfde0[19]],{attributes:[_0xfde0[19]]})[_0xfde0[16]](Util[_0xfde0[18]](_0xb0aexa[_0xfde0[17]]))[_0xfde0[16]](function(_0xb0aexd){_0xb0aexb[_0xfde0[15]](200)[_0xfde0[14]](_0xb0aexd)})[_0xfde0[13]](function(_0xb0aexc){return handleError(_0xb0aexb,_0xb0aexc)});default:return VoiceQueue[_0xfde0[23]](Util[_0xfde0[22]](_0xb0aexa[_0xfde0[17]]))[_0xfde0[16]](function(_0xb0aexd){_0xb0aexb[_0xfde0[15]](200)[_0xfde0[14]](_0xb0aexd)})[_0xfde0[13]](function(_0xb0aexc){return handleError(_0xb0aexb,_0xb0aexc)})}};exports[_0xfde0[25]]= function(_0xb0aexa,_0xb0aexb,_0xb0aexe){var _0xb0aexf;switch(_0xb0aexa[_0xfde0[20]][_0xfde0[24]]){case _0xfde0[20]:var _0xb0aex10=[];return User[_0xfde0[21]](_0xb0aexa[_0xfde0[20]][_0xfde0[19]],{attributes:[_0xfde0[19]]})[_0xfde0[16]](Util[_0xfde0[18]]({},{attributes:[_0xfde0[31]],include:[{raw:true,model:User,attributes:[_0xfde0[19]]}]}))[_0xfde0[16]](function(_0xb0aex11){_0xb0aexf= _[_0xfde0[32]](_0xb0aex11[_0xfde0[30]],_0xfde0[31]);_0xb0aex11[_0xfde0[30]][_0xfde0[34]](function(_0xb0aex12){_0xb0aex10= _[_0xfde0[33]](_0xb0aex10,_[_0xfde0[32]](_0xb0aex12.Users,_0xfde0[19]))});return VoiceQueue[_0xfde0[23]](_[_0xfde0[35]](Util[_0xfde0[22]](_0xb0aexa[_0xfde0[17]],{name:_0xb0aexf}),{include:[{model:User,where:{id:_0xb0aex10},required:false}]}))})[_0xfde0[16]](function(_0xb0aexd){_0xb0aexa[_0xfde0[29]][_0xfde0[28]][_0xfde0[27]][_0xfde0[14]]({message:_0xfde0[26],queues:_0xb0aexf});return _0xb0aexb[_0xfde0[15]](200)[_0xfde0[14]](_0xb0aexd)})[_0xfde0[13]](function(_0xb0aexc){return handleError(_0xb0aexb,_0xb0aexc)});default:return VoiceQueue[_0xfde0[23]](_[_0xfde0[35]](Util[_0xfde0[22]](_0xb0aexa[_0xfde0[17]]),{include:[{model:User,required:false}]}))[_0xfde0[16]](function(_0xb0aexd){_0xb0aexf= _[_0xfde0[32]](_0xb0aexd[_0xfde0[30]],_0xfde0[31]);_0xb0aexa[_0xfde0[29]][_0xfde0[28]][_0xfde0[27]][_0xfde0[14]]({message:_0xfde0[26],queues:_0xb0aexf});return _0xb0aexb[_0xfde0[15]](200)[_0xfde0[14]](_0xb0aexd)})[_0xfde0[13]](function(_0xb0aexc){return handleError(_0xb0aexb,_0xb0aexc)})}};exports[_0xfde0[36]]= function(_0xb0aexa,_0xb0aexb){return VoiceQueue[_0xfde0[21]](_0xb0aexa[_0xfde0[38]][_0xfde0[31]])[_0xfde0[16]](function(_0xb0aex13){if(!_0xb0aex13){return _0xb0aexb[_0xfde0[37]](404)};return _0xb0aexb[_0xfde0[14]](_0xb0aex13)})[_0xfde0[13]](function(_0xb0aexc){return handleError(_0xb0aexb,_0xb0aexc)})};exports[_0xfde0[39]]= function(_0xb0aexa,_0xb0aexb){return VoiceQueue[_0xfde0[21]](_0xb0aexa[_0xfde0[38]][_0xfde0[31]])[_0xfde0[16]](function(_0xb0aex12){if(!_0xb0aex12){return _0xb0aexb[_0xfde0[37]](404)};return _0xb0aex12[_0xfde0[42]]({where:{role:_0xfde0[41]}})})[_0xfde0[16]](function(_0xb0aex10){return _0xb0aexb[_0xfde0[15]](200)[_0xfde0[14]]({rows:_0xb0aex10,count:_0xb0aex10[_0xfde0[40]]})})[_0xfde0[13]](function(_0xb0aexc){return handleError(_0xb0aexb,_0xb0aexc)})};exports[_0xfde0[43]]= function(_0xb0aexa,_0xb0aexb){var _0xb0aex14;return VoiceQueue[_0xfde0[43]](_0xb0aexa[_0xfde0[53]])[_0xfde0[16]](function(_0xb0aex13){_0xb0aex14= _0xb0aex13})[_0xfde0[16]](addAgents(_0xb0aexa,_0xb0aexa[_0xfde0[53]][_0xfde0[31]]))[_0xfde0[16]](function(){return _0xb0aexb[_0xfde0[15]](201)[_0xfde0[14]](_0xb0aex14)})[_0xfde0[13]](sequelize.UniqueConstraintError,function(_0xb0aexc){var _0xb0aex15=[];_0xb0aexc[_0xfde0[47]][_0xfde0[34]](function(_0xb0aex16){switch(_0xb0aex16[_0xfde0[46]]){case _0xfde0[45]:_0xb0aex15[_0xfde0[44]](_0xfde0[31]);break;default:_0xb0aex15[_0xfde0[44]](_0xb0aex16[_0xfde0[46]])}});_0xb0aex15[_0xfde0[44]](_0xfde0[48]);_0xb0aexc[_0xfde0[49]]= _0xb0aex15[_0xfde0[50]]();_0xb0aexc[_0xfde0[51]]= _0xfde0[52];return _0xb0aexb[_0xfde0[15]](500)[_0xfde0[14]](_0xb0aexc)})[_0xfde0[13]](function(_0xb0aexc){return handleError(_0xb0aexb,_0xb0aexc)})};exports[_0xfde0[54]]= function(_0xb0aexa,_0xb0aexb){if(_0xb0aexa[_0xfde0[53]][_0xfde0[31]]){delete _0xb0aexa[_0xfde0[53]][_0xfde0[31]]};return VoiceQueue[_0xfde0[21]](_0xb0aexa[_0xfde0[38]][_0xfde0[31]])[_0xfde0[16]](function(_0xb0aex13){if(!_0xb0aex13){return _0xb0aexb[_0xfde0[37]](404)};var _0xb0aex17=_[_0xfde0[35]](_0xb0aex13,_0xb0aexa[_0xfde0[53]]);return _0xb0aex17[_0xfde0[55]]()})[_0xfde0[16]](function(_0xb0aex13){return _0xb0aexb[_0xfde0[15]](200)[_0xfde0[14]](_0xb0aex13)})[_0xfde0[13]](function(_0xb0aexc){return handleError(_0xb0aexb,_0xb0aexc)})};function addAgents(_0xb0aexa,_0xb0aex12){return function(){return User[_0xfde0[61]]({where:{id:_0xb0aexa[_0xfde0[53]][_0xfde0[60]]},raw:true})[_0xfde0[16]](function(_0xb0aex19){var _0xb0aex1a=_[_0xfde0[32]](_0xb0aex19,function(_0xb0aex1b){return {queue:_0xb0aex12,interface:util[_0xfde0[57]](_0xfde0[56],_0xb0aex1b[_0xfde0[31]]),stateinterface:util[_0xfde0[57]](_0xfde0[56],_0xb0aex1b[_0xfde0[31]]),membername:_0xb0aex1b[_0xfde0[31]],UserId:_0xb0aex1b[_0xfde0[19]],penalty:_0xb0aexa[_0xfde0[53]][_0xfde0[58]]}});return UserHasVoiceQueue[_0xfde0[59]](_0xb0aex1a,{individualHooks:true})})}}exports[_0xfde0[62]]= function(_0xb0aexa,_0xb0aexb,_0xb0aexe){return Promise[_0xfde0[63]]([])[_0xfde0[16]](addAgents(_0xb0aexa,_0xb0aexa[_0xfde0[38]][_0xfde0[31]]))[_0xfde0[16]](function(){return _0xb0aexb[_0xfde0[37]](200)})[_0xfde0[13]](function(_0xb0aexc){return handleError(_0xb0aexb,_0xb0aexc)})};exports[_0xfde0[64]]= function(_0xb0aexa,_0xb0aexb,_0xb0aexe){return UserHasVoiceQueue[_0xfde0[65]]({where:{UserId:_0xb0aexa[_0xfde0[17]][_0xfde0[60]],queue:_0xb0aexa[_0xfde0[38]][_0xfde0[31]]},individualHooks:true})[_0xfde0[16]](function(){return _0xb0aexb[_0xfde0[37]](202)})[_0xfde0[13]](function(_0xb0aexc){return _0xb0aexe(_0xb0aexc)})};exports[_0xfde0[65]]= function(_0xb0aexa,_0xb0aexb){return VoiceQueue[_0xfde0[65]]({where:{name:_0xb0aexa[_0xfde0[38]][_0xfde0[31]]},individualHooks:true})[_0xfde0[16]](function(){return _0xb0aexb[_0xfde0[37]](204)})[_0xfde0[13]](function(_0xb0aexc){return handleError(_0xb0aexb,_0xb0aexc)})};exports[_0xfde0[66]]= function(_0xb0aexa,_0xb0aexb){return VoiceQueue[_0xfde0[65]]({where:{name:_0xb0aexa[_0xfde0[17]][_0xfde0[67]]},individualHooks:true})[_0xfde0[16]](function(){return _0xb0aexb[_0xfde0[37]](204)})[_0xfde0[13]](function(_0xb0aexc){return handleError(_0xb0aexb,_0xb0aexc)})};function handleError(_0xb0aexb,_0xb0aexc){logger[_0xfde0[69]](_0xb0aexc[_0xfde0[68]]);return _0xb0aexb[_0xfde0[15]](500)[_0xfde0[14]](_0xb0aexc)}