]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Refactor topic setting logic to go through Channel::SetTopic() in all cases
[user/henk/code/inspircd.git] / src / channels.cpp
index 14b1ea54534b3559750e1e2594db4858ff338575..30bddec5c2bd3470a8e0954343b82d938f4f98cc 100644 (file)
@@ -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));
 }