[Server] Move replay code exchange into the database interface

createHashForReplay, cmdReplayGetCode, cmdReplaySubmitCode,
cmdReplayDownloadByGameId and cmdGrantReplayAccess still issued their own SQL
through Servatrice_DatabaseInterface. Add checkReplayAccess, getReplayName,
getReplayHashSource, addReplayAccess, getLatestReplayForGame and
grantReplayAccessByName to Server_DatabaseInterface, implement them with the
same statements, bind order and response mapping, and let the commands ask the
injected interface. Hashing and code parsing stay in the handler; the shared
insert is reused by both grant paths.
This commit is contained in:
Lukas Brübach 2026-11-10 00:47:48 +01:00
parent a5e259fece
commit 13c27f9cf6
4 changed files with 181 additions and 103 deletions

View file

@ -361,6 +361,36 @@ public:
{
return ReplayWriteResult::Failed;
}
/** @brief Checks whether a user has an access row for a match's replays. */
virtual ReplayAccessResult checkReplayAccess(int /* gameId */, int /* userId */)
{
return ReplayAccessResult::Failed;
}
/** @brief Reads the stored name of a match's replay access row. */
virtual ReplayAccessResult getReplayName(int /* gameId */, QString & /* replayName */)
{
return ReplayAccessResult::Failed;
}
/** @brief Copies the leading bytes of a match's replay files, the input of its share code. */
virtual bool getReplayHashSource(int /* gameId */, QByteArray & /* source */)
{
return false;
}
/** @brief Grants one user access to a match's replays. */
virtual bool addReplayAccess(int /* gameId */, int /* userId */, const QString & /* replayName */)
{
return false;
}
/** @brief Fetches the newest replay file of a game for a download-by-game request. */
virtual ReplayAccessResult getLatestReplayForGame(int /* gameId */, int & /* replayId */, QByteArray & /* data */)
{
return ReplayAccessResult::Failed;
}
/** @brief Grants a user, resolved by name, access to an existing match's replays. */
virtual ReplayWriteResult grantReplayAccessByName(int /* gameId */, const QString & /* userName */)
{
return ReplayWriteResult::Failed;
}
/** @brief Append a moderator/admin action to the server audit log. */
virtual void addAuditRecord(const QString & /* user */,
const QString & /* ipaddress */,