From 79b50300351fdc0ac9e0b2900b282e5a2aa3da2e Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Thu, 13 Dec 2012 12:10:14 +0100 Subject: [PATCH] Check if the user is in room before sending information about nick change. Fixes bug when users have been added to all rooms when they changed their IRC nickname --- backends/libcommuni/session.cpp | 6 ++++++ backends/libcommuni/session.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/backends/libcommuni/session.cpp b/backends/libcommuni/session.cpp index 9222c285..11c48446 100644 --- a/backends/libcommuni/session.cpp +++ b/backends/libcommuni/session.cpp @@ -129,6 +129,9 @@ void MyIrcSession::on_nickChanged(IrcMessage *message) { for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) { std::string nickname = TO_UTF8(m->sender().name()); + if (!hasIRCBuddy(it->second->getChannel(), nickname)) { + continue; + } IRCBuddy &buddy = getIRCBuddy(it->second->getChannel(), nickname); LOG4CXX_INFO(logger, user << ": " << nickname << " changed nickname to " << TO_UTF8(m->nick())); np->handleParticipantChanged(user, nickname, it->second->getChannel() + suffix,(int) buddy.isOp(), pbnetwork::STATUS_ONLINE, "", TO_UTF8(m->nick())); @@ -145,6 +148,9 @@ void MyIrcSession::on_modeChanged(IrcMessage *message) { return; LOG4CXX_INFO(logger, user << ": " << nickname << " changed mode to " << mode); for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) { + if (!hasIRCBuddy(it->second->getChannel(), nickname)) { + continue; + } IRCBuddy &buddy = getIRCBuddy(it->second->getChannel(), nickname); if (mode == "+o") { buddy.setOp(true); diff --git a/backends/libcommuni/session.h b/backends/libcommuni/session.h index 0d819cb0..029905a7 100644 --- a/backends/libcommuni/session.h +++ b/backends/libcommuni/session.h @@ -89,6 +89,10 @@ public: return m_identify; } + bool hasIRCBuddy(const std::string &channel, const std::string &name) { + return m_buddies[channel].find(name) != m_buddies[channel].end(); + } + IRCBuddy &getIRCBuddy(const std::string &channel, const std::string &name) { return m_buddies[channel][name]; }