4fce81e3995f35892964f1e4c9e1c34ef8f5b195
[motion.git] / server / config / routing / fax / session.js
1 var _0xa237=["\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","\x46\x61\x78\x52\x6F\x6F\x6D","\x46\x61\x78\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x52\x65\x70\x6F\x72\x74\x46\x61\x78","\x52\x65\x70\x6F\x72\x74\x46\x61\x78\x52\x6F\x6F\x6D","\x52\x65\x70\x6F\x72\x74\x46\x61\x78\x53\x65\x73\x73\x69\x6F\x6E","\x4E\x65\x77\x20\x46\x61\x78\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","\x66\x61\x78\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\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","\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\x70\x68\x6F\x6E\x65","\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"];_0xa237[0];var _=require(_0xa237[1]);var moment=require(_0xa237[2]);var Agent=require(_0xa237[4])[_0xa237[3]];var FaxRoom=require(_0xa237[4])[_0xa237[5]];var FaxApplication=require(_0xa237[4])[_0xa237[6]];var ReportFax=require(_0xa237[4])[_0xa237[7]];var ReportFaxRoom=require(_0xa237[4])[_0xa237[8]];var ReportFaxSession=require(_0xa237[4])[_0xa237[9]];function Session(_0x4ffexa,_0x4ffexb){console[_0xa237[11]](_0xa237[10]);var _0x4ffexc=0;var _0x4ffexd,_0x4ffexe;var _0x4ffexf=[];Agent[_0xa237[40]]({where:{id:{$in:_[_0xa237[27]](_0x4ffexa[_0xa237[14]],_0xa237[15])},online:true,faxPause:false},include:[{model:FaxRoom,attributes:[_0xa237[15],_0xa237[23]]}],attributes:[_0xa237[15],_0xa237[26],_0xa237[20]]})[_0xa237[39]](function(_0x4ffex11){_[_0xa237[18]](_0x4ffex11,function(_0x4ffex12){var _0x4ffex13=_[_0xa237[16]](_0x4ffexa[_0xa237[14]],{"\x69\x64":_0x4ffex12[_0xa237[15]]});_0x4ffex12[_0xa237[17]]=_0x4ffex13[_0xa237[17]]});_0x4ffex11=_[_0xa237[19]](_0x4ffex11,_0xa237[17]);var _0x4ffex14=_[_0xa237[27]](_[_0xa237[25]](_0x4ffex11,function(_0x4ffex12){if(_0x4ffex12[_0xa237[20]]===0){return true}else {return _0x4ffex12[_0xa237[20]]>_[_0xa237[25]](_0x4ffex12.FaxRooms,function(_0x4ffex15){return _0x4ffex15[_0xa237[15]]!==_0x4ffexa[_0xa237[22]]&&_0x4ffex15[_0xa237[23]]!==_0xa237[24]})[_0xa237[21]]}}),function(_0x4ffex12){return {id:_0x4ffex12[_0xa237[15]],name:_0x4ffex12[_0xa237[26]]}});var _0x4ffex16=[];var _0x4ffex17;var _0x4ffex12;_0x4ffexa[_0xa237[28]]=((_0x4ffexa[_0xa237[29]]-_0x4ffexc)>_0x4ffexa[_0xa237[30]])?_0x4ffexa[_0xa237[30]]:(_0x4ffexa[_0xa237[29]]-_0x4ffexc);switch(_0x4ffexa[_0xa237[38]]){case _0xa237[35]:_0x4ffex17=_[_0xa237[31]](_0x4ffex14);_0x4ffex12=_0x4ffex17[_0xa237[32]]();if(_0x4ffex12){_0x4ffexa[_0xa237[33]]=[{id:_0x4ffex12[_0xa237[15]],name:_0x4ffex12[_0xa237[26]]}];_0x4ffex16[_0xa237[34]]({id:_0x4ffex12[_0xa237[15]],name:_0x4ffex12[_0xa237[26]]});saveReport(_0x4ffexa)};break;case _0xa237[37]:_0x4ffexa[_0xa237[33]]=_[_0xa237[36]](_0x4ffex14,_0x4ffexf,_0xa237[26]);saveReport(_0x4ffexa);break;default:};_0x4ffexe=setTimeout(function(){clearInterval(_0x4ffexd);return _0x4ffexb(null,false)},_0x4ffexa[_0xa237[29]]*1000);_0x4ffexd=setInterval(function(){_0x4ffexc+=_0x4ffexa[_0xa237[30]];return Agent[_0xa237[40]]({where:{id:{$in:_[_0xa237[27]](_0x4ffexa[_0xa237[14]],_0xa237[15])},online:true,faxPause:false},include:[{model:FaxRoom,attributes:[_0xa237[15],_0xa237[23]]}],attributes:[_0xa237[15],_0xa237[26],_0xa237[20]]})[_0xa237[39]](function(_0x4ffex11){_[_0xa237[18]](_0x4ffex11,function(_0x4ffex12){var _0x4ffex13=_[_0xa237[16]](_0x4ffexa[_0xa237[14]],{"\x69\x64":_0x4ffex12[_0xa237[15]]});_0x4ffex12[_0xa237[17]]=_0x4ffex13[_0xa237[17]]});_0x4ffex11=_[_0xa237[19]](_0x4ffex11,_0xa237[17]);_0x4ffex14=_[_0xa237[27]](_[_0xa237[25]](_0x4ffex11,function(_0x4ffex12){if(_0x4ffex12[_0xa237[20]]===0){return true}else {return _0x4ffex12[_0xa237[20]]>_[_0xa237[25]](_0x4ffex12.FaxRooms,function(_0x4ffex15){return _0x4ffex15[_0xa237[15]]!==_0x4ffexa[_0xa237[22]]&&_0x4ffex15[_0xa237[23]]!==_0xa237[24]})[_0xa237[21]]}}),function(_0x4ffex12){return {id:_0x4ffex12[_0xa237[15]],name:_0x4ffex12[_0xa237[26]]}});_0x4ffexa[_0xa237[28]]=((_0x4ffexa[_0xa237[29]]-_0x4ffexc)>_0x4ffexa[_0xa237[30]])?_0x4ffexa[_0xa237[30]]:(_0x4ffexa[_0xa237[29]]-_0x4ffexc);switch(_0x4ffexa[_0xa237[38]]){case _0xa237[35]:_0x4ffex17=_[_0xa237[36]](_0x4ffex14,_0x4ffex16,_0xa237[26]);_0x4ffex17=_[_0xa237[36]](_0x4ffex17,_0x4ffexf,_0xa237[26]);_0x4ffex12=_0x4ffex17[_0xa237[32]]();if(_0x4ffex12){_0x4ffexa[_0xa237[33]]=[{id:_0x4ffex12[_0xa237[15]],name:_0x4ffex12[_0xa237[26]]}];_0x4ffex16[_0xa237[34]]({id:_0x4ffex12[_0xa237[15]],name:_0x4ffex12[_0xa237[26]]});saveReport(_0x4ffexa)}else {_0x4ffex16=[];_0x4ffex14=_[_0xa237[36]](_0x4ffex14,_0x4ffexf,_0xa237[26]);_0x4ffex12=_0x4ffex14[_0xa237[32]]();if(_0x4ffex12){_0x4ffexa[_0xa237[33]]=[{id:_0x4ffex12[_0xa237[15]],name:_0x4ffex12[_0xa237[26]]}];_0x4ffex16[_0xa237[34]]({id:_0x4ffex12[_0xa237[15]],name:_0x4ffex12[_0xa237[26]]});saveReport(_0x4ffexa)}};break;case _0xa237[37]:_0x4ffexa[_0xa237[33]]=_[_0xa237[36]](_0x4ffex14,_0x4ffexf,_0xa237[26]);saveReport(_0x4ffexa);break;default:}})[_0xa237[13]](function(_0x4ffex10){console[_0xa237[12]](_0x4ffex10)})},_0x4ffexa[_0xa237[30]]*1000)})[_0xa237[13]](function(_0x4ffex10){console[_0xa237[12]](_0x4ffex10)});ReportFax[_0xa237[56]](function(_0x4ffex18){if(_0x4ffex18[_0xa237[42]](_0xa237[41])){_0x4ffexf[_0xa237[34]]({id:_0x4ffex18[_0xa237[43]],name:_0x4ffex18[_0xa237[44]]})};if(_0x4ffex18[_0xa237[42]](_0xa237[45])){return FaxRoom[_0xa237[55]](_0x4ffex18[_0xa237[22]])[_0xa237[39]](function(_0x4ffex19){return _0x4ffex19[_0xa237[54]](_0x4ffex18[_0xa237[43]],{individualHooks:true})})[_0xa237[39]](function(){return ReportFaxRoom[_0xa237[49]]({application:_0x4ffex18[_0xa237[50]],memberid:_0x4ffex18[_0xa237[43]],membername:_0x4ffex18[_0xa237[44]],queue:_0x4ffex18[_0xa237[51]],queuename:_0x4ffex18[_0xa237[52]],leaveAt:moment()[_0xa237[47]](_0xa237[46]),status:_0xa237[53]},{where:{uniqueid:_0x4ffex18[_0xa237[48]],leaveAt:null},individualHooks:true})})[_0xa237[39]](function(){return ReportFaxSession[_0xa237[49]]({memberid:_0x4ffex18[_0xa237[43]],membername:_0x4ffex18[_0xa237[44]],leaveAt:moment()[_0xa237[47]](_0xa237[46])},{where:{uniqueid:_0x4ffex18[_0xa237[48]],leaveAt:null},individualHooks:true})})[_0xa237[39]](function(){clearInterval(_0x4ffexd);clearTimeout(_0x4ffexe);return _0x4ffexb(null,true)})[_0xa237[13]](function(_0x4ffex10){console[_0xa237[12]](_0x4ffex10)})}});return {}}function saveReport(_0x4ffexa){var _0x4ffex1b=[];for(var _0x4ffex1c=0;_0x4ffex1c<_0x4ffexa[_0xa237[33]][_0xa237[21]];_0x4ffex1c++){var _0x4ffex12=_0x4ffexa[_0xa237[33]][_0x4ffex1c];_0x4ffex1b[_0xa237[34]]({uniqueid:_0x4ffexa[_0xa237[48]],timeslot:_0x4ffexa[_0xa237[28]],subject:_0x4ffexa[_0xa237[57]],accountid:_0x4ffexa[_0xa237[58]],accountname:_0x4ffexa[_0xa237[59]],accountphone:_0x4ffexa[_0xa237[60]],application:_0x4ffexa[_0xa237[50]],membername:_0x4ffex12[_0xa237[26]],memberid:_0x4ffex12[_0xa237[15]],queue:_0x4ffexa[_0xa237[51]]||null,queuename:_0x4ffexa[_0xa237[52]]||null,roomid:_0x4ffexa[_0xa237[22]]||null,messageid:_0x4ffexa[_0xa237[61]]||null,calledAt:moment()[_0xa237[47]](_0xa237[46]),from:_0x4ffexa[_0xa237[62]]})};if(_0x4ffex1b[_0xa237[21]]){return ReportFax[_0xa237[63]](_0x4ffex1b,{individualHooks:true})[_0xa237[13]](function(_0x4ffex10){console[_0xa237[12]](_0x4ffex10)})}}module[_0xa237[64]]=Session