X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmessage.cpp;h=53d8b34dd1873f233d296f4a9de2ce60f567dfc2;hb=14fff12d9df0ee30e2df4bf9d22c2e83065816df;hp=c0bed87b95d924608af95d2a9bd73a78d5ecda79;hpb=52581afffd81f5a71c129d87e3ac822d9522f12d;p=fms.git diff --git a/src/message.cpp b/src/message.cpp index c0bed87..53d8b34 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -696,8 +696,9 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage) m_body+=bodypart; } // add a binary file attachment - else if((*i)->GetName()!="" && (*i)->GetLength()>0 && (*i)->GetContent()) + else if(((*i)->GetName()!="" || (*i)->GetFilename()!="") && (*i)->GetLength()>0 && (*i)->GetContent()) { + std::string filename=""; std::string contenttype=""; std::vector data((*i)->GetContent(),(*i)->GetContent()+(*i)->GetContentLength()); if((*i)->GetContentType()) @@ -710,7 +711,12 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage) contenttype.erase(endpos); } } - m_fileattachments.push_back(fileattachment((*i)->GetName(),contenttype,data)); + filename=(*i)->GetFilename(); + if(filename=="") + { + filename=(*i)->GetName(); + } + m_fileattachments.push_back(fileattachment(filename,contenttype,data)); } } @@ -723,50 +729,56 @@ const bool Message::StartFreenetInsert() MessageXML xml; int localidentityid=-1; - xml.SetMessageID(m_messageuuid); - 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")); - StripAdministrationBoards(); - for(std::vector::iterator i=m_boards.begin(); i!=m_boards.end(); i++) - { - xml.AddBoard((*i)); - } - - for(std::map::iterator j=m_inreplyto.begin(); j!=m_inreplyto.end(); j++) - { - xml.AddInReplyTo((*j).first,(*j).second); - } - localidentityid=FindLocalIdentityID(m_fromname); - if(localidentityid==-1) + if(m_boards.size()>0) { - return false; - } - SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblMessageInserts(LocalIdentityID,MessageUUID,MessageXML) VALUES(?,?,?);"); - st.Bind(0,localidentityid); - st.Bind(1,m_messageuuid); - st.Bind(2,xml.GetXML()); - st.Step(); + xml.SetMessageID(m_messageuuid); + 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++) + { + xml.AddBoard((*i)); + } + + for(std::map::iterator j=m_inreplyto.begin(); j!=m_inreplyto.end(); j++) + { + xml.AddInReplyTo((*j).first,(*j).second); + } - // insert file attachments into database - st=m_db->Prepare("INSERT INTO tblFileInserts(MessageUUID,FileName,Size,MimeType,Data) VALUES(?,?,?,?,?);"); - for(std::vector::iterator i=m_fileattachments.begin(); i!=m_fileattachments.end(); i++) - { - st.Bind(0,m_messageuuid); - st.Bind(1,(*i).m_filename); - st.Bind(2,(long)(*i).m_data.size()); - st.Bind(3,(*i).m_mimetype); - st.Bind(4,&((*i).m_data[0]),(*i).m_data.size()); + localidentityid=FindLocalIdentityID(m_fromname); + if(localidentityid==-1) + { + return false; + } + + SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblMessageInserts(LocalIdentityID,MessageUUID,MessageXML) VALUES(?,?,?);"); + st.Bind(0,localidentityid); + st.Bind(1,m_messageuuid); + st.Bind(2,xml.GetXML()); st.Step(); - st.Reset(); - } - HandleChangeTrust(); + // insert file attachments into database + st=m_db->Prepare("INSERT INTO tblFileInserts(MessageUUID,FileName,Size,MimeType,Data) VALUES(?,?,?,?,?);"); + for(std::vector::iterator i=m_fileattachments.begin(); i!=m_fileattachments.end(); i++) + { + st.Bind(0,m_messageuuid); + st.Bind(1,(*i).m_filename); + st.Bind(2,(long)(*i).m_data.size()); + st.Bind(3,(*i).m_mimetype); + st.Bind(4,&((*i).m_data[0]),(*i).m_data.size()); + st.Step(); + st.Reset(); + } + + HandleChangeTrust(); + + } return true;