MaxHistoryLength now has some sensible default value if the user set a negative one
This commit is contained in:
@@ -1007,11 +1007,14 @@ void Bridge::send_room_history(const std::string& hostname, const std::string& c
|
|||||||
void Bridge::send_room_history(const std::string& hostname, std::string chan_name, const std::string& resource, const HistoryLimit& history_limit)
|
void Bridge::send_room_history(const std::string& hostname, std::string chan_name, const std::string& resource, const HistoryLimit& history_limit)
|
||||||
{
|
{
|
||||||
#ifdef USE_DATABASE
|
#ifdef USE_DATABASE
|
||||||
const auto coptions = Database::get_irc_channel_options_with_server_and_global_default(this->user_jid, hostname, chan_name);
|
const auto goptions = Database::get_global_options(this->user_jid);
|
||||||
auto limit = coptions.col<Database::MaxHistoryLength>();
|
log_debug(goptions.col<Database::MaxHistoryLength>());
|
||||||
|
auto limit = goptions.col<Database::MaxHistoryLength>();
|
||||||
|
if (limit < 0)
|
||||||
|
limit = 20;
|
||||||
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 result = Database::get_muc_logs(this->user_jid, chan_name, hostname, limit, history_limit.since, {}, Id::unset_value, Database::Paging::last);
|
const auto result = Database::get_muc_logs(this->user_jid, chan_name, hostname, static_cast<std::size_t>(limit), history_limit.since, {}, Id::unset_value, Database::Paging::last);
|
||||||
const auto& lines = std::get<1>(result);
|
const auto& lines = std::get<1>(result);
|
||||||
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)
|
||||||
|
|||||||
@@ -162,10 +162,6 @@ Database::IrcChannelOptions Database::get_irc_channel_options_with_server_and_gl
|
|||||||
coptions.col<EncodingOut>() = get_first_non_empty(coptions.col<EncodingOut>(),
|
coptions.col<EncodingOut>() = get_first_non_empty(coptions.col<EncodingOut>(),
|
||||||
soptions.col<EncodingOut>());
|
soptions.col<EncodingOut>());
|
||||||
|
|
||||||
coptions.col<MaxHistoryLength>() = get_first_non_empty(coptions.col<MaxHistoryLength>(),
|
|
||||||
soptions.col<MaxHistoryLength>(),
|
|
||||||
goptions.col<MaxHistoryLength>());
|
|
||||||
|
|
||||||
return coptions;
|
return coptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,6 @@ void actual_bind(Statement& statement, const std::string& value, int index)
|
|||||||
statement.bind_text(index, value);
|
statement.bind_text(index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void actual_bind(Statement& statement, const std::int64_t& value, int index)
|
|
||||||
{
|
|
||||||
statement.bind_int64(index, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void actual_bind(Statement& statement, const OptionalBool& value, int index)
|
void actual_bind(Statement& statement, const OptionalBool& value, int index)
|
||||||
{
|
{
|
||||||
if (!value.is_set)
|
if (!value.is_set)
|
||||||
|
|||||||
@@ -12,13 +12,14 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
void actual_bind(Statement& statement, const std::string& value, int index);
|
void actual_bind(Statement& statement, const std::string& value, int index);
|
||||||
void actual_bind(Statement& statement, const std::int64_t& value, int index);
|
void actual_bind(Statement& statement, const OptionalBool& value, int index);
|
||||||
template <typename T, typename std::enable_if_t<std::is_integral<T>::value>* = 0>
|
template <typename T>
|
||||||
void actual_bind(Statement& statement, const T& value, int index)
|
void actual_bind(Statement& statement, const T& value, int index)
|
||||||
{
|
{
|
||||||
actual_bind(statement, static_cast<std::int64_t>(value), index);
|
static_assert(std::is_integral<T>::value,
|
||||||
|
"Only a string, an optional-bool or an integer can be used.");
|
||||||
|
statement.bind_int64(index, static_cast<int>(value));
|
||||||
}
|
}
|
||||||
void actual_bind(Statement& statement, const OptionalBool& value, int index);
|
|
||||||
|
|
||||||
#ifdef DEBUG_SQL_QUERIES
|
#ifdef DEBUG_SQL_QUERIES
|
||||||
#include <utils/scopetimer.hpp>
|
#include <utils/scopetimer.hpp>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ struct OptionalBool
|
|||||||
{
|
{
|
||||||
OptionalBool() = default;
|
OptionalBool() = default;
|
||||||
|
|
||||||
OptionalBool(bool value):
|
explicit OptionalBool(bool value):
|
||||||
is_set(true), value(value) {}
|
is_set(true), value(value) {}
|
||||||
|
|
||||||
void set_value(bool value)
|
void set_value(bool value)
|
||||||
|
|||||||
Reference in New Issue
Block a user