diff options
| author | ilotterytea <iltsu@alright.party> | 2024-05-01 01:19:37 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-05-01 01:19:37 +0500 |
| commit | 48bfed5c68220e19bb4a2dd0e70cd227c25062e8 (patch) | |
| tree | 37ea951d313cf971861ea59fbeb74d5b5bae46e7 /src | |
| parent | 733a83a5f1eb3a16360063a28e25bbaf3d118061 (diff) | |
feat: update user alias name if it has been changed
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands/request_util.cpp | 11 | ||||
| -rw-r--r-- | src/schemas/user.hpp | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/commands/request_util.cpp b/src/commands/request_util.cpp index 77d94bc..8ac2471 100644 --- a/src/commands/request_util.cpp +++ b/src/commands/request_util.cpp @@ -106,6 +106,17 @@ namespace bot::command { schemas::User user(query[0]); + if (user.get_alias_name() != irc_message.sender.login) { + work->exec("UPDATE users SET alias_name = '" + irc_message.sender.login + + "' WHERE id = " + std::to_string(user.get_id())); + work->commit(); + + delete work; + work = new pqxx::work(conn); + + user.set_alias_name(irc_message.sender.login); + } + schemas::PermissionLevel level = schemas::PermissionLevel::USER; const auto &badges = irc_message.sender.badges; diff --git a/src/schemas/user.hpp b/src/schemas/user.hpp index a5f3238..443dde9 100644 --- a/src/schemas/user.hpp +++ b/src/schemas/user.hpp @@ -49,6 +49,9 @@ namespace bot::schemas { const int &get_id() const { return this->id; } const int &get_alias_id() const { return this->alias_id; } const std::string &get_alias_name() const { return this->alias_name; } + void set_alias_name(const std::string &alias_name) { + this->alias_name = alias_name; + } const std::chrono::system_clock::time_point &get_joined_at() const { return this->joined_at; } |
