X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Ffreenet%2Fmessagerequester.cpp;h=07faaf98d4d74f0301c468bd351fc22dc7da3f40;hp=d58494b1d731960aecb67dfee8d5d1b16de80142;hb=df316253862dc50e8e5a790d9634ef90be37badb;hpb=f60495a029c54358f82956482fe203fe2b7b5b23 diff --git a/src/freenet/messagerequester.cpp b/src/freenet/messagerequester.cpp index d58494b..07faaf9 100644 --- a/src/freenet/messagerequester.cpp +++ b/src/freenet/messagerequester.cpp @@ -1,6 +1,8 @@ #include "../../include/freenet/messagerequester.h" #include "../../include/freenet/messagexml.h" +#include + #ifdef XMEM #include #endif @@ -113,6 +115,10 @@ const bool MessageRequester::HandleAllData(FCPMessage &message) if(xml.ParseXML(std::string(data.begin(),data.end()))==true) { std::vector boards=xml.GetBoards(); + if(boards.size()>m_maxboardspermessage) + { + boards.resize(m_maxboardspermessage); + } if(boards.size()<=0) { @@ -124,6 +130,12 @@ const bool MessageRequester::HandleAllData(FCPMessage &message) m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"MessageRequester::HandleAllData Message XML did not contain a reply board! "+message["Identifier"]); return true; } + + // make sure the reply board is on the board list - if not, replace the last element of boardswith the reply board + if(xml.GetReplyBoard()!="" && std::find(boards.begin(),boards.end(),xml.GetReplyBoard())==boards.end() && boards.size()>0) + { + boards[boards.size()-1]=xml.GetReplyBoard(); + } st=m_db->Prepare("INSERT INTO tblMessage(IdentityID,FromName,MessageDate,MessageTime,Subject,MessageUUID,ReplyBoardID,Body) VALUES(?,?,?,?,?,?,?,?);"); st.Bind(0,identityid); @@ -252,6 +264,17 @@ void MessageRequester::Initialize() { m_log->WriteLog(LogFile::LOGLEVEL_WARNING,"Option MaxPeerMessagesPerDay is currently set at "+tempval+". This value might be incorrectly configured. The suggested value is 200."); } + Option::Instance()->Get("MaxBoardsPerMessage",tempval); + StringFunctions::Convert(tempval,m_maxboardspermessage); + if(m_maxboardspermessage<1) + { + m_maxboardspermessage=1; + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"Option MaxBoardsPerMessage is currently set at "+tempval+". It must be 1 or greater."); + } + if(m_maxboardspermessage>20) + { + m_log->WriteLog(LogFile::LOGLEVEL_WARNING,"Option MaxBoardsPerMessage is currently set at "+tempval+". This value might be incorrectly configured."); + } } void MessageRequester::PopulateIDList()