X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Fmessage.cpp;h=f8b64e58ac4a964eaa150480b84cdcb06cc9b77a;hp=53d8b34dd1873f233d296f4a9de2ce60f567dfc2;hb=6836fbb5db8464f56e682989996b2210b14231d0;hpb=7ddb1aeb0b3dc7384597e75f7b3557f2d8f6d14c diff --git a/src/message.cpp b/src/message.cpp index 53d8b34..f8b64e5 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -738,8 +738,6 @@ const bool Message::StartFreenetInsert() xml.SetSubject(m_subject); xml.SetBody(m_body); xml.SetReplyBoard(m_replyboardname); - xml.SetDate(m_datetime.Format("%Y-%m-%d")); - xml.SetTime(m_datetime.Format("%H:%M:%S")); for(std::vector::iterator i=m_boards.begin(); i!=m_boards.end(); i++) { @@ -757,10 +755,43 @@ const bool Message::StartFreenetInsert() return false; } - SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblMessageInserts(LocalIdentityID,MessageUUID,MessageXML) VALUES(?,?,?);"); + // add the message delay if there is one + SQLite3DB::Statement st=m_db->Prepare("SELECT MinMessageDelay,MaxMessageDelay FROM tblLocalIdentity WHERE LocalIdentityID=?;"); + st.Bind(0,localidentityid); + st.Step(); + if(st.RowReturned()) + { + int min=0; + int max=0; + st.ResultInt(0,min); + st.ResultInt(1,max); + + min<0 ? min=0 : false; + max<0 ? max=0 : false; + min>max ? min=max : false; + + if(min==max) + { + m_datetime.Add(0,min); + } + else if(max>min) + { + int delay=(rand()%(max-min))+min; + m_datetime.Add(0,delay); + } + + } + st.Finalize(); + + // set date in xml file AFTER we set the delay + xml.SetDate(m_datetime.Format("%Y-%m-%d")); + xml.SetTime(m_datetime.Format("%H:%M:%S")); + + st=m_db->Prepare("INSERT INTO tblMessageInserts(LocalIdentityID,MessageUUID,MessageXML,SendDate) VALUES(?,?,?,?);"); st.Bind(0,localidentityid); st.Bind(1,m_messageuuid); st.Bind(2,xml.GetXML()); + st.Bind(3,m_datetime.Format("%Y-%m-%d %H:%M:%S")); st.Step(); // insert file attachments into database