@ -1010,7 +1010,19 @@ Value newdirectmsg(const Array& params, bool fHelp)
stoDM.m_utcTime = v["userpost"]["time"].integer();
{
LOCK(cs_twister);
m_users[strFrom].m_directmsg[strTo].push_back(stoDM);
std::list<StoredDirectMsg> &dmsFromToUser = m_users[strFrom].m_directmsg[strTo];
std::list<StoredDirectMsg>::const_iterator it;
// prevent duplicates
for( it = dmsFromToUser.begin(); it != dmsFromToUser.end(); ++it ) {
if( stoDM.m_utcTime == (*it).m_utcTime &&
stoDM.m_text == (*it).m_text ) {
break;
}
if( it != dmsFromToUser.end() ) {
dmsFromToUser.push_back(stoDM);
return entryToJson(v);
@ -150,10 +150,8 @@ int saveUserData(std::string const& filename, std::map<std::string,UserData> con
std::map<std::string, std::list<StoredDirectMsg> >::const_iterator j;
for (j = udata.m_directmsg.begin(); j != udata.m_directmsg.end(); ++j) {
std::list<StoredDirectMsg> const &dmsToFromUser = j->second;
entry &dmList = dmDict[j->first];
BOOST_FOREACH( StoredDirectMsg const &stoDm, dmsToFromUser) {
BOOST_FOREACH( StoredDirectMsg const &stoDm, j->second) {
entry dmElem;
dmElem["time"] = stoDm.m_utcTime;
dmElem["text"] = stoDm.m_text;