summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2017-10-12 19:30:48 -0400
committerAdam <Adam@anope.org>2017-10-12 19:30:48 -0400
commitd63e32a579b7a19316fa209a99cba3ce79daf6ef (patch)
tree72435fe19b3e09d9f58462c2f16496c6ea80d713
parentf13c450b938633a27014cabad377821f87ce16b0 (diff)
No longer try to create persistent channels on the fly
Change initial channel creation to on post init so it will be part of the burst.
-rw-r--r--modules/commands/cs_set.cpp67
-rw-r--r--modules/pseudoclients/chanserv.cpp40
2 files changed, 26 insertions, 81 deletions
diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp
index 619222ebb..ccb15661d 100644
--- a/modules/commands/cs_set.cpp
+++ b/modules/commands/cs_set.cpp
@@ -504,20 +504,6 @@ class CommandCSSetPersist : public Command
{
ci->Extend<bool>("PERSIST");
- /* Channel doesn't exist, create it */
- if (!ci->c)
- {
- bool created;
- Channel *c = Channel::FindOrCreate(ci->name, created);
- if (ci->bi)
- {
- ChannelStatus status(BotModes());
- ci->bi->Join(c, &status);
- }
- if (created)
- c->Sync();
- }
-
/* Set the perm mode */
if (cm)
{
@@ -541,7 +527,7 @@ class CommandCSSetPersist : public Command
}
ChanServ->Assign(NULL, ci);
- if (!ci->c->FindUser(ChanServ))
+ if (ci->c && !ci->c->FindUser(ChanServ))
{
ChannelStatus status(BotModes());
ChanServ->Join(ci->c, &status);
@@ -1099,7 +1085,8 @@ class CommandCSSetNoexpire : public Command
class CSSet : public Module
{
SerializableExtensibleItem<bool> noautoop, peace, securefounder,
- restricted, secure, secureops, signkick, signkick_level, noexpire;
+ restricted, secure, secureops, signkick, signkick_level, noexpire,
+ persist;
struct KeepModes : SerializableExtensibleItem<bool>
{
@@ -1147,51 +1134,6 @@ class CSSet : public Module
}
} keep_modes;
- struct Persist : SerializableExtensibleItem<bool>
- {
- Persist(Module *m, const Anope::string &n) : SerializableExtensibleItem<bool>(m, n) { }
-
- void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override
- {
- SerializableExtensibleItem<bool>::ExtensibleUnserialize(e, s, data);
-
- if (s->GetSerializableType()->GetName() != "ChannelInfo" || !this->HasExt(e))
- return;
-
- ChannelInfo *ci = anope_dynamic_static_cast<ChannelInfo *>(s);
- if (ci->c)
- return;
-
- bool created;
- Channel *c = Channel::FindOrCreate(ci->name, created);
-
- ChannelMode *cm = ModeManager::FindChannelModeByName("PERM");
- if (cm)
- {
- c->SetMode(NULL, cm);
- }
- /* on startup we might not know mode availibity here */
- else if (Me && Me->IsSynced())
- {
- if (!ci->bi)
- {
- BotInfo *ChanServ = Config->GetClient("ChanServ");
- if (ChanServ)
- ChanServ->Assign(NULL, ci);
- }
-
- if (ci->bi && !c->FindUser(ci->bi))
- {
- ChannelStatus status(BotModes());
- ci->bi->Join(c, &status);
- }
- }
-
- if (created)
- c->Sync();
- }
- } persist;
-
CommandCSSet commandcsset;
CommandCSSetAutoOp commandcssetautoop;
CommandCSSetBanType commandcssetbantype;
@@ -1218,7 +1160,8 @@ class CSSet : public Module
securefounder(this, "SECUREFOUNDER"), restricted(this, "RESTRICTED"),
secure(this, "CS_SECURE"), secureops(this, "SECUREOPS"), signkick(this, "SIGNKICK"),
signkick_level(this, "SIGNKICK_LEVEL"), noexpire(this, "CS_NO_EXPIRE"),
- keep_modes(this, "CS_KEEP_MODES"), persist(this, "PERSIST"),
+ persist(this, "PERSIST"),
+ keep_modes(this, "CS_KEEP_MODES"),
commandcsset(this), commandcssetautoop(this), commandcssetbantype(this),
commandcssetdescription(this), commandcssetfounder(this), commandcssetkeepmodes(this),
diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp
index b66ae1a63..b3dc1657d 100644
--- a/modules/pseudoclients/chanserv.cpp
+++ b/modules/pseudoclients/chanserv.cpp
@@ -377,34 +377,36 @@ class ChanServCore : public Module, public ChanServService
return EVENT_CONTINUE;
}
- void OnPreUplinkSync(Server *serv) anope_override
+ void OnPostInit() anope_override
{
if (!persist)
return;
+
+ ChannelMode *perm = ModeManager::FindChannelModeByName("PERM");
+
/* Find all persistent channels and create them, as we are about to finish burst to our uplink */
for (registered_channel_map::iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
{
ChannelInfo *ci = it->second;
- if (persist->HasExt(ci))
- {
- bool c;
- ci->c = Channel::FindOrCreate(ci->name, c, ci->time_registered);
+ if (!persist->HasExt(ci))
+ continue;
- if (ModeManager::FindChannelModeByName("PERM") != NULL)
- {
- if (c)
- IRCD->SendChannel(ci->c);
- ci->c->SetMode(NULL, "PERM");
- }
- else
+ bool c;
+ ci->c = Channel::FindOrCreate(ci->name, c, ci->time_registered);
+ ci->c->syncing |= created;
+
+ if (perm)
+ {
+ ci->c->SetMode(NULL, perm);
+ }
+ else
+ {
+ if (!ci->bi)
+ ci->WhoSends()->Assign(NULL, ci);
+ if (ci->c->FindUser(ci->bi) == NULL)
{
- if (!ci->bi)
- ci->WhoSends()->Assign(NULL, ci);
- if (ci->c->FindUser(ci->bi) == NULL)
- {
- ChannelStatus status(BotModes());
- ci->bi->Join(ci->c, &status);
- }
+ ChannelStatus status(BotModes());
+ ci->bi->Join(ci->c, &status);
}
}
}