summaryrefslogtreecommitdiff
path: root/src/database
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2016-08-25 19:43:51 +0200
committerlouiz’ <louiz@louiz.org>2016-08-28 22:42:50 +0200
commit7536a1b3f38fbf093c1629b0db209754ada0c906 (patch)
tree6d5f8f9d8ba3aa7274b75cc733dabdd89f20f29d /src/database
parentb59fc2a834dccb35f12dcfec624b6181e4e2fbe9 (diff)
downloadbiboumi-7536a1b3f38fbf093c1629b0db209754ada0c906.tar.gz
biboumi-7536a1b3f38fbf093c1629b0db209754ada0c906.tar.bz2
biboumi-7536a1b3f38fbf093c1629b0db209754ada0c906.tar.xz
biboumi-7536a1b3f38fbf093c1629b0db209754ada0c906.zip
Respond to MAM requests on a channel JID
At the moment, result-set-management is not implemented, the whole history (well, at most 1024 messages) is returned.
Diffstat (limited to 'src/database')
-rw-r--r--src/database/database.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/database/database.cpp b/src/database/database.cpp
index 009ff0e..be0da8e 100644
--- a/src/database/database.cpp
+++ b/src/database/database.cpp
@@ -138,13 +138,13 @@ void Database::store_muc_message(const std::string& owner, const Iid& iid,
std::vector<db::MucLogLine> Database::get_muc_logs(const std::string& owner, const std::string& chan_name, const std::string& server, int limit)
{
- if (limit < 0)
- limit = 0;
- auto res = litesql::select<db::MucLogLine>(*Database::db,
+ if (limit == -1)
+ limit = 1024;
+ const auto& res = litesql::select<db::MucLogLine>(*Database::db,
db::MucLogLine::Owner == owner &&
db::MucLogLine::IrcChanName == chan_name &&
- db::MucLogLine::IrcServerName == server).orderBy(db::MucLogLine::Date, false).limit(limit).all();
- return {res.rbegin(), res.rend()};
+ db::MucLogLine::IrcServerName == server).orderBy(db::MucLogLine::Id, false).limit(limit).all();
+ return {res.crbegin(), res.crend()};
}
void Database::close()