mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 03:53:26 -08:00
[Server] Serve report list views through the database interface (#7844)
cmdReportList, cmdReportMyList and cmdReportDetails still prepared their SELECTs inline through Servatrice_DatabaseInterface and mapped the result columns to protocol records in the socket handler. Add getReportList, getReportsSubmittedBy, getReportForDetails and getReportComments to Server_DatabaseInterface with fail-closed defaults and a ReportLookupResult outcome, implement them with the previous statements, joins and null handling, and keep the detail authorization check and the tolerated comment-query failure in the handler in the same order. Response codes are unchanged.
This commit is contained in:
parent
fb836c6e0c
commit
2ba80cb61d
4 changed files with 349 additions and 232 deletions
|
|
@ -5,6 +5,7 @@
|
|||
#include "libcockatrice/protocol/pb/serverinfo_chat_message.pb.h"
|
||||
#include "libcockatrice/protocol/pb/serverinfo_moderator_login.pb.h"
|
||||
#include "libcockatrice/protocol/pb/serverinfo_private_chat_message.pb.h"
|
||||
#include "libcockatrice/protocol/pb/serverinfo_report.pb.h"
|
||||
#include "libcockatrice/protocol/pb/serverinfo_user.pb.h"
|
||||
#include "libcockatrice/protocol/pb/serverinfo_user_alt.pb.h"
|
||||
#include "libcockatrice/protocol/pb/serverinfo_user_session.pb.h"
|
||||
|
|
@ -391,6 +392,38 @@ public:
|
|||
{
|
||||
return ReplayWriteResult::Failed;
|
||||
}
|
||||
/** @brief Outcome of fetching one report row for the detail view. */
|
||||
enum class ReportLookupResult
|
||||
{
|
||||
Ok,
|
||||
NotFound,
|
||||
Failed
|
||||
};
|
||||
/** @brief One page of reports with their joined moderator names, plus the total row count. */
|
||||
virtual bool getReportList(bool /* unresolvedOnly */,
|
||||
int /* offset */,
|
||||
int /* limit */,
|
||||
int & /* totalCount */,
|
||||
QList<ServerInfo_Report> & /* reports */)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/** @brief The newest reports the user filed, for their own list. */
|
||||
virtual bool getReportsSubmittedBy(int /* reporterId */, QList<ServerInfo_Report> & /* reports */)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/** @brief One report row for the detail view; also returns the reporter id for the access check. */
|
||||
virtual ReportLookupResult
|
||||
getReportForDetails(int /* reportId */, int & /* reporterId */, ServerInfo_Report & /* report */)
|
||||
{
|
||||
return ReportLookupResult::Failed;
|
||||
}
|
||||
/** @brief The comments of a report in creation order. */
|
||||
virtual bool getReportComments(int /* reportId */, QList<ServerInfo_ReportComment> & /* comments */)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/** @brief One resolved or dismissed report whose reporter has not been told yet. */
|
||||
struct PendingReportNotification
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue