Files
DarkflameServer/dDatabase/GameDatabase/SQLite/Tables/AccountNotes.cpp
Aaron Kimbrell e213a7aeff feat: web dashboard and playground work
The NexusDashboard-parity dashboard (dDashboardServer) and everything built on it on the experimental branch:
accounts, characters, properties and moderation tools, permissions shared with in-game slash commands, economy
reports, World 3D and property 3D views with client scenery, scheduled events (features, vanity changes, live
events, announcements, restarts), vanity files and events, the CDClient browser, the message inspector with saved
captures, chat filter tools, community challenges, live ops, the AI moderator helper, and the server-side changes
they need.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 22:30:43 -05:00

47 lines
2.5 KiB
C++

#include "SQLiteDatabase.h"
void SQLiteDatabase::InsertAccountNote(const AccountNote& note) {
ExecuteInsert("INSERT INTO account_notes (account_id, kind, text, actor, created_at) VALUES (?, ?, ?, ?, ?);", note.accountId, note.kind, note.text, note.actor, note.createdAt);
}
void SQLiteDatabase::DeleteAccountNote(uint64_t id) {
ExecuteDelete("DELETE FROM account_notes WHERE id = ?;", static_cast<int64_t>(id));
}
void SQLiteDatabase::SetAccountBan(uint32_t accountId, bool banned, int64_t expires, const std::string& reason) {
ExecuteUpdate("UPDATE accounts SET banned = ?, ban_expires = ?, ban_reason = ? WHERE id = ?;", banned, banned ? expires : int64_t{ 0 }, banned ? reason : std::string(), accountId);
}
std::vector<IAccountNotes::AccountNote> SQLiteDatabase::GetAccountNotes(uint32_t accountId) {
std::vector<AccountNote> notes;
auto [_, result] = ExecuteSelect("SELECT * FROM account_notes WHERE account_id = ? ORDER BY id DESC;", accountId);
while (!result.eof()) {
notes.push_back({ static_cast<uint64_t>(result.getInt64Field("id")), static_cast<uint32_t>(result.getIntField("account_id")), result.getStringField("kind"),
result.getStringField("text"), result.getStringField("actor"), result.getInt64Field("created_at") });
result.nextRow();
}
return notes;
}
std::optional<IAccountNotes::AccountNote> SQLiteDatabase::GetAccountNote(uint64_t id) {
auto [_, result] = ExecuteSelect("SELECT * FROM account_notes WHERE id = ?;", static_cast<int64_t>(id));
if (result.eof()) return std::nullopt;
return AccountNote{ static_cast<uint64_t>(result.getInt64Field("id")), static_cast<uint32_t>(result.getIntField("account_id")), result.getStringField("kind"),
result.getStringField("text"), result.getStringField("actor"), result.getInt64Field("created_at") };
}
uint32_t SQLiteDatabase::GetAccountWarningCount(uint32_t accountId) {
auto [_, result] = ExecuteSelect("SELECT COUNT(*) AS count FROM account_notes WHERE account_id = ? AND kind = 'warning';", accountId);
return result.eof() ? 0 : static_cast<uint32_t>(result.getIntField("count"));
}
std::vector<uint32_t> SQLiteDatabase::LiftExpiredBans(int64_t now) {
std::vector<uint32_t> ids;
{
auto [_, result] = ExecuteSelect("SELECT id FROM accounts WHERE banned = 1 AND ban_expires > 0 AND ban_expires <= ?;", now);
while (!result.eof()) { ids.push_back(static_cast<uint32_t>(result.getIntField("id"))); result.nextRow(); }
}
if (!ids.empty()) ExecuteUpdate("UPDATE accounts SET banned = 0, ban_expires = 0, ban_reason = NULL WHERE banned = 1 AND ban_expires > 0 AND ban_expires <= ?;", now);
return ids;
}