Built motion from commit 76c0fab.|0.0.109
[motion.git] / server / config / routing / mail / session.js
1 var _0x270a=["\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","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x4D\x61\x69\x6C\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x52\x6F\x6F\x6D","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x53\x65\x73\x73\x69\x6F\x6E","\x4E\x65\x77\x20\x4D\x61\x69\x6C\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","\x6D\x61\x69\x6C\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","\x6E\x61\x6D\x65","\x6D\x61\x70","\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","\x70\x75\x73\x68","\x72\x72\x6D\x65\x6D\x6F\x72\x79","\x64\x69\x66\x66\x65\x72\x65\x6E\x63\x65\x42\x79","\x62\x65\x65\x70\x61\x6C\x6C","\x73\x74\x72\x61\x74\x65\x67\x79","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x72\x65\x6A\x65\x63\x74\x65\x64\x41\x74","\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","\x63\x6F\x6E\x6E\x65\x63\x74\x69\x64","\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","\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","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x73\x75\x62\x6A\x65\x63\x74","\x61\x63\x63\x6F\x75\x6E\x74\x69\x64","\x61\x63\x63\x6F\x75\x6E\x74\x6E\x61\x6D\x65","\x61\x63\x63\x6F\x75\x6E\x74\x61\x64\x64\x72\x65\x73\x73","\x71\x75\x65\x75\x65\x69\x64","\x6D\x65\x73\x73\x61\x67\x65\x69\x64","\x66\x72\x6F\x6D","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0x270a[0];var _=require(_0x270a[1]);var moment=require(_0x270a[2]);var Agent=require(_0x270a[4])[_0x270a[3]];var MailRoom=require(_0x270a[4])[_0x270a[5]];var MailApplication=require(_0x270a[4])[_0x270a[6]];var ReportMail=require(_0x270a[4])[_0x270a[7]];var ReportMailRoom=require(_0x270a[4])[_0x270a[8]];var ReportMailSession=require(_0x270a[4])[_0x270a[9]];function Session(_0xf8c4xa,_0xf8c4xb){console[_0x270a[11]](_0x270a[10]);var _0xf8c4xc=0;var _0xf8c4xd,_0xf8c4xe;var _0xf8c4xf=[];Agent[_0x270a[40]]({where:{id:{$in:_[_0x270a[27]](_0xf8c4xa[_0x270a[14]],_0x270a[15])},online:true,mailPause:false},include:[{model:MailRoom,attributes:[_0x270a[15],_0x270a[23]]}],attributes:[_0x270a[15],_0x270a[26],_0x270a[20]]})[_0x270a[39]](function(_0xf8c4x11){_[_0x270a[18]](_0xf8c4x11,function(_0xf8c4x12){var _0xf8c4x13=_[_0x270a[16]](_0xf8c4xa[_0x270a[14]],{"\x69\x64":_0xf8c4x12[_0x270a[15]]});_0xf8c4x12[_0x270a[17]]=_0xf8c4x13[_0x270a[17]]});_0xf8c4x11=_[_0x270a[19]](_0xf8c4x11,_0x270a[17]);var _0xf8c4x14=_[_0x270a[27]](_[_0x270a[25]](_0xf8c4x11,function(_0xf8c4x12){if(_0xf8c4x12[_0x270a[20]]===0){return true}else {return _0xf8c4x12[_0x270a[20]]>_[_0x270a[25]](_0xf8c4x12.MailRooms,function(_0xf8c4x15){return _0xf8c4x15[_0x270a[15]]!==_0xf8c4xa[_0x270a[22]]&&_0xf8c4x15[_0x270a[23]]!==_0x270a[24]})[_0x270a[21]]}}),function(_0xf8c4x12){return {id:_0xf8c4x12[_0x270a[15]],name:_0xf8c4x12[_0x270a[26]]}});var _0xf8c4x16=[];var _0xf8c4x17;var _0xf8c4x12;_0xf8c4xa[_0x270a[28]]=((_0xf8c4xa[_0x270a[29]]-_0xf8c4xc)>_0xf8c4xa[_0x270a[30]])?_0xf8c4xa[_0x270a[30]]:(_0xf8c4xa[_0x270a[29]]-_0xf8c4xc);switch(_0xf8c4xa[_0x270a[38]]){case _0x270a[35]:_0xf8c4x17=_[_0x270a[31]](_0xf8c4x14);_0xf8c4x12=_0xf8c4x17[_0x270a[32]]();if(_0xf8c4x12){_0xf8c4xa[_0x270a[33]]=[{id:_0xf8c4x12[_0x270a[15]],name:_0xf8c4x12[_0x270a[26]]}];_0xf8c4x16[_0x270a[34]]({id:_0xf8c4x12[_0x270a[15]],name:_0xf8c4x12[_0x270a[26]]});saveReport(_0xf8c4xa)};break;case _0x270a[37]:_0xf8c4xa[_0x270a[33]]=_[_0x270a[36]](_0xf8c4x14,_0xf8c4xf,_0x270a[26]);saveReport(_0xf8c4xa);break;default:};_0xf8c4xe=setTimeout(function(){clearInterval(_0xf8c4xd);return _0xf8c4xb(null,false)},_0xf8c4xa[_0x270a[29]]*1000);_0xf8c4xd=setInterval(function(){_0xf8c4xc+=_0xf8c4xa[_0x270a[30]];return Agent[_0x270a[40]]({where:{id:{$in:_[_0x270a[27]](_0xf8c4xa[_0x270a[14]],_0x270a[15])},online:true,mailPause:false},include:[{model:MailRoom,attributes:[_0x270a[15],_0x270a[23]]}],attributes:[_0x270a[15],_0x270a[26],_0x270a[20]]})[_0x270a[39]](function(_0xf8c4x11){_[_0x270a[18]](_0xf8c4x11,function(_0xf8c4x12){var _0xf8c4x13=_[_0x270a[16]](_0xf8c4xa[_0x270a[14]],{"\x69\x64":_0xf8c4x12[_0x270a[15]]});_0xf8c4x12[_0x270a[17]]=_0xf8c4x13[_0x270a[17]]});_0xf8c4x11=_[_0x270a[19]](_0xf8c4x11,_0x270a[17]);_0xf8c4x14=_[_0x270a[27]](_[_0x270a[25]](_0xf8c4x11,function(_0xf8c4x12){if(_0xf8c4x12[_0x270a[20]]===0){return true}else {return _0xf8c4x12[_0x270a[20]]>_[_0x270a[25]](_0xf8c4x12.MailRooms,function(_0xf8c4x15){return _0xf8c4x15[_0x270a[15]]!==_0xf8c4xa[_0x270a[22]]&&_0xf8c4x15[_0x270a[23]]!==_0x270a[24]})[_0x270a[21]]}}),function(_0xf8c4x12){return {id:_0xf8c4x12[_0x270a[15]],name:_0xf8c4x12[_0x270a[26]]}});_0xf8c4xa[_0x270a[28]]=((_0xf8c4xa[_0x270a[29]]-_0xf8c4xc)>_0xf8c4xa[_0x270a[30]])?_0xf8c4xa[_0x270a[30]]:(_0xf8c4xa[_0x270a[29]]-_0xf8c4xc);switch(_0xf8c4xa[_0x270a[38]]){case _0x270a[35]:_0xf8c4x17=_[_0x270a[36]](_0xf8c4x14,_0xf8c4x16,_0x270a[26]);_0xf8c4x17=_[_0x270a[36]](_0xf8c4x17,_0xf8c4xf,_0x270a[26]);_0xf8c4x12=_0xf8c4x17[_0x270a[32]]();if(_0xf8c4x12){_0xf8c4xa[_0x270a[33]]=[{id:_0xf8c4x12[_0x270a[15]],name:_0xf8c4x12[_0x270a[26]]}];_0xf8c4x16[_0x270a[34]]({id:_0xf8c4x12[_0x270a[15]],name:_0xf8c4x12[_0x270a[26]]});saveReport(_0xf8c4xa)}else {_0xf8c4x16=[];_0xf8c4x14=_[_0x270a[36]](_0xf8c4x14,_0xf8c4xf,_0x270a[26]);_0xf8c4x12=_0xf8c4x14[_0x270a[32]]();if(_0xf8c4x12){_0xf8c4xa[_0x270a[33]]=[{id:_0xf8c4x12[_0x270a[15]],name:_0xf8c4x12[_0x270a[26]]}];_0xf8c4x16[_0x270a[34]]({id:_0xf8c4x12[_0x270a[15]],name:_0xf8c4x12[_0x270a[26]]});saveReport(_0xf8c4xa)}};break;case _0x270a[37]:_0xf8c4xa[_0x270a[33]]=_[_0x270a[36]](_0xf8c4x14,_0xf8c4xf,_0x270a[26]);saveReport(_0xf8c4xa);break;default:}})[_0x270a[13]](function(_0xf8c4x10){console[_0x270a[12]](_0xf8c4x10)})},_0xf8c4xa[_0x270a[30]]*1000)})[_0x270a[13]](function(_0xf8c4x10){console[_0x270a[12]](_0xf8c4x10)});ReportMail[_0x270a[56]](function(_0xf8c4x18){if(_0xf8c4x18[_0x270a[42]](_0x270a[41])){_0xf8c4xf[_0x270a[34]]({id:_0xf8c4x18[_0x270a[43]],name:_0xf8c4x18[_0x270a[44]]})};if(_0xf8c4x18[_0x270a[42]](_0x270a[45])){return MailRoom[_0x270a[55]](_0xf8c4x18[_0x270a[22]])[_0x270a[39]](function(_0xf8c4x19){return _0xf8c4x19[_0x270a[54]](_0xf8c4x18[_0x270a[43]],{individualHooks:true})})[_0x270a[39]](function(){return ReportMailRoom[_0x270a[49]]({application:_0xf8c4x18[_0x270a[50]],memberid:_0xf8c4x18[_0x270a[43]],membername:_0xf8c4x18[_0x270a[44]],queue:_0xf8c4x18[_0x270a[51]],queuename:_0xf8c4x18[_0x270a[52]],leaveAt:moment()[_0x270a[47]](_0x270a[46]),status:_0x270a[53]},{where:{uniqueid:_0xf8c4x18[_0x270a[48]],leaveAt:null},individualHooks:true})})[_0x270a[39]](function(){return ReportMailSession[_0x270a[49]]({memberid:_0xf8c4x18[_0x270a[43]],membername:_0xf8c4x18[_0x270a[44]],leaveAt:moment()[_0x270a[47]](_0x270a[46])},{where:{uniqueid:_0xf8c4x18[_0x270a[48]],leaveAt:null},individualHooks:true})})[_0x270a[39]](function(){clearInterval(_0xf8c4xd);clearTimeout(_0xf8c4xe);return _0xf8c4xb(null,true)})[_0x270a[13]](function(_0xf8c4x10){console[_0x270a[12]](_0xf8c4x10)})}});return {}}function saveReport(_0xf8c4xa){var _0xf8c4x1b=[];for(var _0xf8c4x1c=0;_0xf8c4x1c<_0xf8c4xa[_0x270a[33]][_0x270a[21]];_0xf8c4x1c++){var _0xf8c4x12=_0xf8c4xa[_0x270a[33]][_0xf8c4x1c];_0xf8c4x1b[_0x270a[34]]({uniqueid:_0xf8c4xa[_0x270a[48]],timeslot:_0xf8c4xa[_0x270a[28]],subject:_0xf8c4xa[_0x270a[57]],accountid:_0xf8c4xa[_0x270a[58]],accountname:_0xf8c4xa[_0x270a[59]],accountaddress:_0xf8c4xa[_0x270a[60]],application:_0xf8c4xa[_0x270a[50]],membername:_0xf8c4x12[_0x270a[26]],memberid:_0xf8c4x12[_0x270a[15]],queue:_0xf8c4xa[_0x270a[61]]||null,queuename:_0xf8c4xa[_0x270a[52]]||null,roomid:_0xf8c4xa[_0x270a[22]]||null,messageid:_0xf8c4xa[_0x270a[62]]||null,calledAt:moment()[_0x270a[47]](_0x270a[46]),from:_0xf8c4xa[_0x270a[63]]})};if(_0xf8c4x1b[_0x270a[21]]){return ReportMail[_0x270a[64]](_0xf8c4x1b,{individualHooks:true})[_0x270a[13]](function(_0xf8c4x10){console[_0x270a[12]](_0xf8c4x10)})}}module[_0x270a[65]]=Session