diff options
| author | 2013-07-09 20:01:03 +0200 | |
|---|---|---|
| committer | 2013-08-27 18:32:32 +0200 | |
| commit | 86f8294c2de86b8d060abbb02f7c51c0ca0d9ead (patch) | |
| tree | 0231a6f54a4721b4237dfe699656ab86bee25cf5 /src/modules/m_permchannels.cpp | |
| parent | m_permchannels Construct the final line that will be saved in a std::string i... (diff) | |
| download | inspircd++-86f8294c2de86b8d060abbb02f7c51c0ca0d9ead.tar.gz inspircd++-86f8294c2de86b8d060abbb02f7c51c0ca0d9ead.tar.bz2 inspircd++-86f8294c2de86b8d060abbb02f7c51c0ca0d9ead.zip | |
m_permchannels Save channel TS, topic set time and set by information
When loading, ignore and log channels with a name longer than Limits.MaxChan
Diffstat (limited to 'src/modules/m_permchannels.cpp')
| -rw-r--r-- | src/modules/m_permchannels.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index bd65c5822..1bcb2ac17 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -58,12 +58,20 @@ static bool WriteDatabase() if (!chan->IsModeSet('P')) continue; + std::string chants = ConvToStr(chan->age); + std::string topicts = ConvToStr(chan->topicset); const char* items[] = { "<permchannels channel=", chan->name.c_str(), + " ts=", + chants.c_str(), " topic=", chan->topic.c_str(), + " topicts=", + topicts.c_str(), + " topicsetby=", + chan->setby.c_str(), " modes=", chan->ChanModes(true), ">\n" @@ -71,7 +79,7 @@ static bool WriteDatabase() line.clear(); int item = 0, ipos = 0; - while (item < 7) + while (item < 13) { char c = items[item][ipos++]; if (c == 0) @@ -222,9 +230,9 @@ public: std::string topic = tag->getString("topic"); std::string modes = tag->getString("modes"); - if (channel.empty()) + if ((channel.empty()) || (channel.length() > ServerInstance->Config->Limits.ChanMax)) { - ServerInstance->Logs->Log("m_permchannels", DEBUG, "Malformed permchannels tag with empty channel name."); + ServerInstance->Logs->Log("m_permchannels", DEFAULT, "Ignoring permchannels tag with empty or too long channel name (\"" + channel + "\")"); continue; } @@ -232,19 +240,16 @@ public: if (!c) { - c = new Channel(channel, ServerInstance->Time()); - if (!topic.empty()) - { - c->SetTopic(NULL, topic, true); + time_t TS = tag->getInt("ts"); + c = new Channel(channel, ((TS > 0) ? TS : ServerInstance->Time())); + + c->SetTopic(NULL, topic, true); + c->setby = tag->getString("topicsetby"); + unsigned int topicset = tag->getInt("topicts"); + // SetTopic() sets the topic TS to now, if there was no topicts saved then don't overwrite that with a 0 + if (topicset > 0) + c->topicset = topicset; - /* - * Due to the way protocol works in 1.2, we need to hack the topic TS in such a way that this - * topic will always win over others. - * - * This is scheduled for (proper) fixing in a later release, and can be removed at a later date. - */ - c->topicset = 42; - } ServerInstance->Logs->Log("m_permchannels", DEBUG, "Added %s with topic %s", channel.c_str(), topic.c_str()); if (modes.empty()) |
