]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_channel/core_channel.cpp
Rewrite invite system
[user/henk/code/inspircd.git] / src / coremods / core_channel / core_channel.cpp
index ec617af134d9a1676110e6412bb6851811ea75b5..aba4d97690ddb28d6270cc05357850b68e4300b3 100644 (file)
 
 #include "inspircd.h"
 #include "core_channel.h"
+#include "invite.h"
 
 class CoreModChannel : public Module
 {
+       Invite::APIImpl invapi;
        CommandInvite cmdinvite;
        CommandJoin cmdjoin;
        CommandKick cmdkick;
@@ -31,21 +33,23 @@ class CoreModChannel : public Module
        ModResult IsInvited(User* user, Channel* chan)
        {
                LocalUser* localuser = IS_LOCAL(user);
-               if ((localuser) && (localuser->IsInvited(chan)))
+               if ((localuser) && (invapi.IsInvited(localuser, chan)))
                        return MOD_RES_ALLOW;
                return MOD_RES_PASSTHRU;
        }
 
  public:
        CoreModChannel()
-               : cmdinvite(this), cmdjoin(this), cmdkick(this), cmdnames(this), cmdtopic(this)
+               : invapi(this)
+               , cmdinvite(this, invapi), cmdjoin(this), cmdkick(this), cmdnames(this), cmdtopic(this)
        {
        }
 
        void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
        {
+               ConfigTag* optionstag = ServerInstance->Config->ConfValue("options");
                Implementation events[] = { I_OnCheckKey, I_OnCheckLimit, I_OnCheckChannelBan };
-               if (ServerInstance->Config->InvBypassModes)
+               if (optionstag->getBool("invitebypassmodes", true))
                        ServerInstance->Modules.Attach(events, this, sizeof(events)/sizeof(Implementation));
                else
                {
@@ -61,7 +65,7 @@ class CoreModChannel : public Module
                if (localuser)
                {
                        // Remove existing invite, if any
-                       localuser->RemoveInvite(chan);
+                       invapi.Remove(localuser, chan);
 
                        if (chan->topicset)
                                Topic::ShowTopic(localuser, chan);
@@ -95,6 +99,17 @@ class CoreModChannel : public Module
                return IsInvited(user, chan);
        }
 
+       void OnUserDisconnect(LocalUser* user) CXX11_OVERRIDE
+       {
+               invapi.RemoveAll(user);
+       }
+
+       void OnChannelDelete(Channel* chan) CXX11_OVERRIDE
+       {
+               // Make sure the channel won't appear in invite lists from now on, don't wait for cull to unset the ext
+               invapi.RemoveAll(chan);
+       }
+
        void Prioritize() CXX11_OVERRIDE
        {
                ServerInstance->Modules.SetPriority(this, I_OnPostJoin, PRIORITY_FIRST);