summaryrefslogtreecommitdiff
path: root/src/bridge
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2016-08-23 00:11:51 +0200
committerlouiz’ <louiz@louiz.org>2016-08-23 01:11:51 +0200
commitcfebca4d7c46959fc490cb9c72363d4ac3ee0c7a (patch)
tree1bafdcff85c2000573cdaf8398665135e3ebbf9d /src/bridge
parentf7fa34436a4d0f92d8d454ceb48d3df111c822b1 (diff)
downloadbiboumi-cfebca4d7c46959fc490cb9c72363d4ac3ee0c7a.tar.gz
biboumi-cfebca4d7c46959fc490cb9c72363d4ac3ee0c7a.tar.bz2
biboumi-cfebca4d7c46959fc490cb9c72363d4ac3ee0c7a.tar.xz
biboumi-cfebca4d7c46959fc490cb9c72363d4ac3ee0c7a.zip
Only save the logs if recordHistory global config option is true
Diffstat (limited to 'src/bridge')
-rw-r--r--src/bridge/bridge.cpp19
-rw-r--r--src/bridge/bridge.hpp8
2 files changed, 23 insertions, 4 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index ad1a45e..9b91474 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -32,6 +32,10 @@ Bridge::Bridge(const std::string& user_jid, BiboumiComponent& xmpp, std::shared_
xmpp(xmpp),
poller(poller)
{
+#ifdef USE_DATABASE
+ const auto options = Database::get_global_options(this->user_jid);
+ this->set_record_history(options.recordHistory.value());
+#endif
}
/**
@@ -241,8 +245,9 @@ void Bridge::send_channel_message(const Iid& iid, const std::string& body)
#ifdef USE_DATABASE
const auto xmpp_body = this->make_xmpp_body(line);
- Database::store_muc_message(this->get_bare_jid(), iid, std::chrono::system_clock::now(),
- std::get<0>(xmpp_body), irc->get_own_nick());
+ if (this->record_history)
+ Database::store_muc_message(this->get_bare_jid(), iid, std::chrono::system_clock::now(),
+ std::get<0>(xmpp_body), irc->get_own_nick());
#endif
for (const auto& resource: this->resources_in_chan[iid.to_tuple()])
this->xmpp.send_muc_message(std::to_string(iid), irc->get_own_nick(),
@@ -616,7 +621,7 @@ void Bridge::send_message(const Iid& iid, const std::string& nick, const std::st
{
#ifdef USE_DATABASE
const auto xmpp_body = this->make_xmpp_body(body, encoding);
- if (!nick.empty())
+ if (!nick.empty() && this->record_history)
Database::store_muc_message(this->get_bare_jid(), iid, std::chrono::system_clock::now(),
std::get<0>(xmpp_body), nick);
#endif
@@ -971,7 +976,6 @@ void Bridge::generate_channel_join_for_resource(const Iid& iid, const std::strin
{
if (user->nick != self->nick)
{
- log_debug(user->nick);
this->send_user_join(iid.get_server(), iid.get_encoded_local(),
user.get(), user->get_most_significant_mode(irc->get_sorted_user_modes()),
false, resource);
@@ -982,3 +986,10 @@ void Bridge::generate_channel_join_for_resource(const Iid& iid, const std::strin
true, resource);
this->send_topic(iid.get_server(), iid.get_encoded_local(), channel->topic, channel->topic_author, resource);
}
+
+#ifdef USE_DATABASE
+void Bridge::set_record_history(const bool val)
+{
+ this->record_history = val;
+}
+#endif \ No newline at end of file
diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp
index c26995f..0e1fbf4 100644
--- a/src/bridge/bridge.hpp
+++ b/src/bridge/bridge.hpp
@@ -13,6 +13,8 @@
#include <string>
#include <memory>
+#include <biboumi.h>
+
class BiboumiComponent;
class Poller;
@@ -215,6 +217,9 @@ public:
void trigger_on_irc_message(const std::string& irc_hostname, const IrcMessage& message);
std::unordered_map<std::string, std::shared_ptr<IrcClient>>& get_irc_clients();
std::set<char> get_chantypes(const std::string& hostname) const;
+#ifdef USE_DATABASE
+ void set_record_history(const bool val);
+#endif
private:
/**
@@ -295,6 +300,9 @@ private:
* TODO: send message history
*/
void generate_channel_join_for_resource(const Iid& iid, const std::string& resource);
+#ifdef USE_DATABASE
+ bool record_history { true };
+#endif
};
struct IRCNotConnected: public std::exception