diff options
author | Jonas Smedegaard <dr@jones.dk> | 2017-06-24 09:21:31 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2017-06-24 09:21:31 +0200 |
commit | c21cbbf9667991d2b928562a9c199e625d3f9bba (patch) | |
tree | ffd5e6895a578102ed9055fbb02a88031154ae0b /src/database | |
parent | de62b6456bebd130f98ce6192cd63ff42e654fac (diff) | |
parent | 23a3372144215c9ba7a30d599164677284813fa4 (diff) | |
download | biboumi-c21cbbf9667991d2b928562a9c199e625d3f9bba.tar.gz biboumi-c21cbbf9667991d2b928562a9c199e625d3f9bba.tar.bz2 biboumi-c21cbbf9667991d2b928562a9c199e625d3f9bba.tar.xz biboumi-c21cbbf9667991d2b928562a9c199e625d3f9bba.zip |
New upstream version 5.0
Diffstat (limited to 'src/database')
-rw-r--r-- | src/database/database.cpp | 18 | ||||
-rw-r--r-- | src/database/database.hpp | 4 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/database/database.cpp b/src/database/database.cpp index f7d309b..9f310da 100644 --- a/src/database/database.cpp +++ b/src/database/database.cpp @@ -20,7 +20,7 @@ void Database::open(const std::string& filename, const std::string& db_type) "database="s + filename); if (new_db->needsUpgrade()) new_db->upgrade(); - Database::db.reset(new_db.release()); + Database::db = std::move(new_db); } catch (const litesql::DatabaseError& e) { log_error("Failed to open database ", filename, ". ", e.what()); throw; @@ -119,22 +119,26 @@ db::IrcChannelOptions Database::get_irc_channel_options_with_server_and_global_d return coptions; } -void Database::store_muc_message(const std::string& owner, const Iid& iid, - Database::time_point date, - const std::string& body, - const std::string& nick) +std::string Database::store_muc_message(const std::string& owner, const Iid& iid, + Database::time_point date, + const std::string& body, + const std::string& nick) { db::MucLogLine line(*Database::db); - line.uuid = Database::gen_uuid(); + auto uuid = Database::gen_uuid(); + + line.uuid = uuid; line.owner = owner; line.ircChanName = iid.get_local(); line.ircServerName = iid.get_server(); - line.date = date.time_since_epoch().count() / 1'000'000'000; + line.date = std::chrono::duration_cast<std::chrono::seconds>(date.time_since_epoch()).count(); line.body = body; line.nick = nick; line.update(); + + return uuid; } std::vector<db::MucLogLine> Database::get_muc_logs(const std::string& owner, const std::string& chan_name, const std::string& server, diff --git a/src/database/database.hpp b/src/database/database.hpp index 6823574..b08a175 100644 --- a/src/database/database.hpp +++ b/src/database/database.hpp @@ -49,8 +49,8 @@ public: const std::string& server, const std::string& channel); static std::vector<db::MucLogLine> get_muc_logs(const std::string& owner, const std::string& chan_name, const std::string& server, - int limit=-1, const std::string& before="", const std::string& after=""); - static void store_muc_message(const std::string& owner, const Iid& iid, + int limit=-1, const std::string& start="", const std::string& end=""); + static std::string store_muc_message(const std::string& owner, const Iid& iid, time_point date, const std::string& body, const std::string& nick); static void close(); |