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.
This commit is contained in:
louiz’
2016-08-28 22:42:50 +02:00
parent b59fc2a834
commit 7536a1b3f3
11 changed files with 176 additions and 30 deletions
+5 -5
View File
@@ -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()