summaryrefslogtreecommitdiff
path: root/src/xmpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2018-02-10 19:51:59 +0100
committerlouiz’ <louiz@louiz.org>2018-02-10 19:51:59 +0100
commit0280343ced6c520700c3ca508e2d04c6b512d319 (patch)
treec495521dbc46dc931acc2f48d23f1aed33d8387f /src/xmpp
parentce1b6583e82cc03130700222e64796bacd704463 (diff)
downloadbiboumi-0280343ced6c520700c3ca508e2d04c6b512d319.tar.gz
biboumi-0280343ced6c520700c3ca508e2d04c6b512d319.tar.bz2
biboumi-0280343ced6c520700c3ca508e2d04c6b512d319.tar.xz
biboumi-0280343ced6c520700c3ca508e2d04c6b512d319.zip
Handle the “after” RSM value to page through results
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/biboumi_component.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp
index 250007e..cd6d570 100644
--- a/src/xmpp/biboumi_component.cpp
+++ b/src/xmpp/biboumi_component.cpp
@@ -715,11 +715,19 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza)
}
const XmlNode* set = query->get_child("set", RSM_NS);
int limit = -1;
+ Id::real_type after_id{Id::unset_value};
if (set)
{
const XmlNode* max = set->get_child("max", RSM_NS);
if (max)
limit = std::atoi(max->get_inner().data());
+ const XmlNode* after = set->get_child("after", RSM_NS);
+ if (after)
+ {
+ auto after_record = Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(),
+ after->get_inner(), start, end);
+ after_id = after_record.col<Id>();
+ }
}
// Do not send more than 100 messages, even if the client asked for more,
// or if it didn’t specify any limit.
@@ -729,7 +737,7 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza)
if ((limit == -1 && start.empty() && end.empty())
|| limit > 100)
limit = 101;
- auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end);
+ auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end, after_id);
bool complete = true;
if (lines.size() > 100)
{