inspircd

A modular C++ IRC daemon (ircd). https://www.inspircd.org/
Log | Files | Refs | README

commit 8f94fcc856dd492c6ecd5d1ebd1acdb7e59cbbe2
parent 5b152cfcd993119c0d0ef87b73b3b0f20c940cdc
Author: linuxdaemon <linuxdaemon@snoonet.org>
Date:   Sat, 22 Jun 2019 09:10:32 -0500

Fix msgid inconsistencies with TAGMSG

Also fixes accidentally copying incoming tags on TAGMSG when sending to
other users

Diffstat:
Msrc/modules/m_ircv3_ctctags.cpp | 12++++++++----
Msrc/modules/m_spanningtree/main.cpp | 37+++++++++++++++++++++++++++++++++++++
Msrc/modules/m_spanningtree/main.h | 3+++
3 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/src/modules/m_ircv3_ctctags.cpp b/src/modules/m_ircv3_ctctags.cpp @@ -75,7 +75,7 @@ class CommandTagMsg : public Command return CMD_FAILURE; unsigned int minrank = pm ? pm->GetPrefixRank() : 0; - CTCTags::TagMessage message(source, chan, parameters.GetTags()); + CTCTags::TagMessage message(source, chan, msgdetails.tags_out); message.SetSideEffect(true); const Channel::MemberMap& userlist = chan->GetUsers(); for (Channel::MemberMap::const_iterator iter = userlist.begin(); iter != userlist.end(); ++iter) @@ -117,7 +117,7 @@ class CommandTagMsg : public Command // the message out to the local users. if (InspIRCd::Match(ServerInstance->Config->ServerName, servername)) { - CTCTags::TagMessage message(source, "$*", parameters.GetTags()); + CTCTags::TagMessage message(source, "$*", msgdetails.tags_out); message.SetSideEffect(true); const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers(); for (UserManager::LocalList::const_iterator iter = list.begin(); iter != list.end(); ++iter) @@ -185,7 +185,7 @@ class CommandTagMsg : public Command if (localtarget && cap.get(localtarget)) { // Send to the target if they have the capability and are a local user. - CTCTags::TagMessage message(source, localtarget, parameters.GetTags()); + CTCTags::TagMessage message(source, localtarget, msgdetails.tags_out); message.SetSideEffect(true); localtarget->Send(msgevprov, message); } @@ -233,7 +233,11 @@ class CommandTagMsg : public Command RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE { - return ROUTE_MESSAGE(parameters[0]); + if (IS_LOCAL(user)) + // This is handled by the OnUserPostTagMessage hook to split the LoopCall pieces + return ROUTE_LOCALONLY; + else + return ROUTE_MESSAGE(parameters[0]); } }; diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp @@ -39,6 +39,7 @@ ModuleSpanningTree::ModuleSpanningTree() : Away::EventListener(this) , Stats::EventListener(this) + , CTCTags::EventListener(this) , rconnect(this) , rsquit(this) , map(this) @@ -418,6 +419,42 @@ void ModuleSpanningTree::OnUserPostMessage(User* user, const MessageTarget& targ } } +void ModuleSpanningTree::OnUserPostTagMessage(User* user, const MessageTarget& target, const CTCTags::TagMessageDetails& details) +{ + if (!IS_LOCAL(user)) + return; + + switch (target.type) + { + case MessageTarget::TYPE_USER: + { + User* d = target.Get<User>(); + if (!IS_LOCAL(d)) + { + CmdBuilder params(user, "TAGMSG"); + params.push_tags(details.tags_out); + params.push_back(d->uuid); + params.Unicast(d); + } + break; + } + case MessageTarget::TYPE_CHANNEL: + { + Utils->SendChannelMessage(user->uuid, target.Get<Channel>(), "", target.status, details.tags_out, details.exemptions, "TAGMSG"); + break; + } + case MessageTarget::TYPE_SERVER: + { + const std::string* serverglob = target.Get<std::string>(); + CmdBuilder par(user, "TAGMSG"); + par.push_tags(details.tags_out); + par.push_back(*serverglob); + par.Broadcast(); + break; + } + } +} + void ModuleSpanningTree::OnBackgroundTimer(time_t curtime) { AutoConnectServers(curtime); diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h @@ -28,6 +28,7 @@ #include "modules/dns.h" #include "modules/ssl.h" #include "modules/stats.h" +#include "modules/ctctags.h" #include "servercommand.h" #include "commands.h" #include "protocolinterface.h" @@ -72,6 +73,7 @@ class ModuleSpanningTree : public Module , public Away::EventListener , public Stats::EventListener + , public CTCTags::EventListener { /** Client to server commands, registered in the core */ @@ -169,6 +171,7 @@ class ModuleSpanningTree ModResult OnPreTopicChange(User* user, Channel* chan, const std::string& topic) CXX11_OVERRIDE; void OnPostTopicChange(User* user, Channel* chan, const std::string &topic) CXX11_OVERRIDE; void OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE; + void OnUserPostTagMessage(User* user, const MessageTarget& target, const CTCTags::TagMessageDetails& details) CXX11_OVERRIDE; void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE; void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts) CXX11_OVERRIDE; void OnChangeHost(User* user, const std::string &newhost) CXX11_OVERRIDE;