summaryrefslogtreecommitdiff
path: root/src/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/biboumi_component.cpp37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp
index a49f52e..a2fda60 100644
--- a/src/xmpp/biboumi_component.cpp
+++ b/src/xmpp/biboumi_component.cpp
@@ -550,13 +550,36 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza)
Iid iid(to.local, {'#', '&'});
if (iid.type == Iid::Type::Channel && to.resource.empty())
{
- const auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), -1);
- for (const db::MucLogLine& line: lines)
- {
- const auto queryid = query->get_tag("queryid");
- if (!line.nick.value().empty())
- this->send_archived_message(line, to.full(), from.full(), queryid);
- }
+ std::string start;
+ std::string end;
+ const XmlNode* x = query->get_child("x", DATAFORM_NS);
+ if (x)
+ {
+ const XmlNode* value;
+ const auto fields = x->get_children("field", DATAFORM_NS);
+ for (const auto& field: fields)
+ {
+ if (field->get_tag("var") == "start")
+ {
+ value = field->get_child("value", DATAFORM_NS);
+ if (value)
+ start = value->get_inner();
+ }
+ else if (field->get_tag("var") == "end")
+ {
+ value = field->get_child("value", DATAFORM_NS);
+ if (value)
+ end = value->get_inner();
+ }
+ }
+ }
+ const auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), -1, start, end);
+ for (const db::MucLogLine& line: lines)
+ {
+ const auto queryid = query->get_tag("queryid");
+ if (!line.nick.value().empty())
+ this->send_archived_message(line, to.full(), from.full(), queryid);
+ }
this->send_iq_result_full_jid(id, from.full(), to.full());
return true;
}