summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2023-11-14 13:50:52 +0000
committerSadie Powell <sadie@witchery.services>2023-11-14 13:53:45 +0000
commit0f1f0c5a221d199fefc38e116a98fb4ff2c0a4f3 (patch)
treefaf427e3fa711a200f6d438121a1c1a9f99e673d /modules
parent6e16e71fdaf4b725c8e4b3e89db5ed66d497a1a4 (diff)
Deduplicate account sending code in the inspircd module.
Diffstat (limited to 'modules')
-rw-r--r--modules/protocol/inspircd.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/modules/protocol/inspircd.cpp b/modules/protocol/inspircd.cpp
index d3628fb8f..e76d745e3 100644
--- a/modules/protocol/inspircd.cpp
+++ b/modules/protocol/inspircd.cpp
@@ -55,6 +55,12 @@ class InspIRCdProto : public IRCDProto
UplinkSocket::Message(Me) << "DELLINE " << xtype << " " << mask;
}
+ void SendAccount(const Anope::string &uid, NickAlias *na)
+ {
+ UplinkSocket::Message(Me) << "METADATA " << uid << " accountid :" << (na ? na->nc->GetId() : Anope::string());
+ UplinkSocket::Message(Me) << "METADATA " << uid << " accountname :" << (na ? na->nc->display : Anope::string());
+ }
+
public:
PrimitiveExtensibleItem<ListLimits> maxlist;
@@ -432,17 +438,13 @@ class InspIRCdProto : public IRCDProto
void SendLogin(User *u, NickAlias *na) override
{
/* InspIRCd uses an account to bypass chmode +R, not umode +r, so we can't send this here */
- if (na->nc->HasExt("UNCONFIRMED"))
- return;
-
- UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountid :" << na->nc->GetId();
- UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :" << na->nc->display;
+ if (!na->nc->HasExt("UNCONFIRMED"))
+ SendAccount(u->GetUID(), na);
}
void SendLogout(User *u) override
{
- UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountid :";
- UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :";
+ SendAccount(u->GetUID(), nullptr);
}
void SendChannel(Channel *c) override
@@ -457,8 +459,7 @@ class InspIRCdProto : public IRCDProto
void SendSVSLogin(const Anope::string &uid, NickAlias *na) override
{
- UplinkSocket::Message(Me) << "METADATA " << uid << " accountid :" << na->nc->GetId();
- UplinkSocket::Message(Me) << "METADATA " << uid << " accountname :" << na->nc->display;
+ SendAccount(uid, na);
if (!na->GetVhostIdent().empty())
UplinkSocket::Message(Me) << "ENCAP " << uid.substr(0, 3) << " CHGIDENT " << uid << " " << na->GetVhostIdent();