From 131ef9946fff0f5cfd794203e819df931b72600f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 26 Dec 2017 20:21:18 +0100 Subject: Include the nodes in the MAM iq result fix #3322 --- src/xmpp/biboumi_component.cpp | 19 ++++++++++++++++++- src/xmpp/xmpp_component.cpp | 4 +++- src/xmpp/xmpp_component.hpp | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 51ca78d..a998fbe 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -725,7 +725,24 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) if (!line.col().empty()) this->send_archived_message(line, to.full(), from.full(), query_id); } - this->send_iq_result_full_jid(id, from.full(), to.full()); + { + auto fin_ptr = std::make_unique("fin"); + { + XmlNode& fin = *(fin_ptr.get()); + fin["xmlns"] = MAM_NS; + XmlSubNode set(fin, "set"); + set["xmlns"] = RSM_NS; + if (!lines.empty()) + { + XmlSubNode first(set, "first"); + first["index"] = "0"; + first.set_inner(lines[0].col()); + XmlSubNode last(set, "last"); + last.set_inner(lines[lines.size() - 1].col()); + } + } + this->send_iq_result_full_jid(id, from.full(), to.full(), std::move(fin_ptr)); + } return true; } return false; diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp index c44b990..8f6826e 100644 --- a/src/xmpp/xmpp_component.cpp +++ b/src/xmpp/xmpp_component.cpp @@ -640,13 +640,15 @@ void XmppComponent::send_iq_version_request(const std::string& from, this->send_stanza(iq); } -void XmppComponent::send_iq_result_full_jid(const std::string& id, const std::string& to_jid, const std::string& from_full_jid) +void XmppComponent::send_iq_result_full_jid(const std::string& id, const std::string& to_jid, const std::string& from_full_jid, std::unique_ptr inner) { Stanza iq("iq"); iq["from"] = from_full_jid; iq["to"] = to_jid; iq["id"] = id; iq["type"] = "result"; + if (inner) + iq.add_child(std::move(inner)); this->send_stanza(iq); } diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp index 2bbbe3b..3950863 100644 --- a/src/xmpp/xmpp_component.hpp +++ b/src/xmpp/xmpp_component.hpp @@ -203,7 +203,7 @@ public: */ void send_iq_result(const std::string& id, const std::string& to_jid, const std::string& from); void send_iq_result_full_jid(const std::string& id, const std::string& to_jid, - const std::string& from_full_jid); + const std::string& from_full_jid, std::unique_ptr inner=nullptr); void handle_handshake(const Stanza& stanza); void handle_error(const Stanza& stanza); -- cgit v1.2.3