b6d7d950e45d563deed0377b30c53b40a69663c0
[motion.git] / server / api / voice_queue / voice_queue.controller.js
1 var _0x6c5f=["\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"];_0x6c5f[0];var _=require(_0x6c5f[1]);var logger=require(_0x6c5f[3])(_0x6c5f[2]);var util=require(_0x6c5f[4]);var Util=require(_0x6c5f[5]);var sequelize=require(_0x6c5f[7])[_0x6c5f[6]];var User=require(_0x6c5f[7])[_0x6c5f[8]];var VoiceQueue=require(_0x6c5f[7])[_0x6c5f[9]];var UserHasVoiceQueue=require(_0x6c5f[7])[_0x6c5f[10]];var VoiceExtension=require(_0x6c5f[7])[_0x6c5f[11]];exports[_0x6c5f[12]]= function(_0xcda0xa,_0xcda0xb){switch(_0xcda0xa[_0x6c5f[20]][_0x6c5f[24]]){case _0x6c5f[20]:return User[_0x6c5f[21]](_0xcda0xa[_0x6c5f[20]][_0x6c5f[19]],{attributes:[_0x6c5f[19]]})[_0x6c5f[16]](Util[_0x6c5f[18]](_0xcda0xa[_0x6c5f[17]]))[_0x6c5f[16]](function(_0xcda0xd){_0xcda0xb[_0x6c5f[15]](200)[_0x6c5f[14]](_0xcda0xd)})[_0x6c5f[13]](function(_0xcda0xc){return handleError(_0xcda0xb,_0xcda0xc)});default:return VoiceQueue[_0x6c5f[23]](Util[_0x6c5f[22]](_0xcda0xa[_0x6c5f[17]]))[_0x6c5f[16]](function(_0xcda0xd){_0xcda0xb[_0x6c5f[15]](200)[_0x6c5f[14]](_0xcda0xd)})[_0x6c5f[13]](function(_0xcda0xc){return handleError(_0xcda0xb,_0xcda0xc)})}};exports[_0x6c5f[25]]= function(_0xcda0xa,_0xcda0xb,_0xcda0xe){var _0xcda0xf;switch(_0xcda0xa[_0x6c5f[20]][_0x6c5f[24]]){case _0x6c5f[20]:var _0xcda0x10=[];return User[_0x6c5f[21]](_0xcda0xa[_0x6c5f[20]][_0x6c5f[19]],{attributes:[_0x6c5f[19]]})[_0x6c5f[16]](Util[_0x6c5f[18]]({},{attributes:[_0x6c5f[31]],include:[{raw:true,model:User,attributes:[_0x6c5f[19]]}]}))[_0x6c5f[16]](function(_0xcda0x11){_0xcda0xf= _[_0x6c5f[32]](_0xcda0x11[_0x6c5f[30]],_0x6c5f[31]);_0xcda0x11[_0x6c5f[30]][_0x6c5f[34]](function(_0xcda0x12){_0xcda0x10= _[_0x6c5f[33]](_0xcda0x10,_[_0x6c5f[32]](_0xcda0x12.Users,_0x6c5f[19]))});return VoiceQueue[_0x6c5f[23]](_[_0x6c5f[35]](Util[_0x6c5f[22]](_0xcda0xa[_0x6c5f[17]],{name:_0xcda0xf}),{include:[{model:User,where:{id:_0xcda0x10},required:false}]}))})[_0x6c5f[16]](function(_0xcda0xd){_0xcda0xa[_0x6c5f[29]][_0x6c5f[28]][_0x6c5f[27]][_0x6c5f[14]]({message:_0x6c5f[26],queues:_0xcda0xf});return _0xcda0xb[_0x6c5f[15]](200)[_0x6c5f[14]](_0xcda0xd)})[_0x6c5f[13]](function(_0xcda0xc){return handleError(_0xcda0xb,_0xcda0xc)});default:return VoiceQueue[_0x6c5f[23]](_[_0x6c5f[35]](Util[_0x6c5f[22]](_0xcda0xa[_0x6c5f[17]]),{include:[{model:User,required:false}]}))[_0x6c5f[16]](function(_0xcda0xd){_0xcda0xf= _[_0x6c5f[32]](_0xcda0xd[_0x6c5f[30]],_0x6c5f[31]);_0xcda0xa[_0x6c5f[29]][_0x6c5f[28]][_0x6c5f[27]][_0x6c5f[14]]({message:_0x6c5f[26],queues:_0xcda0xf});return _0xcda0xb[_0x6c5f[15]](200)[_0x6c5f[14]](_0xcda0xd)})[_0x6c5f[13]](function(_0xcda0xc){return handleError(_0xcda0xb,_0xcda0xc)})}};exports[_0x6c5f[36]]= function(_0xcda0xa,_0xcda0xb){return VoiceQueue[_0x6c5f[21]](_0xcda0xa[_0x6c5f[38]][_0x6c5f[31]])[_0x6c5f[16]](function(_0xcda0x13){if(!_0xcda0x13){return _0xcda0xb[_0x6c5f[37]](404)};return _0xcda0xb[_0x6c5f[14]](_0xcda0x13)})[_0x6c5f[13]](function(_0xcda0xc){return handleError(_0xcda0xb,_0xcda0xc)})};exports[_0x6c5f[39]]= function(_0xcda0xa,_0xcda0xb){return VoiceQueue[_0x6c5f[21]](_0xcda0xa[_0x6c5f[38]][_0x6c5f[31]])[_0x6c5f[16]](function(_0xcda0x12){if(!_0xcda0x12){return _0xcda0xb[_0x6c5f[37]](404)};return _0xcda0x12[_0x6c5f[42]]({where:{role:_0x6c5f[41]}})})[_0x6c5f[16]](function(_0xcda0x10){return _0xcda0xb[_0x6c5f[15]](200)[_0x6c5f[14]]({rows:_0xcda0x10,count:_0xcda0x10[_0x6c5f[40]]})})[_0x6c5f[13]](function(_0xcda0xc){return handleError(_0xcda0xb,_0xcda0xc)})};exports[_0x6c5f[43]]= function(_0xcda0xa,_0xcda0xb){var _0xcda0x14;return VoiceQueue[_0x6c5f[43]](_0xcda0xa[_0x6c5f[53]])[_0x6c5f[16]](function(_0xcda0x13){_0xcda0x14= _0xcda0x13})[_0x6c5f[16]](addAgents(_0xcda0xa,_0xcda0xa[_0x6c5f[53]][_0x6c5f[31]]))[_0x6c5f[16]](function(){return _0xcda0xb[_0x6c5f[15]](201)[_0x6c5f[14]](_0xcda0x14)})[_0x6c5f[13]](sequelize.UniqueConstraintError,function(_0xcda0xc){var _0xcda0x15=[];_0xcda0xc[_0x6c5f[47]][_0x6c5f[34]](function(_0xcda0x16){switch(_0xcda0x16[_0x6c5f[46]]){case _0x6c5f[45]:_0xcda0x15[_0x6c5f[44]](_0x6c5f[31]);break;default:_0xcda0x15[_0x6c5f[44]](_0xcda0x16[_0x6c5f[46]])}});_0xcda0x15[_0x6c5f[44]](_0x6c5f[48]);_0xcda0xc[_0x6c5f[49]]= _0xcda0x15[_0x6c5f[50]]();_0xcda0xc[_0x6c5f[51]]= _0x6c5f[52];return _0xcda0xb[_0x6c5f[15]](500)[_0x6c5f[14]](_0xcda0xc)})[_0x6c5f[13]](function(_0xcda0xc){return handleError(_0xcda0xb,_0xcda0xc)})};exports[_0x6c5f[54]]= function(_0xcda0xa,_0xcda0xb){if(_0xcda0xa[_0x6c5f[53]][_0x6c5f[31]]){delete _0xcda0xa[_0x6c5f[53]][_0x6c5f[31]]};return VoiceQueue[_0x6c5f[21]](_0xcda0xa[_0x6c5f[38]][_0x6c5f[31]])[_0x6c5f[16]](function(_0xcda0x13){if(!_0xcda0x13){return _0xcda0xb[_0x6c5f[37]](404)};var _0xcda0x17=_[_0x6c5f[35]](_0xcda0x13,_0xcda0xa[_0x6c5f[53]]);return _0xcda0x17[_0x6c5f[55]]()})[_0x6c5f[16]](function(_0xcda0x13){return _0xcda0xb[_0x6c5f[15]](200)[_0x6c5f[14]](_0xcda0x13)})[_0x6c5f[13]](function(_0xcda0xc){return handleError(_0xcda0xb,_0xcda0xc)})};function addAgents(_0xcda0xa,_0xcda0x12){return function(){return User[_0x6c5f[61]]({where:{id:_0xcda0xa[_0x6c5f[53]][_0x6c5f[60]]},raw:true})[_0x6c5f[16]](function(_0xcda0x19){var _0xcda0x1a=_[_0x6c5f[32]](_0xcda0x19,function(_0xcda0x1b){return {queue:_0xcda0x12,interface:util[_0x6c5f[57]](_0x6c5f[56],_0xcda0x1b[_0x6c5f[31]]),stateinterface:util[_0x6c5f[57]](_0x6c5f[56],_0xcda0x1b[_0x6c5f[31]]),membername:_0xcda0x1b[_0x6c5f[31]],UserId:_0xcda0x1b[_0x6c5f[19]],penalty:_0xcda0xa[_0x6c5f[53]][_0x6c5f[58]]}});return UserHasVoiceQueue[_0x6c5f[59]](_0xcda0x1a,{individualHooks:true})})}}exports[_0x6c5f[62]]= function(_0xcda0xa,_0xcda0xb,_0xcda0xe){return Promise[_0x6c5f[63]]([])[_0x6c5f[16]](addAgents(_0xcda0xa,_0xcda0xa[_0x6c5f[38]][_0x6c5f[31]]))[_0x6c5f[16]](function(){return _0xcda0xb[_0x6c5f[37]](200)})[_0x6c5f[13]](function(_0xcda0xc){return handleError(_0xcda0xb,_0xcda0xc)})};exports[_0x6c5f[64]]= function(_0xcda0xa,_0xcda0xb,_0xcda0xe){return UserHasVoiceQueue[_0x6c5f[65]]({where:{UserId:_0xcda0xa[_0x6c5f[17]][_0x6c5f[60]],queue:_0xcda0xa[_0x6c5f[38]][_0x6c5f[31]]},individualHooks:true})[_0x6c5f[16]](function(){return _0xcda0xb[_0x6c5f[37]](202)})[_0x6c5f[13]](function(_0xcda0xc){return _0xcda0xe(_0xcda0xc)})};exports[_0x6c5f[65]]= function(_0xcda0xa,_0xcda0xb){return VoiceQueue[_0x6c5f[65]]({where:{name:_0xcda0xa[_0x6c5f[38]][_0x6c5f[31]]},individualHooks:true})[_0x6c5f[16]](function(){return _0xcda0xb[_0x6c5f[37]](204)})[_0x6c5f[13]](function(_0xcda0xc){return handleError(_0xcda0xb,_0xcda0xc)})};exports[_0x6c5f[66]]= function(_0xcda0xa,_0xcda0xb){return VoiceQueue[_0x6c5f[65]]({where:{name:_0xcda0xa[_0x6c5f[17]][_0x6c5f[67]]},individualHooks:true})[_0x6c5f[16]](function(){return _0xcda0xb[_0x6c5f[37]](204)})[_0x6c5f[13]](function(_0xcda0xc){return handleError(_0xcda0xb,_0xcda0xc)})};function handleError(_0xcda0xb,_0xcda0xc){logger[_0x6c5f[69]](_0xcda0xc[_0x6c5f[68]]);return _0xcda0xb[_0x6c5f[15]](500)[_0x6c5f[14]](_0xcda0xc)}