// parse file into xml and update the database\r
if(xml.ParseXML(std::string(data.begin(),data.end()))==true)\r
{\r
+\r
+ // TODO - check if last part of UUID matches public key of identity who inserted it\r
+\r
st=m_db->Prepare("INSERT INTO tblIntroductionPuzzleRequests(IdentityID,Day,RequestIndex,Found,UUID,Type,MimeType,PuzzleData) VALUES(?,?,?,?,?,?,?,?);");\r
st.Bind(0,identityid);\r
st.Bind(1,idparts[4]);\r
st.Step();\r
st.Finalize();\r
\r
- m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" parsed IntroductionPuzzle XML file : "+message["Identifier"]);\r
+ m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"IntroductionPuzzleRequester::HandleAllData parsed IntroductionPuzzle XML file : "+message["Identifier"]);\r
}\r
else\r
{\r
st.Step();\r
st.Finalize();\r
\r
- m_log->WriteLog(LogFile::LOGLEVEL_ERROR,__FUNCTION__" error parsing IntroductionPuzzle XML file : "+message["Identifier"]);\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleAllData error parsing IntroductionPuzzle XML file : "+message["Identifier"]);\r
}\r
\r
// remove this identityid from request list\r
st.Step();\r
st.Finalize();\r
\r
- m_log->WriteLog(LogFile::LOGLEVEL_ERROR,__FUNCTION__" fatal error requesting "+message["Identifier"]);\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleGetFailed fatal error requesting "+message["Identifier"]);\r
}\r
\r
// remove this identityid from request list\r
void IntroductionPuzzleRequester::Initialize()\r
{\r
std::string tempval="";\r
- Option::instance()->Get("MaxIntroductionPuzzleRequests",tempval);\r
+ Option::Instance()->Get("MaxIntroductionPuzzleRequests",tempval);\r
StringFunctions::Convert(tempval,m_maxrequests);\r
if(m_maxrequests<1)\r
{\r
{\r
m_log->WriteLog(LogFile::LOGLEVEL_WARNING,"Option MaxIntroductionPuzzleRequests is currently set at "+tempval+". This value might be incorrectly configured.");\r
}\r
- Option::instance()->Get("MessageBase",m_messagebase);\r
+ Option::Instance()->Get("MessageBase",m_messagebase);\r
m_tempdate.SetToGMTime();\r
}\r
\r
{\r
DateTime now;\r
int id;\r
+ std::string limitnum="30";\r
+\r
+ // if we don't have an identity that we haven't seen yet, then set limit to 5\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT tblLocalIdentity.LocalIdentityID FROM tblLocalIdentity LEFT JOIN tblIdentity ON tblLocalIdentity.PublicKey=tblIdentity.PublicKey WHERE tblIdentity.IdentityID IS NULL;");\r
+ st.Step();\r
+ if(!st.RowReturned())\r
+ {\r
+ limitnum="5";\r
+ }\r
+ st.Finalize();\r
\r
now.SetToGMTime();\r
\r
- // select identities that aren't single use and have been seen today\r
- SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND LastSeen>='"+now.Format("%Y-%m-%d")+"';");\r
+ // select identities that aren't single use and have been seen today ( order by trust DESC and limit to limitnum )\r
+ st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND LastSeen>='"+now.Format("%Y-%m-%d")+"' ORDER BY LocalMessageTrust DESC LIMIT 0,"+limitnum+";");\r
st.Step();\r
\r
m_ids.clear();\r
// this will recheck for ids every minute\r
DateTime now;\r
now.SetToGMTime();\r
- if(m_tempdate<(now-(1.0/1440.0)))\r
+ if(m_ids.size()==0 && m_tempdate<(now-(1.0/1440.0)))\r
{\r
PopulateIDList();\r
m_tempdate=now;\r