added test to prevent msgs with a different name to be used as different version

This commit is contained in:
csoler 2017-02-28 18:05:44 +01:00
parent 763f2271a8
commit bd8189ccdf

View File

@ -204,18 +204,24 @@ void GxsForumsFillThread::run()
#endif
std::map<RsGxsMessageId,RsGxsForumMsg>::iterator msgIt2 = msgs.find(msgIt->second.mMeta.mOrigMsgId);
// always add the post a a self version
if(msgIt2 != msgs.end())
{
// Ensuring that the post exists allows to only collect the existing data.
if(msgIt2 == msgs.end())
continue ;
// Make sure that the author is the same than the original message. This should always happen, but nothing can prevent someone to
// craft a new version of a message with his own signature.
if(msgIt2->second.mMeta.mAuthorId != msgIt->second.mMeta.mAuthorId)
continue ;
// always add the post a self version
if(mPostVersions[msgIt->second.mMeta.mOrigMsgId].empty())
mPostVersions[msgIt->second.mMeta.mOrigMsgId].push_back(QPair<time_t,RsGxsMessageId>(msgIt2->second.mMeta.mPublishTs,msgIt2->second.mMeta.mMsgId)) ;
mPostVersions[msgIt->second.mMeta.mOrigMsgId].push_back(QPair<time_t,RsGxsMessageId>(msgIt->second.mMeta.mPublishTs,msgIt->second.mMeta.mMsgId)) ;
}
}
// The following code assembles all new versions of a given post into the same array, indexed by the oldest version of the post.