diff options
author | louiz’ <louiz@louiz.org> | 2018-02-13 03:51:03 +0100 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2018-02-13 03:51:03 +0100 |
commit | 4a2a280d76e45e165d5c4657f4a46eebf71594bf (patch) | |
tree | 118d8a448f5af21f66a35f30cc375f37ce4273ff /src/database | |
parent | 50d3c4a0b20a4fde582d186e4c9a2226755b1a04 (diff) | |
download | biboumi-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/database')
-rw-r--r-- | src/database/database.cpp | 16 | ||||
-rw-r--r-- | src/database/database.hpp | 2 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/database/database.cpp b/src/database/database.cpp index 2a63a6b..b2413d0 100644 --- a/src/database/database.cpp +++ b/src/database/database.cpp @@ -165,7 +165,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, - int limit, const std::string& start, const std::string& end, const Id::real_type after_id, 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) return {}; @@ -187,15 +187,21 @@ std::vector<Database::MucLogLine> Database::get_muc_logs(const std::string& owne if (end_time != -1) request << " and " << Database::Date{} << "<=" << end_time; } - if (after_id != Id::unset_value) + if (reference_record_id != Id::unset_value) { - request << " and " << Id{} << ">" << after_id; + request << " and " << Id{}; + if (paging == Database::Paging::first) + request << ">"; + else + request << "<"; + request << reference_record_id; } + request.order_by() << Id{}; if (paging == Database::Paging::first) - request.order_by() << Id{} << " ASC "; + request << " ASC "; else - request.order_by() << Id{} << " DESC "; + request << " DESC "; if (limit >= 0) request.limit() << limit; diff --git a/src/database/database.hpp b/src/database/database.hpp index 9c483f4..ce7595b 100644 --- a/src/database/database.hpp +++ b/src/database/database.hpp @@ -126,7 +126,7 @@ class Database */ 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="", - const Id::real_type after_id=Id::unset_value, 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. |