mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 10:39:02 -04:00
Send an ISupport diff when a user moves to a new connect class.
This commit is contained in:
parent
b5032fb641
commit
45f7640d2a
@ -169,6 +169,17 @@ public:
|
||||
ServerInstance->AtomicActions.AddAction(new ISupportAction(isupport));
|
||||
}
|
||||
|
||||
void OnChangeConnectClass(LocalUser* user, const std::shared_ptr<ConnectClass>& klass, bool force) override
|
||||
{
|
||||
// TODO: this should be OnPostChangeConnectClass but we need the old
|
||||
// connect class which isn't exposed to the module interface and we
|
||||
// can't break the API in a stable release. For now we use this and
|
||||
// prioritise it to be after core_user checks whether the user needs
|
||||
// to die.
|
||||
if (user->IsFullyConnected() && !user->quitting)
|
||||
isupport.ChangeClass(user, user->GetClass(), klass);
|
||||
}
|
||||
|
||||
void OnUserConnect(LocalUser* user) override
|
||||
{
|
||||
user->WriteNumeric(RPL_WELCOME, INSP_FORMAT("Welcome to the {} IRC Network {}", ServerInstance->Config->Network, user->GetRealMask()));
|
||||
|
@ -59,6 +59,13 @@ public:
|
||||
*/
|
||||
void Build();
|
||||
|
||||
/** Sends an 005 (ISUPPORT) diff from the old class to the new one.
|
||||
* @param user The user to send the diff to.
|
||||
* @param oldclass The connect class the user is moving from.
|
||||
* @param newclass The conenct class the user is moving to.
|
||||
*/
|
||||
void ChangeClass(LocalUser* user, const std::shared_ptr<ConnectClass>& oldclass, const std::shared_ptr<ConnectClass>& newclass);
|
||||
|
||||
/** Send the 005 numerics (ISUPPORT) to a user.
|
||||
* @param user The user to send the ISUPPORT numerics to
|
||||
*/
|
||||
|
@ -160,6 +160,23 @@ void ISupportManager::BuildNumerics(ISupport::TokenMap& tokens, std::vector<Nume
|
||||
}
|
||||
}
|
||||
|
||||
void ISupportManager::ChangeClass(LocalUser* user, const std::shared_ptr<ConnectClass>& oldclass, const std::shared_ptr<ConnectClass>& newclass)
|
||||
{
|
||||
auto oldtokens = cachedtokens.find(oldclass);
|
||||
auto newtokens = cachedtokens.find(newclass);
|
||||
if (oldtokens == cachedtokens.end() || newtokens == cachedtokens.end())
|
||||
return; // Should never happen.
|
||||
|
||||
ISupport::TokenMap difftokens;
|
||||
TokenDifference(difftokens, oldtokens->second, newtokens->second);
|
||||
|
||||
std::vector<Numeric::Numeric> diffnumerics;
|
||||
BuildNumerics(difftokens, diffnumerics);
|
||||
|
||||
for (const auto& numeric : diffnumerics)
|
||||
user->WriteNumeric(numeric);
|
||||
}
|
||||
|
||||
void ISupportManager::SendTo(LocalUser* user)
|
||||
{
|
||||
auto numerics = cachednumerics.find(user->GetClass());
|
||||
|
@ -280,6 +280,11 @@ public:
|
||||
const auto& performance = ServerInstance->Config->ConfValue("performance");
|
||||
clonesonconnect = performance->getBool("clonesonconnect", true);
|
||||
}
|
||||
|
||||
void Prioritize() override
|
||||
{
|
||||
ServerInstance->Modules.SetPriority(this, I_OnChangeConnectClass, PRIORITY_FIRST);
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(CoreModUser)
|
||||
|
Loading…
x
Reference in New Issue
Block a user