[Server] Move deck share storage into the database interface (#7837)

The five deck-share commands reached through Servatrice_DatabaseInterface for share lookups, and cmdDeckShareCreate still issued the per-user rate-limit count and the folder deck listing inline. Move DeckShareItemRecord and DeckShareSummaryRecord to Server_DatabaseInterface, declare the share operations plus getDeckSharesCreatedToday and getDeckFilesInFolder there with failing defaults, and switch the commands to the injected interface. The MySQL statements and every response code stay as they were, including the -1-on-failure sentinel for the count.
This commit is contained in:
BruebachL 2026-11-10 12:16:24 +01:00 • committed by GitHub
parent 417e7f7db4
commit ba037cbf04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 131 additions and 65 deletions

View file

@ -1825,6 +1825,36 @@ void Servatrice_DatabaseInterface::cleanupExpiredDeckShares()
execSqlQuery(query);
}
int Servatrice_DatabaseInterface::getDeckSharesCreatedToday(int userId)
{
checkSql();
QSqlQuery *query = prepareQuery("select count(*) from {prefix}_deck_share where created_by = :created_by and "
"created_at >= DATE_SUB(NOW(), INTERVAL 1 DAY)");
query->bindValue(":created_by", userId);
if (!execSqlQuery(query) || !query->next()) {
return -1;
}
return query->value(0).toInt();
}
bool Servatrice_DatabaseInterface::getDeckFilesInFolder(int folderId, int userId, QList<DeckFileListItem> &files)
{
checkSql();
QSqlQuery *query = prepareQuery("select id, color_identity from {prefix}_decklist_files where id_folder = "
":id_folder and id_user = :id_user");
query->bindValue(":id_folder", folderId);
query->bindValue(":id_user", userId);
if (!execSqlQuery(query)) {
return false;
}
while (query->next()) {
files.append(DeckFileListItem{.id = query->value(0).toInt(), .colorIdentity = query->value(1).toString()});
}
return true;
}
bool Servatrice_DatabaseInterface::getDeckSharesForUser(int userId, QList<DeckShareSummaryRecord> &shares)
{
checkSql();