summaryrefslogtreecommitdiff
path: root/src/bridge
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2018-08-23 20:30:11 +0200
committerlouiz’ <louiz@louiz.org>2018-08-23 20:30:11 +0200
commit0b51e3828116f6847865fae93893eb97a10d1cc2 (patch)
tree39abd4550930b6c5d0fc99fa75ddab0724970371 /src/bridge
parent4a583c7b7ea6046202a4cb7c0437241c8f597356 (diff)
downloadbiboumi-0b51e3828116f6847865fae93893eb97a10d1cc2.tar.gz
biboumi-0b51e3828116f6847865fae93893eb97a10d1cc2.tar.bz2
biboumi-0b51e3828116f6847865fae93893eb97a10d1cc2.tar.xz
biboumi-0b51e3828116f6847865fae93893eb97a10d1cc2.zip
MaxHistoryLength now has some sensible default value if the user set a negative one
Diffstat (limited to 'src/bridge')
-rw-r--r--src/bridge/bridge.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index ad03f38..a69bdff 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -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)
{
#ifdef USE_DATABASE
- const auto coptions = Database::get_irc_channel_options_with_server_and_global_default(this->user_jid, hostname, chan_name);
- auto limit = coptions.col<Database::MaxHistoryLength>();
+ const auto goptions = Database::get_global_options(this->user_jid);
+ 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)
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);
chan_name.append(utils::empty_if_fixed_server("%" + hostname));
for (const auto& line: lines)