From 5a30466990e02d2533976061247d6c6ae097e0bd Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 24 Nov 2022 19:01:22 +0000 Subject: 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. --- include/modules/ircv3_replies.h | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'include') 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 + 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 + 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 + 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 + 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 + 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. */ -- cgit v1.3.1-10-gc9f91