summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-07-02 09:37:11 +0100
committerPeter Powell <petpow@saberuk.com>2019-07-02 09:37:11 +0100
commitfa0ee25eaf4c9bd6c5f3656c30ce1f69653a3132 (patch)
treeeef64265684734b8739b83427cb9897d762b96e3
parente86b4311c090d9f3d06c5762a978563acfd84039 (diff)
Revert "Add the msgid tag to all outgoing messages".
This causes inconsistent message ids between servers. This reverts commit 638e4bb417ebcd4f0a384ac19585620b0fde1569.
-rw-r--r--src/modules/m_ircv3_msgid.cpp58
1 files changed, 27 insertions, 31 deletions
diff --git a/src/modules/m_ircv3_msgid.cpp b/src/modules/m_ircv3_msgid.cpp
index 00854a19c..4d34455b9 100644
--- a/src/modules/m_ircv3_msgid.cpp
+++ b/src/modules/m_ircv3_msgid.cpp
@@ -22,49 +22,18 @@
#include "modules/cap.h"
#include "modules/ctctags.h"
-class MsgIdGenerator
-{
- uint64_t counter;
- std::string strid;
- const std::string::size_type baselen;
-
- public:
- MsgIdGenerator()
- : counter(0)
- , strid(InspIRCd::Format("%s~%lu~", ServerInstance->Config->GetSID().c_str(), ServerInstance->startup_time))
- , baselen(strid.length())
- {
- }
-
- const std::string& GetNext()
- {
- strid.erase(baselen);
- strid.append(ConvToStr(counter++));
- return strid;
- }
-};
-
class MsgIdTag : public ClientProtocol::MessageTagProvider
{
private:
Cap::Reference ctctagcap;
public:
- MsgIdGenerator generator;
-
MsgIdTag(Module* mod)
: ClientProtocol::MessageTagProvider(mod)
, ctctagcap(mod, "message-tags")
{
}
- void OnPopulateTags(ClientProtocol::Message& msg) CXX11_OVERRIDE
- {
- const ClientProtocol::TagMap& tags = msg.GetTags();
- if (tags.find("msgid") == tags.end())
- msg.AddTag("msgid", this, generator.GetNext());
- }
-
ModResult OnProcessTag(User* user, const std::string& tagname, std::string& tagvalue) CXX11_OVERRIDE
{
if (!irc::equals(tagname, "msgid"))
@@ -80,12 +49,35 @@ class MsgIdTag : public ClientProtocol::MessageTagProvider
}
};
+class MsgIdGenerator
+{
+ uint64_t counter;
+ std::string strid;
+ const std::string::size_type baselen;
+
+ public:
+ MsgIdGenerator()
+ : counter(0)
+ , strid(InspIRCd::Format("%s~%lu~", ServerInstance->Config->GetSID().c_str(), ServerInstance->startup_time))
+ , baselen(strid.length())
+ {
+ }
+
+ const std::string& GetNext()
+ {
+ strid.erase(baselen);
+ strid.append(ConvToStr(counter++));
+ return strid;
+ }
+};
+
class ModuleMsgId
: public Module
, public CTCTags::EventListener
{
private:
MsgIdTag tag;
+ MsgIdGenerator generator;
ModResult CopyMessageId(const ClientProtocol::TagMap& tags_in, ClientProtocol::TagMap& tags_out)
{
@@ -95,7 +87,11 @@ class ModuleMsgId
// If the remote server has sent a message identifier we should use that as
// identifiers need to be the same on all sides of the network.
tags_out.insert(*iter);
+ return MOD_RES_PASSTHRU;
}
+
+ // Otherwise, we can just create a new message identifier.
+ tags_out.insert(std::make_pair("msgid", ClientProtocol::MessageTagData(&tag, generator.GetNext())));
return MOD_RES_PASSTHRU;
}