aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-06-29 22:29:34 +0100
committerGravatar Sadie Powell2023-06-29 22:52:07 +0100
commit1d96baaf774eacd5eacd357500a01af693aad654 (patch)
tree8c2e960bba6dc28f9c381c27a9c38524fda56946
parentFix remote users on legacy servers not having a real username. (diff)
Remove OnPreChange{Host,RealName} events and deboolify methods.
These have not ever been used as far as I can see.
-rw-r--r--include/modules.h18
-rw-r--r--include/users.h13
-rw-r--r--src/modules.cpp2
-rw-r--r--src/modules/m_chghost.cpp3
-rw-r--r--src/modules/m_sethost.cpp10
-rw-r--r--src/modules/m_setname.cpp7
-rw-r--r--src/users.cpp34
7 files changed, 18 insertions, 69 deletions
diff --git a/include/modules.h b/include/modules.h
index 16b0c1e27..70d37a1df 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -177,8 +177,6 @@ enum Implementation
I_OnPostOperLogout,
I_OnPostTopicChange,
I_OnPreChangeConnectClass,
- I_OnPreChangeHost,
- I_OnPreChangeRealName,
I_OnPreCommand,
I_OnPreMode,
I_OnPreOperLogin,
@@ -839,22 +837,6 @@ public:
*/
virtual ModResult OnCheckPassword(const std::string& password, const std::string& passwordhash, const std::string& value);
- /** Called whenever a change of a local users displayed host is attempted.
- * Return 1 to deny the host change, or 0 to allow it.
- * @param user The user whose host will be changed
- * @param newhost The new hostname
- * @return 1 to deny the host change, 0 to allow
- */
- virtual ModResult OnPreChangeHost(LocalUser* user, const std::string& newhost);
-
- /** Called whenever a change of a local users real name is attempted.
- * return MOD_RES_DENY to deny the name change, or MOD_RES_ALLOW to allow it.
- * @param user The user whose real name will be changed
- * @param newhost The new real name.
- * @return MOD_RES_DENY to deny the real name change, MOD_RES_ALLOW to allow
- */
- virtual ModResult OnPreChangeRealName(LocalUser* user, const std::string& newhost);
-
/** Called before a topic is changed.
* Return 1 to deny the topic change, 0 to check details on the change, -1 to let it through with no checks
* As with other 'pre' events, you should only ever block a local event.
diff --git a/include/users.h b/include/users.h
index 28a689297..dd74bb6c7 100644
--- a/include/users.h
+++ b/include/users.h
@@ -703,9 +703,8 @@ public:
/** Change the displayed hostname of this user.
* @param host The new displayed hostname of this user.
- * @return True if the hostname was changed successfully; otherwise, false.
*/
- bool ChangeDisplayedHost(const std::string& host);
+ void ChangeDisplayedHost(const std::string& host);
/** Change the real hostname of this user.
* @param host The new real hostname of this user.
@@ -715,9 +714,8 @@ public:
/** Change the displayed username of this user.
* @param newuser The new displayed username of this user.
- * @return True if the username was changed successfully; otherwise, false.
*/
- bool ChangeDisplayedUser(const std::string& newuser);
+ void ChangeDisplayedUser(const std::string& newuser);
/** Change the real username of this user.
* @param newuser The new real username of this user.
@@ -725,11 +723,10 @@ public:
*/
void ChangeRealUser(const std::string& newuser, bool resetdisplay);
- /** Change a users realname field.
- * @param real The user's new real name
- * @return True if the change succeeded, false if otherwise
+ /** Change the real name of this user.
+ * @param newreal The new real name of this user.
*/
- bool ChangeRealName(const std::string& real);
+ void ChangeRealName(const std::string& newreal);
/** Change a user's nick
* @param newnick The new nick. If equal to the users uuid, the nick change always succeeds.
diff --git a/src/modules.cpp b/src/modules.cpp
index 4d45bd016..6bd448409 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -129,8 +129,6 @@ ModResult Module::OnCheckKey(User*, Channel*, const std::string&) { DetachEvent(
ModResult Module::OnCheckLimit(User*, Channel*) { DetachEvent(I_OnCheckLimit); return MOD_RES_PASSTHRU; }
ModResult Module::OnCheckChannelBan(User*, Channel*) { DetachEvent(I_OnCheckChannelBan); return MOD_RES_PASSTHRU; }
ModResult Module::OnCheckBan(User*, Channel*, const std::string&) { DetachEvent(I_OnCheckBan); return MOD_RES_PASSTHRU; }
-ModResult Module::OnPreChangeHost(LocalUser*, const std::string&) { DetachEvent(I_OnPreChangeHost); return MOD_RES_PASSTHRU; }
-ModResult Module::OnPreChangeRealName(LocalUser*, const std::string&) { DetachEvent(I_OnPreChangeRealName); return MOD_RES_PASSTHRU; }
ModResult Module::OnPreTopicChange(User*, Channel*, const std::string&) { DetachEvent(I_OnPreTopicChange); return MOD_RES_PASSTHRU; }
ModResult Module::OnCheckPassword(const std::string&, const std::string&, const std::string&) { DetachEvent(I_OnCheckPassword); return MOD_RES_PASSTHRU; }
void Module::OnPostConnect(User*) { DetachEvent(I_OnPostConnect); }
diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp
index 590bdb2d7..e45832dce 100644
--- a/src/modules/m_chghost.cpp
+++ b/src/modules/m_chghost.cpp
@@ -68,7 +68,8 @@ public:
if (IS_LOCAL(dest))
{
- if ((dest->ChangeDisplayedHost(parameters[1])) && (!user->server->IsService()))
+ dest->ChangeDisplayedHost(parameters[1]);
+ if (!user->server->IsService())
{
ServerInstance->SNO.WriteGlobalSno('a', user->nick+" used CHGHOST to make the displayed host of "+dest->nick+" become "+dest->GetDisplayedHost());
}
diff --git a/src/modules/m_sethost.cpp b/src/modules/m_sethost.cpp
index 00bd92580..c20c22e3f 100644
--- a/src/modules/m_sethost.cpp
+++ b/src/modules/m_sethost.cpp
@@ -55,13 +55,9 @@ public:
}
}
- if (user->ChangeDisplayedHost(parameters[0]))
- {
- ServerInstance->SNO.WriteGlobalSno('a', user->nick+" used SETHOST to change their displayed host to "+user->GetDisplayedHost());
- return CmdResult::SUCCESS;
- }
-
- return CmdResult::FAILURE;
+ user->ChangeDisplayedHost(parameters[0]);
+ ServerInstance->SNO.WriteGlobalSno('a', user->nick+" used SETHOST to change their displayed host to "+user->GetDisplayedHost());
+ return CmdResult::SUCCESS;
}
};
diff --git a/src/modules/m_setname.cpp b/src/modules/m_setname.cpp
index 0d50b3882..455632641 100644
--- a/src/modules/m_setname.cpp
+++ b/src/modules/m_setname.cpp
@@ -55,12 +55,7 @@ public:
return CmdResult::FAILURE;
}
- if (!user->ChangeRealName(parameters[0]))
- {
- fail.SendIfCap(user, &cap, this, "CANNOT_CHANGE_REALNAME", "Unable to change your real name");
- return CmdResult::FAILURE;
- }
-
+ user->ChangeRealName(parameters[0]);
if (notifyopers)
ServerInstance->SNO.WriteGlobalSno('a', "{} used SETNAME to change their real name to '{}'",
user->nick, parameters[0]);
diff --git a/src/users.cpp b/src/users.cpp
index 16267a94d..3e288b4e2 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -903,38 +903,21 @@ bool User::SharesChannelWith(User* other) const
return false;
}
-bool User::ChangeRealName(const std::string& real)
+void User::ChangeRealName(const std::string& real)
{
if (!this->realname.compare(real))
- return true;
+ return;
- if (IS_LOCAL(this))
- {
- ModResult MOD_RESULT;
- FIRST_MOD_RESULT(OnPreChangeRealName, MOD_RESULT, (IS_LOCAL(this), real));
- if (MOD_RESULT == MOD_RES_DENY)
- return false;
- }
FOREACH_MOD(OnChangeRealName, (this, real));
+
this->realname.assign(real, 0, ServerInstance->Config->Limits.MaxReal);
this->realname.shrink_to_fit();
-
- return true;
}
-bool User::ChangeDisplayedHost(const std::string& shost)
+void User::ChangeDisplayedHost(const std::string& shost)
{
if (GetDisplayedHost() == shost)
- return true;
-
- LocalUser* luser = IS_LOCAL(this);
- if (luser)
- {
- ModResult MOD_RESULT;
- FIRST_MOD_RESULT(OnPreChangeHost, MOD_RESULT, (luser, shost));
- if (MOD_RESULT == MOD_RES_DENY)
- return false;
- }
+ return;
FOREACH_MOD(OnChangeHost, (this, shost));
@@ -948,8 +931,6 @@ bool User::ChangeDisplayedHost(const std::string& shost)
if (IS_LOCAL(this) && connected != User::CONN_NONE)
this->WriteNumeric(RPL_YOURDISPLAYEDHOST, this->GetDisplayedHost(), "is now your displayed host");
-
- return true;
}
void User::ChangeRealHost(const std::string& host, bool resetdisplay)
@@ -1028,10 +1009,10 @@ void User::ChangeRealUser(const std::string& newuser, bool resetdisplay)
FOREACH_MOD(OnPostChangeRealUser, (this));
}
-bool User::ChangeDisplayedUser(const std::string& newuser)
+void User::ChangeDisplayedUser(const std::string& newuser)
{
if (GetDisplayedUser() == newuser)
- return true;
+ return;
FOREACH_MOD(OnChangeUser, (this, newuser));
@@ -1042,7 +1023,6 @@ bool User::ChangeDisplayedUser(const std::string& newuser)
this->displayuser.shrink_to_fit();
this->InvalidateCache();
- return true;
}
void User::PurgeEmptyChannels()