diff options
| author | 2021-05-23 01:53:34 +0100 | |
|---|---|---|
| committer | 2021-05-23 01:58:34 +0100 | |
| commit | ee1325cf9ddcb47b2d2c1b79093e0fa5a38b75c7 (patch) | |
| tree | 8ede088cbb9a89f2f10d194d6c094b84db61fc06 /src/channels.cpp | |
| parent | Refactor the population of exceptions in delayjoin. (diff) | |
Fire OnUserPreJoin regardless of whether the join is an override.
Diffstat (limited to 'src/channels.cpp')
| -rw-r--r-- | src/channels.cpp | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index d1e318b51..332adcd44 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -198,21 +198,18 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co cname.resize(ServerInstance->Config->Limits.MaxChannel); Channel* chan = ServerInstance->Channels.Find(cname); - bool created_by_local = (chan == NULL); // Flag that will be passed to modules in the OnUserJoin() hook later + bool created_by_local = !chan; // Flag that will be passed to ForceJoin later std::string privs; // Prefix mode(letter)s to give to the joining user if (!chan) { privs = ServerInstance->Config->DefaultModes.substr(0, ServerInstance->Config->DefaultModes.find(' ')); - if (override == false) - { - // Ask the modules whether they're ok with the join, pass NULL as Channel* as the channel is yet to be created - ModResult MOD_RESULT; - FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, NULL, cname, privs, key)); - if (MOD_RESULT == MOD_RES_DENY) - return NULL; // A module wasn't happy with the join, abort - } + // Ask the modules whether they're ok with the join, pass NULL as Channel* as the channel is yet to be created + ModResult MOD_RESULT; + FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, NULL, cname, privs, key, override)); + if (!override && MOD_RESULT == MOD_RES_DENY) + return nullptr; // A module wasn't happy with the join, abort chan = new Channel(cname, ServerInstance->Time()); // Set the default modes on the channel (<options:defaultmodes>) @@ -222,18 +219,15 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co { /* Already on the channel */ if (chan->HasUser(user)) - return NULL; + return nullptr; - if (override == false) - { - ModResult MOD_RESULT; - FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, chan, cname, privs, key)); + ModResult MOD_RESULT; + FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, chan, cname, privs, key, override)); - // A module explicitly denied the join and (hopefully) generated a message - // describing the situation, so we may stop here without sending anything - if (MOD_RESULT == MOD_RES_DENY) - return NULL; - } + // A module explicitly denied the join and (hopefully) generated a message + // describing the situation, so we may stop here without sending anything + if (!override && MOD_RESULT == MOD_RES_DENY) + return nullptr; } // We figured that this join is allowed and also created the |
