aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-11-24 19:01:22 +0000
committerGravatar Sadie Powell2022-11-24 19:01:22 +0000
commit5a30466990e02d2533976061247d6c6ae097e0bd (patch)
tree292181c659e178b2cd7432855da33da42d9f4a22 /include
parentAllow silence flag metadata to contain unknown flags. (diff)
Add a workaround for the replies API not working with a cap reference.
A Cap::Reference can not be cast to a Cap::Capability& because it may not be available and that would create a null reference. In v4 we can change the API to take a Cap::Capability* but for now this is the best we can do.
Diffstat (limited to 'include')
-rw-r--r--include/modules/ircv3_replies.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/include/modules/ircv3_replies.h b/include/modules/ircv3_replies.h
index dd47d97c3..3bceb5964 100644
--- a/include/modules/ircv3_replies.h
+++ b/include/modules/ircv3_replies.h
@@ -254,6 +254,53 @@ class IRCv3::Replies::Reply
else
SendNoticeInternal(user, command, description);
}
+
+ void SendIfCap(LocalUser* user, const Cap::Capability* cap, Command* command, const std::string& code,
+ const std::string& description)
+ {
+ if (cap)
+ SendIfCap(user, *cap, command, code, description);
+ }
+
+ template<typename T1>
+ void SendIfCap(LocalUser* user, const Cap::Capability* cap, Command* command, const std::string& code,
+ const T1& p1, const std::string& description)
+ {
+ if (cap)
+ SendIfCap(user, *cap, command, code, p1, description);
+ }
+
+ template<typename T1, typename T2>
+ void SendIfCap(LocalUser* user, const Cap::Capability* cap, Command* command, const std::string& code,
+ const T1& p1, const T2& p2, const std::string& description)
+ {
+ if (cap)
+ SendIfCap(user, *cap, command, code, p1, p2, description);
+ }
+
+ template<typename T1, typename T2, typename T3>
+ void SendIfCap(LocalUser* user, const Cap::Capability* cap, Command* command, const std::string& code,
+ const T1& p1, const T2& p2, const T3& p3, const std::string& description)
+ {
+ if (cap)
+ SendIfCap(user, *cap, command, code, p1, p2, p3, description);
+ }
+
+ template<typename T1, typename T2, typename T3, typename T4>
+ void SendIfCap(LocalUser* user, const Cap::Capability* cap, Command* command, const std::string& code,
+ const T1& p1, const T2& p2, const T3& p3, const T4& p4, const std::string& description)
+ {
+ if (cap)
+ SendIfCap(user, *cap, command, code, p1, p2, p3, p4, description);
+ }
+
+ template<typename T1, typename T2, typename T3, typename T4, typename T5>
+ void SendIfCap(LocalUser* user, const Cap::Capability* cap, Command* command, const std::string& code,
+ const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5, const std::string& description)
+ {
+ if (cap)
+ SendIfCap(user, *cap, command, code, p1, p2, p3, p4, p5, description);
+ }
};
/** Sends a FAIL standard reply. */