Revert "Use the Date to find a next page in RSM, not the id"
This reverts commit 5ef7ba0802.
This commit is contained in:
@@ -1005,7 +1005,7 @@ void Bridge::send_room_history(const std::string& hostname, std::string chan_nam
|
|||||||
auto limit = coptions.col<Database::MaxHistoryLength>();
|
auto limit = coptions.col<Database::MaxHistoryLength>();
|
||||||
if (history_limit.stanzas >= 0 && history_limit.stanzas < limit)
|
if (history_limit.stanzas >= 0 && history_limit.stanzas < limit)
|
||||||
limit = history_limit.stanzas;
|
limit = history_limit.stanzas;
|
||||||
const auto lines = Database::get_muc_logs(this->user_jid, chan_name, hostname, limit, history_limit.since, {}, {}, Database::Paging::last);
|
const auto lines = Database::get_muc_logs(this->user_jid, chan_name, hostname, limit, history_limit.since, {}, Id::unset_value, Database::Paging::last);
|
||||||
chan_name.append(utils::empty_if_fixed_server("%" + hostname));
|
chan_name.append(utils::empty_if_fixed_server("%" + hostname));
|
||||||
for (const auto& line: lines)
|
for (const auto& line: lines)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ std::string Database::store_muc_message(const std::string& owner, const std::str
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Database::MucLogLine> Database::get_muc_logs(const std::string& owner, const std::string& chan_name, const std::string& server,
|
std::vector<Database::MucLogLine> Database::get_muc_logs(const std::string& owner, const std::string& chan_name, const std::string& server,
|
||||||
int limit, const std::string& start, const std::string& end, const std::string& reference_uuid, Database::Paging paging)
|
int limit, const std::string& start, const std::string& end, const Id::real_type reference_record_id, Database::Paging paging)
|
||||||
{
|
{
|
||||||
if (limit == 0)
|
if (limit == 0)
|
||||||
return {};
|
return {};
|
||||||
@@ -222,15 +222,14 @@ std::vector<Database::MucLogLine> Database::get_muc_logs(const std::string& owne
|
|||||||
request << " and " << Database::Date{} << "<=" << writer;
|
request << " and " << Database::Date{} << "<=" << writer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!reference_uuid.empty())
|
if (reference_record_id != Id::unset_value)
|
||||||
{
|
{
|
||||||
request << " and " << Database::Date{};
|
request << " and " << Id{};
|
||||||
if (paging == Database::Paging::first)
|
if (paging == Database::Paging::first)
|
||||||
request << ">";
|
request << ">";
|
||||||
else
|
else
|
||||||
request << "<";
|
request << "<";
|
||||||
request << "(SELECT " << Database::Date{} << " FROM " << Database::muc_log_lines.get_name().data()
|
request << reference_record_id;
|
||||||
<< " WHERE " << Database::Uuid{} << " = " << reference_uuid << ")";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paging == Database::Paging::first)
|
if (paging == Database::Paging::first)
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ class Database
|
|||||||
*/
|
*/
|
||||||
static std::vector<MucLogLine> get_muc_logs(const std::string& owner, const std::string& chan_name, const std::string& server,
|
static std::vector<MucLogLine> get_muc_logs(const std::string& owner, const std::string& chan_name, const std::string& server,
|
||||||
int limit=-1, const std::string& start="", const std::string& end="",
|
int limit=-1, const std::string& start="", const std::string& end="",
|
||||||
const std::string& reference_record_id={}, Paging=Paging::first);
|
const Id::real_type reference_record_id=Id::unset_value, Paging=Paging::first);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get just one single record matching the given uuid, between (optional) end and start.
|
* Get just one single record matching the given uuid, between (optional) end and start.
|
||||||
|
|||||||
@@ -716,7 +716,7 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza)
|
|||||||
}
|
}
|
||||||
const XmlNode* set = query->get_child("set", RSM_NS);
|
const XmlNode* set = query->get_child("set", RSM_NS);
|
||||||
int limit = -1;
|
int limit = -1;
|
||||||
std::string reference_uuid{};
|
Id::real_type reference_record_id{Id::unset_value};
|
||||||
Database::Paging paging_order{Database::Paging::first};
|
Database::Paging paging_order{Database::Paging::first};
|
||||||
if (set)
|
if (set)
|
||||||
{
|
{
|
||||||
@@ -726,10 +726,9 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza)
|
|||||||
const XmlNode* after = set->get_child("after", RSM_NS);
|
const XmlNode* after = set->get_child("after", RSM_NS);
|
||||||
if (after)
|
if (after)
|
||||||
{
|
{
|
||||||
// Will throw if the uuid does not exist, that’s all.
|
auto after_record = Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(),
|
||||||
Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(),
|
|
||||||
after->get_inner(), start, end);
|
after->get_inner(), start, end);
|
||||||
reference_uuid = after->get_inner();
|
reference_record_id = after_record.col<Id>();
|
||||||
}
|
}
|
||||||
const XmlNode* before = set->get_child("before", RSM_NS);
|
const XmlNode* before = set->get_child("before", RSM_NS);
|
||||||
if (before)
|
if (before)
|
||||||
@@ -737,9 +736,8 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza)
|
|||||||
paging_order = Database::Paging::last;
|
paging_order = Database::Paging::last;
|
||||||
if (!before->get_inner().empty())
|
if (!before->get_inner().empty())
|
||||||
{
|
{
|
||||||
// Will throw if the uuid does not exist
|
auto before_record = Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), before->get_inner(), start, end);
|
||||||
Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), before->get_inner(), start, end);
|
reference_record_id = before_record.col<Id>();
|
||||||
reference_uuid = before->get_inner();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -751,7 +749,7 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza)
|
|||||||
if ((limit == -1 && start.empty() && end.empty())
|
if ((limit == -1 && start.empty() && end.empty())
|
||||||
|| limit > 100)
|
|| limit > 100)
|
||||||
limit = 101;
|
limit = 101;
|
||||||
auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end, reference_uuid, paging_order);
|
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;
|
bool complete = true;
|
||||||
if (lines.size() > 100)
|
if (lines.size() > 100)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user