1 #include "../../include/freenet/inactivemessagelistrequester.h"
\r
3 #include <Poco/DateTimeFormatter.h>
\r
9 InactiveMessageListRequester::InactiveMessageListRequester()
\r
14 InactiveMessageListRequester::InactiveMessageListRequester(FCPv2::Connection *fcp):MessageListRequester(fcp)
\r
19 void InactiveMessageListRequester::Initialize()
\r
21 m_fcpuniquename="InactiveMessageListRequester";
\r
22 std::string tempval="";
\r
25 Option::Instance()->GetInt("MaxMessageListRequests",m_maxrequests);
\r
27 // inactive identities get 1/2 of the max requests option - active identities get 1/2 + any remaining if not evenly divisible
\r
28 m_maxrequests=(m_maxrequests/2);
\r
33 m_log->error("Option MaxMessageListRequests is currently set at "+tempval+". It must be 1 or greater.");
\r
35 if(m_maxrequests>100)
\r
37 m_log->warning("Option MaxMessageListRequests is currently set at "+tempval+". This value might be incorrectly configured.");
\r
41 Option::Instance()->Get("LocalTrustOverridesPeerTrust",tempval);
\r
44 m_localtrustoverrides=true;
\r
48 m_localtrustoverrides=false;
\r
52 Option::Instance()->Get("SaveMessagesFromNewBoards",tempval);
\r
55 m_savetonewboards=true;
\r
59 m_savetonewboards=false;
\r
62 m_messagedownloadmaxdaysbackward=5;
\r
64 Option::Instance()->Get("MessageDownloadMaxDaysBackward",tempval);
\r
65 StringFunctions::Convert(tempval,m_messagedownloadmaxdaysbackward);
\r
69 void InactiveMessageListRequester::PopulateIDList()
\r
71 Poco::DateTime date;
\r
72 Poco::DateTime yesterday=date-Poco::Timespan(1,0,0,0,0);
\r
75 SQLite3DB::Statement st;
\r
77 // select identities we want to query (we've seen them today) - sort by their trust level (descending) with secondary sort on how long ago we saw them (ascending)
\r
78 if(m_localtrustoverrides==false)
\r
80 st=m_db->Prepare("SELECT tblIdentity.IdentityID FROM tblIdentity INNER JOIN vwIdentityStats ON tblIdentity.IdentityID=vwIdentityStats.IdentityID WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen>='"+Poco::DateTimeFormatter::format(date,"%Y-%m-%d")+"' AND (vwIdentityStats.LastMessageDate IS NULL OR vwIdentityStats.LastMessageDate<'"+Poco::DateTimeFormatter::format(yesterday,"%Y-%m-%d")+"') AND (LocalMessageTrust IS NULL OR LocalMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalMessageTrust')) AND (PeerMessageTrust IS NULL OR PeerMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerMessageTrust')) ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;");
\r
84 st=m_db->Prepare("SELECT tblIdentity.IdentityID FROM tblIdentity INNER JOIN vwIdentityStats ON tblIdentity.IdentityID=vwIdentityStats.IdentityID WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen>='"+Poco::DateTimeFormatter::format(date,"%Y-%m-%d")+"' AND (vwIdentityStats.LastMessageDate IS NULL OR vwIdentityStats.LastMessageDate<'"+Poco::DateTimeFormatter::format(yesterday,"%Y-%m-%d")+"') AND (LocalMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalMessageTrust') OR (LocalMessageTrust IS NULL AND (PeerMessageTrust IS NULL OR PeerMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerMessageTrust')))) ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;");
\r
90 while(st.RowReturned())
\r