diff options
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/biboumi_component.cpp | 23 | ||||
-rw-r--r-- | src/xmpp/xmpp_component.cpp | 4 | ||||
-rw-r--r-- | src/xmpp/xmpp_component.hpp | 4 |
3 files changed, 25 insertions, 6 deletions
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 91be091..f49b3b6 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -302,7 +302,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* stanza_id: stanza.get_children("stanza-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 (stanza_id->get_tag("by") != own_address) + nodes_to_reflect.push_back(*stanza_id); + } + bridge->send_channel_message(iid, body->get_inner(), id, std::move(nodes_to_reflect)); + } else { error_type = "modify"; @@ -1008,7 +1027,7 @@ void BiboumiComponent::send_irc_channel_disco_info(const std::string& id, const identity["category"] = "conference"; identity["type"] = "irc"; identity["name"] = ""s + iid.get_local() + " on " + iid.get_server(); - for (const char *ns: {DISCO_INFO_NS, MUC_NS, ADHOC_NS, PING_NS, MAM_NS, VERSION_NS, STABLE_MUC_ID_NS, SELF_PING_FLAG, "muc_nonanonymous"}) + for (const char *ns: {DISCO_INFO_NS, MUC_NS, ADHOC_NS, PING_NS, MAM_NS, VERSION_NS, STABLE_MUC_ID_NS, SELF_PING_FLAG, "muc_nonanonymous", STABLE_ID_NS}) { XmlSubNode feature(query, "feature"); feature["var"] = ns; diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp index f82f9ce..767fb2e 100644 --- a/src/xmpp/xmpp_component.cpp +++ b/src/xmpp/xmpp_component.cpp @@ -367,7 +367,7 @@ void XmppComponent::send_topic(const std::string& from, Xmpp::body&& topic, cons this->send_stanza(message); } -void XmppComponent::send_muc_message(const std::string& muc_name, const std::string& nick, Xmpp::body&& xmpp_body, const std::string& jid_to, std::string uuid, std::string id) +Stanza XmppComponent::make_muc_message(const std::string& muc_name, const std::string& nick, Xmpp::body&& xmpp_body, const std::string& jid_to, std::string uuid, std::string id) { Stanza message("message"); message["to"] = jid_to; @@ -399,7 +399,7 @@ void XmppComponent::send_muc_message(const std::string& muc_name, const std::str stanza_id["id"] = std::move(uuid); } - this->send_stanza(message); + return message; } #ifdef USE_DATABASE diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp index 156e286..ee6b776 100644 --- a/src/xmpp/xmpp_component.hpp +++ b/src/xmpp/xmpp_component.hpp @@ -135,8 +135,8 @@ public: /** * Send a (non-private) message to the MUC */ - void send_muc_message(const std::string& muc_name, const std::string& nick, Xmpp::body&& body, const std::string& jid_to, - std::string uuid, std::string id); + Stanza make_muc_message(const std::string& muc_name, const std::string& nick, Xmpp::body&& xmpp_body, const std::string& jid_to, + std::string uuid, std::string id); #ifdef USE_DATABASE /** * Send a message, with a <delay/> element, part of a MUC history |