summaryrefslogtreecommitdiff
path: root/src/bridge
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2020-03-11 00:08:18 +0100
committerlouiz’ <louiz@louiz.org>2020-03-11 00:13:46 +0100
commite967088986f0d32eec662e2ab3749e4ba8e07a21 (patch)
treed0024347d28fed1afafc330ead744ca1bb9043db /src/bridge
parent49a3931784d4b58e1f618f5424701ae6de79833b (diff)
downloadbiboumi-e967088986f0d32eec662e2ab3749e4ba8e07a21.tar.gz
biboumi-e967088986f0d32eec662e2ab3749e4ba8e07a21.tar.bz2
biboumi-e967088986f0d32eec662e2ab3749e4ba8e07a21.tar.xz
biboumi-e967088986f0d32eec662e2ab3749e4ba8e07a21.zip
Make sure we keep the stable-id and origin-id nodes when required
See https://xmpp.org/extensions/xep-0359.html
Diffstat (limited to 'src/bridge')
-rw-r--r--src/bridge/bridge.cpp20
-rw-r--r--src/bridge/bridge.hpp2
2 files changed, 15 insertions, 7 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index bfcb8fe..28869c8 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -196,7 +196,7 @@ bool Bridge::join_irc_channel(const Iid& iid, std::string nickname,
return false;
}
-void Bridge::send_channel_message(const Iid& iid, const std::string& body, std::string id)
+void Bridge::send_channel_message(const Iid& iid, const std::string& body, std::string id, std::vector<XmlNode> nodes_to_reflect)
{
if (iid.get_server().empty())
{
@@ -234,15 +234,21 @@ void Bridge::send_channel_message(const Iid& iid, const std::string& body, std::
if (!first || id.empty())
id = utils::gen_uuid();
- MessageCallback mirror_to_all_resources = [this, iid, uuid, id](const IrcClient* irc, const IrcMessage& message) {
+ MessageCallback mirror_to_all_resources = [this, iid, uuid, id, nodes_to_reflect](const IrcClient* irc, const IrcMessage& message) {
std::string line = message.arguments[1];
// “temporary” workaround for \01ACTION…\01 -> /me messages
if ((line.size() > strlen("\01ACTION\01")) &&
(line.substr(0, 7) == "\01ACTION") && line[line.size() - 1] == '\01')
line = "/me " + line.substr(8, line.size() - 9);
for (const auto& resource: this->resources_in_chan[iid.to_tuple()])
- this->xmpp.send_muc_message(std::to_string(iid), irc->get_own_nick(), this->make_xmpp_body(line),
- this->user_jid + "/" + resource, uuid, id);
+ {
+ auto stanza = this->xmpp.make_muc_message(std::to_string(iid), irc->get_own_nick(), this->make_xmpp_body(line),
+ this->user_jid + "/"
+ + resource, uuid, id);
+ for (const auto& node: nodes_to_reflect)
+ stanza.add_child(node);
+ this->xmpp.send_stanza(stanza);
+ }
};
if (line.substr(0, 5) == "/mode")
@@ -859,8 +865,10 @@ void Bridge::send_message(const Iid& iid, const std::string& nick, const std::st
#endif
for (const auto& resource: this->resources_in_chan[iid.to_tuple()])
{
- this->xmpp.send_muc_message(std::to_string(iid), nick, this->make_xmpp_body(body, encoding),
- this->user_jid + "/" + resource, uuid, utils::gen_uuid());
+ auto stanza = this->xmpp.make_muc_message(std::to_string(iid), nick, this->make_xmpp_body(body, encoding),
+ this->user_jid + "/"
+ + resource, uuid, utils::gen_uuid());
+ this->xmpp.send_stanza(stanza);
}
}
else
diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp
index fa2a31f..a94f07b 100644
--- a/src/bridge/bridge.hpp
+++ b/src/bridge/bridge.hpp
@@ -81,7 +81,7 @@ public:
HistoryLimit history_limit,
const bool force_join);
- void send_channel_message(const Iid& iid, const std::string& body, std::string id);
+ void send_channel_message(const Iid& iid, const std::string& body, std::string id, std::vector<XmlNode> nodes_to_reflect);
void send_private_message(const Iid& iid, const std::string& body, const std::string& type="PRIVMSG");
void send_raw_message(const std::string& hostname, const std::string& body);
void leave_irc_channel(Iid&& iid, const std::string& status_message, const std::string& resource);