From 802962a2fa7ed453385ebf985ecaa6dddc240433 Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 1 Mar 2024 11:58:21 -0500 Subject: [PATCH] commitn --- src/main.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e6227ac..b9114fd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,7 @@ #include #include "blt/std/types.h" #include "blt/std/utility.h" +#include "blt/std/time.h" #include #include #include @@ -102,12 +103,28 @@ struct db_obj void commit(const user_info_t& edited) { - + auto existing_user = db.select(sql::object(), sql::where(sql::c(&user_info_t::userID) == edited.userID)); + + if (!existing_user.empty()) + { + for (const auto& v : existing_user) + { + user_history_t history; + history.userID = v.userID; + history.old_username = v.username; + history.old_global_nickname = v.global_nickname; + history.old_server_name = v.server_name; + history.time_changed = blt::system::getCurrentTimeMilliseconds(); + commit(history); + } + } + + db.replace(edited); } void commit(const user_history_t& edited) { - + db.insert(edited); } void commit(const channel_info_t& channel) @@ -117,7 +134,7 @@ struct db_obj void commit(const channel_history_t& channel) { - + db.insert(channel); } void commit(const message_t& message)