X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Fmessage.cpp;fp=src%2Fmessage.cpp;h=0445e294e71125b5612aae3978b82a1b83456b12;hp=8a3935de8d926f980e447b0fc0768c28d6e5150e;hb=221236a4d3aac4144529d418ce368db5c98facb0;hpb=d5c9f7e6c1dd263dfc85a3cb5941a378a5ddd923 diff --git a/src/message.cpp b/src/message.cpp index 8a3935d..0445e29 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -49,6 +49,63 @@ const bool Message::CheckForAdministrationBoard(const std::vector & return false; } +const bool Message::Create(const long localidentityid, const long boardid, const std::string &subject, const std::string &body, const std::string &references) +{ + Initialize(); + + Poco::UUIDGenerator uuidgen; + Poco::UUID uuid; + + // get header info + // date is always set to now regardless of what message has + m_datetime=Poco::Timestamp(); + + // messageuuid is always a unique id we generate regardless of message message-id + try + { + uuid=uuidgen.createRandom(); + m_messageuuid=uuid.toString(); + StringFunctions::UpperCase(m_messageuuid,m_messageuuid); + } + catch(...) + { + m_log->fatal("Message::ParseNNTPMessage could not create UUID"); + } + + // get from + SQLite3DB::Statement st=m_db->Prepare("SELECT Name FROM tblLocalIdentity WHERE LocalIdentityID=?;"); + st.Bind(0,localidentityid); + st.Step(); + if(st.RowReturned()) + { + st.ResultText(0,m_fromname); + } + + // get boards posted to + std::string boardname=""; + SQLite3DB::Statement boardst=m_db->Prepare("SELECT BoardName FROM tblBoard WHERE BoardID=?;"); + boardst.Bind(0,boardid); + boardst.Step(); + if(boardst.RowReturned()) + { + boardst.ResultText(0,boardname); + } + + m_boards.push_back(boardname); + m_replyboardname=boardname; + + m_subject=subject; + + m_body=body; + + if(references!="") + { + m_inreplyto[0]=references; + } + + return true; +} + const int Message::FindLocalIdentityID(const std::string &name) { SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID FROM tblLocalIdentity WHERE Name=?;");