summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/xmpp/biboumi_component.cpp19
-rw-r--r--src/xmpp/xmpp_component.cpp4
-rw-r--r--src/xmpp/xmpp_component.hpp2
-rw-r--r--tests/end_to_end/__main__.py5
4 files changed, 26 insertions, 4 deletions
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<Database::Nick>().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<XmlNode>("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<Database::Uuid>());
+ XmlSubNode last(set, "last");
+ last.set_inner(lines[lines.size() - 1].col<Database::Uuid>());
+ }
+ }
+ 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<XmlNode> 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<XmlNode> inner=nullptr);
void handle_handshake(const Stanza& stanza);
void handle_error(const Stanza& stanza);
diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py
index 2becdef..271f87b 100644
--- a/tests/end_to_end/__main__.py
+++ b/tests/end_to_end/__main__.py
@@ -130,6 +130,7 @@ def match(stanza, xpath):
'dataform': 'jabber:x:data',
'version': 'jabber:iq:version',
'mam': 'urn:xmpp:mam:2',
+ 'rms': 'http://jabber.org/protocol/rsm',
'delay': 'urn:xmpp:delay',
'forward': 'urn:xmpp:forward:0',
'client': 'jabber:client',
@@ -1852,7 +1853,9 @@ if __name__ == '__main__':
),
partial(expect_stanza,
- "/iq[@type='result'][@id='id1'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"),
+ ("/iq[@type='result'][@id='id1'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']",
+ "/iq/mam:fin/rms:set/rsm:last",
+ "/iq/mam:fin/rsm:set/rsm:first")),
# Retrieve an empty archive by specifying an early “end” date
partial(send_stanza, """<iq to='#foo%{irc_server_one}' from='{jid_one}/{resource_one}' type='set' id='id2'>