summaryrefslogtreecommitdiff
path: root/src/channels.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2016-04-11 15:53:01 +0200
committerAttila Molnar <attilamolnar@hush.com>2016-04-11 15:53:01 +0200
commit2706a993b3f8ee52e2728047fad6a56f7e3cf405 (patch)
tree30d99f78630372bbe630fcf47f2f32fc8891fbe9 /src/channels.cpp
parentb25070bf5e9447533bf1a0555c6954740ca12340 (diff)
Refactor topic setting logic to go through Channel::SetTopic() in all cases
- Pass topic set time and optionally the setter to SetTopic() - Don't do anything if the topic is changed by a local user to what it is currently
Diffstat (limited to 'src/channels.cpp')
-rw-r--r--src/channels.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 14b1ea545..30bddec5c 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -46,12 +46,20 @@ void Channel::SetMode(ModeHandler* mh, bool on)
modes[mh->GetId()] = on;
}
-void Channel::SetTopic(User* u, const std::string& ntopic)
+void Channel::SetTopic(User* u, const std::string& ntopic, time_t topicts, const std::string* setter)
{
- this->topic.assign(ntopic, 0, ServerInstance->Config->Limits.MaxTopic);
- this->setby.assign(ServerInstance->Config->FullHostInTopic ? u->GetFullHost() : u->nick, 0, 128);
- this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str());
- this->topicset = ServerInstance->Time();
+ // Send a TOPIC message to the channel only if the new topic text differs
+ if (this->topic != ntopic)
+ {
+ this->topic = ntopic;
+ this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str());
+ }
+
+ // Always update setter and set time
+ if (!setter)
+ setter = ServerInstance->Config->FullHostInTopic ? &u->GetFullHost() : &u->nick;
+ this->setby.assign(*setter, 0, 128);
+ this->topicset = topicts;
FOREACH_MOD(OnPostTopicChange, (u, this, this->topic));
}