mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-25 02:43:02 -07:00
[Server/Client] Unify report categories (#7345)
* [Server/Client] Unify report categories into one shared source of truth * Lont. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
a1d8ce6165
commit
eae9591a17
8 changed files with 173 additions and 20 deletions
|
|
@ -6,8 +6,12 @@ set(CMAKE_AUTOUIC ON)
|
|||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
set(UTILITY_SOURCES
|
||||
libcockatrice/utility/cryptoutil.cpp libcockatrice/utility/expression.cpp libcockatrice/utility/levenshtein.cpp
|
||||
libcockatrice/utility/passwordhasher.cpp libcockatrice/utility/server_rate_limiter.cpp
|
||||
libcockatrice/utility/cryptoutil.cpp
|
||||
libcockatrice/utility/expression.cpp
|
||||
libcockatrice/utility/levenshtein.cpp
|
||||
libcockatrice/utility/passwordhasher.cpp
|
||||
libcockatrice/utility/report_categories.cpp
|
||||
libcockatrice/utility/server_rate_limiter.cpp
|
||||
libcockatrice/utility/warning_categories.cpp
|
||||
)
|
||||
|
||||
|
|
@ -20,6 +24,7 @@ set(UTILITY_HEADERS
|
|||
libcockatrice/utility/macros.h
|
||||
libcockatrice/utility/passwordhasher.h
|
||||
libcockatrice/utility/playmat_params.h
|
||||
libcockatrice/utility/report_categories.h
|
||||
libcockatrice/utility/string_limits.h
|
||||
libcockatrice/utility/dice_limits.h
|
||||
libcockatrice/utility/counter_limits.h
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
#include "report_categories.h"
|
||||
|
||||
namespace ReportCategories
|
||||
{
|
||||
const QStringList &keys()
|
||||
{
|
||||
static const QStringList categories = {"cheating", "bug_abuse", "harassment", "verbal_abuse",
|
||||
"hate_speech", "spam", "other"};
|
||||
return categories;
|
||||
}
|
||||
|
||||
bool isValid(const QString &key)
|
||||
{
|
||||
return keys().contains(key, Qt::CaseInsensitive);
|
||||
}
|
||||
} // namespace ReportCategories
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef REPORT_CATEGORIES_H
|
||||
#define REPORT_CATEGORIES_H
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
/**
|
||||
* Canonical report categories, shared by the client and the server.
|
||||
*
|
||||
* This is the single source of truth for the category keys exchanged over the
|
||||
* wire (Command_Report.category) and stored in the reports table. The server
|
||||
* only accepts keys from this list and the client report dialog only offers
|
||||
* keys from this list, so the two sides cannot drift apart again.
|
||||
*/
|
||||
namespace ReportCategories
|
||||
{
|
||||
/** @brief The complete list of valid category keys, in canonical order. */
|
||||
const QStringList &keys();
|
||||
|
||||
/** @brief Whether @a key is a valid report category (case-insensitive). */
|
||||
bool isValid(const QString &key);
|
||||
} // namespace ReportCategories
|
||||
|
||||
#endif // REPORT_CATEGORIES_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue