X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmessage.cpp;h=f4a6ea6eaba0dbb1c4f1253b1f3aefa64b4f0ab8;hb=4430e7762844c66428b6f822288beb71b7f82b95;hp=41add1081e9d0acca8ec5e8585cae1fea11c6b9e;hpb=52c0819bfc1d083c6e0738f75f0d7eeba521295a;p=fms.git diff --git a/src/message.cpp b/src/message.cpp index 41add10..f4a6ea6 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -140,8 +140,22 @@ void Message::HandleAdministrationMessage() { origmess.ResultInt(0,identityid); origmess.ResultText(1,identityname); - origmess.ResultInt(2,origmessagetrust); - origmess.ResultInt(3,origtrustlisttrust); + if(origmess.ResultNull(2)==false) + { + origmess.ResultInt(2,origmessagetrust); + } + else + { + origmessagetrust=50; + } + if(origmess.ResultNull(3)==false) + { + origmess.ResultInt(3,origtrustlisttrust); + } + else + { + origtrustlisttrust=50; + } origmessagetrust+=changemessagetrust; origtrustlisttrust+=changetrustlisttrust; @@ -222,7 +236,14 @@ void Message::HandleChangeTrust() int localmessagetrust=0; st.ResultInt(0,identityid); - st.ResultInt(1,localmessagetrust); + if(st.ResultNull(1)==false) + { + st.ResultInt(1,localmessagetrust); + } + else + { + localmessagetrust=50; + } localmessagetrust+=m_changemessagetrustonreply; if(localmessagetrust<0) @@ -258,6 +279,15 @@ void Message::Initialize() m_changemessagetrustonreply=0; Option::Instance()->Get("ChangeMessageTrustOnReply",tempval); StringFunctions::Convert(tempval,m_changemessagetrustonreply); + Option::Instance()->Get("AddNewPostFromIdentities",tempval); + if(tempval=="true") + { + m_addnewpostfromidentities=true; + } + else + { + m_addnewpostfromidentities=false; + } } const bool Message::Load(const long messageid, const long boardid) @@ -587,7 +617,7 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage) return true; } -void Message::StartFreenetInsert() +const bool Message::StartFreenetInsert() { MessageXML xml; @@ -600,6 +630,7 @@ void Message::StartFreenetInsert() xml.SetDate(m_datetime.Format("%Y-%m-%d")); xml.SetTime(m_datetime.Format("%H:%M:%S")); + StripAdministrationBoards(); for(std::vector::iterator i=m_boards.begin(); i!=m_boards.end(); i++) { xml.AddBoard((*i)); @@ -618,12 +649,19 @@ void Message::StartFreenetInsert() // couldn't find identity with this name - insert a new identity if(!st.RowReturned()) { - DateTime now; - now.SetToGMTime(); - st=m_db->Prepare("INSERT INTO tblLocalIdentity(Name) VALUES(?);"); - st.Bind(0,m_fromname); - st.Step(true); - localidentityid=st.GetLastInsertRowID(); + if(m_addnewpostfromidentities==true) + { + DateTime now; + now.SetToGMTime(); + st=m_db->Prepare("INSERT INTO tblLocalIdentity(Name) VALUES(?);"); + st.Bind(0,m_fromname); + st.Step(true); + localidentityid=st.GetLastInsertRowID(); + } + else + { + return false; + } } else { @@ -638,4 +676,25 @@ void Message::StartFreenetInsert() HandleChangeTrust(); + return true; + +} + +void Message::StripAdministrationBoards() +{ + SQLite3DB::Statement st=m_db->Prepare("SELECT tblBoard.BoardID FROM tblBoard INNER JOIN tblAdministrationBoard ON tblBoard.BoardID=tblAdministrationBoard.BoardID WHERE BoardName=?;"); + for(std::vector::iterator i=m_boards.begin(); i!=m_boards.end(); ) + { + st.Bind(0,(*i)); + st.Step(); + if(st.RowReturned()) + { + i=m_boards.erase(i); + } + else + { + i++; + } + st.Reset(); + } }