summaryrefslogtreecommitdiff
path: root/src/bridge
diff options
context:
space:
mode:
authorlouiz <louiz@louiz.org>2017-06-14 11:11:17 +0200
committerlouiz <louiz@louiz.org>2017-06-14 11:11:17 +0200
commit5ba66c33519567f9f4e806a9ab41c3c94d93237f (patch)
tree4b51bece4f4dec660e0c48297404a5da51aee4ec /src/bridge
parentceb496369f834ffa055eb5b7ffc273b2a21f9b9a (diff)
parent2677ac42e8d2e1cf162fec773a9acb453bef8b9b (diff)
downloadbiboumi-5ba66c33519567f9f4e806a9ab41c3c94d93237f.tar.gz
biboumi-5ba66c33519567f9f4e806a9ab41c3c94d93237f.tar.bz2
biboumi-5ba66c33519567f9f4e806a9ab41c3c94d93237f.tar.xz
biboumi-5ba66c33519567f9f4e806a9ab41c3c94d93237f.zip
Merge branch 'orm' into 'master'
Pure c++ sqlite3 ORM Closes #3271 See merge request !11
Diffstat (limited to 'src/bridge')
-rw-r--r--src/bridge/bridge.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index 4a41b50..23ecfe9 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -23,22 +23,24 @@ static std::string in_encoding_for(const Bridge& bridge, const Iid& iid)
#ifdef USE_DATABASE
const auto jid = bridge.get_bare_jid();
auto options = Database::get_irc_channel_options_with_server_default(jid, iid.get_server(), iid.get_local());
- return options.encodingIn.value();
+ auto result = options.col<Database::EncodingIn>();
+ if (!result.empty())
+ return result;
#else
(void)bridge;
(void)iid;
- return {"ISO-8859-1"};
#endif
+ return {"ISO-8859-1"};
}
Bridge::Bridge(std::string user_jid, BiboumiComponent& xmpp, std::shared_ptr<Poller>& poller):
- user_jid(std::move(user_jid)),
+ user_jid(std::move(user_jid)),
xmpp(xmpp),
poller(poller)
{
#ifdef USE_DATABASE
const auto options = Database::get_global_options(this->user_jid);
- this->set_record_history(options.recordHistory.value());
+ this->set_record_history(options.col<Database::RecordHistory>());
#endif
}
@@ -258,7 +260,7 @@ void Bridge::send_channel_message(const Iid& iid, const std::string& body)
#ifdef USE_DATABASE
const auto xmpp_body = this->make_xmpp_body(line);
if (this->record_history)
- uuid = Database::store_muc_message(this->get_bare_jid(), iid, std::chrono::system_clock::now(),
+ uuid = Database::store_muc_message(this->get_bare_jid(), iid.get_local(), iid.get_server(), 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()])
@@ -436,7 +438,7 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con
#ifdef USE_DATABASE
const auto coptions = Database::get_irc_channel_options_with_server_default(this->user_jid,
iid.get_server(), iid.get_local());
- persistent = coptions.persistent.value();
+ persistent = coptions.col<Database::Persistent>();
#endif
if (channel->joined && !channel->parting && !persistent)
{
@@ -837,7 +839,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() && this->record_history)
- Database::store_muc_message(this->get_bare_jid(), iid, std::chrono::system_clock::now(),
+ Database::store_muc_message(this->get_bare_jid(), iid.get_local(), iid.get_server(), std::chrono::system_clock::now(),
std::get<0>(xmpp_body), nick);
#endif
for (const auto& resource: this->resources_in_chan[iid.to_tuple()])
@@ -994,12 +996,12 @@ void Bridge::send_room_history(const std::string& hostname, std::string chan_nam
{
#ifdef USE_DATABASE
const auto coptions = Database::get_irc_channel_options_with_server_and_global_default(this->user_jid, hostname, chan_name);
- const auto lines = Database::get_muc_logs(this->user_jid, chan_name, hostname, coptions.maxHistoryLength.value());
+ const auto lines = Database::get_muc_logs(this->user_jid, chan_name, hostname, coptions.col<Database::MaxHistoryLength>());
chan_name.append(utils::empty_if_fixed_server("%" + hostname));
for (const auto& line: lines)
{
- const auto seconds = line.date.value().timeStamp();
- this->xmpp.send_history_message(chan_name, line.nick.value(), line.body.value(),
+ const auto seconds = line.col<Database::Date>();
+ this->xmpp.send_history_message(chan_name, line.col<Database::Nick>(), line.col<Database::Body>(),
this->user_jid + "/" + resource, seconds);
}
#else