diff options
author | louiz’ <louiz@louiz.org> | 2017-06-13 10:38:39 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2017-06-14 00:19:15 +0200 |
commit | 50cadf3dac0d56ef8181d1800cc30f8dcb749141 (patch) | |
tree | 23e56307a6fba4f926d261f858c8df8b6b8d5ea7 /src/bridge | |
parent | 7ca95a09740297ae9c041c5f8ae4caa0a57a149a (diff) | |
download | biboumi-50cadf3dac0d56ef8181d1800cc30f8dcb749141.tar.gz biboumi-50cadf3dac0d56ef8181d1800cc30f8dcb749141.tar.bz2 biboumi-50cadf3dac0d56ef8181d1800cc30f8dcb749141.tar.xz biboumi-50cadf3dac0d56ef8181d1800cc30f8dcb749141.zip |
Implement our own database ORM, and update the whole code to use it
Entirely replace LiteSQL
fix #3271
Diffstat (limited to 'src/bridge')
-rw-r--r-- | src/bridge/bridge.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index 4a41b50..fcfcc24 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -23,7 +23,7 @@ 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(); + return options.col<Database::EncodingIn>(); #else (void)bridge; (void)iid; @@ -32,13 +32,13 @@ static std::string in_encoding_for(const Bridge& bridge, const Iid& iid) } 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 +258,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 +436,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 +837,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 +994,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 |