mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 03:53:26 -08:00
[Server] Move replay access reads and writes into the database interface (#7838)
cmdReplayList, cmdReplayDownload, cmdReplayModifyMatch and cmdReplayDeleteMatch issued their own SQL through Servatrice_DatabaseInterface. Add ReplayMatchRecord/ReplayEntry and the ReplayAccessResult/ReplayWriteResult enums to Server_DatabaseInterface, implement the list, data, do-not-hide and delete operations with the same statements and response mapping, and let the commands ask the injected interface. checkSql stays in the two write commands where it already was.
This commit is contained in:
parent
ba037cbf04
commit
b2e69d3443
4 changed files with 196 additions and 78 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#include "libcockatrice/protocol/pb/serverinfo_warning.pb.h"
|
||||
#include "server.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
|
@ -311,6 +312,55 @@ public:
|
|||
{
|
||||
return false;
|
||||
}
|
||||
/** @brief One downloaded replay file of a match. */
|
||||
struct ReplayEntry
|
||||
{
|
||||
int replayId = 0;
|
||||
int duration = 0;
|
||||
};
|
||||
/** @brief One replay match visible to a user, with its players and replay files. */
|
||||
struct ReplayMatchRecord
|
||||
{
|
||||
int gameId = 0;
|
||||
QString replayName;
|
||||
QString roomName;
|
||||
int timeStarted = 0;
|
||||
int timeFinished = 0;
|
||||
QString description;
|
||||
bool doNotHide = false;
|
||||
QStringList playerNames;
|
||||
QList<ReplayEntry> replays;
|
||||
};
|
||||
/** @brief Why a replay read succeeded or not, so callers can map it to a response code. */
|
||||
enum class ReplayAccessResult
|
||||
{
|
||||
Ok,
|
||||
AccessDenied,
|
||||
NotFound,
|
||||
Failed
|
||||
};
|
||||
enum class ReplayWriteResult
|
||||
{
|
||||
Ok,
|
||||
NotFound,
|
||||
Failed
|
||||
};
|
||||
virtual QList<ReplayMatchRecord> getReplayList(int /* userId */)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
virtual ReplayAccessResult getReplayData(int /* replayId */, int /* userId */, QByteArray & /* data */)
|
||||
{
|
||||
return ReplayAccessResult::Failed;
|
||||
}
|
||||
virtual ReplayWriteResult setReplayDoNotHide(int /* gameId */, int /* userId */, bool /* doNotHide */)
|
||||
{
|
||||
return ReplayWriteResult::Failed;
|
||||
}
|
||||
virtual ReplayWriteResult deleteReplayAccess(int /* gameId */, int /* userId */)
|
||||
{
|
||||
return ReplayWriteResult::Failed;
|
||||
}
|
||||
/** @brief Append a moderator/admin action to the server audit log. */
|
||||
virtual void addAuditRecord(const QString & /* user */,
|
||||
const QString & /* ipaddress */,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue