summaryrefslogtreecommitdiff
path: root/src/xmpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2018-02-13 03:51:03 +0100
committerlouiz’ <louiz@louiz.org>2018-02-13 03:51:03 +0100
commit4a2a280d76e45e165d5c4657f4a46eebf71594bf (patch)
tree118d8a448f5af21f66a35f30cc375f37ce4273ff /src/xmpp
parent50d3c4a0b20a4fde582d186e4c9a2226755b1a04 (diff)
downloadbiboumi-4a2a280d76e45e165d5c4657f4a46eebf71594bf.tar.gz
biboumi-4a2a280d76e45e165d5c4657f4a46eebf71594bf.tar.bz2
biboumi-4a2a280d76e45e165d5c4657f4a46eebf71594bf.tar.xz
biboumi-4a2a280d76e45e165d5c4657f4a46eebf71594bf.zip
Support the <before/> element in MAM requests
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/biboumi_component.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp
index 75a55e6..fe6cc1b 100644
--- a/src/xmpp/biboumi_component.cpp
+++ b/src/xmpp/biboumi_component.cpp
@@ -720,7 +720,8 @@ 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};
+ Id::real_type reference_record_id{Id::unset_value};
+ Database::Paging paging_order{Database::Paging::first};
if (set)
{
const XmlNode* max = set->get_child("max", RSM_NS);
@@ -731,7 +732,17 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza)
{
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>();
+ reference_record_id = after_record.col<Id>();
+ }
+ const XmlNode* before = set->get_child("before", RSM_NS);
+ if (before)
+ {
+ paging_order = Database::Paging::last;
+ if (!before->get_inner().empty())
+ {
+ auto before_record = Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), before->get_inner(), start, end);
+ reference_record_id = before_record.col<Id>();
+ }
}
}
// Do not send more than 100 messages, even if the client asked for more,
@@ -742,7 +753,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, after_id);
+ auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end, reference_record_id, paging_order);
bool complete = true;
if (lines.size() > 100)
{