X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Ftrustlistinserter.cpp;h=79745ee53e072f6969af538edf19e2363af263aa;hb=175f098e7e712b839db433b93fe8649a402c6784;hp=6cd8843349023dc959bff8153d1c05f3e73b336c;hpb=964f55fd550fc711c0320ce6a24ad713040695d0;p=fms.git diff --git a/src/freenet/trustlistinserter.cpp b/src/freenet/trustlistinserter.cpp index 6cd8843..79745ee 100644 --- a/src/freenet/trustlistinserter.cpp +++ b/src/freenet/trustlistinserter.cpp @@ -21,7 +21,13 @@ void TrustListInserter::CheckForNeededInsert() { DateTime date; date.SetToGMTime(); - date.Add(0,0,-1); + int currentday=date.GetDay(); + date.Add(0,0,-6); + // insert trust lists every 6 hours - if 6 hours ago was different day then set to midnight of current day to insert list today ASAP + if(currentday!=date.GetDay()) + { + date.Set(date.GetYear(),date.GetMonth(),currentday); + } SQLite3DB::Recordset rs=m_db->Query("SELECT LocalIdentityID, PrivateKey FROM tblLocalIdentity WHERE PrivateKey IS NOT NULL AND PrivateKey <> '' AND PublishTrustList='true' AND InsertingTrustList='false' AND (LastInsertedTrustList<='"+date.Format("%Y-%m-%d %H:%M:%S")+"' OR LastInsertedTrustList IS NULL);"); if(rs.Empty()==false) @@ -93,7 +99,7 @@ const bool TrustListInserter::HandleMessage(FCPMessage &message) void TrustListInserter::Initialize() { - Option::instance()->Get("MessageBase",m_messagebase); + Option::Instance()->Get("MessageBase",m_messagebase); m_lastchecked.SetToGMTime(); } @@ -130,21 +136,39 @@ void TrustListInserter::StartInsert(const long localidentityid, const std::strin int index; std::string indexstr; std::string localidentityidstr; + std::string messagetrustcomment=""; + std::string trustlisttrustcomment=""; now.SetToGMTime(); date.SetToGMTime(); // build the xml file - we only want to add identities that we recently saw, otherwise we could be inserting a ton of identities date.Add(0,0,0,-20); // identities seen in last 20 days - SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey, LocalMessageTrust, LocalTrustListTrust FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey<>'' AND LastSeen>=?;"); + SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey, LocalMessageTrust, LocalTrustListTrust, MessageTrustComment, TrustListTrustComment FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey<>'' AND LastSeen>=?;"); st.Bind(0,date.Format("%Y-%m-%d")); st.Step(); while(st.RowReturned()) { st.ResultText(0,publickey); - st.ResultInt(1,messagetrust); - st.ResultInt(2,trustlisttrust); - xml.AddTrust(publickey,messagetrust,trustlisttrust); + if(st.ResultNull(1)==false) + { + st.ResultInt(1,messagetrust); + } + else + { + messagetrust=-1; + } + if(st.ResultNull(2)==false) + { + st.ResultInt(2,trustlisttrust); + } + else + { + trustlisttrust=-1; + } + st.ResultText(3,messagetrustcomment); + st.ResultText(4,trustlisttrustcomment); + xml.AddTrust(publickey,messagetrust,trustlisttrust,messagetrustcomment,trustlisttrustcomment); st.Step(); }