X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Ffreenet%2Fboardlistinserter.cpp;h=69ca3622234870feaa5007ab4713a20f2120b3ec;hp=6099ff67cac5f786153b801e7ea1cd1f4fb9069a;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hpb=9b22dd53fe62e312c1647310b7ec43aa127090af diff --git a/src/freenet/boardlistinserter.cpp b/src/freenet/boardlistinserter.cpp index 6099ff6..69ca362 100644 --- a/src/freenet/boardlistinserter.cpp +++ b/src/freenet/boardlistinserter.cpp @@ -1,6 +1,10 @@ #include "../../include/freenet/boardlistinserter.h" #include "../../include/freenet/boardlistxml.h" +#include +#include +#include + #ifdef XMEM #include #endif @@ -20,19 +24,16 @@ void BoardListInserter::CheckForNeededInsert() // only do 1 insert at a time if(m_inserting.size()==0) { - DateTime today; - DateTime daysback; - - today.SetToGMTime(); - daysback.SetToGMTime(); + Poco::DateTime today; + Poco::DateTime daysback; - // 20 days - daysback.Add(0,0,0,-20); + // 20 days back + daysback-=Poco::Timespan(20,0,0,0,0); // get identities who posted messages to boards in the past 20 days SQLite3DB::Statement st=m_db->Prepare("SELECT tblLocalIdentity.LocalIdentityID FROM tblLocalIdentity INNER JOIN tblMessageInserts ON tblLocalIdentity.LocalIdentityID=tblMessageInserts.LocalIdentityID WHERE tblLocalIdentity.PublishBoardList='true' AND (tblLocalIdentity.LastInsertedBoardList=? GROUP BY tblLocalIdentity.LocalIdentityID;"); - st.Bind(0,today.Format("%Y-%m-%d")); - st.Bind(1,daysback.Format("%Y-%m-%d")); + st.Bind(0,Poco::DateTimeFormatter::format(today,"%Y-%m-%d")); + st.Bind(1,Poco::DateTimeFormatter::format(daysback,"%Y-%m-%d")); st.Step(); if(st.RowReturned()) @@ -70,7 +71,7 @@ const bool BoardListInserter::HandlePutFailed(FCPMessage &message) const bool BoardListInserter::HandlePutSuccessful(FCPMessage &message) { - DateTime now; + Poco::DateTime now; std::vector idparts; long localidentityid; long index; @@ -85,15 +86,14 @@ const bool BoardListInserter::HandlePutSuccessful(FCPMessage &message) st.Bind(2,index); st.Step(); - now.SetToGMTime(); st=m_db->Prepare("UPDATE tblLocalIdentity SET LastInsertedBoardList=? WHERE LocalIdentityID=?;"); - st.Bind(0,now.Format("%Y-%m-%d %H:%M:%S")); + st.Bind(0,Poco::DateTimeFormatter::format(now,"%Y-%m-%d %H:%M:%S")); st.Bind(1,localidentityid); st.Step(); RemoveFromInsertList(localidentityid); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"BoardListInserter::HandlePutSuccessful successfully inserted BoardList."); + m_log->debug("BoardListInserter::HandlePutSuccessful successfully inserted BoardList."); return true; } @@ -105,8 +105,8 @@ void BoardListInserter::Initialize() const bool BoardListInserter::StartInsert(const long &localidentityid) { - DateTime daysback; - DateTime now; + Poco::DateTime daysback; + Poco::DateTime now; BoardListXML xml; FCPMessage message; std::string data; @@ -116,14 +116,13 @@ const bool BoardListInserter::StartInsert(const long &localidentityid) std::string indexstr=""; std::string localidentityidstr; - now.SetToGMTime(); - daysback.SetToGMTime(); - daysback.Add(0,0,0,-20); + // 20 days back + daysback-=Poco::Timespan(20,0,0,0,0); // get boards SQLite3DB::Statement st=m_db->Prepare("SELECT BoardName,BoardDescription FROM tblBoard INNER JOIN tblMessageBoard ON tblBoard.BoardID=tblMessageBoard.BoardID INNER JOIN tblMessage ON tblMessageBoard.MessageID=tblMessage.MessageID INNER JOIN tblMessageInserts ON tblMessage.MessageUUID=tblMessageInserts.MessageUUID WHERE tblMessageInserts.LocalIdentityID=? AND tblMessageInserts.Day>=? GROUP BY tblBoard.BoardID;"); st.Bind(0,localidentityid); - st.Bind(1,daysback.Format("%Y-%m-%d")); + st.Bind(1,Poco::DateTimeFormatter::format(daysback,"%Y-%m-%d")); st.Step(); while(st.RowReturned()) @@ -152,7 +151,7 @@ const bool BoardListInserter::StartInsert(const long &localidentityid) index=0; st=m_db->Prepare("SELECT MAX(InsertIndex) FROM tblBoardListInserts WHERE LocalIdentityID=? AND Day=?;"); st.Bind(0,localidentityid); - st.Bind(1,now.Format("%Y-%m-%d")); + st.Bind(1,Poco::DateTimeFormatter::format(now,"%Y-%m-%d")); st.Step(); if(st.RowReturned()) { @@ -169,7 +168,7 @@ const bool BoardListInserter::StartInsert(const long &localidentityid) StringFunctions::Convert(localidentityid,localidentityidstr); message.SetName("ClientPut"); - message["URI"]=privatekey+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|BoardList|"+indexstr+".xml"; + message["URI"]=privatekey+m_messagebase+"|"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"|BoardList|"+indexstr+".xml"; message["Identifier"]=m_fcpuniquename+"|"+localidentityidstr+"|"+indexstr+"|"+message["URI"]; message["UploadFrom"]="direct"; message["DataLength"]=datasizestr;