Built motion from commit 88549cd59.|1.0.20
[motion.git] / server / config / forked_routing / sms / queue.js
1 var _0x5520=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x6D\x6F\x6D\x65\x6E\x74","\x73\x6D\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x6C\x6F\x67\x67\x65\x72\x2E\x6A\x73","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x53\x6D\x73\x52\x6F\x6F\x6D","\x53\x6D\x73\x51\x75\x65\x75\x65","\x52\x65\x70\x6F\x72\x74\x53\x6D\x73","\x52\x65\x70\x6F\x72\x74\x53\x6D\x73\x53\x65\x73\x73\x69\x6F\x6E","\x65\x78\x70\x6F\x72\x74\x73","\x6D\x65\x73\x73\x61\x67\x65","\x74\x6F\x55\x70\x70\x65\x72\x43\x61\x73\x65","\x63\x68\x61\x6E\x6E\x65\x6C","\x41\x50\x50\x20\x51\x55\x45\x55\x45\x2C\x20\x51\x55\x45\x55\x45\x3A","\x6E\x61\x6D\x65","\x53\x54\x52\x41\x54\x45\x47\x59\x3A","\x73\x74\x72\x61\x74\x65\x67\x79","\x49\x4E\x54\x45\x52\x41\x43\x54\x49\x4F\x4E\x3A","\x75\x6E\x69\x71\x75\x65\x69\x64","\x41\x47\x45\x4E\x54","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x52\x45\x4A\x45\x43\x54\x45\x44","\x69\x6E\x66\x6F","\x69\x64","\x70\x75\x73\x68","\x72\x65\x6A\x65\x63\x74","\x74\x79\x70\x65","\x6F\x6E","\x66\x69\x6E\x64","\x74\x69\x6D\x65\x6F\x75\x74","\x6C\x65\x6E\x67\x74\x68","\x6D\x61\x70","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x6F\x6E\x6C\x69\x6E\x65","\x73\x6D\x73\x50\x61\x75\x73\x65","\x46\x49\x45\x4C\x44\x28\x55\x73\x65\x72\x2E\x69\x64\x2C\x25\x73\x29","\x6A\x6F\x69\x6E","\x66\x6F\x72\x6D\x61\x74","\x45\x52\x52\x4F\x52","\x65\x72\x72\x6F\x72","\x73\x74\x61\x63\x6B","\x63\x61\x74\x63\x68","\x74\x68\x65\x6E","\x72\x65\x70\x6F\x72\x74\x5F\x73\x6D\x73\x3A\x73\x61\x76\x65","\x65\x6D\x69\x74","\x61\x67\x65\x6E\x74\x3A\x25\x64","\x6D\x65\x6D\x62\x65\x72\x69\x64","\x74\x6F","\x67\x65\x74","\x41\x47\x45\x4E\x54\x20\x53\x45\x4C\x45\x43\x54\x45\x44\x3A","\x66\x69\x6E\x64\x49\x6E\x64\x65\x78","\x73\x70\x6C\x69\x63\x65","\x68\x65\x61\x64","\x71\x75\x65\x75\x65","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x6D\x65\x72\x67\x65","\x63\x72\x65\x61\x74\x65","\x4E\x4F\x20\x41\x56\x41\x49\x4C\x41\x42\x4C\x45\x20\x41\x47\x45\x4E\x54\x53","\x66\x69\x6E\x64\x41\x6C\x6C","\x72\x65\x70\x6F\x72\x74\x5F\x73\x6D\x73\x5F\x73\x65\x73\x73\x69\x6F\x6E\x3A\x73\x61\x76\x65","\x61\x64\x6D\x69\x6E\x73","\x75\x73\x65\x72\x73","\x45\x4E\x44\x20\x28\x4E\x4F\x20\x41\x4E\x53\x57\x45\x52\x20\x42\x59\x20\x41\x47\x45\x4E\x54\x53\x29","\x75\x70\x64\x61\x74\x65","\x55\x73\x65\x72\x48\x61\x73\x53\x6D\x73\x51\x75\x65\x75\x65\x2E\x70\x65\x6E\x61\x6C\x74\x79","\x67\x72\x6F\x75\x70\x42\x79","\x76\x61\x6C\x75\x65\x73","\x72\x65\x6D\x6F\x76\x65","\x63\x6C\x6F\x6E\x65","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x6C\x61\x73\x74\x41\x67\x65\x6E\x74","\x66\x69\x6E\x64\x42\x79\x49\x64","\x62\x65\x65\x70\x61\x6C\x6C","\x70\x65\x6E\x61\x6C\x74\x79","\x55\x73\x65\x72\x48\x61\x73\x53\x6D\x73\x51\x75\x65\x75\x65","\x73\x6F\x72\x74\x42\x79","\x72\x6F\x75\x6E\x64\x72\x6F\x62\x69\x6E","\x72\x72\x6D\x65\x6D\x6F\x72\x79","\x73\x6D\x73\x5F\x72\x6F\x6F\x6D\x3A\x73\x61\x76\x65","\x63\x72\x65\x61\x74\x65\x53\x6D\x73\x51\x75\x65\x75\x65\x53\x65\x73\x73\x69\x6F\x6E","\x73\x65\x6E\x64","\x72\x6F\x6F\x6D\x69\x64","\x54\x49\x4D\x45\x4F\x55\x54","\x53\x45\x43"];_0x5520[0];var _=require(_0x5520[1]);var util=require(_0x5520[2]);var moment=require(_0x5520[3]);var logger=require(_0x5520[5])(_0x5520[4]);var Agent=require(_0x5520[7])[_0x5520[6]];var Room=require(_0x5520[7])[_0x5520[8]];var Queue=require(_0x5520[7])[_0x5520[9]];var Report=require(_0x5520[7])[_0x5520[10]];var Session=require(_0x5520[7])[_0x5520[11]];module[_0x5520[12]]= function(_0xa50dxa,_0xa50dxb,_0xa50dxc,_0xa50dxd,_0xa50dxe){var _0xa50dxf=[];var _0xa50dx10;var _0xa50dx11;var _0xa50dx12;var _0xa50dx13=0;process[_0x5520[30]](_0x5520[13],function(_0xa50dxc){switch(_0xa50dxc[_0x5520[29]]){case _0x5520[28]:logger[_0x5520[25]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[22],_0xa50dxc[_0x5520[23]],_0x5520[24]);_0xa50dxf[_0x5520[27]]({id:_0xa50dxc[_0x5520[26]]});break;default:}});function _0xa50dx14(_0xa50dx15){var _0xa50dx16=_[_0x5520[31]](_0xa50dxf,{id:_0xa50dx15[_0x5520[26]]});return _0xa50dx16?true:false}function _0xa50dx17(){var _0xa50dx18=((_0xa50dxa[_0x5520[32]]- _0xa50dx13)> _0xa50dx12[_0x5520[32]])?_0xa50dx12[_0x5520[32]]:(_0xa50dxa[_0x5520[32]]- _0xa50dx13);if(_0xa50dx18> 0){if(_0xa50dx11[_0x5520[33]]){var _0xa50dx19={where:{id:{$in:_[_0x5520[34]](_0xa50dx11,_0x5520[26])},online:true,smsPause:false},include:[{model:Room,attributes:[_0x5520[26]],raw:true}],attributes:[_0x5520[26],_0x5520[17],_0x5520[35],_0x5520[36],_0x5520[37]],order:[[{raw:util[_0x5520[40]](_0x5520[38],_[_0x5520[34]](_0xa50dx11,_0x5520[26])[_0x5520[39]]())}]]};Agent[_0x5520[61]](_0xa50dx19)[_0x5520[45]](function(_0xa50dx1c){if(_0xa50dx1c[_0x5520[33]]){var _0xa50dx1d;for(var _0xa50dx1e=0;_0xa50dx1e< _0xa50dx1c[_0x5520[33]];_0xa50dx1e++){var _0xa50dx15=_0xa50dx1c[_0xa50dx1e][_0x5520[51]]({plain:true});if(!_0xa50dx14(_0xa50dx15)){_0xa50dx1d= _0xa50dx15;break}};if(_0xa50dx1d){logger[_0x5520[25]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[52],_0xa50dx1d[_0x5520[26]],_0xa50dx1d[_0x5520[17]]);var _0xa50dx1f=_[_0x5520[53]](_0xa50dx11,{"\x69\x64":_0xa50dx1d[_0x5520[26]]});if(_0xa50dx1f>= 0){var _0xa50dx20=_0xa50dx11[_0x5520[54]](_0xa50dx1f,1);if(_0xa50dx20&& _0xa50dx20[_0x5520[33]]){_0xa50dx11[_0x5520[27]](_[_0x5520[55]](_0xa50dx20))}};return Report[_0x5520[59]](_[_0x5520[58]](_0xa50dxb,{timeslot:_0xa50dx18,application:_0x5520[56],membername:_0xa50dx1d[_0x5520[17]],memberid:_0xa50dx1d[_0x5520[26]],queue:_0xa50dx12[_0x5520[26]],queuename:_0xa50dx12[_0x5520[17]],calledAt:moment()[_0x5520[40]](_0x5520[57])}))};logger[_0x5520[25]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[60]);return}else {logger[_0x5520[25]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[60]);return}})[_0x5520[45]](function(_0xa50dx1b){if(_0xa50dx1b){_0xa50dxd[_0x5520[50]](util[_0x5520[40]](_0x5520[48],_0xa50dx1b[_0x5520[49]]))[_0x5520[47]](_0x5520[46],_0xa50dx1b)}})[_0x5520[45]](function(){_0xa50dx10= setTimeout(function(){_0xa50dx13+= _0xa50dx12[_0x5520[32]];_0xa50dx17()},_0xa50dx18* 1000)})[_0x5520[44]](function(_0xa50dx1a){logger[_0x5520[42]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[41]);logger[_0x5520[42]](_0xa50dx1a[_0x5520[43]]);_0xa50dxe(_0xa50dx1a)})}else {logger[_0x5520[25]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[60]);_0xa50dx10= setTimeout(function(){_0xa50dx13+= _0xa50dx12[_0x5520[32]];_0xa50dx17()},_0xa50dx18* 1000)}}else {return Session[_0x5520[66]]({leaveAt:moment()[_0x5520[40]](_0x5520[57]),timeout:true},{where:{uniqueid:_0xa50dxb[_0x5520[21]],leaveAt:null},individualHooks:true})[_0x5520[45]](function(_0xa50dx21){if(_0xa50dx21&& _0xa50dx21[_0x5520[33]]&& _0xa50dx21[1][_0x5520[33]]){for(var _0xa50dx1e=0;_0xa50dx1e< _0xa50dx21[1][_0x5520[33]];_0xa50dx1e++){var _0xa50dx22=_0xa50dx21[1][_0xa50dx1e][_0x5520[51]]({plain:true});_0xa50dxd[_0x5520[50]](_0x5520[63])[_0x5520[47]](_0x5520[62],_0xa50dx22);_0xa50dxd[_0x5520[50]](_0x5520[64])[_0x5520[47]](_0x5520[62],_0xa50dx22)}};logger[_0x5520[25]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[65]);clearTimeout(_0xa50dx10);_0xa50dxe()})[_0x5520[44]](function(_0xa50dx1a){logger[_0x5520[42]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[41]);logger[_0x5520[42]](_0xa50dx1a[_0x5520[43]]);_0xa50dxe(_0xa50dx1a)})}}function _0xa50dx23(){var _0xa50dx18=((_0xa50dxa[_0x5520[32]]- _0xa50dx13)> _0xa50dx12[_0x5520[32]])?_0xa50dx12[_0x5520[32]]:(_0xa50dxa[_0x5520[32]]- _0xa50dx13);if(_0xa50dx18> 0){Queue[_0x5520[74]](_0xa50dxa.SmsQueueId,{attributes:[_0x5520[26],_0x5520[17],_0x5520[32],_0x5520[19],_0x5520[73]],include:[{model:Agent,where:{online:true,smsPause:false},attributes:[_0x5520[26],_0x5520[17],_0x5520[35],_0x5520[36],_0x5520[37]],raw:true}]})[_0x5520[45]](function(_0xa50dx25){if(_0xa50dx25){var _0xa50dx1c=_[_0x5520[69]](_[_0x5520[68]](_0xa50dx25.Users,_0x5520[67]));if(_0xa50dx1c&& _0xa50dx1c[_0x5520[33]]){var _0xa50dx26;for(var _0xa50dx1e=0;_0xa50dx1e< _0xa50dx1c[_0x5520[33]];_0xa50dx1e++){_[_0x5520[70]](_0xa50dx1c[_0xa50dx1e],function(_0xa50dx15){return _0xa50dx14(_0xa50dx15)});if(_0xa50dx1c[_0xa50dx1e][_0x5520[33]]){_0xa50dx26= _0xa50dx1c[_0xa50dx1e];break}};if(_0xa50dx26&& _0xa50dx26[_0x5520[33]]){var _0xa50dx27=_[_0x5520[34]](_0xa50dx26,function(_0xa50dx15){return _[_0x5520[71]](_[_0x5520[58]](_0xa50dxb,{timeslot:_0xa50dx18,application:_0x5520[56],membername:_0xa50dx15[_0x5520[17]],memberid:_0xa50dx15[_0x5520[26]],queue:_0xa50dx12[_0x5520[26]],queuename:_0xa50dx12[_0x5520[17]],calledAt:moment()[_0x5520[40]](_0x5520[57])}))});return Report[_0x5520[72]](_0xa50dx27,{individualHooks:true})}else {logger[_0x5520[25]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[60])}}else {logger[_0x5520[25]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[60])}}else {logger[_0x5520[25]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[60])}})[_0x5520[45]](function(_0xa50dx24){if(_0xa50dx24&& _0xa50dx24[_0x5520[33]]){for(var _0xa50dx1e=0;_0xa50dx1e< _0xa50dx24[_0x5520[33]];_0xa50dx1e++){var _0xa50dx1b=_0xa50dx24[_0xa50dx1e][_0x5520[51]]({plain:true});_0xa50dxd[_0x5520[50]](util[_0x5520[40]](_0x5520[48],_0xa50dx1b[_0x5520[49]]))[_0x5520[47]](_0x5520[46],_0xa50dx1b)}};_0xa50dx10= setTimeout(function(){_0xa50dx13+= _0xa50dx12[_0x5520[32]];_0xa50dx23()},_0xa50dx18* 1000)})[_0x5520[44]](function(_0xa50dx1a){logger[_0x5520[42]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[41]);logger[_0x5520[42]](_0xa50dx1a[_0x5520[43]]);_0xa50dxe(_0xa50dx1a)})}else {return Session[_0x5520[66]]({leaveAt:moment()[_0x5520[40]](_0x5520[57]),timeout:true},{where:{uniqueid:_0xa50dxb[_0x5520[21]],leaveAt:null},individualHooks:true})[_0x5520[45]](function(_0xa50dx21){if(_0xa50dx21&& _0xa50dx21[_0x5520[33]]&& _0xa50dx21[1][_0x5520[33]]){for(var _0xa50dx1e=0;_0xa50dx1e< _0xa50dx21[1][_0x5520[33]];_0xa50dx1e++){var _0xa50dx22=_0xa50dx21[1][_0xa50dx1e][_0x5520[51]]({plain:true});_0xa50dxd[_0x5520[50]](_0x5520[63])[_0x5520[47]](_0x5520[62],_0xa50dx22);_0xa50dxd[_0x5520[50]](_0x5520[64])[_0x5520[47]](_0x5520[62],_0xa50dx22)}};logger[_0x5520[25]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[65]);clearTimeout(_0xa50dx10);_0xa50dxe()})[_0x5520[44]](function(_0xa50dx1a){logger[_0x5520[42]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[41]);logger[_0x5520[42]](_0xa50dx1a[_0x5520[43]]);_0xa50dxe(_0xa50dx1a)})}}return Queue[_0x5520[74]](_0xa50dxa.SmsQueueId,{attributes:[_0x5520[26],_0x5520[17],_0x5520[32],_0x5520[19],_0x5520[73]],include:[{model:Agent,attributes:[_0x5520[26]],raw:true}]})[_0x5520[45]](function(_0xa50dx25){_0xa50dx12= _0xa50dx25[_0x5520[51]]({plain:true});logger[_0x5520[25]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[85],_0xa50dxa[_0x5520[32]],_0x5520[86]);return Session[_0x5520[59]](_[_0x5520[58]](_0xa50dxb,{timeslot:_0xa50dxa[_0x5520[32]],application:_0x5520[56],queue:_0xa50dx25[_0x5520[26]],queuename:_0xa50dx25[_0x5520[17]],calledAt:moment()[_0x5520[40]](_0x5520[57]),joinAt:moment()[_0x5520[40]](_0x5520[57]),membername:null,memberid:null}))})[_0x5520[45]](function(_0xa50dx22){_0xa50dxc[_0x5520[56]]= _0xa50dx12[_0x5520[17]];process[_0x5520[83]]({type:_0x5520[82],msg:_0xa50dxc});_0xa50dxd[_0x5520[50]](_0x5520[63])[_0x5520[47]](_0x5520[62],_0xa50dx22);_0xa50dxd[_0x5520[50]](_0x5520[64])[_0x5520[47]](_0x5520[62],_0xa50dx22);return Room[_0x5520[74]](_0xa50dxb[_0x5520[84]])})[_0x5520[45]](function(_0xa50dx28){if(_0xa50dx28){return _0xa50dx28[_0x5520[66]]({waiting:true})}})[_0x5520[45]](function(_0xa50dx28){if(_0xa50dx28){_0xa50dxd[_0x5520[47]](_0x5520[81],_0xa50dx28[_0x5520[51]]({plain:true}))}})[_0x5520[45]](function(_0xa50dx28){switch(_0xa50dx12[_0x5520[19]]){case _0x5520[75]:_0xa50dx23();break;case _0x5520[79]:_0xa50dx11= _[_0x5520[78]](_0xa50dx12.Users,[function(_0xa50dx29){return _0xa50dx29[_0x5520[77]][_0x5520[76]]|| 0}]);_0xa50dx17();break;case _0x5520[80]:_0xa50dx11= _[_0x5520[78]](_0xa50dx12.Users,[function(_0xa50dx29){return _0xa50dx29[_0x5520[77]][_0x5520[76]]|| 0}]);_0xa50dx17();break;default:}})[_0x5520[44]](function(_0xa50dx1a){logger[_0x5520[42]](_0xa50dxb[_0x5520[15]][_0x5520[14]](),_0x5520[16],_0xa50dx12[_0x5520[17]][_0x5520[14]](),_0x5520[18],_0xa50dx12[_0x5520[19]],_0x5520[20],_0xa50dxb[_0x5520[21]],_0x5520[41]);logger[_0x5520[42]](_0xa50dx1a[_0x5520[43]]);_0xa50dxe(_0xa50dx1a)})}