Built motion from commit 0010de3.|0.0.91
[motion.git] / server / config / routing / chat / index.js
1 var _0x162e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x6D\x6F\x6D\x65\x6E\x74","\x75\x74\x69\x6C","\x61\x73\x79\x6E\x63","\x2E\x2E\x2F\x2E\x2E\x2F\x75\x74\x69\x6C","\x43\x68\x61\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65","\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74\x53\x65\x73\x73\x69\x6F\x6E","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x49\x6E\x74\x65\x72\x76\x61\x6C","\x55\x73\x65\x72","\x2E\x2F\x73\x65\x73\x73\x69\x6F\x6E","\x65\x78\x70\x6F\x72\x74\x73","\x43\x68\x61\x74\x20\x52\x6F\x75\x74\x69\x6E\x67\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E","\x6C\x6F\x67","\x6F\x72\x69\x67\x69\x6E","\x77\x65\x62\x63\x68\x61\x74","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x77\x65\x62\x73\x69\x74\x65\x69\x64","\x69\x64","\x77\x65\x62\x73\x69\x74\x65\x6E\x61\x6D\x65","\x6E\x61\x6D\x65","\x77\x65\x62\x73\x69\x74\x65\x61\x64\x64\x72\x65\x73\x73","\x61\x64\x64\x72\x65\x73\x73","\x66\x69\x64\x65\x6C\x69\x74\x79","\x61\x70\x70\x74\x69\x6D\x65\x6F\x75\x74","\x71\x75\x65\x75\x65\x74\x69\x6D\x65\x6F\x75\x74","\x74\x69\x6D\x65\x6F\x75\x74","\x73\x74\x72\x61\x74\x65\x67\x79","\x62\x65\x65\x70\x61\x6C\x6C","\x70\x72\x69\x6F\x72\x69\x74\x79\x20\x41\x53\x43","\x6F\x6E\x6C\x69\x6E\x65","\x63\x68\x61\x74\x50\x61\x75\x73\x65","\x67\x65\x74\x43\x68\x61\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x65\x78\x74\x65\x72\x6E\x61\x6C","\x76\x69\x73\x69\x74\x6F\x72\x69\x64","\x63\x72\x65\x61\x74\x65","\x72\x6F\x6F\x6D\x69\x64","\x75\x6E\x69\x71\x75\x65\x69\x64","\x25\x73\x2E\x25\x73","\x75\x6E\x69\x78","\x66\x6F\x72\x6D\x61\x74","\x61\x67\x65\x6E\x74\x73","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x63\x6C\x6F\x6E\x65\x44\x65\x65\x70","\x6C\x65\x6E\x67\x74\x68","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x74\x68\x65\x6E","\x76\x69\x73\x69\x74\x6F\x72\x6E\x61\x6D\x65","\x76\x69\x73\x69\x74\x6F\x72\x65\x6D\x61\x69\x6C","\x61\x67\x65\x6E\x74","\x71\x75\x65\x75\x65\x69\x64","\x71\x75\x65\x75\x65\x6E\x61\x6D\x65","\x74\x69\x6D\x65\x73\x6C\x6F\x74","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x73\x75\x62\x6A\x65\x63\x74","\x66\x72\x6F\x6D","\x64\x61\x74\x61\x31","\x64\x61\x74\x61\x32","\x64\x61\x74\x61\x33","\x6C\x61\x62\x65\x6C\x44\x61\x74\x61\x31","\x6C\x61\x62\x65\x6C\x44\x61\x74\x61\x32","\x6C\x61\x62\x65\x6C\x44\x61\x74\x61\x33","\x61\x70\x70","\x6D\x61\x70","\x71\x75\x65\x75\x65","\x75\x70\x64\x61\x74\x65","\x45\x6E\x64\x20\x63\x68\x61\x74\x20\x72\x6F\x75\x74\x69\x6E\x67\x2E\x2E","\x43\x68\x61\x74\x20\x75\x6E\x6D\x61\x6E\x61\x67\x65\x64\x3A","\x43\x68\x61\x74\x20\x61\x62\x61\x6E\x64\x6F\x6E\x3A","\x77\x61\x74\x65\x72\x66\x61\x6C\x6C","\x61\x62\x61\x6E\x64\x6F\x6E","\x55\x4E\x4D\x41\x4E\x41\x47\x45\x44","\x75\x6E\x73\x65\x72\x76\x65\x64","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65\x49\x64","\x65\x72\x72","\x55\x6E\x6B\x6E\x6F\x77\x6E\x20\x43\x68\x61\x74\x52\x6F\x6F\x6D\x2E\x2E","\x55\x6E\x6B\x6E\x6F\x77\x6E\x20\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65\x20\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73\x2E\x2E","\x55\x6E\x6B\x6E\x6F\x77\x6E\x20\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65\x2E\x2E","\x66\x69\x6E\x64\x42\x79\x49\x64","\x55\x73\x65\x72\x73","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x44\x45\x53\x43","\x66\x69\x6E\x64\x4F\x6E\x65"];_0x162e[0];var _=require(_0x162e[1]);var moment=require(_0x162e[2]);var util=require(_0x162e[3]);var async=require(_0x162e[4]);var Util=require(_0x162e[5]);var ChatApplication=require(_0x162e[7])[_0x162e[6]];var ChatVisitor=require(_0x162e[7])[_0x162e[8]];var ChatWebsite=require(_0x162e[7])[_0x162e[9]];var ChatQueue=require(_0x162e[7])[_0x162e[10]];var ChatRoom=require(_0x162e[7])[_0x162e[11]];var ReportChat=require(_0x162e[7])[_0x162e[12]];var ReportChatSession=require(_0x162e[7])[_0x162e[13]];var ReportChatRoom=require(_0x162e[7])[_0x162e[14]];var Interval=require(_0x162e[7])[_0x162e[15]];var User=require(_0x162e[7])[_0x162e[16]];var Session=require(_0x162e[17]);module[_0x162e[18]]=function(){console[_0x162e[20]](_0x162e[19]);ChatVisitor[_0x162e[23]](function(_0xcd98x11){if(_0xcd98x11[_0x162e[21]]===_0x162e[22]){handleVisitor(_0xcd98x11)}})};function handleEntityNotFound(_0xcd98x13){return function(_0xcd98x14){if(!_0xcd98x14){throw {message:_0xcd98x13}};return _0xcd98x14}}function handleChatWebsite(_0xcd98x16,_0xcd98x17){return function(_0xcd98x18){_0xcd98x16[_0x162e[24]]=_0xcd98x18[_0x162e[25]];_0xcd98x16[_0x162e[26]]=_0xcd98x18[_0x162e[27]];_0xcd98x16[_0x162e[28]]=_0xcd98x18[_0x162e[29]];_0xcd98x17[_0x162e[30]]=_0xcd98x18[_0x162e[30]];if(_0xcd98x18[_0x162e[30]]){_0xcd98x17[_0x162e[31]]=_0xcd98x17[_0x162e[32]]=_0xcd98x18[_0x162e[33]];_0xcd98x17[_0x162e[30]]=_0xcd98x18[_0x162e[33]];_0xcd98x17[_0x162e[34]]=_0x162e[35]};return _0xcd98x18[_0x162e[39]]({order:_0x162e[36],include:[{model:ChatQueue,attributes:[_0x162e[25],_0x162e[27],_0x162e[33],_0x162e[34]],include:[{model:User,attributes:[_0x162e[25],_0x162e[27],_0x162e[37],_0x162e[38]]}]},{model:User,attributes:[_0x162e[25],_0x162e[27],_0x162e[37],_0x162e[38]]},{model:Interval,include:[{all:true}]}]})}}function handleChatRoom(_0xcd98x16,_0xcd98x1a,_0xcd98x17){return function(_0xcd98x1b){_0xcd98x1b[_0x162e[41]](function(_0xcd98x1c){_0xcd98x1a[_0x162e[40]](_0xcd98x1c)});_0xcd98x1a=_0xcd98x1b;return ChatRoom[_0x162e[44]]({type:_0x162e[42],ChatVisitorId:_0xcd98x16[_0x162e[43]],ChatWebsiteId:_0xcd98x16[_0x162e[24]]},{include:[{all:true}]})}}function handleApps(_0xcd98x16,_0xcd98x1a,_0xcd98x17){return function(_0xcd98x1e){var _0xcd98x1f=[];_0xcd98x16[_0x162e[45]]=_0xcd98x1e[_0x162e[25]];_0xcd98x16[_0x162e[46]]=util[_0x162e[49]](_0x162e[47],moment()[_0x162e[48]](),_0xcd98x1e[_0x162e[25]]);if(_0xcd98x17[_0x162e[30]]){_0xcd98x16[_0x162e[32]]=_0xcd98x17[_0x162e[30]];_0xcd98x16[_0x162e[31]]=_0xcd98x17[_0x162e[30]];_0xcd98x16[_0x162e[50]]=_0xcd98x17[_0x162e[50]];_0xcd98x16[_0x162e[51]]=_0x162e[30];_0xcd98x16[_0x162e[34]]=_0x162e[35];var _0xcd98x20=_[_0x162e[52]](_0xcd98x16);if(_0xcd98x20[_0x162e[50]][_0x162e[53]]){_0xcd98x1f[_0x162e[40]](function(_0xcd98x21){return ReportChatRoom[_0x162e[44]]({uniqueid:_0xcd98x20[_0x162e[46]],subject:_0xcd98x20[_0x162e[64]],websitename:_0xcd98x20[_0x162e[26]],websiteaddress:_0xcd98x20[_0x162e[28]],websiteid:_0xcd98x20[_0x162e[24]],visitorid:_0xcd98x20[_0x162e[43]],visitorname:_0xcd98x20[_0x162e[57]],visitoremail:_0xcd98x20[_0x162e[58]],from:_0xcd98x20[_0x162e[65]],roomid:_0xcd98x20[_0x162e[45]],data1:_0xcd98x16[_0x162e[66]],data2:_0xcd98x16[_0x162e[67]],data3:_0xcd98x16[_0x162e[68]],labelData1:_0xcd98x16[_0x162e[69]],labelData2:_0xcd98x16[_0x162e[70]],labelData3:_0xcd98x16[_0x162e[71]],joinAt:moment()[_0x162e[49]](_0x162e[63])})[_0x162e[56]](function(){return ReportChatSession[_0x162e[44]]({uniqueid:_0xcd98x20[_0x162e[46]],websitename:_0xcd98x20[_0x162e[26]],websiteaddress:_0xcd98x20[_0x162e[28]],websiteid:_0xcd98x20[_0x162e[24]],application:_0xcd98x20[_0x162e[51]],visitorid:_0xcd98x20[_0x162e[43]],visitorname:_0xcd98x20[_0x162e[57]],visitoremail:_0xcd98x20[_0x162e[58]],memberid:(_0xcd98x20[_0x162e[51]]===_0x162e[59]&&_0xcd98x20[_0x162e[50]][0])?_0xcd98x20[_0x162e[50]][0][_0x162e[25]]:null,membername:(_0xcd98x20[_0x162e[51]]===_0x162e[59]&&_0xcd98x20[_0x162e[50]][0])?_0xcd98x20[_0x162e[50]][0][_0x162e[27]]:null,queueid:_0xcd98x20[_0x162e[60]],queuename:_0xcd98x20[_0x162e[61]],roomid:_0xcd98x20[_0x162e[45]],fidelity:_0xcd98x20[_0x162e[51]]===_0x162e[30]?_0xcd98x20[_0x162e[62]]:null,joinAt:moment()[_0x162e[49]](_0x162e[63])})})[_0x162e[56]](function(){ new Session(_0xcd98x20,_0xcd98x21)})[_0x162e[55]](function(_0xcd98x22){console[_0x162e[54]](_0xcd98x22)})})}};_0xcd98x1a[_0x162e[41]](function(_0xcd98x1c,_0xcd98x23){var _0xcd98x20=_[_0x162e[52]](_0xcd98x16);_0xcd98x20[_0x162e[31]]=_0xcd98x1c[_0x162e[33]];_0xcd98x20[_0x162e[51]]=_0xcd98x1c[_0x162e[72]];switch(_0xcd98x1c[_0x162e[72]]){case _0x162e[74]:_0xcd98x20[_0x162e[60]]=_0xcd98x1c[_0x162e[10]][_0x162e[25]];_0xcd98x20[_0x162e[61]]=_0xcd98x1c[_0x162e[10]][_0x162e[27]];_0xcd98x20[_0x162e[34]]=_0xcd98x1c[_0x162e[10]][_0x162e[34]];_0xcd98x20[_0x162e[32]]=_0xcd98x1c[_0x162e[10]][_0x162e[33]];_0xcd98x20[_0x162e[50]]=_[_0x162e[73]](_0xcd98x1c[_0x162e[10]].Users,function(_0xcd98x24){return {id:_0xcd98x24[_0x162e[25]],name:_0xcd98x24[_0x162e[27]]}});break;case _0x162e[59]:_0xcd98x20[_0x162e[32]]=_0xcd98x1c[_0x162e[33]];_0xcd98x20[_0x162e[34]]=_0x162e[35];_0xcd98x20[_0x162e[50]]=[{id:_0xcd98x1c[_0x162e[16]][_0x162e[25]],name:_0xcd98x1c[_0x162e[16]][_0x162e[27]]}];break;default:};if(_0xcd98x1f[_0x162e[53]]){_0xcd98x1f[_0x162e[40]](function(_0xcd98x25,_0xcd98x26,_0xcd98x21){if(_0xcd98x25){return _0xcd98x21(null,_0xcd98x25,_0xcd98x26)}else {return ReportChatSession[_0x162e[75]]({leaveAt:moment()[_0x162e[49]](_0x162e[63]),unmanaged:true},{where:{leaveAt:null,uniqueid:_0xcd98x20[_0x162e[46]]}})[_0x162e[56]](function(){return ReportChatSession[_0x162e[44]]({uniqueid:_0xcd98x20[_0x162e[46]],websitename:_0xcd98x20[_0x162e[26]],websiteaddress:_0xcd98x20[_0x162e[28]],websiteid:_0xcd98x20[_0x162e[24]],application:_0xcd98x20[_0x162e[51]],visitorid:_0xcd98x20[_0x162e[43]],visitorname:_0xcd98x20[_0x162e[57]],visitoremail:_0xcd98x20[_0x162e[58]],memberid:(_0xcd98x20[_0x162e[51]]===_0x162e[59]&&_0xcd98x20[_0x162e[50]][0])?_0xcd98x20[_0x162e[50]][0][_0x162e[25]]:null,membername:(_0xcd98x20[_0x162e[51]]===_0x162e[59]&&_0xcd98x20[_0x162e[50]][0])?_0xcd98x20[_0x162e[50]][0][_0x162e[27]]:null,queueid:_0xcd98x20[_0x162e[60]],queuename:_0xcd98x20[_0x162e[61]],roomid:_0xcd98x20[_0x162e[45]],fidelity:_0xcd98x20[_0x162e[51]]===_0x162e[30]?_0xcd98x20[_0x162e[62]]:null,joinAt:moment()[_0x162e[49]](_0x162e[63])})})[_0x162e[56]](function(){ new Session(_0xcd98x20,_0xcd98x21)})[_0x162e[55]](function(_0xcd98x22){console[_0x162e[54]](_0xcd98x22)})}})}else {_0xcd98x1f[_0x162e[40]](function(_0xcd98x21){return ReportChatRoom[_0x162e[44]]({uniqueid:_0xcd98x20[_0x162e[46]],subject:_0xcd98x20[_0x162e[64]],websitename:_0xcd98x20[_0x162e[26]],websiteaddress:_0xcd98x20[_0x162e[28]],websiteid:_0xcd98x20[_0x162e[24]],visitorid:_0xcd98x20[_0x162e[43]],visitorname:_0xcd98x20[_0x162e[57]],visitoremail:_0xcd98x20[_0x162e[58]],from:_0xcd98x20[_0x162e[65]],roomid:_0xcd98x20[_0x162e[45]],data1:_0xcd98x16[_0x162e[66]],data2:_0xcd98x16[_0x162e[67]],data3:_0xcd98x16[_0x162e[68]],labelData1:_0xcd98x16[_0x162e[69]],labelData2:_0xcd98x16[_0x162e[70]],labelData3:_0xcd98x16[_0x162e[71]],joinAt:moment()[_0x162e[49]](_0x162e[63])})[_0x162e[56]](function(){return ReportChatSession[_0x162e[44]]({uniqueid:_0xcd98x20[_0x162e[46]],websitename:_0xcd98x20[_0x162e[26]],websiteaddress:_0xcd98x20[_0x162e[28]],websiteid:_0xcd98x20[_0x162e[24]],application:_0xcd98x20[_0x162e[51]],visitorid:_0xcd98x20[_0x162e[43]],visitorname:_0xcd98x20[_0x162e[57]],visitoremail:_0xcd98x20[_0x162e[58]],memberid:(_0xcd98x20[_0x162e[51]]===_0x162e[59]&&_0xcd98x20[_0x162e[50]][0])?_0xcd98x20[_0x162e[50]][0][_0x162e[25]]:null,membername:(_0xcd98x20[_0x162e[51]]===_0x162e[59]&&_0xcd98x20[_0x162e[50]][0])?_0xcd98x20[_0x162e[50]][0][_0x162e[27]]:null,queueid:_0xcd98x20[_0x162e[60]],queuename:_0xcd98x20[_0x162e[61]],roomid:_0xcd98x20[_0x162e[45]],fidelity:_0xcd98x20[_0x162e[51]]===_0x162e[30]?_0xcd98x20[_0x162e[62]]:null,joinAt:moment()[_0x162e[49]](_0x162e[63])})})[_0x162e[56]](function(){ new Session(_0xcd98x20,_0xcd98x21)})[_0x162e[55]](function(_0xcd98x22){console[_0x162e[54]](_0xcd98x22)})})}});async[_0x162e[79]](_0xcd98x1f,function(_0xcd98x22,_0xcd98x27,_0xcd98x26){if(_0xcd98x22){console[_0x162e[54]](_0xcd98x22)};console[_0x162e[20]](_0x162e[76]);if(!_0xcd98x27){console[_0x162e[20]](_0x162e[77],_0xcd98x16[_0x162e[46]]);return ReportChatRoom[_0x162e[75]]({leaveAt:moment()[_0x162e[49]](_0x162e[63]),unmanaged:true},{where:{leaveAt:null,uniqueid:_0xcd98x16[_0x162e[46]]},individualHooks:true})[_0x162e[56]](function(){return ReportChatSession[_0x162e[75]]({leaveAt:moment()[_0x162e[49]](_0x162e[63]),unmanaged:true},{where:{leaveAt:null,uniqueid:_0xcd98x16[_0x162e[46]]},individualHooks:true})})[_0x162e[56]](handleUnmanaged(_0xcd98x16))[_0x162e[55]](function(_0xcd98x22){console[_0x162e[54]](_0xcd98x22)})};if(_0xcd98x26){console[_0x162e[20]](_0x162e[78],_0xcd98x16[_0x162e[46]]);return ReportChatRoom[_0x162e[75]]({leaveAt:moment()[_0x162e[49]](_0x162e[63]),abandon:true},{where:{leaveAt:null,uniqueid:_0xcd98x16[_0x162e[46]]},individualHooks:true})[_0x162e[56]](handleAbandon(_0xcd98x16))[_0x162e[55]](function(_0xcd98x22){console[_0x162e[54]](_0xcd98x22)})};return})}}function handleAbandon(_0xcd98x16){return function(_0xcd98x29){return ChatVisitor[_0x162e[75]]({status:_0x162e[80]},{where:{id:_0xcd98x16[_0x162e[43]]}})}}function handleUnmanaged(_0xcd98x16){return function(_0xcd98x2b){return ChatVisitor[_0x162e[75]]({status:_0x162e[82]},{where:{id:_0xcd98x16[_0x162e[43]]}})[_0x162e[56]](function(){return ChatRoom[_0x162e[75]]({status:_0x162e[81]},{where:{id:_0xcd98x16[_0x162e[45]]}})})}}function handleVisitor(_0xcd98x11){var _0xcd98x1a=[];var _0xcd98x17={agents:[]};var _0xcd98x16={visitorid:_0xcd98x11[_0x162e[25]],visitorname:_0xcd98x11[_0x162e[83]],visitoremail:_0xcd98x11[_0x162e[84]],websiteid:_0xcd98x11[_0x162e[85]],data1:_0xcd98x11[_0x162e[66]]||null,data2:_0xcd98x11[_0x162e[67]]||null,data3:_0xcd98x11[_0x162e[68]]||null,labelData1:_0xcd98x11[_0x162e[69]]||null,labelData2:_0xcd98x11[_0x162e[70]]||null,labelData3:_0xcd98x11[_0x162e[71]]||null,joinAt:moment()[_0x162e[49]](_0x162e[63])};return ChatRoom[_0x162e[94]]({order:[[_0x162e[92],_0x162e[93]]],include:[{model:User,attributes:[_0x162e[25],_0x162e[27],_0x162e[37],_0x162e[38]],where:{id:{$gt:0}}},{model:ChatVisitor,where:{email:_0xcd98x11[_0x162e[84]]}}]})[_0x162e[56]](function(_0xcd98x2d){if(_0xcd98x2d&&_0xcd98x2d[_0x162e[91]][_0x162e[53]]>0){_0xcd98x17[_0x162e[50]]=_[_0x162e[73]](_0xcd98x2d.Users,function(_0xcd98x2e){return {id:_0xcd98x2e[_0x162e[25]],name:_0xcd98x2e[_0x162e[27]]}})};return})[_0x162e[56]](function(){return ChatWebsite[_0x162e[90]](_0xcd98x11.ChatWebsiteId)})[_0x162e[56]](handleEntityNotFound(_0x162e[89]))[_0x162e[56]](handleChatWebsite(_0xcd98x16,_0xcd98x17))[_0x162e[56]](handleEntityNotFound(_0x162e[88]))[_0x162e[56]](handleChatRoom(_0xcd98x16,_0xcd98x1a,_0xcd98x17))[_0x162e[56]](handleEntityNotFound(_0x162e[87]))[_0x162e[56]](handleApps(_0xcd98x16,_0xcd98x1a,_0xcd98x17))[_0x162e[55]](function(_0xcd98x22){console[_0x162e[54]](_0x162e[86],_0xcd98x22)})}