Always return the oldest matching messages from MAM, even if no date is set
This commit is contained in:
@@ -185,13 +185,36 @@ std::vector<Database::MucLogLine> Database::get_muc_logs(const std::string& owne
|
||||
request << " and " << Database::Date{} << "<=" << end_time;
|
||||
}
|
||||
|
||||
if (limit >= 0)
|
||||
request.limit() << limit;
|
||||
|
||||
auto result = request.execute(*Database::db);
|
||||
|
||||
return {result.cbegin(), result.cend()};
|
||||
}
|
||||
|
||||
std::vector<Database::MucLogLine> Database::get_muc_most_recent_logs(const std::string& owner, const std::string& chan_name, const std::string& server,
|
||||
int limit, const std::string& start)
|
||||
{
|
||||
auto request = Database::muc_log_lines.select();
|
||||
request.where() << Database::Owner{} << "=" << owner << \
|
||||
" and " << Database::IrcChanName{} << "=" << chan_name << \
|
||||
" and " << Database::IrcServerName{} << "=" << server;
|
||||
|
||||
if (!start.empty())
|
||||
{
|
||||
const auto start_time = utils::parse_datetime(start);
|
||||
if (start_time != -1)
|
||||
request << " and " << Database::Date{} << ">=" << start_time;
|
||||
}
|
||||
|
||||
request.order_by() << Id{} << " DESC ";
|
||||
|
||||
if (limit >= 0)
|
||||
request.limit() << limit;
|
||||
|
||||
auto result = request.execute(*Database::db);
|
||||
|
||||
|
||||
return {result.crbegin(), result.crend()};
|
||||
}
|
||||
|
||||
|
||||
@@ -118,8 +118,17 @@ class Database
|
||||
static IrcChannelOptions get_irc_channel_options_with_server_and_global_default(const std::string& owner,
|
||||
const std::string& server,
|
||||
const std::string& channel);
|
||||
/**
|
||||
* Get all the lines between (optional) start and end dates, with a (optional) limit.
|
||||
*/
|
||||
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="");
|
||||
|
||||
/**
|
||||
* Get the most recent messages from the archive, with optional limit and start date
|
||||
*/
|
||||
static std::vector<MucLogLine> get_muc_most_recent_logs(const std::string& owner, const std::string& chan_name, const std::string& server,
|
||||
int limit=-1, const std::string& start="");
|
||||
static std::string store_muc_message(const std::string& owner, const std::string& chan_name, const std::string& server_name,
|
||||
time_point date, const std::string& body, const std::string& nick);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user