Built motion from commit e155ad4.|0.0.101
[motion.git] / server / config / routing / chat / session.js
1 var _0xf403=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x6D\x6F\x6D\x65\x6E\x74","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x43\x68\x61\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74\x53\x65\x73\x73\x69\x6F\x6E","\x4E\x65\x77\x20\x43\x68\x61\x74\x20\x73\x65\x73\x73\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x61\x67\x65\x6E\x74\x73","\x69\x64","\x66\x69\x6E\x64","\x70\x65\x6E\x61\x6C\x74\x79","\x66\x6F\x72\x45\x61\x63\x68","\x6F\x72\x64\x65\x72\x42\x79","\x63\x68\x61\x74\x43\x61\x70\x61\x63\x69\x74\x79","\x6C\x65\x6E\x67\x74\x68","\x72\x6F\x6F\x6D\x69\x64","\x73\x74\x61\x74\x75\x73","\x43\x4C\x4F\x53\x45\x44","\x66\x69\x6C\x74\x65\x72","\x74\x69\x6D\x65\x73\x6C\x6F\x74","\x61\x70\x70\x74\x69\x6D\x65\x6F\x75\x74","\x71\x75\x65\x75\x65\x74\x69\x6D\x65\x6F\x75\x74","\x63\x6C\x6F\x6E\x65\x44\x65\x65\x70","\x73\x68\x69\x66\x74","\x61\x76\x61\x69\x6C\x61\x62\x6C\x65","\x6E\x61\x6D\x65","\x70\x75\x73\x68","\x72\x72\x6D\x65\x6D\x6F\x72\x79","\x62\x65\x65\x70\x61\x6C\x6C","\x73\x74\x72\x61\x74\x65\x67\x79","\x64\x69\x66\x66\x65\x72\x65\x6E\x63\x65\x42\x79","\x74\x68\x65\x6E","\x6D\x61\x70","\x66\x69\x6E\x64\x41\x6C\x6C","\x63\x6F\x6E\x6E\x65\x63\x74\x69\x64","\x63\x68\x61\x6E\x67\x65\x64","\x6D\x65\x6D\x62\x65\x72\x69\x64","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x75\x6E\x69\x71\x75\x65\x69\x64","\x75\x70\x64\x61\x74\x65","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x71\x75\x65\x75\x65\x69\x64","\x71\x75\x65\x75\x65\x6E\x61\x6D\x65","\x4F\x50\x45\x4E","\x61\x64\x64\x55\x73\x65\x72","\x66\x69\x6E\x64\x42\x79\x49\x64","\x72\x65\x6A\x65\x63\x74\x65\x64\x41\x74","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x61\x62\x61\x6E\x64\x6F\x6E","\x41\x42\x41\x4E\x44\x4F\x4E","\x76\x69\x73\x69\x74\x6F\x72\x69\x64","\x76\x69\x73\x69\x74\x6F\x72\x6E\x61\x6D\x65","\x76\x69\x73\x69\x74\x6F\x72\x65\x6D\x61\x69\x6C","\x77\x65\x62\x73\x69\x74\x65\x69\x64","\x77\x65\x62\x73\x69\x74\x65\x6E\x61\x6D\x65","\x77\x65\x62\x73\x69\x74\x65\x61\x64\x64\x72\x65\x73\x73","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xf403[0];var _=require(_0xf403[1]);var moment=require(_0xf403[2]);var Agent=require(_0xf403[4])[_0xf403[3]];var ChatRoom=require(_0xf403[4])[_0xf403[5]];var ChatApplication=require(_0xf403[4])[_0xf403[6]];var ReportChat=require(_0xf403[4])[_0xf403[7]];var ReportChatRoom=require(_0xf403[4])[_0xf403[8]];var ReportChatSession=require(_0xf403[4])[_0xf403[9]];function Session(_0x915cxa,_0x915cxb){console[_0xf403[11]](_0xf403[10]);var _0x915cxc=0;var _0x915cxd,_0x915cxe;var _0x915cxf=[];Agent[_0xf403[40]]({where:{id:{$in:_[_0xf403[39]](_0x915cxa[_0xf403[14]],_0xf403[15])},online:true,chatPause:false},include:[{model:ChatRoom,attributes:[_0xf403[15],_0xf403[23]]}],attributes:[_0xf403[15],_0xf403[32],_0xf403[20]]})[_0xf403[38]](function(_0x915cx11){_[_0xf403[18]](_0x915cx11,function(_0x915cx12){var _0x915cx13=_[_0xf403[16]](_0x915cxa[_0xf403[14]],{"\x69\x64":_0x915cx12[_0xf403[15]]});_0x915cx12[_0xf403[17]]=_0x915cx13[_0xf403[17]]});_0x915cx11=_[_0xf403[19]](_0x915cx11,_0xf403[17]);var _0x915cx14=_[_0xf403[25]](_0x915cx11,function(_0x915cx12){if(_0x915cx12[_0xf403[20]]===0){return true}else {return _0x915cx12[_0xf403[20]]>_[_0xf403[25]](_0x915cx12.ChatRooms,function(_0x915cx15){return _0x915cx15[_0xf403[15]]!==_0x915cxa[_0xf403[22]]&&_0x915cx15[_0xf403[23]]!==_0xf403[24]})[_0xf403[21]]}});var _0x915cx16=[];var _0x915cx17;var _0x915cx12;_0x915cxa[_0xf403[26]]=((_0x915cxa[_0xf403[27]]-_0x915cxc)>_0x915cxa[_0xf403[28]])?_0x915cxa[_0xf403[28]]:(_0x915cxa[_0xf403[27]]-_0x915cxc);switch(_0x915cxa[_0xf403[36]]){case _0xf403[34]:_0x915cx17=_[_0xf403[29]](_0x915cx14);_0x915cx12=_0x915cx17[_0xf403[30]]();if(_0x915cx12){_0x915cxa[_0xf403[31]]=[{id:_0x915cx12[_0xf403[15]],name:_0x915cx12[_0xf403[32]]}];_0x915cx16[_0xf403[33]]({id:_0x915cx12[_0xf403[15]],name:_0x915cx12[_0xf403[32]]});saveReport(_0x915cxa)};break;case _0xf403[35]:_0x915cxa[_0xf403[31]]=_0x915cx14;saveReport(_0x915cxa);break;default:};_0x915cxe=setTimeout(function(){clearInterval(_0x915cxd);return _0x915cxb(null,false,false)},_0x915cxa[_0xf403[27]]*1000);_0x915cxd=setInterval(function(){_0x915cxc+=_0x915cxa[_0xf403[28]];return Agent[_0xf403[40]]({where:{id:{$in:_[_0xf403[39]](_0x915cxa[_0xf403[14]],_0xf403[15])},online:true,chatPause:false},include:[{model:ChatRoom,attributes:[_0xf403[15],_0xf403[23]]}],attributes:[_0xf403[15],_0xf403[32],_0xf403[20]]})[_0xf403[38]](function(_0x915cx11){_[_0xf403[18]](_0x915cx11,function(_0x915cx12){var _0x915cx13=_[_0xf403[16]](_0x915cxa[_0xf403[14]],{"\x69\x64":_0x915cx12[_0xf403[15]]});_0x915cx12[_0xf403[17]]=_0x915cx13[_0xf403[17]]});_0x915cx11=_[_0xf403[19]](_0x915cx11,_0xf403[17]);_0x915cx14=_[_0xf403[25]](_0x915cx11,function(_0x915cx12){if(_0x915cx12[_0xf403[20]]===0){return true}else {return _0x915cx12[_0xf403[20]]>_[_0xf403[25]](_0x915cx12.ChatRooms,function(_0x915cx15){return _0x915cx15[_0xf403[15]]!==_0x915cxa[_0xf403[22]]&&_0x915cx15[_0xf403[23]]!==_0xf403[24]})[_0xf403[21]]}});_0x915cxa[_0xf403[26]]=((_0x915cxa[_0xf403[27]]-_0x915cxc)>_0x915cxa[_0xf403[28]])?_0x915cxa[_0xf403[28]]:(_0x915cxa[_0xf403[27]]-_0x915cxc);switch(_0x915cxa[_0xf403[36]]){case _0xf403[34]:_0x915cx17=_[_0xf403[37]](_0x915cx14,_0x915cx16,_0xf403[32]);_0x915cx17=_[_0xf403[37]](_0x915cx17,_0x915cxf,_0xf403[32]);_0x915cx12=_0x915cx17[_0xf403[30]]();if(_0x915cx12){_0x915cxa[_0xf403[31]]=[{id:_0x915cx12[_0xf403[15]],name:_0x915cx12[_0xf403[32]]}];_0x915cx16[_0xf403[33]]({id:_0x915cx12[_0xf403[15]],name:_0x915cx12[_0xf403[32]]});saveReport(_0x915cxa)}else {_0x915cx16=[];_0x915cx14=_[_0xf403[37]](_0x915cx14,_0x915cxf,_0xf403[32]);_0x915cx12=_0x915cx14[_0xf403[30]]();if(_0x915cx12){_0x915cxa[_0xf403[31]]=[{id:_0x915cx12[_0xf403[15]],name:_0x915cx12[_0xf403[32]]}];_0x915cx16[_0xf403[33]]({id:_0x915cx12[_0xf403[15]],name:_0x915cx12[_0xf403[32]]});saveReport(_0x915cxa)}};break;case _0xf403[35]:_0x915cxa[_0xf403[31]]=_[_0xf403[37]](_0x915cx14,_0x915cxf,_0xf403[32]);saveReport(_0x915cxa);break;default:}})[_0xf403[13]](function(_0x915cx10){console[_0xf403[12]](_0x915cx10)})},_0x915cxa[_0xf403[28]]*1000)})[_0xf403[13]](function(_0x915cx10){console[_0xf403[12]](_0x915cx10)});ReportChat[_0xf403[56]](function(_0x915cx18){if(_0x915cx18[_0xf403[42]](_0xf403[41])){var _0x915cx19;return ChatRoom[_0xf403[54]](_0x915cx18[_0xf403[22]])[_0xf403[38]](function(ChatRoom){_0x915cx19=ChatRoom;return ChatRoom[_0xf403[53]](_0x915cx18[_0xf403[43]],{individualHooks:true})})[_0xf403[38]](function(){return _0x915cx19[_0xf403[48]]({status:_0xf403[52]})})[_0xf403[38]](function(){return ReportChatRoom[_0xf403[48]]({application:_0x915cx18[_0xf403[49]],memberid:_0x915cx18[_0xf403[43]],membername:_0x915cx18[_0xf403[44]],queueid:_0x915cx18[_0xf403[50]]||null,queuename:_0x915cx18[_0xf403[51]]||null,leaveAt:moment()[_0xf403[46]](_0xf403[45]),status:_0xf403[52]},{where:{uniqueid:_0x915cx18[_0xf403[47]],leaveAt:null},individualHooks:true})})[_0xf403[38]](function(){return ReportChatSession[_0xf403[48]]({memberid:_0x915cx18[_0xf403[43]],membername:_0x915cx18[_0xf403[44]],leaveAt:moment()[_0xf403[46]](_0xf403[45])},{where:{uniqueid:_0x915cx18[_0xf403[47]],leaveAt:null},individualHooks:true})})[_0xf403[38]](function(){clearInterval(_0x915cxd);clearTimeout(_0x915cxe);return _0x915cxb(null,true,false)})[_0xf403[13]](function(_0x915cx10){console[_0xf403[12]](_0x915cx10)})};if(_0x915cx18[_0xf403[42]](_0xf403[55])){_0x915cxf[_0xf403[33]]({id:_0x915cx18[_0xf403[43]],name:_0x915cx18[_0xf403[44]]})}});ReportChatSession[_0xf403[56]](function(_0x915cx18){if(_0x915cx18[_0xf403[42]](_0xf403[57])&&_0x915cx18[_0xf403[57]]){return ChatRoom[_0xf403[54]](_0x915cx18[_0xf403[22]])[_0xf403[38]](function(_0x915cx1a){return _0x915cx1a[_0xf403[48]]({status:_0xf403[58]})})[_0xf403[38]](function(){clearInterval(_0x915cxd);clearTimeout(_0x915cxe);return _0x915cxb(null,true,true)})[_0xf403[13]](function(_0x915cx10){console[_0xf403[12]](_0x915cx10)})}});return {}}function saveReport(_0x915cxa){var _0x915cx1c=[];for(var _0x915cx1d=0;_0x915cx1d<_0x915cxa[_0xf403[31]][_0xf403[21]];_0x915cx1d++){var _0x915cx12=_0x915cxa[_0xf403[31]][_0x915cx1d];_0x915cx1c[_0xf403[33]]({uniqueid:_0x915cxa[_0xf403[47]],visitorid:_0x915cxa[_0xf403[59]],visitorname:_0x915cxa[_0xf403[60]],visitoremail:_0x915cxa[_0xf403[61]],timeslot:_0x915cxa[_0xf403[26]],websiteid:_0x915cxa[_0xf403[62]],websitename:_0x915cxa[_0xf403[63]],websiteaddress:_0x915cxa[_0xf403[64]],application:_0x915cxa[_0xf403[49]],membername:_0x915cx12[_0xf403[32]],memberid:_0x915cx12[_0xf403[15]],queueid:_0x915cxa[_0xf403[50]]||null,queuename:_0x915cxa[_0xf403[51]]||null,roomid:_0x915cxa[_0xf403[22]]||null,calledAt:moment()[_0xf403[46]](_0xf403[45])})};if(_0x915cx1c[_0xf403[21]]){return ReportChat[_0xf403[65]](_0x915cx1c,{individualHooks:true})[_0xf403[13]](function(_0x915cx10){console[_0xf403[12]](_0x915cx10)})}}module[_0xf403[66]]=Session