summaryrefslogtreecommitdiff
path: root/src/xmpp/biboumi_component.cpp
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/xmpp/biboumi_component.cpp
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/xmpp/biboumi_component.cpp')
-rw-r--r--src/xmpp/biboumi_component.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp
index 6c0d0e9..c531bd0 100644
--- a/src/xmpp/biboumi_component.cpp
+++ b/src/xmpp/biboumi_component.cpp
@@ -286,7 +286,26 @@ void BiboumiComponent::handle_message(const Stanza& stanza)
if (body && !body->get_inner().empty())
{
if (bridge->is_resource_in_chan(iid.to_tuple(), from.resource))
- bridge->send_channel_message(iid, body->get_inner(), id);
+ {
+ // Extract some XML nodes that we must include in the
+ // reflection (if any), because XMPP says so
+ std::vector<XmlNode> nodes_to_reflect;
+ const XmlNode* origin_id = stanza.get_child("origin-id", STABLE_ID_NS);
+ if (origin_id)
+ nodes_to_reflect.push_back(*origin_id);
+ const auto own_address = std::to_string(iid) + '@' + this->served_hostname;
+ for (const XmlNode* stable_id: stanza.get_children("stable-id", STABLE_ID_NS))
+ {
+ // Stanza ID generating entities, which encounter a
+ // <stanza-id/> element where the 'by' attribute matches
+ // the 'by' attribute they would otherwise set, MUST
+ // delete that element even if they are not adding their
+ // own stanza ID.
+ if (stable_id->get_tag("by") != own_address)
+ nodes_to_reflect.push_back(*stable_id);
+ }
+ bridge->send_channel_message(iid, body->get_inner(), id, std::move(nodes_to_reflect));
+ }
else
{
error_type = "modify";