summaryrefslogtreecommitdiff
path: root/modules/chanserv/main/chanserv.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2017-10-08 11:37:09 -0400
committerAdam <Adam@anope.org>2017-10-08 11:37:09 -0400
commit20c7bcad55597f17c01089ae2ec0c458bafa705f (patch)
treeb23f8d20ed5caec167592debba920013aba23881 /modules/chanserv/main/chanserv.cpp
parent85f10a20bb3f59afb0d97e42452f2aea60882551 (diff)
Simplify initial burst of persistent channels
Also don't create/destroy channels as persist is set on and off which no longer makes since with the live database backend
Diffstat (limited to 'modules/chanserv/main/chanserv.cpp')
-rw-r--r--modules/chanserv/main/chanserv.cpp56
1 files changed, 28 insertions, 28 deletions
diff --git a/modules/chanserv/main/chanserv.cpp b/modules/chanserv/main/chanserv.cpp
index 2521ee22e..3c6fe000a 100644
--- a/modules/chanserv/main/chanserv.cpp
+++ b/modules/chanserv/main/chanserv.cpp
@@ -43,7 +43,7 @@ class ChanServCore : public Module
, public EventHook<Event::Log>
, public EventHook<Event::ExpireTick>
, public EventHook<Event::CheckDelete>
- , public EventHook<Event::PreUplinkSync>
+ , public EventHook<Event::PostInit>
, public EventHook<Event::ChanRegistered>
, public EventHook<Event::JoinChannel>
, public EventHook<Event::ChanInfo>
@@ -71,7 +71,7 @@ class ChanServCore : public Module
, EventHook<Event::Log>(this)
, EventHook<Event::ExpireTick>(this)
, EventHook<Event::CheckDelete>(this)
- , EventHook<Event::PreUplinkSync>(this)
+ , EventHook<Event::PostInit>(this)
, EventHook<Event::ChanRegistered>(this)
, EventHook<Event::JoinChannel>(this)
, EventHook<Event::ChanInfo>(this)
@@ -462,42 +462,42 @@ class ChanServCore : public Module
return EVENT_CONTINUE;
}
- void OnPreUplinkSync(Server *serv) override
+ void OnPostInit() override
{
- /* Find all persistent channels and create them, as we are about to finish burst to our uplink */
+ ChannelMode *perm = ModeManager::FindChannelModeByName("PERM");
+
+ /* Find all persistent channels and create them, so they will be bursted to the uplink */
for (ChanServ::Channel *ci : Serialize::GetObjects<ChanServ::Channel *>())
{
- if (ci->IsPersist())
- {
- bool created;
- Channel *c = Channel::FindOrCreate(ci->GetName(), created, ci->GetTimeRegistered());
+ if (!ci->IsPersist())
+ continue;
- if (ModeManager::FindChannelModeByName("PERM") != NULL)
+ bool created;
+ Channel *c = Channel::FindOrCreate(ci->GetName(), created, ci->GetTimeRegistered());
+ c->syncing |= created;
+
+ if (perm != nullptr)
+ {
+ c->SetMode(NULL, perm);
+ }
+ else
+ {
+ if (!ci->GetBot())
{
- if (created)
- IRCD->Send<messages::MessageChannel>(c);
- c->SetMode(NULL, "PERM");
+ ServiceBot *bi = ci->WhoSends();
+ if (bi != nullptr)
+ bi->Assign(nullptr, ci);
}
- else
- {
- if (!ci->GetBot())
- {
- ServiceBot *bi = ci->WhoSends();
- if (bi != nullptr)
- bi->Assign(nullptr, ci);
- }
- if (ci->GetBot() != nullptr && c->FindUser(ci->GetBot()) == nullptr)
- {
- Anope::string botmodes = Config->GetModule("botserv/main")->Get<Anope::string>("botmodes",
- Config->GetModule("chanserv/main")->Get<Anope::string>("botmodes"));
- ChannelStatus status(botmodes);
- ci->GetBot()->Join(c, &status);
- }
+ if (ci->GetBot() != nullptr && c->FindUser(ci->GetBot()) == nullptr)
+ {
+ Anope::string botmodes = Config->GetModule("botserv/main")->Get<Anope::string>("botmodes",
+ Config->GetModule("chanserv/main")->Get<Anope::string>("botmodes"));
+ ChannelStatus status(botmodes);
+ ci->GetBot()->Join(c, &status);
}
}
}
-
}
void OnChanRegistered(ChanServ::Channel *ci) override