aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
authorGravatar Sadie Powell2020-02-21 09:01:48 +0000
committerGravatar Sadie Powell2021-12-28 13:19:22 +0000
commit4c931b6f6acbb3bc77d3d60d6a67d9d8cf867e76 (patch)
tree038599233bd87ad93832aa336ff7aa0c6691a8ad /src/modules
parentFix not being able to look up hostnames that point to multiple IPs. (diff)
downloadinspircd++-4c931b6f6acbb3bc77d3d60d6a67d9d8cf867e76.tar.gz
inspircd++-4c931b6f6acbb3bc77d3d60d6a67d9d8cf867e76.tar.bz2
inspircd++-4c931b6f6acbb3bc77d3d60d6a67d9d8cf867e76.zip
Send an account id tag when account-tag & message-tags are enabled.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_ircv3_accounttag.cpp33
-rw-r--r--src/modules/m_services_account.cpp2
2 files changed, 35 insertions, 0 deletions
diff --git a/src/modules/m_ircv3_accounttag.cpp b/src/modules/m_ircv3_accounttag.cpp
index a8f940169..6201ee267 100644
--- a/src/modules/m_ircv3_accounttag.cpp
+++ b/src/modules/m_ircv3_accounttag.cpp
@@ -19,6 +19,7 @@
#include "inspircd.h"
+#include "modules/ctctags.h"
#include "modules/ircv3.h"
#include "modules/account.h"
@@ -44,13 +45,45 @@ class AccountTag : public IRCv3::CapTag<AccountTag>
}
};
+class AccountIdTag : public ClientProtocol::MessageTagProvider
+{
+ private:
+ AccountTag& acctag;
+ CTCTags::CapReference ctctagcap;
+
+ public:
+ AccountIdTag(Module* mod, AccountTag& tag)
+ : ClientProtocol::MessageTagProvider(mod)
+ , acctag(tag)
+ , ctctagcap(mod)
+ {
+ }
+
+ void OnPopulateTags(ClientProtocol::Message& msg) CXX11_OVERRIDE
+ {
+ const User* user = msg.GetSourceUser();
+ const AccountExtItem* accextitem = user ? GetAccountIdExtItem() : NULL;
+ const std::string* accountid = accextitem ? accextitem->get(user) : NULL;
+ if (accountid)
+ msg.AddTag("inspircd.org/account-id", this, *accountid);
+ }
+
+ bool ShouldSendTag(LocalUser* user, const ClientProtocol::MessageTagData& tagdata) CXX11_OVERRIDE
+ {
+ return acctag.GetCap().get(user) && ctctagcap.get(user);
+ }
+};
+
class ModuleIRCv3AccountTag : public Module
{
+ private:
AccountTag tag;
+ AccountIdTag idtag;
public:
ModuleIRCv3AccountTag()
: tag(this)
+ , idtag(this, tag)
{
}
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index cf57a4246..87bd5cf13 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -148,6 +148,7 @@ class ModuleServicesAccount
SimpleUserModeHandler regdeafmode;
Channel_r chanregmode;
User_r userregmode;
+ AccountExtItem accountid;
AccountExtItemImpl accountname;
bool checking_ban;
@@ -162,6 +163,7 @@ class ModuleServicesAccount
, regdeafmode(this, "regdeaf", 'R')
, chanregmode(this)
, userregmode(this)
+ , accountid("accountid", ExtensionItem::EXT_USER, this)
, accountname(this)
, checking_ban(false)
{